📄 cformaddaccount.cpp
字号:
#include "link.h"
/************************************************************************
function:信息添加界面默认构造函数
param:无
return:无
************************************************************************/
CFormAddAccount::CFormAddAccount()
{
}
/***********************************************************************
添加账户信息界面类操作函数
***********************************************************************/
void CFormAddAccount::load()
{
do{
int accno;
string accsex;
string accname;
string mobile;
addform();
CAccManager &accman=CAccManager::GetInstance();
accno=accman.GetSize()+1;
GotoXY(21,7);
cout<<accno;cout.flush();
GotoXY(21,8);
accsex=InputSex();
int len=accsex.length();
if(accsex[len-1]==27)
return;
cout<<accsex;cout.flush();
GotoXY(21,9);
accname=InputName();
len=accname.length();
if(accname[len-1]==27)
return;
cout<<accname;cout.flush();
GotoXY(21,10);
string birth;
birth=InputBirth();//需要重载=运算符(在日期类中)
len=birth.length();
if(birth[len-1]==27)
return;
cout<<birth;cout.flush();//需要重载<<运算符(在日期类中)
GotoXY(21,11);
mobile=InputMobile();
len=mobile.length();
if(mobile[len-1]==27)
return;
cout<<mobile;cout.flush();
CAccount tempaccount(accno,accsex,accname,birth,mobile);
//确认是否创建账户
CMessageBox::ShowMessage("Do you confirm to save this account?(Y/N/C)");
char ch;
do
{
ch=getch();
if (ch=='Y' || ch=='y' || ch=='N' || ch=='n' || ch=='C' ||ch=='c')
{
if (ch=='Y' || ch=='y')
{
accman.AddNewAcc(tempaccount);//保存
//询问是否充值?
CMessageBox::ShowMessage("Add Account success !");
CDateTime::DelayTime(1);
CMessageBox::ShowMessage("Do you want to appmoney for the account?(Y/N)");
ch=getch();
if(ch=='Y' || ch=='y')
{
int k;
k=accman.GetRec(accno-1).AddBalance();//2保存成功,1不保存,0重新输入
if(k==0)
return;
}
else if (ch=='N' ||ch=='n')
//返回菜单
return;
}
else if (ch=='N' ||ch=='n')
{
//返回主菜单
return;
}
else
{
//取消重新添加账户
break;
}
}
else
continue;
} while (1);
continue;
}while(1);
}
/***********************************************************************
账户信息添加框架
***********************************************************************/
void CFormAddAccount::addform()
{//信息添加
CFormBase::load();
GotoXY(2,25);
string title("Add member account");
int len=title.length();
GotoXY((80-len)/2,3);
cout<<title<<endl;
GotoXY(16,7);
cout<<"No.:";cout.flush();
GotoXY(55,7);
cout<<"Orange:Auto";cout.flush();
GotoXY(16,8);
cout<<"Sex:";cout.flush();
GotoXY(55,8);
cout<<"Orange:M or F";cout.flush();
GotoXY(15,9);
cout<<"Name:";cout.flush();
GotoXY(55,9);
cout<<"Orange:letter or space";cout.flush();
GotoXY(11,10);
cout<<"Birthday:";cout.flush();
GotoXY(55,10);
cout<<"Orange:1900-2010";cout.flush();
GotoXY(13,11);
cout<<"Mobile:";cout.flush();
GotoXY(55,11);
cout<<"Orange:length 11 or 12";cout.flush();
}
/***********************************************************************
性别输入
***********************************************************************/
string CFormAddAccount::InputSex()
{
string _sex;
int x,y;
WhereXY(&x,&y);
do
{
GotoXY(x,y);
CMessageBox::Clear(x,1);
GetString(_sex,1);
int len=_sex.length();
if(_sex[len-1]==27)
break;
if (CMyString::CheckSex(_sex))
break;
_sex="";
}while(1);
GotoXY(x,y);
CMessageBox::Clear(x,1);
return _sex;
}
/***********************************************************************
姓名输入
***********************************************************************/
string CFormAddAccount::InputName()
{
string _name;
int x,y,len;
WhereXY(&x,&y);
do
{
GotoXY(x,y);
CMessageBox::Clear(x,21);
GetString(_name,21);
len=_name.length();
if(_name[len-1]==27)
break;
if (CMyString::CheckName(_name))
break;
} while (1);
GotoXY(x,y);
CMessageBox::Clear(x,21);
return _name;
}
/***********************************************************************
电话输入
***********************************************************************/
string CFormAddAccount::InputMobile()
{
string _mobile;
int len,x,y;
WhereXY(&x,&y);
while (1)
{
GotoXY(x,y);
CMessageBox::Clear(x,12);
GetString(_mobile,12);
len=_mobile.length();
if(_mobile[len-1]==27)
break;
if (CMyString::CheckMobile(_mobile))
{
break;
}
}
GotoXY(x,y);
CMessageBox::Clear(x,12);
return _mobile;
}
/***********************************************************************
生日输入
***********************************************************************/
string CFormAddAccount::InputBirth()
{
string _birth;
int x,y,len;
WhereXY(&x,&y);
do
{
GotoXY(x,y);
CMessageBox::Clear(x,10);
GetString(_birth,10);
len=_birth.length();
if(_birth[len-1]==27)
break;
if (CMyString::CheckDate(_birth))
break;
} while (1);
GotoXY(x,y);
CMessageBox::Clear(x,10);
return _birth;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -