void QueryHistoryBillForm::Query() { if (editBeginDate_->GetText().length() < 10) { std::vector<std::string> v; v.push_back(" YES "); std::string msg = "开始日期小于10位"; int result = JMessageBox::Show("-ERROR-", msg, v); ClearWindow(); Show(); editBeginDate_->Show(); return; } if (editEndDate_->GetText().length() < 10) { std::vector<std::string> v; v.push_back(" YES "); std::string msg = "结束日期小于10位"; int result = JMessageBox::Show("-ERROR-", msg, v); ClearWindow(); Show(); editEndDate_->Show(); return; } //TODO 以下为实际的查询操作 try { BankSession* bs = Singleton<Client>::Instance().GetBankSession(); bs->Clear(); bs->SetCmd(CMD_HISTORY_BILL); bs->SetAttribute("begin_date", editBeginDate_->GetText()); bs->SetAttribute("end_date", editEndDate_->GetText()); bs->SetAttribute("page", "0"); Singleton<TransactionManager>::Instance().DoAction(*bs); if (bs->GetErrorCode() == 0) { ReportForm* form; form = dynamic_cast<ReportForm*>(Singleton<FormManager>::Instance().Get("ReportForm")); form->SetCmd(CMD_HISTORY_BILL); list<TransDetail>& tds = bs->GetDetails(); list<TransDetail>::iterator it = tds.begin(); form->SetLines(it->total); form->SetDetails(bs->GetDetails()); form->SetBeginDate(editBeginDate_->GetText()); form->SetEndDate(editEndDate_->GetText()); Reset(); form->ClearWindow(); form->Show(); } else { std::vector<std::string> v; v.push_back(" YES "); JMessageBox::Show("-ERROR-", bs->GetErrorMsg(), v); Reset(); ClearWindow(); Show(); return; } } catch (Exception& e) { std::vector<std::string> v; v.push_back(" YES "); JMessageBox::Show("-ERROR-", e.what(), v); Reset(); ClearWindow(); Show(); return; } }
void BalanceInquiryForm::Submit() { if (editAccountId_->GetText().length() < 6) { std::vector<std::string> v; v.push_back(" YES "); std::string msg = "帐号小于6位"; int result = JMessageBox::Show("-ERROR-", msg, v); ClearWindow(); Show(); editAccountId_->Show(); return; } if (editPass_->GetText().length() < 6) { std::vector<std::string> v; v.push_back(" YES "); std::string msg = "密码小于6位"; int result = JMessageBox::Show("-ERROR-", msg, v); ClearWindow(); Show(); editPass_->Show(); return; } //TODO 以下为实际的余额查询操作 try { BankSession* bs = Singleton<Client>::Instance().GetBankSession(); bs->Clear(); bs->SetCmd(CMD_BALANCE_INQUIRY); bs->SetAttribute("account_id", editAccountId_->GetText()); bs->SetAttribute("pass", editPass_->GetText()); Singleton<TransactionManager>::Instance().DoAction(*bs); if (bs->GetErrorCode() == 0) { Reset(); ReceiptForm* form; form = dynamic_cast<ReceiptForm*>(Singleton<FormManager>::Instance().Get("BalanceInquiryReceiptForm")); form->SetReceiptFormType(ReceiptForm::RFT_BALANCE_INQUIRY); form->SetTitle("余额查询成功"); form->SetItemText("交易日期", bs->GetResponse("trans_date")); form->SetItemText("户 名", bs->GetResponse("name")); form->SetItemText("帐 号", bs->GetAttribute("account_id")); form->SetItemText("余 额", bs->GetResponse("balance")); form->Show(); } else { std::vector<std::string> v; v.push_back(" YES "); JMessageBox::Show("-ERROR-", bs->GetErrorMsg(), v); ClearWindow(); Show(); return; } } catch (Exception& e) { std::vector<std::string> v; v.push_back(" YES "); JMessageBox::Show("-ERROR-", e.what(), v); ClearWindow(); Show(); return; } }
void LoginForm::Login() { if (editUser_->GetText().length() < 3) { std::vector<std::string> v; v.push_back(" YES "); std::string msg = "用户名小于3位"; int result = JMessageBox::Show("-ERROR-", msg,v); ClearWindow(); Show(); return; } if (editPass_->GetText().length() < 6) { std::vector<std::string> v; v.push_back(" YES "); std::string msg = "密码小于6位"; JMessageBox::Show("-ERROR-", msg, v); ClearWindow(); Show(); return; } // TODO:以下为实际的登录操作 /* Socket sock; sock.Create(); sock.Connect("127.0.0.1", 8888); std::string str; str.append(editUser_->GetText()); str.append("#"); str.append(editPass_->GetText()); sock.Send(str.c_str(), str.length()); char buffer[1024] = {0}; sock.Recv(buffer, sizeof(buffer)); std::vector<std::string> v; v.push_back(" YES "); JMessageBox::Show("-MESSAGE-", buffer, v); Reset(); JForm* form = Singleton<FormManager>::Instance().Get("MainMenuForm"); form->ClearWindow(); form->Show(); */ try { BankSession* bs = Singleton<Client>::Instance().GetBankSession(); bs->Connect(); bs->Clear(); bs->SetCmd(CMD_LOGIN); bs->SetAttribute("name", editUser_->GetText()); bs->SetAttribute("pass", editPass_->GetText()); Singleton<TransactionManager>::Instance().DoAction(*bs); if (bs->GetErrorCode() == 0) { std::vector<std::string> v; v.push_back(" YES "); JMessageBox::Show("-MESSAGE-", "登录成功", v); Reset(); JForm* form = Singleton<FormManager>::Instance().Get("MainMenuForm"); form->ClearWindow(); form->Show(); } else { std::vector<std::string> v; v.push_back(" YES "); JMessageBox::Show("-ERROR-", bs->GetErrorMsg(), v); ClearWindow(); Show(); } } catch (Exception& e) { std::vector<std::string> v; v.push_back(" YES "); JMessageBox::Show("-ERROR-", e.what(), v); ClearWindow(); Show(); } }