Ejemplo n.º 1
0
void Utils::AddStaff(CString name, CString no, CString sex, CString duty, CString tel, CListCtrl* list, int nCount)
{
	MYSQL mysql;
	MYSQL_RES *result = NULL;
	SQLUtils* sqlutils = new SQLUtils("localhost","root","root","work_database",3306);

	mysql_init(&mysql);

	string serverName = sqlutils->getServerName();
	string userName = sqlutils->getUserName();
	string password = sqlutils->getPassword();
	string databaseName = sqlutils->getDatabaseName();
	int port = sqlutils->getPort();
	if (mysql_real_connect(&mysql,serverName.c_str(),userName.c_str(),password.c_str(),databaseName.c_str(),port,NULL,0))
	{
		mysql_set_character_set(&mysql, "gbk");
		if (!CheckNo(mysql,sqlutils,no) && !CheckTel(mysql,sqlutils,tel))
		{
			string sql = "insert into t_staff (staff_name,staff_no,staff_sex,staff_duty,staff_tel) values(";
			sql.append(1,'\'').append(name).append(1,'\'').append(",").append(1,'\'').append(no).append(1,'\'').append(",")
				.append(1,'\'').append(sex).append(1,'\'').append(",").append(1,'\'').append(duty).append(1,'\'')
				.append(",").append(1,'\'').append(tel).append(1,'\'').append(")");
			mysql_query(&mysql,sql.c_str());
			mysql_close(&mysql);
			list->InsertItem(nCount,no);
			list->SetItemText(nCount,1,name);
			list->SetItemText(nCount,2,sex);
			list->SetItemText(nCount,3,duty);
			list->SetItemText(nCount,4,tel);
			AfxMessageBox("添加信息成功");
			return;
		}else if(CheckNo(mysql,sqlutils,no)){
			AfxMessageBox("此员工编号已存在");
		}else if (CheckTel(mysql,sqlutils,tel)){
			AfxMessageBox("此员工电话已存在");
		}
		return;
	}else{
		AfxMessageBox("系统出错");
	}
}
Ejemplo n.º 2
0
MRESULT EXPENTRY O_CONFIGDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  PO_CONFIGFORMINFO pO_CONFIGFormInfo=(PO_CONFIGFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER);
  HWND hwndFrame = hwndDlg;
 /* ##START Form.37 Top of window procedure */
 /* ##END Top of window procedure */
   switch (msg) {
   /* Form event Opened WM_INITDLG */
   case WM_INITDLG :
     if (mp2==0)
        mp2 = (MPARAM) malloc(sizeof(O_CONFIGFORMINFO));
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
     pO_CONFIGFormInfo=(PO_CONFIGFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER);
      WinAssociateHelpInstance(pMainFormInfo->hwndHelpInstance, hwndFrame);

      {
      /* ##START Form.1  */
      /* Event Opened - Form STICKY2\O_CONFIG */
      CHAR aTextValue[255]="text";
      LONG anIntegerValue=0;
      ULONG anUnsignedValue=0;

      c_cas = c_car = c_pop = c_aus = c_beep = c_mini = c_clr = 0;

      WinCheckButton(hwndDlg, SEND_CONFIG, CheckYes(gAfterSend));
      WinCheckButton(hwndDlg, REPLY_CONFIG, CheckYes(gAfterReply));
      WinCheckButton(hwndDlg, BACKGROUND_CONFIG, CheckYes(gPUS));
      WinCheckButton(hwndDlg, SURE_CONFIG, CheckYes(gSure));
      WinCheckButton(hwndDlg, MINI_CONFIG, CheckYes(gStickyIcon));

      WinCheckButton(hwndDlg, BEEP_CONFIG, CheckYes(gBeep));

      if (CheckNo(gBeep))
      {

      WinEnableControl(hwndDlg, 1006, FALSE);
      WinEnableControl(hwndDlg, 1007, FALSE);
      WinEnableControl(hwndDlg, FREQUENCY_CONFIG, FALSE);
      WinEnableControl(hwndDlg, DURATION_CONFIG, FALSE);

      } /* end if */


      /* Set range (numeric style) FREQUENCY_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, FREQUENCY_CONFIG,
                        SPBM_SETLIMITS,
                        MPFROMLONG(5000),                  /* Upper limit */
                        MPFROMLONG(10));                   /* Lower limit */ 
      WinSendDlgItemMsg(hwndDlg, DURATION_CONFIG,
                        SPBM_SETLIMITS,
                        MPFROMLONG(1000),                  /* Upper limit */
                        MPFROMLONG(10));                   /* Lower limit */ 

      WinSendDlgItemMsg(hwndDlg, FREQUENCY_CONFIG,
                        SPBM_SETCURRENTVALUE,
                        MPFROMLONG(atol(gFreq)), /* Value within range */
                        0);

      WinSendDlgItemMsg(hwndDlg, DURATION_CONFIG,
                        SPBM_SETCURRENTVALUE,
                        MPFROMLONG(atol(gDur)), /* Value within range */
                        0);


      /* Set range without update CLEAR_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, CLEAR_CONFIG,
                        SPBM_OVERRIDESETLIMITS,
                        MPFROMLONG(120),         /* Upper limit */
                        MPFROMLONG(0));          /* Lower limit */

      /* Set item value (numeric style) CLEAR_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, CLEAR_CONFIG,
                        SPBM_SETCURRENTVALUE,
                        MPFROMLONG(atol(gClearAuto)), /* Value within range */
                        0);
      /* ##END  */
      }
      break;

   /* Form event Closed WM_CLOSE */
   case WM_CLOSE :
      {
      /* ##START Form.2  */
      /* Event Closed - Form STICKY2\O_CONFIG */
      CHAR aTextValue[255]="text";
      LONG anIntegerValue=0;
      ULONG anUnsignedValue=0;


      MsgLog("Closing O_CONFIG");

      if (c_mini)
      {
      SWP swp;
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,MINI_CONFIG);
        
        strcpy(gStickyIcon, anUnsignedValue ? gYes : gNo);  
        PutString(S_StickyIcon, gStickyIcon); 
        WinQueryWindowPos(gHwndFrame, &swp);
        if (swp.fl & SWP_RESTORE)
           {
           MsgLog("O_CONFIG - RESTORE");
           WinPostMsg(gHwndFrame, WM_USER_RESTORE, 0, 0);
           }
       

      } /* end if */

      if (c_cas)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,SEND_CONFIG);

        strcpy(gAfterSend, anUnsignedValue ? gYes : gNo);  
        PutString(S_CloseAfterSend, gAfterSend); 
      } /* end if */
      if (c_car)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,REPLY_CONFIG);
        strcpy(gAfterReply, anUnsignedValue ? gYes: gNo );  
        PutString(S_CloseAfterReply, gAfterReply); 

      } /* end if */
      if (c_pop)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,BACKGROUND_CONFIG);
        strcpy(gPUS, anUnsignedValue ? gYes: gNo );  
        PutString(S_PopUpSticky, gPUS); 

          
      } /* end if */
      if (c_aus)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,SURE_CONFIG);
        
         strcpy(gSure, anUnsignedValue ? gYes : gNo );
         PutString(S_AreYouSure, gSure ); 

        
      } /* end if */
      if (c_beep)
      {
      anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,BEEP_CONFIG);
        
        PutString(S_Beep, anUnsignedValue ? gYes: gNo ); 
        strcpy(gBeep, anUnsignedValue ? gYes : gNo);
        
      } /* end if */
      /* Get item value (numeric style) FREQUENCY_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, FREQUENCY_CONFIG,
                        SPBM_QUERYVALUE,
                        MPFROMP(&anUnsignedValue),   /* Buffer for value */
                        MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));
      if (atol(gFreq) != anUnsignedValue)
      {
        sprintf(gFreq, "%d", anUnsignedValue);
        PutString(S_Frequency, gFreq);
      } /* end if */
                        

      /* Get item value (numeric style) DURATION_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, DURATION_CONFIG,
                        SPBM_QUERYVALUE,
                        MPFROMP(&anUnsignedValue),   /* Buffer for value */
                        MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));
      if (atol(gDur) != anUnsignedValue)
      {
        sprintf(gDur, "%d", anUnsignedValue);
        PutString(S_Duration, gDur);
      } /* end if */

      /* Get item value (numeric style) DURATION_CONFIG Spin Button */
      WinSendDlgItemMsg(hwndDlg, CLEAR_CONFIG,
                        SPBM_QUERYVALUE,
                        MPFROMP(&anUnsignedValue),   /* Buffer for value */
                        MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));
      if (atol(gClearAuto) != anUnsignedValue)
      {
        sprintf(gClearAuto, "%d", anUnsignedValue);
        PutString(S_ClearAuto, gClearAuto);
      } /* end if */
      /* ##END  */
      }
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
      break;

   /* Form event Destroyed WM_DESTROY */
   case WM_DESTROY :
      /* ##START Form.3  */
      /* ##END  */
     /* Remove help instance */
     WinAssociateHelpInstance((HWND) 0, hwndFrame);
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
      break;

   case WM_COMMAND :
      switch (SHORT1FROMMP(mp1)) {
      } /* end switch */
      break;

   case WM_CONTROL :
      switch (SHORT1FROMMP(mp1)) {
      /* Check Box SEND_CONFIG Event Handlers */
      case SEND_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1000.0  */
            /* Event Clicked/Selected - Close window after Send SEND_CONFIG */

            c_cas = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box REPLY_CONFIG Event Handlers */
      case REPLY_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1001.0  */
            /* Event Clicked/Selected - Close Window after Reply REPLY_CONFIG */

            c_car = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box BACKGROUND_CONFIG Event Handlers */
      case BACKGROUND_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1002.0  */
            /* Event Clicked/Selected - Popup Sticky on Receive BACKGROUND_CONFIG */
            c_pop = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box BEEP_CONFIG Event Handlers */
      case BEEP_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1003.0  */
            /* Event Clicked/Selected - Beep BEEP_CONFIG */
            ULONG	anUnsignedValue;

            c_beep = 1;
            /* Is button selected? BEEP_CONFIG Check Box */
            anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,BEEP_CONFIG);

            WinEnableControl(hwndDlg, 1006, anUnsignedValue);
            WinEnableControl(hwndDlg, 1007, anUnsignedValue);
            WinEnableControl(hwndDlg, FREQUENCY_CONFIG, anUnsignedValue);
            WinEnableControl(hwndDlg, DURATION_CONFIG, anUnsignedValue);
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box SURE_CONFIG Event Handlers */
      case SURE_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1009.0  */
            /* Event Clicked/Selected - Are You Sure Prompts SURE_CONFIG */
            c_aus = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      /* Check Box MINI_CONFIG Event Handlers */
      case MINI_CONFIG:
         switch (SHORT2FROMMP(mp1)) {
         /* Clicked/Selected */
         case BN_CLICKED:
            {
            /* ##START 1010.0  */
            /* Event Clicked/Selected - Mini ICON when shrunk MINI_CONFIG */
            CHAR aTextValue[255]="text";
            LONG anIntegerValue=0;
            ULONG anUnsignedValue=0;

            c_mini = 1;
            /* ##END  */
            }
            break;
         } /* end switch */
         break;

      } /* end switch */
      break;

 /* ##START Form.38 User defined messages */
 /* ##END User defined messages */
   default :
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
     return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
   } /* end switch for main msg dispatch */
   return (MRESULT)FALSE;
} /* end dialog procedure */
Ejemplo n.º 3
0
MRESULT EXPENTRY O_AUTODlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    PO_AUTOFORMINFO pO_AUTOFormInfo=(PO_AUTOFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER);
    HWND hwndFrame = hwndDlg;
    /* ##START Form.37 Top of window procedure */
    /* ##END Top of window procedure */
    switch (msg) {
    /* Form event Opened WM_INITDLG */
    case WM_INITDLG :
        if (mp2==0)
            mp2 = (MPARAM) malloc(sizeof(O_AUTOFORMINFO));
        HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
        pO_AUTOFormInfo=(PO_AUTOFORMINFO) WinQueryWindowULong(hwndDlg, QWL_USER);
        WinAssociateHelpInstance(pMainFormInfo->hwndHelpInstance, hwndFrame);

        {
            /* ##START Form.1  */
            /* Event Opened - Form STICKY2\O_CONFIG */
            CHAR aTextValue[255]="text";
            LONG anIntegerValue=0;
            ULONG anUnsignedValue=0;

            c_e = c_v = c_t = c_n = 0;

            WinCheckButton(hwndDlg, ENABLE_AUTO, CheckYes(gAutoReply));
            WinCheckButton(hwndDlg, VERSION_AUTO, CheckYes(gAutoVer));
            WinCheckButton(hwndDlg, TIME_AUTO, CheckYes(gAutoTime));
            WinCheckButton(hwndDlg, NAME_AUTO, CheckYes(gAutoName));
            /* Set text limit TEXT_AUTO Multi-Line Entry Field */
            WinSendDlgItemMsg(hwndDlg, TEXT_AUTO,
                              MLM_SETTEXTLIMIT,
                              MPFROMLONG(255),  /* New text limit */
                              0);


            /* Set item text TEXT_AUTO Multi-Line Entry Field */
            WinSetDlgItemText(hwndDlg, TEXT_AUTO, gAutoText);



            if (CheckNo(gAutoReply))
            {

                WinEnableControl(hwndDlg, 1004, FALSE);
                WinEnableControl(hwndDlg, VERSION_AUTO, FALSE);
                WinEnableControl(hwndDlg, TIME_AUTO, FALSE);
                WinEnableControl(hwndDlg, NAME_AUTO, FALSE);
                WinEnableControl(hwndDlg, TEXT_AUTO, FALSE);

            } /* end if */
            /* ##END  */
        }
        break;

    /* Form event Closed WM_CLOSE */
    case WM_CLOSE :
    {
        /* ##START Form.2  */
        /* Event Closed - Form STICKY2\O_CONFIG */
        CHAR aTextValue[512];
        LONG anIntegerValue=0;
        ULONG anUnsignedValue=0;
        CHAR *c_ptr, *e_ptr;


        MsgLog("Closing O_AUTO");


        if (c_e)
        {
            anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg, ENABLE_AUTO);
            strcpy(gAutoReply, anUnsignedValue ? gYes : gNo);
            PutString(S_AutoReply, gAutoReply);

        } /* end if */
        if (c_v)
        {
            anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg, VERSION_AUTO);
            strcpy(gAutoVer, anUnsignedValue ? gYes : gNo);
            PutString(S_AutoVer, gAutoVer);

        } /* end if */
        if (c_t)
        {
            anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg, TIME_AUTO);
            strcpy(gAutoTime, anUnsignedValue ? gYes : gNo);
            PutString(S_AutoTime, gAutoTime);

        } /* end if */
        if (c_n)
        {
            anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg, NAME_AUTO);
            strcpy(gAutoName, anUnsignedValue ? gYes : gNo);
            PutString(S_AutoName, gAutoName);

        } /* end if */


        /* Has text value changed? TEXT_AUTO Multi-Line Entry Field */
        if((ULONG)WinSendDlgItemMsg(hwndDlg, TEXT_AUTO,
                                    MLM_QUERYCHANGED ,
                                    0, 0))
        {
            WinQueryDlgItemText(hwndDlg, TEXT_AUTO, sizeof(aTextValue), aTextValue);
            strcpy(gAutoText, aTextValue);

            e_ptr = strchr(aTextValue, '\r');
            while (e_ptr)
            {
                *e_ptr = '~';
                e_ptr = strchr(e_ptr, '\r');
            } /* end while */
            e_ptr = strchr(aTextValue, '\n');
            while (e_ptr)
            {
                *e_ptr = '^';
                e_ptr = strchr(e_ptr, '\n');
            } /* end while */

            PutString(S_AutoText, aTextValue);
        }
        /* ##END  */
    }
    HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
    break;

    /* Form event Destroyed WM_DESTROY */
    case WM_DESTROY :
        /* ##START Form.3  */
        /* ##END  */
        /* Remove help instance */
        WinAssociateHelpInstance((HWND) 0, hwndFrame);
        HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
        break;

    case WM_COMMAND :
        switch (SHORT1FROMMP(mp1)) {
        } /* end switch */
        break;

    case WM_CONTROL :
        switch (SHORT1FROMMP(mp1)) {
        /* Check Box ENABLE_AUTO Event Handlers */
        case ENABLE_AUTO:
            switch (SHORT2FROMMP(mp1)) {
            /* Clicked/Selected */
            case BN_CLICKED:
            {
                /* ##START 1000.0  */
                /* Event Clicked/Selected - Enable Auto Reply ENABLE_AUTO */
                CHAR aTextValue[255]="text";
                LONG anIntegerValue=0;
                ULONG anUnsignedValue=0;


                c_e = 1;
                /* Is button selected? BEEP_CONFIG Check Box */
                anUnsignedValue=(ULONG)WinQueryButtonCheckstate(hwndDlg,ENABLE_AUTO);

                WinEnableControl(hwndDlg, 1004, anUnsignedValue);
                WinEnableControl(hwndDlg, VERSION_AUTO, anUnsignedValue);
                WinEnableControl(hwndDlg, TIME_AUTO, anUnsignedValue);
                WinEnableControl(hwndDlg, NAME_AUTO, anUnsignedValue);
                WinEnableControl(hwndDlg, TEXT_AUTO, anUnsignedValue);
                /* ##END  */
            }
            break;
            } /* end switch */
            break;

        /* Check Box VERSION_AUTO Event Handlers */
        case VERSION_AUTO:
            switch (SHORT2FROMMP(mp1)) {
            /* Clicked/Selected */
            case BN_CLICKED:
            {
                /* ##START 1001.0  */
                /* Event Clicked/Selected - Include Version number VERSION_AUTO */
                c_v = 1;
                /* ##END  */
            }
            break;
            } /* end switch */
            break;

        /* Check Box TIME_AUTO Event Handlers */
        case TIME_AUTO:
            switch (SHORT2FROMMP(mp1)) {
            /* Clicked/Selected */
            case BN_CLICKED:
            {
                /* ##START 1002.0  */
                /* Event Clicked/Selected - Include Local Time Received TIME_AUTO */

                c_t = 1;
                /* ##END  */
            }
            break;
            } /* end switch */
            break;

        /* Check Box NAME_AUTO Event Handlers */
        case NAME_AUTO:
            switch (SHORT2FROMMP(mp1)) {
            /* Clicked/Selected */
            case BN_CLICKED:
            {
                /* ##START 1003.0  */
                /* Event Clicked/Selected - Include Your Name NAME_AUTO */
                c_n = 1;
                /* ##END  */
            }
            break;
            } /* end switch */
            break;

        } /* end switch */
        break;

    /* ##START Form.38 User defined messages */
    /* ##END User defined messages */
    default :
        HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
        return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
    } /* end switch for main msg dispatch */
    return (MRESULT)FALSE;
} /* end dialog procedure */