⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adaccountdlg.cpp

📁 一个模仿ATM提款机的MFC程序
💻 CPP
字号:
// AdAccountDlg.cpp : implementation file
//

#include "stdafx.h"
#include "atm.h"
#include "ATMDlg.h"

#include "AdAccountDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// AdAccountDlg dialog

CEnterPaswd enterpaswdlg;

AdAccountDlg::AdAccountDlg(CWnd* pParent /*=NULL*/)
	: CDialog(AdAccountDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(AdAccountDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void AdAccountDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(AdAccountDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(AdAccountDlg, CDialog)
	//{{AFX_MSG_MAP(AdAccountDlg)
	ON_BN_CLICKED(IDCHANGECODE, OnChangecode)
	ON_BN_CLICKED(IDCHECK, OnCheck)
	ON_BN_CLICKED(IDEXCHANGE, OnExchange)
	ON_BN_CLICKED(IDSUR, OnSur)
	ON_BN_CLICKED(IDTRANSFER, OnTransfer)
	ON_BN_CLICKED(IDWITHDRAW, OnWithdraw)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// AdAccountDlg message handlers

void AdAccountDlg::OnChangecode() 
{
	// TODO: Add your control notification handler code here
	KillTimer(0);
	CChanegpass change1dlg;
	
	if(change1dlg.DoModal()==IDOK)
	{    
		CChangepassword2 change2dlg;
		if(change2dlg.DoModal()==IDOK)
		{
			if(change1dlg.m_newpassword1==change2dlg.m_newpassword2&&change1dlg.m_newpassword1!="")//两次输入的密码比较及非空检验
			{
				if(CurrentAcnt *pCyrntAcnt=CurrentAcnt::searchAccount(enterpaswdlg.m_password)) //搜寻检测用户密码
				{
					pCyrntAcnt->changePassword(change1dlg.m_newpassword1);
					enterpaswdlg.m_password=change1dlg.m_newpassword1;
					CChangesuccess successdlg;      //修改成功
					successdlg.DoModal();
				}
				else 
				{
					CPassworderror passerrordlg;   //密码错误
					passerrordlg.DoModal();
					enterpaswdlg.m_password="";    //重输密码
					enterpaswdlg.DoModal();
				}
			}
			else                                
			{
				if(change1dlg.m_newpassword1=="")//密码为空
				{
					CSuggest suggestdlg;
					suggestdlg.m_suggest="密码不能为空";
					suggestdlg.DoModal();
				}
				else                        //两次密码不一样
				{	CDifpass difpassdlg;    
				difpassdlg.DoModal();
				}
				
			}
		}     
	}
	
	
}

void AdAccountDlg::OnCheck() 
{
	// TODO: Add your control notification handler code here
	KillTimer(0);
	CCheckchoose checkchoosedlg;
	if(checkchoosedlg.DoModal()==IDOK)
	{	
		
		if(CurrentAcnt *pCyrntAcnt=CurrentAcnt::searchAccount(enterpaswdlg.m_password))//搜寻检测用户密码
		{
			CCheck check;
			check.m_Balance=pCyrntAcnt->AcntBalan();
			check.m_Availbal=check.m_Balance-1;
			check.DoModal();
		}
		else 
		{
			CPassworderror passerrordlg;  //密码错误
			passerrordlg.DoModal();
			enterpaswdlg.m_password="";  //重输密码
			enterpaswdlg.DoModal();
		}
}

void AdAccountDlg::OnExchange() 
{
	// TODO: Add your control notification handler code here

}

void AdAccountDlg::OnSur() 
{
	// TODO: Add your control notification handler code here
	KillTimer(0);
	CSurrogate surrogatedlg;
	CSuggest suggestdlg;
	if(surrogatedlg.DoModal()==IDOK)
	{
	}
	
}

void AdAccountDlg::OnTransfer() 
{
	// TODO: Add your control notification handler code here
		KillTimer(0);
CTransfer transferdlg;
CSuggest suggestdlg;
int id=transferdlg.DoModal();
switch(id)
{
case IDOK:   //转本行帐户
	{
		CAccountno1 accountno1dlg;
		if(accountno1dlg.DoModal()==IDOK)
		{
			CAccountno2 accountno2dlg;
			if(accountno2dlg.DoModal()==IDOK)
			{
				if(accountno1dlg.m_accountno1==accountno2dlg.m_accountno2) //比较两次输入的帐号
				{
					CTranamount tranamountdlg;
					if(tranamountdlg.DoModal()==IDOK)
					{
						if(CurrentAcnt *pCyrntAcnt=CurrentAcnt::searchAccount(enterpaswdlg.m_password)) //搜寻检测用户密码
						{
							if(CurrentAcnt *ptTranacnt=CurrentAcnt::searchtranAccount(accountno1dlg.m_accountno1))//搜索检测转帐帐号
							{
								if(pCyrntAcnt->GetacntNo()==ptTranacnt->GetacntNo())  //不能给自己转帐
								{
									CTranmis tranmisdlg;
									tranmisdlg.DoModal();
								}
								else
								{
								    double remain=pCyrntAcnt->AcntBalan();
									double tranremain=ptTranacnt->AcntBalan();
									double amount=tranamountdlg.m_tranamount;
									if(amount>remain)   //余额不足
									{
										suggestdlg.m_suggest="余额不足";
										suggestdlg.DoModal();
									}
									else  //交易成功
									{
										remain-=amount;
										tranremain+=amount;
										pCyrntAcnt->reloadbalance(remain);
										ptTranacnt->reloadbalance(tranremain);
										CPrint3 print3dlg;
										print3dlg.DoModal();
									}
								}
							}
							else       //无此帐号
							{
								suggestdlg.m_suggest="帐号不存在";
							    suggestdlg.DoModal();
							}
						}
						else
						{
							CPassworderror passerrordlg;   //密码错误
                            passerrordlg.DoModal();
		                    enterpaswdlg.m_password="";    //重输密码
		                    enterpaswdlg.DoModal();
						}
					}
				}
				else   //两次帐号异
				{
					suggestdlg.m_suggest="您两次输入的帐号不一样";
					suggestdlg.DoModal();
				}
			}  
		}
	}break;
case IDC_OUT:   //转他行卡,和转本行操作差不多
	{	
	  CText textdlg;
	  if(textdlg.DoModal()==IDOK)
	  {
		CAccountno1 accountno1dlg;
		if(accountno1dlg.DoModal()==IDOK)
		{
			CAccountno2 accountno2dlg;
			if(accountno2dlg.DoModal()==IDOK)
			{
				if(accountno1dlg.m_accountno1==accountno2dlg.m_accountno2) //比较两次输入的帐号
				{
					CTranamount tranamountdlg;
					if(tranamountdlg.DoModal()==IDOK)
					{
						if(CurrentAcnt *pCyrntAcnt=CurrentAcnt::searchAccount(enterpaswdlg.m_password)) //搜寻检测用户密码
						{
							if(Exaccount *ptTranexacnt=Exaccount::searchtranAccount(accountno1dlg.m_accountno1))//搜索检测转帐帐号
							{								
								double remain=pCyrntAcnt->AcntBalan();
								double tranremain=ptTranexacnt->AcntBalan();
								double amount=tranamountdlg.m_tranamount;
								if(amount>50000)
								{
									suggestdlg.m_suggest="每天转帐限额五万元";
									suggestdlg.DoModal();
								}
								else
								{
									if(amount>remain)   //余额不足
									{
										suggestdlg.m_suggest="余额不足";
										suggestdlg.DoModal();
									}
									else  //交易成功
									{
										remain-=amount;
										tranremain+=amount;
										pCyrntAcnt->reloadbalance(remain-5);//5元手续费
										ptTranexacnt->reloadbalance(tranremain);
										CPrint3 print3dlg;
										print3dlg.DoModal();
									}
								}
								
							}
							else       //无此帐号
							{
								suggestdlg.m_suggest="帐号不存在";
							    suggestdlg.DoModal();
							}
						}
						else
						{
							CPassworderror passerrordlg;   //密码错误
                            passerrordlg.DoModal();
		                    enterpaswdlg.m_password="";    //重输密码
		                    enterpaswdlg.DoModal();
						}
					}
				}
				else   //两次帐号异
				{
					suggestdlg.m_suggest="您两次输入的帐号不一样";
					suggestdlg.DoModal();
				}
			}
		}
	  }
	}break;
default:break;		
}	
}

void AdAccountDlg::OnWithdraw() 
{
	// TODO: Add your control notification handler code here
	KillTimer(0);
	CWithdraw withdrawdlg;
	withdrawdlg.DoModal();	
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -