⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cappmoney.cpp

📁 AA制消费管理系统(简易型) 实现账户信息
💻 CPP
字号:
#include "link.h"
/************************************************************************/
/* 默认构造函数                                                         */
/************************************************************************/
CAppMoney::CAppMoney()
{

}
/************************************************************************/
/* 构造函数重载                                                         */
/************************************************************************/
CAppMoney::CAppMoney(int _id,string _name,string _date,float _money,string _comment)
{
	id=_id;
	name=_name;
	date=_date;
	money=_money;
	comment=_comment;
}
/************************************************************************/
/*默认析构函数                                                          */
/************************************************************************/
CAppMoney::~CAppMoney()
{

}
/************************************************************************/
/*id获取函数                                                            */
/************************************************************************/
int CAppMoney::GetID()
{
	return id;
}
/************************************************************************/
/*name获取函数                                                          */
/************************************************************************/
string CAppMoney::GetName()
{
	return name;
}
/************************************************************************/
/*date获取函数                                                          */
/************************************************************************/
string CAppMoney::GetDate()
{
	return date;
}
/************************************************************************/
/*money获取函数                                                         */
/************************************************************************/
float CAppMoney::GetMoney()
{
	return money;
}
/************************************************************************/
/*comment获取函数                                                       */
/************************************************************************/
string CAppMoney::GetComment()
{
	return comment;
}
/************************************************************************/
/*id设置函数                                                            */
/************************************************************************/
void CAppMoney::SetID(int _id)
{
	id=_id;
}
/************************************************************************/
/*name设置函数                                                          */
/************************************************************************/
void CAppMoney::SetName(string _name)
{
	name=_name;
}
/************************************************************************/
/*money设置函数                                                         */
/************************************************************************/
void CAppMoney::SetMoney(float _money)
{
	money=_money;
}
/************************************************************************/
/*comment设置函数                                                       */
/************************************************************************/
void CAppMoney::SetComment(string _comment)
{
	comment=_comment;
}
/************************************************************************/
/*date设置函数                                                          */
/************************************************************************/
void CAppMoney::SetDate(string _date)
{
	date=_date;
}
/************************************************************************/
/* 充值操作函数                                                         */
/************************************************************************/
int CAppMoney::ActApp()
{
	CFormBase appmessage;
	appmessage.load();
	ShowAppMoneyInfo();	
// 	int len;
//	CMessageBox::Clear(27,26);
// 	string apptitle="Add money to account";
// 	len=apptitle.length();
// 	appmessage.GotoXY((80-len)/2,3);
// 	cout<<apptitle;cout.flush();

	//询问是否添加充值记录
	appmessage.GotoXY(28,16);
	cout<<"Do you want to save ?";cout.flush();
	appmessage.GotoXY(25,18);
	cout<<"Y: Save and back to main menu.";cout.flush();
	appmessage.GotoXY(25,19);
	cout<<"N: Back to main menu.";cout.flush();
	appmessage.GotoXY(25,20);
	cout<<"C: Abandon save and add money again.";cout.flush();
	appmessage.GotoXY(25,22);
	cout<<"Please make a choice[Y/N/C]:";
	char choice;
	int x,y;
	appmessage.WhereXY(&x,&y);
	do 
	{
		appmessage.GotoXY(x,y);
		choice=getch();
		if (isalpha(choice))
		{
			if (choice=='Y'||choice=='y')
			{
				return 0;
			}
			else if(choice=='N'||choice=='n')
			{
				return 1;
			}
			else if(choice=='C'||choice=='c')
			{
				return 2;
			}
			else
			{
				CMessageBox::ShowMessage("Input must be Y/N/C !");
				continue;
			}
		}
		else
		{
			CMessageBox::ShowMessage("Input must be letter !");
			continue;
		}
	} while (1);
}
/************************************************************************/
/* 充值记录添加函数                                                     */
/************************************************************************/
int CAppMoney::AddAppMoney()
{
	CFormBase addbal;
	int len;
	string apptitle="Add money to account";
	len=apptitle.length();
	addbal.GotoXY((80-len)/2,3);
	CMessageBox::Clear(27,26);
	cout<<apptitle;cout.flush();
	//询问是否添加充值记录	
	int k=ActApp();
	switch(k)
	{
	case 0:
		{	//保存,成功后打印账户信息,后返回菜单
			CAccManager& accman=CAccManager::GetInstance();
			float _balance=accman.GetRec(id-1).GetBalance();
			accman.GetRec(id-1).SetBalance(_balance+money);
			_balance=accman.GetRec(id-1).GetBalance();
			accman.SaveData();
			CAppMoneyManager& appman=CAppMoneyManager::GetInstance();
			CAppMoney tempapp(id,name,date,money,comment);
			appman.AddNewAppmoneyReport(tempapp);
			appman.SaveAppMoneyData();
			CMessageBox::ShowMessage("AppMoney success!");
			accman.GetVecAccount().clear();
			accman.Restore();
			CDateTime::DelayTime(1);
			return 0;
		}
	case 1:	return 1;//直接返回主菜单
	case 2:	return 2;//不保存,重新进入添加界面
				
	}
	return 0;
}
/************************************************************************/
/* 充值记录打印函数                                                     */
/************************************************************************/
void CAppMoney::ShowAppMoneyInfo()
{
	CFormBase addbal;
	int len;
	string acctitle="Add money to account";
	len=acctitle.length();
	addbal.GotoXY((80-len)/2,3);
	CMessageBox::Clear(27,26);
	cout<<acctitle;cout.flush();
	
	addbal.GotoXY(10,5);
	cout<<"--------------- Add money record information ---------------";cout.flush();
	addbal.GotoXY(28,7);
	cout<<"ID     : "<<id<<ends;
	addbal.GotoXY(28,8);
	cout<<"Date   : "<<date<<endl;
	addbal.GotoXY(28,9);
	string _smoney=CMyString::FloatToStr(money);
	cout<<"Money  : "<<_smoney<<endl;
	addbal.GotoXY(28,10);
	cout<<"Comment: "<<comment<<endl;	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -