?? atmdlg.cpp
字號:
// ATMDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ATM.h"
#include "ATMDlg.h"
#include "GasUser.h"
#include "WaterUser.h"
#include "TelephoneUser.h"
#include "NewAccount.h"
#include "Ref.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
CEnterPaswd enterpaswdlg;
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CATMDlg dialog
CATMDlg::CATMDlg(CWnd* pParent /*=NULL*/)
: CDialog(CATMDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CATMDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CATMDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CATMDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CATMDlg, CDialog)
//{{AFX_MSG_MAP(CATMDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CHECK, OnCheck)
ON_BN_CLICKED(IDC_WITHDRAW, OnWithdraw)
ON_BN_CLICKED(IDC_CHANGEPASWD, OnChangepaswd)
ON_BN_CLICKED(IDC_TRANSFER, OnTransfer)
ON_BN_CLICKED(IDC_SURROGATE, OnSurrogate)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_FORACCOUNT, OnForaccount)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CATMDlg message handlers
BOOL CATMDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
ifstream fin("活期帳戶.txt");//,ios::nocreate);
if (fin.is_open())
{
while (!fin.eof())
{
CString acntNum;
char strNo[19],strpwd[7];
fin >> strNo;
acntNum = strNo;
CString paswrd;
fin>>strpwd;
paswrd=strpwd;
double balan;
fin>>balan;
if(fin.eof())
break;
CurrentAcnt *p=new CurrentAcnt(acntNum,paswrd);
p->reloadbalance(balan);
}
fin.close();
}
// remove("活期帳戶.txt");
ifstream finP("電話用戶.txt");//,ios::nocreate);
if (finP.is_open())
{
while (!finP.eof())
{
CString phno;
char strNo[19];
finP >> strNo;
phno = strNo;
double co;
finP>>co;
if(finP.eof())
break;
CPhoneuser *p=new CPhoneuser(phno,co);
}
finP.close();
}
ifstream finG("煤氣用戶.txt");//,ios::nocreate);
if (finG.is_open())
{
while (!finG.eof())
{
CString phno;
char strNo[19];
finG >> strNo;
phno = strNo;
double co;
finG>>co;
if(finG.eof())
break;
CGasuser *p=new CGasuser(phno,co);
}
finG.close();
}
//水費用戶
ifstream finW("水費用戶.txt");//,ios::nocreate);
if (finW.is_open())
{
while (!finW.eof())
{
CString phno;
char strNo[19];
finW >> strNo;
phno = strNo;
double co;
finW>>co;
if(finW.eof())
break;
WaterUser *p=new WaterUser(phno,co);
}
finW.close();
}
ifstream finT("電話費用戶.txt");//,ios::nocreate);
if (finT.is_open())
{
while (!finT.eof())
{
CString phno;
char strNo[19];
finT>> strNo;
phno = strNo;
double co;
finT>>co;
if(finT.eof())
break;
TelephoneUser *p=new TelephoneUser(phno,co);
}
finT.close();
}
// remove("電話用戶.txt");
ifstream finE("外行帳戶.txt");//,ios::nocreate);
if (finE.is_open())
{
while (!finE.eof())
{
CString acntNum;
char strNo[19],strpwd[7];
finE >> strNo;
acntNum = strNo;
CString paswrd;
finE>>strpwd;
paswrd=strpwd;
double balan;
finE>>balan;
if(finE.eof())
break;
Exaccount *p=new Exaccount(acntNum,paswrd);
p->reloadbalance(balan);
}
finE.close();
}
// remove("外行帳戶.txt");
enterpaswdlg.DoModal();
SetTimer(0,15000,NULL); //設置計時器,15秒無操作發出提示
return TRUE; // return TRUE unless you set the focus to a control
}
void CATMDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CATMDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CATMDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CATMDlg::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;
pCyrntAcnt->reloadbalance(check.m_Balance-pCyrntAcnt->GetCheckFee(0)); //收費依據屬地跟屬行而定
check.DoModal();
}
else
{
CPassworderror passerrordlg; //密碼錯誤
passerrordlg.DoModal();
enterpaswdlg.m_password=""; //重輸密碼
enterpaswdlg.DoModal();
}
}
}
void CATMDlg::OnWithdraw()
{
// TODO: Add your control notification handler code here
KillTimer(0);
CWithdraw withdrawdlg;
withdrawdlg.DoModal();
}
void CATMDlg::OnChangepaswd()
{
// 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();
Ref ref;
ref.Refresh(pCyrntAcnt->GetacntNo(),pCyrntAcnt->GetBalance(),0,"修改密碼");
}
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 CATMDlg::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();
Ref ref;
ref.Refresh(pCyrntAcnt->GetacntNo(),remain,amount,"轉賬");
}
}
}
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();
Ref ref;
ref.Refresh(pCyrntAcnt->GetacntNo(),remain,amount,"轉賬");
}
}
}
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 CATMDlg::OnSurrogate() //代理業務
{
// TODO: Add your control notification handler code here
KillTimer(0);
CSurrogate surrogatedlg;
CSuggest suggestdlg;
if(surrogatedlg.DoModal()==IDOK)
{
}
}
void CATMDlg::OnCancel()
{
// TODO: Add extra cleanup here
CurrentAcnt::storageC();
CPhoneuser::storageP();
Exaccount::storageE();
CDialog::OnCancel();
CEnd endlg;
endlg.DoModal();
}
BOOL CATMDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
switch(pMsg->message)
{
case WM_KEYUP:SetTimer(0,15000,NULL);break; //設置計時器,15秒無操作發出提示
case WM_KEYDOWN:KillTimer(0);break; //鍵盤操作,取消計時器
}
return CDialog::PreTranslateMessage(pMsg);
}
void CATMDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
Beep(1000,500); //定時器
KillTimer(0);
CAlarm alarmdlg;
alarmdlg.DoModal();
CDialog::OnTimer(nIDEvent);
}
void CATMDlg::OnForaccount()
{
// TODO: Add your control notification handler code here
NewAccount dlg;
dlg.DoModal();
CDialog::OnOK();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -