void CTradeLockDlg::OnBnClickedBtOk() { // TODO: Add your control notification handler code here CString sTmp; m_edPsw.GetWindowText(sTmp); //IAccount* pAccount = m_pAccountMng->GetCurrentAccount(atTrade); int nIndex = m_cbFundAccount.GetCurSel(); IAccount* pAccount = (IAccount*)m_cbFundAccount.GetItemDataPtr(nIndex); if (pAccount->GetConnectHandle() == 0) { pAccount->SetPassword(sTmp); if(pAccount->Login(sTmp)) { pAccount->SetIsLocked(FALSE); this->GetLayoutWindow()->OpenLayout(CURRENT_LAYOUT_TARGET,LN_TRADINGPANEL,PUBLIC_OWNER); m_pAccountMng->SetCurrentAccount(pAccount); } else MessageBox(sTmp, "提示", MB_ICONINFORMATION); } else { if (pAccount->GetPassword() == sTmp) { pAccount->SetIsLocked(FALSE); this->GetLayoutWindow()->OpenLayout(CURRENT_LAYOUT_TARGET,LN_TRADINGPANEL,PUBLIC_OWNER); m_pAccountMng->SetCurrentAccount(pAccount); } else { MessageBox("密码错误!", "提示", MB_ICONINFORMATION); m_edPsw.SetFocus(); m_edPsw.SetSel(0, -1); } } }
BOOL CDlgLevelInput::LoginLevel(const CString &strAccName, const CString &strAccPwd) { CString strUserAcc(""), strPwd(""); if (strAccName.IsEmpty() || strAccPwd.IsEmpty()) { EnableInput(FALSE); CString strText; CString strTitle; strTitle.LoadString(IDS_STRING_Error); ////////////////////////////////////////////////////////////////////////// // 获取账号、密码 GetDlgItem(IDC_EDIT_SHACC)->GetWindowText(strUserAcc); if (strUserAcc.IsEmpty()) { strText.LoadString(IDS_STRING_AccountError); MessageBox(strText,strTitle); EnableInput(TRUE); GetDlgItem(IDC_EDIT_SHACC)->SetFocus(); return FALSE; } strPwd = m_sEdit.GetRealText(); if (strPwd.IsEmpty()) { strText.LoadString(IDS_STRING_PasswardError); MessageBox(strText,strTitle); EnableInput(TRUE); m_sEdit.SetFocus(); return FALSE; } } else { strUserAcc = strAccName; strPwd = strAccPwd; } long handle = g_pDoLogin->ConnectServer(CEV_Connect_LEVEL2); if (handle) {// level2服务连接成功 IAccountMng *pTradeAccountMng = g_pDoLogin->m_pTradeCore->GetAccountMng(); if(pTradeAccountMng && pTradeAccountMng->GetCount(atLevel2) == 0) { //IAccount* pQHAccount = pTradeAccountMng->Add(atLevel2); IAccount* pQHAccount = pTradeAccountMng->NewAccount(atLevel2); if(pQHAccount) { pQHAccount->SetLoginAccount(strUserAcc); pQHAccount->SetCellNo(""); pQHAccount->SetLoginAccountType(""); pQHAccount->SetPassword(strPwd); pQHAccount->SetServerID(0); pQHAccount->SetBranchNo("0"); pQHAccount->SetConnectHandle(handle); CString sMsg = ""; if( pQHAccount->Login(sMsg) ) { pTradeAccountMng->Add(pQHAccount); pTradeAccountMng->SetCurrentAccount(pQHAccount); return TRUE; } else { pQHAccount->Release(); //pTradeAccountMng->DeleteAccount(pQHAccount); // CDataSourceInitDataStauts msg; // strncpy(msg.m_szMsg, sMsg, min(sMsg.GetLength()+1, 256)); // FSetProgressMsg(&msg); MessageBox(sMsg, "Error", MB_OK | MB_ICONERROR); } } } } EnableInput(TRUE); return TRUE; }