123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- // DlgConfig.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "lyfzAttendance.h"
- #include "DlgConfig.h"
- // CDlgConfig 对话框
- IMPLEMENT_DYNAMIC(CDlgConfig, CDialog)
- CDlgConfig::CDlgConfig(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgConfig::IDD, pParent)
- , m_radio(0)
- , m_strDBService(_T(""))
- , m_dwDBServicePort(0)
- , m_strDBAccount(_T(""))
- , m_strDBPassword(_T(""))
- , m_strDBName(_T(""))
- , m_lMachineNumber(0)
- , m_strMachineIP(_T(""))
- , m_nMachinePort(0)
- , m_nMachinePassword(0)
- , m_nMachineTimeout(0)
- , m_nProtocolType(0)
- , m_lpCfg(NULL)
- {
- }
- CDlgConfig::~CDlgConfig()
- {
- m_lpCfg = NULL;
- }
- void CDlgConfig::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_DBService, m_strDBService);
- DDX_Text(pDX, IDC_DBServicePort, m_dwDBServicePort);
- DDX_Text(pDX, IDC_DBAccount, m_strDBAccount);
- DDX_Text(pDX, IDC_DBPassword, m_strDBPassword);
- DDX_Text(pDX, IDC_DBName, m_strDBName);
- DDX_Text(pDX, IDC_ManchineNo, m_lMachineNumber);
- DDX_Text(pDX, IDC_ManchineIP, m_strMachineIP);
- DDX_Text(pDX, IDC_ManchinePort, m_nMachinePort);
- DDX_Text(pDX, IDC_ManchinePassword, m_nMachinePassword);
- DDX_Text(pDX, IDC_ManchineTimeout, m_nMachineTimeout);
- DDX_Control(pDX, IDC_MACHINETYPE_COMBO, m_TypeCombox);
- }
- BEGIN_MESSAGE_MAP(CDlgConfig, CDialog)
- ON_BN_CLICKED(IDOK, &CDlgConfig::OnBnClickedOk)
- ON_BN_CLICKED(IDCANCEL, &CDlgConfig::OnBnClickedCancel)
- ON_BN_CLICKED(IDC_Radio_USB, &CDlgConfig::OnBnClickedRadioUsb)
- ON_BN_CLICKED(IDC_Radio_Net, &CDlgConfig::OnBnClickedRadioNet)
- ON_BN_CLICKED(IDC_CHECKUDP, &CDlgConfig::OnBnClickedCheckudp)
- END_MESSAGE_MAP()
- BOOL CDlgConfig::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: 在此添加额外的初始化
- if(m_lpCfg == NULL)
- return FALSE;
- m_TypeCombox.AddString(_T("奥芯U200"));
- m_TypeCombox.AddString(_T("鑫澳康FK6xx"));
- m_strDBService.Format(_T("%s"),g_szDBServer);
- m_dwDBServicePort = g_dwDBServerPort;
- m_strDBAccount.Format(_T("%s"), g_szDBAccount);
- m_strDBPassword.Format(_T("%s"), g_szDBPassWord);
- m_strDBName.Format(_T("%s"), g_szDBName);
- m_lMachineNumber = m_lpCfg->lMachineNumber;
- m_strMachineIP.Format(_T("%s"), m_lpCfg->szIpAddress);
- m_nMachinePort = m_lpCfg->lPort;
- m_nMachinePassword = m_lpCfg->lNetPassword;
- m_nMachineTimeout = m_lpCfg->lTimeOut;
- m_nProtocolType = m_lpCfg->lProtocolType;
- int nMachineType = m_lpCfg->nMachineType;
- m_TypeCombox.SetCurSel(nMachineType);
- if ( m_nProtocolType == 0 )//TCP
- ((CButton*)GetDlgItem(IDC_CHECKUDP))->SetCheck(FALSE);
- else
- ((CButton*)GetDlgItem(IDC_CHECKUDP))->SetCheck(TRUE);
- if ( m_lpCfg->nType == TYPE_USB)
- {
- m_radio = 0;
- // 禁用网络设置;
- ((CButton*)GetDlgItem(IDC_Radio_USB))->SetCheck(TRUE);
- ((CButton*)GetDlgItem(IDC_Radio_Net))->SetCheck(FALSE);
- GetDlgItem(IDC_CHECKUDP)->EnableWindow(FALSE);
- GetDlgItem(IDC_ManchineIP)->EnableWindow(FALSE);
- GetDlgItem(IDC_ManchinePassword)->EnableWindow(FALSE);
- GetDlgItem(IDC_ManchinePort)->EnableWindow(FALSE);
- GetDlgItem(IDC_ManchineTimeout)->EnableWindow(FALSE);
- }
- else
- {
- m_radio = 1;
- ((CButton*)GetDlgItem(IDC_Radio_USB))->SetCheck(FALSE);
- ((CButton*)GetDlgItem(IDC_Radio_Net))->SetCheck(TRUE);
- GetDlgItem(IDC_CHECKUDP)->EnableWindow(TRUE);
- GetDlgItem(IDC_ManchineIP)->EnableWindow(TRUE);
- GetDlgItem(IDC_ManchinePassword)->EnableWindow(TRUE);
- GetDlgItem(IDC_ManchinePort)->EnableWindow(TRUE);
- GetDlgItem(IDC_ManchineTimeout)->EnableWindow(TRUE);
- }
-
- UpdateData(0);
- return TRUE; // return TRUE unless you set the focus to a control
- }
- // CDlgConfig 消息处理程序
- void CDlgConfig::OnBnClickedOk()
- {
- // TODO: 在此添加控件通知处理程序代码
- UpdateData();
- // 1.
- wsprintf(g_szDBServer, _T("%s"), m_strDBService);
- wsprintf(g_szDBAccount, _T("%s"), m_strDBAccount);
- wsprintf(g_szDBPassWord, _T("%s"), m_strDBPassword);
- wsprintf(g_szDBName, _T("%s"), m_strDBName);
- g_dwDBServerPort = m_dwDBServicePort;
- // 2.
- m_lpCfg->lPort = m_nMachinePort;
- m_lpCfg->lTimeOut = m_nMachineTimeout;
- m_lpCfg->lNetPassword = m_nMachinePassword;
- m_lpCfg->lMachineNumber = m_lMachineNumber;
-
- wcscpy(m_lpCfg->szIpAddress, CT2CW(m_strMachineIP));
- m_lpCfg->nMachineType = m_TypeCombox.GetCurSel();
- switch(m_lpCfg->nMachineType)
- {
- case 0:
- m_lpCfg->lLicense = 0;
- break;
- case 1:
- m_lpCfg->lLicense = g_lLicense;
- }
- //--------------------------------------
- // 3.
- WCHAR szFile[MAX_PATH + 1] = {0};
- // 1.
- CString str;
- wsprintf(szFile, _T("%s\\lyfzServiceInfo.ini"),g_ModulePath);
- WritePrivateProfileString(_T("ServerInfo"), _T("dbServer"), g_szDBServer, szFile);
- if ( g_dwDBServerPort != 0 )
- {
- str.Format(_T("%ld"),g_dwDBServerPort);
- WritePrivateProfileString(_T("ServerInfo"), _T("dbServerPort"), str, szFile);
- }
- else
- {
- WritePrivateProfileString(_T("ServerInfo"), _T("dbServerPort"), _T(""), szFile);
- }
-
- WritePrivateProfileString(_T("ServerInfo"), _T("dbAccount"), g_szDBAccount, szFile);
- WritePrivateProfileString(_T("ServerInfo"), _T("dbPassWord"), g_szDBPassWord, szFile);
- WritePrivateProfileString(_T("ServerInfo"), _T("dbName"), g_szDBName, szFile);
- // 2.
- wsprintf(szFile, _T("%s\\GC0307.ini"), g_ModulePath);
- // 1.公共信息;
- str.Format(_T("%ld"), m_lpCfg->nMachineType);
- WritePrivateProfileString(_T("CommonInfo"), _T("MachineType"), str, szFile);
- str.Format(_T("%ld"), m_lpCfg->nType);
- WritePrivateProfileString(_T("CommonInfo"), _T("ConnectType"), str, szFile);
- str.Format(_T("%ld"), m_lpCfg->lMachineNumber);
- WritePrivateProfileString(_T("CommonInfo"), _T("MachineNumber"), str, szFile);
- str.Format(_T("%ld"), m_lpCfg->lLicense);
- WritePrivateProfileString(_T("CommonInfo"), _T("License"), str, szFile);
-
- // 2.网络信息;
- WritePrivateProfileString(_T("NetInfo"), _T("IP"), m_lpCfg->szIpAddress, szFile);
- str.Format(_T("%ld"), m_lpCfg->lPort);
- WritePrivateProfileString(_T("NetInfo"), _T("Port"), str, szFile);
- str.Format(_T("%ld"), m_lpCfg->lTimeOut);
- WritePrivateProfileString(_T("NetInfo"), _T("TimeOut"), str, szFile);
- str.Format(_T("%ld"), m_lpCfg->lProtocolType);
- WritePrivateProfileString(_T("NetInfo"), _T("ProtocolType"), str, szFile);
- str.Format(_T("%ld"), m_lpCfg->lNetPassword);
- WritePrivateProfileString(_T("NetInfo"), _T("NetPassword"), str, szFile);
- OnOK();
- }
- void CDlgConfig::OnBnClickedCancel()
- {
- // TODO: 在此添加控件通知处理程序代码
- OnCancel();
- }
- void CDlgConfig::OnBnClickedRadioUsb()
- {
- // TODO: 在此添加控件通知处理程序代码
- m_radio = 0;
- ((CButton*)GetDlgItem(IDC_Radio_USB))->SetCheck(TRUE);
- ((CButton*)GetDlgItem(IDC_Radio_Net))->SetCheck(FALSE);
- m_lpCfg->nType = TYPE_USB;
- GetDlgItem(IDC_CHECKUDP)->EnableWindow(FALSE);
- GetDlgItem(IDC_ManchineIP)->EnableWindow(FALSE);
- GetDlgItem(IDC_ManchinePassword)->EnableWindow(FALSE);
- GetDlgItem(IDC_ManchinePort)->EnableWindow(FALSE);
- GetDlgItem(IDC_ManchineTimeout)->EnableWindow(FALSE);
- }
- void CDlgConfig::OnBnClickedRadioNet()
- {
- // TODO: 在此添加控件通知处理程序代码
- m_radio = 1;
- m_lpCfg->nType = TYPE_TCP;
- ((CButton*)GetDlgItem(IDC_Radio_USB))->SetCheck(FALSE);
- ((CButton*)GetDlgItem(IDC_Radio_Net))->SetCheck(TRUE);
- GetDlgItem(IDC_CHECKUDP)->EnableWindow(TRUE);
- GetDlgItem(IDC_ManchineIP)->EnableWindow(TRUE);
- GetDlgItem(IDC_ManchinePassword)->EnableWindow(TRUE);
- GetDlgItem(IDC_ManchinePort)->EnableWindow(TRUE);
- GetDlgItem(IDC_ManchineTimeout)->EnableWindow(TRUE);
- }
- void CDlgConfig::OnBnClickedCheckudp()
- {
- // TODO: 在此添加控件通知处理程序代码
- if(((CButton*)GetDlgItem(IDC_CHECKUDP))->GetCheck())
- m_nProtocolType = 1;
- else
- m_nProtocolType = 0;
- m_lpCfg->lProtocolType = m_nProtocolType;
- }
|