📄 cconsume.cpp
字号:
#include "link.h"
/************************************************************************/
/*默认构造函数 */
/************************************************************************/
CConsume::CConsume()
{
}
/************************************************************************/
/*重载构造函数 */
/************************************************************************/
CConsume::CConsume(int _id,int _mancount,string _idlist,string _date,float _money,string _comment)
{
ID=_id;
mancount=_mancount;
IDList=_idlist;
date=_date;
money=_money;
comment=_comment;
}
/************************************************************************/
/*默认析构函数 */
/************************************************************************/
CConsume::~CConsume()
{
}
/************************************************************************/
/*id获取函数 */
/************************************************************************/
int CConsume::GetID()
{
return ID;
}
/************************************************************************/
/*idlist获取函数 */
/************************************************************************/
string CConsume::GetIDList()
{
return IDList;
}
/************************************************************************/
/*name获取函数 */
/************************************************************************/
int CConsume::GetManCount()
{
return mancount;
}
/************************************************************************/
/*date获取函数 */
/************************************************************************/
string CConsume::GetDate()
{
return date;
}
/************************************************************************/
/*money获取函数 */
/************************************************************************/
float CConsume::GetMoney()
{
return money;
}
/************************************************************************/
/*comment获取函数 */
/************************************************************************/
string CConsume::GetComment()
{
return comment;
}
/************************************************************************/
/*money设置函数 */
/************************************************************************/
void CConsume::SetMoney(float _money)
{
money=_money;
}
/************************************************************************/
/*id设置函数 */
/************************************************************************/
void CConsume::SetID(int _id)
{
ID=_id;
}
/************************************************************************/
/*date设置函数 */
/************************************************************************/
void CConsume::SetDate(string _date)
{
date=_date;
}
/************************************************************************/
/*idlist设置函数 */
/************************************************************************/
void CConsume::SetIDList(string _idlist)
{
IDList=_idlist;
}
/************************************************************************/
/*mancount设置函数 */
/************************************************************************/
void CConsume::SetManCount(int _mancount)
{
mancount=_mancount;
}
/************************************************************************/
/*comment设置函数 */
/************************************************************************/
void CConsume::SetComment(string _comment)
{
comment=_comment;
}
/************************************************************************/
/*消费操作函数 */
/************************************************************************/
int CConsume::ActCon()
{
//询问操作
CFormBase conmessage;
// conmessage.load();
//账户浏览列表查看
// string acctitle="Consume Message";
// int len=acctitle.length();
// conmessage.GotoXY((80-len)/2,3);
// cout<<acctitle;cout.flush();
conmessage.GotoXY(22,17);
cout<<"0.All member join this consume.";cout.flush();
conmessage.GotoXY(22,18);
cout<<"1.Only member here join this consume.";cout.flush();
conmessage.GotoXY(22,19);
cout<<"2.Only member absent join this consume.";cout.flush();
conmessage.GotoXY(22,21);
cout<<"Please make a choice[0-2]:";
int x,y;
char choice;
conmessage.WhereXY(&x,&y);
do
{
choice=getch();
CMessageBox::ShowMessage("");
if (isdigit(choice))
{
switch(choice)
{
case '0':return 0;
case '1':return 1;
case '2':return 2;
default:CMessageBox::ShowMessage("Input 0 to 2 .");break;
}
continue;
}
else
{
CMessageBox::ShowMessage("Input must be digit !");
continue;
}
} while (1);
}
/************************************************************************/
/* 消费记录添加函数 */
/************************************************************************/
int CConsume::AddConsume()
{
//界面
CFormBase addcon;
addcon.load();
string acctitle="Add consume report";
int len=acctitle.length();
addcon.GotoXY((80-len)/2,3);
cout<<acctitle;cout.flush();
//打印消费信息:消费日期,消费账户列表,消费金额及备注。
//询问是否保存
char temp[50];
addcon.GotoXY(10,5);
cout<<"--------------- Consume record information ---------------";cout.flush();
addcon.GotoXY(28,7);
sprintf(temp,"%s%s","Date : ",date.c_str());
cout<<temp<<endl;
addcon.GotoXY(28,8);
sprintf(temp,"%s%d","People count: ",mancount);
cout<<temp<<endl;
addcon.GotoXY(28,9);
sprintf(temp,"%s%s","IDList : ",IDList.c_str());
cout<<temp<<endl;
addcon.GotoXY(28,10);
sprintf(temp,"%s%.2f","Money : ",money);
cout<<temp<<endl;
addcon.GotoXY(28,11);
sprintf(temp,"%s%s","Comment : ",comment.c_str());
cout<<temp<<endl;
//询问是否添加消费记录============================================================
addcon.GotoXY(28,16);
cout<<"Do you want to save consume ?";cout.flush();
addcon.GotoXY(25,18);
cout<<"Y: Save consume and back to main menu.";cout.flush();
addcon.GotoXY(25,19);
cout<<"N: Abandon save and back to main menu.";cout.flush();
addcon.GotoXY(25,20);
cout<<"C: Abandon save and add consume detail again.";cout.flush();
addcon.GotoXY(25,22);
cout<<"Please make a choice[Y/N/C]:";
char choice;
int x,y;
addcon.WhereXY(&x,&y);
do
{
addcon.GotoXY(x,y);
choice=getche();
if (isalpha(choice))
{
if (choice=='Y'||choice=='y'||choice=='N'||choice=='n'||choice=='C'||choice=='c')
{
if (choice=='Y'||choice=='y')
{
return 2;
}
else if(choice=='N'||choice=='n')
{
//直接返回主菜单
return 1;
}
else
{
//不保存,重新进入添加消费记录界面
return 0;
}
break;
}
else
{
//提示,重新输入选项
CMessageBox::ShowMessage("You must input Y or N !");
continue;
}
}
else
{
CMessageBox::ShowMessage("You must input letter !");
continue;
}
} while (1);
return 2;
}
/************************************************************************/
/*消费信息打印函数 */
/************************************************************************/
void CConsume::ShowConsumeInfo()
{
CFormBase cominfo;
char temp[50];
cominfo.GotoXY(10,5);
cout<<"------------------- Consume Information ------------------";cout.flush();
cominfo.GotoXY(29,7);
sprintf(temp,"%s%d","ID : ",ID);
cout<<temp<<endl;
cominfo.GotoXY(29,8);
sprintf(temp,"%s%d","Count : ",mancount);
cout<<temp<<endl;
cominfo.GotoXY(29,9);
cominfo.GotoXY(29,8);
sprintf(temp,"%s%s","IdList : ",IDList.c_str());
cout<<temp<<endl;
cominfo.GotoXY(29,10);
sprintf(temp,"%s%s","Date : ",date.c_str());
cout<<temp<<endl;
cominfo.GotoXY(29,11);
sprintf(temp,"%s%.2f","Money : ",money);
cout<<temp<<endl;
cominfo.GotoXY(29,12);
sprintf(temp,"%s%s","Comment : ",comment.c_str());
cout<<temp<<endl;
}
/************************************************************************/
/*字符串分割函数 */
/************************************************************************/
int CConsume::TokBias(string str)
{
char temp[200],*result;
int a[10]={0};
for (int i=0;i<str.length();i++)
{
temp[i]=str[i];
}
temp[i]='\0';
result=strtok(temp,"/");
while(result!=NULL)//有错待改
{
a[i]=atoi(result);
result=strtok(NULL,"/");
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -