|
@@ -62,7 +62,7 @@ BOOL CDlgLogin::OnInitDialog()
|
|
|
SetBackgroundImage(IDB_LOGO);
|
|
|
|
|
|
if ( _tcslen(GLOBAL::g_config.szLine) )
|
|
|
- SetDlgItemText(EDIT_LINE, GLOBAL::g_config.szLine);
|
|
|
+ SetDlgItemText(CB_LINE, GLOBAL::g_config.szLine);
|
|
|
|
|
|
if ( _tcslen(GLOBAL::g_config.szAccount) )
|
|
|
SetDlgItemText(EDIT_ACCOUNT, GLOBAL::g_config.szAccount);
|
|
@@ -72,13 +72,66 @@ BOOL CDlgLogin::OnInitDialog()
|
|
|
if (m_bConfigLogin)
|
|
|
{
|
|
|
GetDlgItem(CHECK_OFFLINE)->EnableWindow(FALSE);
|
|
|
- GetDlgItem(EDIT_LINE)->EnableWindow(FALSE);
|
|
|
+ GetDlgItem(CB_LINE)->EnableWindow(FALSE);
|
|
|
}
|
|
|
|
|
|
+ InitCBLine();
|
|
|
+
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
|
// 异常: OCX 属性页应返回 FALSE
|
|
|
}
|
|
|
|
|
|
+void CDlgLogin::InitCBLine()
|
|
|
+{
|
|
|
+ CComboBox *pCB = (CComboBox*)GetDlgItem(CB_LINE);
|
|
|
+ // 如果是在线模式,先更新;
|
|
|
+ if (GLOBAL::g_config.nOffline == 0)
|
|
|
+ {
|
|
|
+ if (CMESdb::GetInstance())
|
|
|
+ {
|
|
|
+ std::vector<TString> vtLineName;
|
|
|
+ if (CMESdb::GetInstance()->GetAllLineName(vtLineName))
|
|
|
+ {
|
|
|
+ TString strLineNames;
|
|
|
+ for ( std::vector<TString>::iterator it = vtLineName.begin(); it != vtLineName.end(); it++ )
|
|
|
+ {
|
|
|
+ strLineNames.append(it->c_str());
|
|
|
+ strLineNames.append(_T(";"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存到配置文件;
|
|
|
+ if (strLineNames.size())
|
|
|
+ {
|
|
|
+ WritePrivateProfileString(_T("SYSTEM"), _T("Line"), strLineNames.c_str(), GLOBAL::g_szConfigFile);
|
|
|
+ }
|
|
|
+
|
|
|
+ strLineNames.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 再从文件中获取;
|
|
|
+ int nPos = -1;
|
|
|
+ TString strVal;
|
|
|
+ TCHAR szLine[4096] = {0};
|
|
|
+ GetPrivateProfileString(_T("SYSTEM"), _T("Line"), _T(""), szLine, 4096, GLOBAL::g_szConfigFile);
|
|
|
+ TString strLineName = szLine;
|
|
|
+ for (;;)
|
|
|
+ {
|
|
|
+ nPos = strLineName.find(_T(";"));
|
|
|
+ if (nPos == TString::npos)
|
|
|
+ break;
|
|
|
+
|
|
|
+ strVal = strLineName.substr(0, nPos);
|
|
|
+ if (strVal.size())
|
|
|
+ pCB->AddString(strVal.c_str());
|
|
|
+
|
|
|
+ strLineName = strLineName.substr(nPos + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ pCB->SelectString(0, GLOBAL::g_config.szLine);
|
|
|
+}
|
|
|
+
|
|
|
HBRUSH CDlgLogin::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
|
|
{
|
|
|
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
@@ -116,7 +169,7 @@ void CDlgLogin::OnBnClickedOk()
|
|
|
{
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
CString strAccount, strPassword, strLine;
|
|
|
- GetDlgItemText(EDIT_LINE, strLine);
|
|
|
+ GetDlgItemText(CB_LINE, strLine);
|
|
|
GetDlgItemText(EDIT_ACCOUNT, strAccount);
|
|
|
GetDlgItemText(EDIT_PASSWORD, strPassword);
|
|
|
|
|
@@ -162,7 +215,7 @@ void CDlgLogin::OnBnClickedOk()
|
|
|
}
|
|
|
|
|
|
CString strDynamicPassword;
|
|
|
- strDynamicPassword.Format(_T("OGC%s"), CTime::GetCurrentTime().Format(_T("%Y%m%d%w%p")));
|
|
|
+ strDynamicPassword.Format(_T("OGC%s"), CTime::GetCurrentTime().Format(_T("%Y%m%d%w%p")).GetString());
|
|
|
if ( strPassword != strDynamicPassword )
|
|
|
{
|
|
|
MessageBox(_T("密码错误"), _T("提示"), MB_OK);
|