📄 cformappendmoney.cpp
字号:
#include "link.h"
/***********************************************************************
默认构造函数
***********************************************************************/
CFormAppendMoney::CFormAppendMoney()
{
}
/***********************************************************************
充值界面类操作函数
***********************************************************************/
void CFormAppendMoney::load()
{
int _id=id;
string _date;
string _name;
string _smoney;
string _comment;
float _money;
CAppMoney tempapp;
do
{
int len;
CFormBase::load();
CMessageBox::Clear(27,26);
string apptitle="Add money to account";
len=apptitle.length();
GotoXY((80-len)/2,3);
cout<<apptitle;cout.flush();
addappform();
GotoXY(40,14);
_date=InputDate();
len=_date.length();
if(_date[len-1]==27)
return;
cout<<_date<<ends;
GotoXY(40,15);
_smoney=InputMoney();
len=_smoney.length();
if(_smoney[len-1]==27)
return;
cout<<_smoney<<ends;
GotoXY(40,16);
_comment=InputComment();
len=_comment.length();
if(_comment[len-1]==27)
return;
cout<<_comment<<ends;
CDateTime::DelayTime(1);
_money=CMyString::StrToFloat(_smoney);
CAccManager& accman=CAccManager::GetInstance();
_name=accman.GetRec(id-1).GetName();
tempapp.SetID(_id);
tempapp.SetName(_name);
tempapp.SetDate(_date);
tempapp.SetMoney(_money);
tempapp.SetComment(_comment);
int k=tempapp.AddAppMoney();
switch(k)
{
case 0:
case 1:return;//0,1返回菜单
case 2:continue;
}
}while(1);
}
/***********************************************************************
添加充值记录框架
***********************************************************************/
void CFormAppendMoney::addappform()
{
CFormBase addapp;
addapp.load();
string apptitle="Add money to account";
int len=apptitle.length();
addapp.GotoXY((80-len)/2,3);
cout<<apptitle;cout.flush();
addapp.GotoXY(10,14);
cout<<"Input the date<1900-2010> : ";cout.flush();
addapp.GotoXY(10,15);
cout<<"Input add money<-50~100> : ";cout.flush();
addapp.GotoXY(10,16);
cout<<"Input comment<length:0-200>: ";cout.flush();//备注,可不写
}
/***********************************************************************
id输入函数
***********************************************************************/
int CFormAppendMoney::InputID(int _id)
{
id=_id;
return id;
}
/***********************************************************************
日期输入函数
***********************************************************************/
string CFormAppendMoney::InputDate()
{
//日期输入
string date;
CDateTime datetime;
date=datetime.GetDateTime().substr(0,10);
int x,y;
WhereXY(&x,&y);
do
{
GotoXY(x,y);
CMessageBox::Clear(x,10);
GetString(date,10);
int len=date.length();
if(date[len-1]==27)
break;
if(len==0)
{
CMessageBox::ShowMessage("Date cannot be null ! Input again.");
continue;
}
if(date[len-1]==27)
break;
if(CMyString::CheckDate(date))
break;
else
continue;
}while(1);
GotoXY(x,y);
CMessageBox::Clear(x,10);
return date;
}
/***********************************************************************
金额输入
***********************************************************************/
string CFormAppendMoney::InputMoney()
{
//金额输入
string _conmoney;
float money;
int x,y,len;
WhereXY(&x,&y);
do
{
GotoXY(x,y);
CMessageBox::Clear(x,5);//列数,个数
GetString(_conmoney,5);//需要验证
len=_conmoney.length();
if(_conmoney[len-1]==27)
break;
if(CMyString::CheckMoney(_conmoney))
{
money=CMyString::StrToFloat(_conmoney);
if(money>=-50&&money<=100)
{
GotoXY(x,y);
CMessageBox::Clear(x,5);
_conmoney=CMyString::FloatToStr(money);
cout<<_conmoney;
break;
}
else
{
CMessageBox::ShowMessage("Input money must be in -50.00 to 100.00 !");
_conmoney="";//置空
continue;
}
}
else
{
int len=_conmoney.length();
if(len==0)
{
CMessageBox::ShowMessage("Money cannot be null ! Input again.");
continue;
}
continue;
}
}while(1);
GotoXY(x,y);
CMessageBox::Clear(x,5);
return _conmoney;
}
/***********************************************************************
备注输入
***********************************************************************/
string CFormAppendMoney::InputComment()
{
//备注输入
string comment;
int x,y,len;
WhereXY(&x,&y);
GetString(comment,200);
CMyString::RemoveLeftBlank(comment);
CMyString::RemoveRightBlank(comment);
CMyString::RemoveMiddleBlank(comment);
len=comment.length();
if(comment[len-1]==27)
return comment;
if(len==0)
comment="Null";
GotoXY(x,y);
CMessageBox::Clear(x,comment.length());
return comment;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -