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

📄 caccount.cpp

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

}
/************************************************************************
function:账户信息类构造函数
param:
return:
************************************************************************/
CAccount::CAccount(int _id,string _sex,string _name,string _birth,string _mobile,float _balance/* =0 */,string _stat/* = */)
{
	id=_id;
	if (_sex=="f"||_sex=="F")
		sex="Female";
	else
		sex="Male";
	name=_name;
	birth=_birth;
	mobile=_mobile;
	balance=_balance;
	stat=_stat;
}
/************************************************************************
function:账户信息类析构函数
param:
return:
************************************************************************/
CAccount::~CAccount()
{
	
}
/************************************************************************
function:账户id获取函数
param:
return:
************************************************************************/
int CAccount::GetID()
{
	return id;
}
/************************************************************************
function:账户性别获取函数
param:
return:
************************************************************************/
string CAccount::GetSex()
{
	return sex;
}
/************************************************************************
function:账户姓名获取函数
param:
return:
************************************************************************/
string CAccount::GetName()
{
	return name;
}
/************************************************************************
function:账户状态获取函数
param:
return:
************************************************************************/
string CAccount::GetStat()
{
	return stat;
}
/************************************************************************
function:账户生日获取函数
param:
return:
************************************************************************/
string CAccount::GetBirth()
{
	return birth;
}
/************************************************************************
function:账户电话获取函数
param:
return:
************************************************************************/
string CAccount::GetMobile()
{
	return mobile;
}
/************************************************************************
function:账户余额获取函数
param:
return:
************************************************************************/
float CAccount::GetBalance()
{
	return balance;
}

/************************************************************************
function:id设置函数
param:
return:
************************************************************************/
void CAccount::SetID(int _id)
{
	id=_id;
}
/************************************************************************
function:sex设置函数
param:
return:
************************************************************************/
void CAccount::SetSex(string _sex)
{
	sex=_sex;
}
/************************************************************************
function:name设置函数
param:
return:
************************************************************************/
void CAccount::SetName(string _name)
{
	name=_name;
}
/************************************************************************
function:mobile设置函数
param:
return:
************************************************************************/
void CAccount::SetMobile(string _mobile)
{
	mobile=_mobile;
}
/************************************************************************
function:birthday设置函数
param:
return:
************************************************************************/
void CAccount::SetBirth(string _birth)
{
	birth=_birth;
}
/************************************************************************
function:balance设置函数
param:
return:
************************************************************************/
void CAccount::SetBalance(float _balance)
{
	balance=_balance;

}
/************************************************************************
function:stat状态设置函数
param:
return:
************************************************************************/
void CAccount::SetStat(string _stat)
{
	stat=_stat;
}
/************************************************************************
function:账户信息打印函数
param:
return:无
************************************************************************/
void CAccount::ShowAccInfo()
{
 	CFormBase accinfo;
	accinfo.load();
	string acctitle="Account Message";
	int len=acctitle.length();
	accinfo.GotoXY((80-len)/2,3);
	cout<<acctitle;cout.flush();
 	accinfo.GotoXY(10,5);
	cout<<"------------------- Account Information ------------------";cout.flush();
	accinfo.GotoXY(29,7);
	char temp[50]={0};
	sprintf(temp,"ID      : %d",id);
	cout<<temp<<endl;
	accinfo.GotoXY(29,8);
	sprintf(temp,"Sex     : %s",sex.c_str());
	cout<<temp<<endl;
	accinfo.GotoXY(29,9);
	sprintf(temp,"Name    : %s",name.c_str());
	cout<<temp<<endl;
	accinfo.GotoXY(29,10);
	sprintf(temp,"Birthday: %s",birth.c_str());
	cout<<temp<<endl;
	accinfo.GotoXY(29,11);
	sprintf(temp,"Mobile  : %s",mobile.c_str());
	cout<<temp<<endl;
	accinfo.GotoXY(29,12);
	sprintf(temp,"Balance : %.2f",balance);
	cout<<temp<<endl;
}
/***********************************************************************
账户信息操作函数
***********************************************************************/
int CAccount::ActAcc()
{
	
	//询问操作:充值或者停用账户,或返回浏览页面
	CFormBase accmessage;
	accmessage.load();
	ShowAccInfo();
	string acctitle="Account Message";
	int len=acctitle.length();
	accmessage.GotoXY((80-len)/2,3);
	cout<<acctitle;cout.flush();
	accmessage.GotoXY(22,17);
	cout<<"1.Add money to this account.";cout.flush();
	accmessage.GotoXY(22,18);
	cout<<"2.Stop this account.";cout.flush();
	accmessage.GotoXY(22,19);
	cout<<"0.Back to Browse account.";cout.flush();
	accmessage.GotoXY(22,21);
	cout<<"Please make a choice[0-2]:";
	int x,y;
	char choice;
	accmessage.WhereXY(&x,&y);
	do 
	{
		choice=getch();
		if (isdigit(choice))
		{
			if (choice<'3')
			{
				if (choice=='0')
				{
					return 0;
				}
				else if(choice=='1')
				{
					return 1;
				}
				else
				{
					return 2;
				}
				break;
			}
			else
			{
				CMessageBox::ShowMessage("Input must be in 0 to 2 !");
				continue;
			}
		}
		else
		{
			CMessageBox::ShowMessage("Input must be digit.");
			continue;
		}
	} while (1);
}
/************************************************************************
function:账户充值函数
param:
return:
************************************************************************/
int CAccount::AddBalance()
{
	CFormAppendMoney appmoney;
	appmoney.InputID(id);
	appmoney.load();

	return 0;
}
/************************************************************************
function:帐户停用设置函数
param:
return:
************************************************************************/
bool CAccount::Stop()
{
	CFormBase stopacc;
	ShowAccInfo();
	string acctitle="Stop a member account";
	int len=acctitle.length();
	stopacc.GotoXY((80-len)/2,3);
	cout<<acctitle;cout.flush();
	
	CMessageBox::ShowMessage("Do you confirm to stop this account?(Y/N)");
	int x,y;
	stopacc.WhereXY(&x,&y);
	char ch;
	do 
	{
		stopacc.GotoXY(x,y);
		ch=getch();
		if (isalpha(ch))
		{
			cout<<ch;
			if (ch=='Y'||ch=='y')
			{
				SetStat("Stop");//停用,stat='Q'销户
				return true;
			}
			else if (ch=='N'||ch=='n')
			{
				return false;
			}
			break;
		}
	} while (1);
	return true;
}
/************************************************************************/
/*   管理类文件读取inout=0 保存inout=1 读取 							*/
/************************************************************************/
bool CAccount::Serial(fstream &fs, int inout )
{
	int len;
	char temp[200];
	
	if(inout==0)
	{
		fs.write((char*)&id, sizeof(id));
		
		len=name.size();
		fs.write((char*)&len, sizeof(len));
		fs.write(name.c_str(), len);
		
		fs.write((char *)&sex,sizeof(sex));
		
		len=birth.size();
		fs.write((char*)&len, sizeof(len));
		fs.write(birth.c_str(), len);
		
		len=mobile.size();
		fs.write((char*)&len, sizeof(len));
		fs.write(mobile.c_str(), len);	
		
		len=comment.size();
		fs.write((char*)&len, sizeof(len));
		fs.write(comment.c_str(),len);
		
		len=birth.size();
		fs.write((char*)&len, sizeof(len));
		fs.write(birth.c_str(),len);
		
		fs.write((char*)&balance, sizeof(balance));
		fs.write((char*)&stat, sizeof(stat));
		
		return true;
		
	}
	else if(inout==1)
	{
		fs.read((char*)&id, sizeof(id));
		
		fs.read((char*)&len, sizeof(len));
		fs.read(temp, len);
		temp[len]=0;
		name=temp;
		
		fs.read((char *)&sex,sizeof(sex));
		
		fs.read((char*)&len, sizeof(len));
		fs.read(temp, len);
		temp[len]=0;
		birth=temp;
		
		fs.read((char*)&len, sizeof(len));
		fs.read(temp, len);
		temp[len]=0;
		mobile=temp;	
		
		fs.read((char*)&len, sizeof(len));
		fs.read(temp,len);
		temp[len]=0;
		comment=temp;
		
		fs.read((char*)&len, sizeof(len));
		fs.read(temp,len);
		temp[len]=0;
		birth=temp;
		
		fs.read((char*)&balance, sizeof(balance));
		fs.read((char*)&stat, sizeof(stat));
		return true;		
	}
	else	return false;	
}

⌨️ 快捷键说明

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