📄 login.cpp
字号:
// LOGIN.cpp : implementation file
//
#include "stdafx.h"
#include "银行储蓄系统.h"
#include "LOGIN.h"
#include "iostream.h"
#include "fstream.h"
#include "String.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLOGIN dialog
CLOGIN::CLOGIN(CWnd* pParent /*=NULL*/)
: CDialog(CLOGIN::IDD, pParent)
{
//{{AFX_DATA_INIT(CLOGIN)
m_accnumber = 0;
m_password = 0;
//}}AFX_DATA_INIT
}
void CLOGIN::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLOGIN)
DDX_Text(pDX, IDC_EDIT1, m_accnumber);
DDX_Text(pDX, IDC_EDIT2, m_password);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLOGIN, CDialog)
//{{AFX_MSG_MAP(CLOGIN)
ON_BN_CLICKED(IDC_EXIT_BUTTON, OnExitButton)
ON_BN_CLICKED(IDC_CREATE_BUTTON, OnCreateButton)
ON_BN_CLICKED(IDC_LOGIN_BUTTON, OnLoginButton)
ON_BN_CLICKED(IDC_DELETE_BUTTON, OnDeleteButton)
ON_BN_CLICKED(IDC_SAVE_BUTTON, OnSaveButton)
ON_BN_CLICKED(IDC_READ_BUTTON, OnReadButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLOGIN message handlers
void CLOGIN::OnExitButton()
{
// TODO: Add your control notification handler code here
OnOK();
}
void CLOGIN::OnCreateButton()
{
// TODO: Add your control notification handler code here
creat.DoModal();
}
void CLOGIN::OnLoginButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
int item=0;
if(m_accnumber/100==1)
{
Savings *pS;
for(Savings* p=(Savings*)pS->getFirst(); p ;p=(Savings*)p->getNext())
{
if(m_accnumber==p->AccountNo()&&m_password==p->getPass())
{
operation.aS=p;
operation.tag=1;
operation.DoModal();
item=1;
}
}
}
else if(m_accnumber/100==2)
{
Checkings *pC;
for(Checkings* pp=(Checkings*)pC->getFirst(); pp ;pp=(Checkings*)pp->getNext())
{
if(m_accnumber==pp->AccountNo()&&m_password==pp->getPass())
{
operation.aC=pp;
operation.tag=2;
operation.DoModal();
item=1;
}
}
}
if(item==0)
MessageBox("密码或帐号错误");
}
void CLOGIN::OnDeleteButton()
{
// TODO: Add your control notification handler code here
deleteaccount.DoModal();
}
void CLOGIN::OnSaveButton()
{
// TODO: Add your control notification handler code here
int aN;
double bal;
long password;
ofstream outfile("account.dat",ios::trunc);
if(outfile)
{
Savings *pS;
for(Savings* p=(Savings*)pS->getFirst(); p ;p=(Savings*)p->getNext())
{
aN=p->AccountNo();
bal=p->GetBalance();
password=p->getPass();
outfile<<aN<<" "<<bal<<" "<<password<<endl;
}
}
else cout<<"错误,文件无法打开!"<<endl;
outfile.close();
MessageBox("保存完毕");
}
void CLOGIN::OnReadButton()
{
// TODO: Add your control notification handler code here
int aN;
double bal;
long password;
Savings *pS;
for(Savings* p=(Savings*)pS->getFirst(); p; )
{
Savings* t=p;
p=(Savings*)p->getNext();
delete t;
}
pS->getFirst()=NULL;
ifstream infile("account.dat");
if(infile)
while(infile.good())
{
infile>>aN;
infile>>bal;
infile>>password;
if(aN/100==1)
{
Savings *pSS;
pSS=new Savings(aN,bal);
pSS->Password(password);
}
else if((aN/100)==2)
{
Checkings *pCC;
pCC=new Checkings(aN,bal);
pCC->Password(password);
}
}
else cout<<"错误,文件无法打开!"<<endl;
infile.close();
MessageBox("导入完毕");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -