Example #1
0
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;
	}

}
Example #2
0
void TransferForm::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;
	}
	if (editOtherAccountId_->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 (editMoney_->GetText().empty())
	{
		std::vector<std::string> v;
		v.push_back(" YES ");
		std::string msg = "金额不能为空";

		JMessageBox::Show("-ERROR-", msg, v);
		ClearWindow();
		Show();
		editAccountId_->Show();
		return;
	}
	if (editAccountId_->GetText() == editOtherAccountId_->GetText())
	{
		std::vector<std::string> v;
		v.push_back(" YES ");
		std::string msg = "不能转入到自身帐户";

		JMessageBox::Show("-ERROR-", msg, v);
		ClearWindow();
		Show();
		editAccountId_->Show();
		return;
	}

	// 以下为实际的转帐操作
	try
	{
		BankSession bs;
		bs.Connect();
		bs.SetCmd(CMD_TRANSFER);
		bs.SetAttribute("account_id", editAccountId_->GetText());
		bs.SetAttribute("pass", editPass_->GetText());
		bs.SetAttribute("money", editMoney_->GetText());
		bs.SetAttribute("other_account_id", editOtherAccountId_->GetText());

		Singleton<TransactionManager>::Instance().DoAction(bs);
		if (bs.GetErrorCode() == 0)
		{
			Reset();
			std::vector<std::string> v;
			v.push_back(" YES ");
			std::string msg = "转帐成功"+bs.GetResponse("account_id");

			/*int result = JMessageBox::Show("-MESSAGE-", msg,v);
			ClearWindow();
			Show();*/

			ReceiptForm* form;
			form = dynamic_cast<ReceiptForm*>(Singleton<FormManager>::Instance().Get("TransferReceiptForm"));
			form->SetReceiptFormType(ReceiptForm::RFT_TRANSFER);
			form->SetTitle("转帐成功");
			form->SetItemText("交易日期", bs.GetResponse("trans_date"));
			form->SetItemText("户    名", bs.GetResponse("name"));
			form->SetItemText("帐    号", bs.GetAttribute("account_id"));
			form->SetItemText("对方帐号", bs.GetAttribute("other_account_id"));
			form->SetItemText("交易金额", bs.GetAttribute("money"));
			form->SetItemText("摘    要", "转帐");
			form->SetItemText("余    额", bs.GetResponse("balance"));
			form->ClearWindow();
			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 ");

		int result = JMessageBox::Show("-ERROR-", e.what(), v);
		ClearWindow();
		Show();

		return;
	}
}