Esempio n. 1
0
void QueryDayBillForm::Query()
{
	if (editDate_->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();
		editDate_->Show();
		return;
	}

	//TODO 以下为实际的查询操作(某日交易记录)
	try
	{
		BankSession bs;
		bs.SetCmd(CMD_DAY_BILL);
		bs.SetAttribute("date", editDate_->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_DAY_BILL);
			list<TransDetail>& tds = bs.GetDetails();
			list<TransDetail>::iterator it = tds.begin();
			form->SetLines(it->total);
			form->SetDetails(bs.GetDetails());
			form->SetDate(editDate_->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;
	}

}
Esempio n. 2
0
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);

		JWindow* win = jApp->GetCurrent();		//这里的win是之前按纽,就是引发消息窗的按纽
		editUser_->Show();
		win->Draw();
		win->Refresh();
		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);

		JWindow* win = jApp->GetCurrent();
		editPass_->Show();
		win->Draw();
		win->Refresh();
		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("-ERROR-", buffer, v);


	Rest();
	JForm* form = Singleton<FormManager>::Instance().Get("MainMenuForm");
	form->ClearWindow();
	form->Show();
	*/

	try
	{
		BankSession bs;
		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);

			Rest();
			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();
	}


}
Esempio n. 3
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;
	}

}
Esempio n. 4
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;
	}
}