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

📄 cformbrowseaccount.cpp

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

}
/************************************************************************/
/*默认析构函数                                                          */
/************************************************************************/
CFormBrowseAccount::~CFormBrowseAccount()
{

}
/************************************************************************/
/* 浏览类界面函数                                                       */
/************************************************************************/

void CFormBrowseAccount::load()
{
	do 
	{
		CFormBase::load();
		//遍历一次向量容器,将账户打印出来
		CAccManager &accman=CAccManager::GetInstance();
		int accsize;
		accsize=accman.GetSize();
		vector<CAccount> tempvec;
		string _state;
		for (int i=0;i<accsize;i++)
		{
			_state=accman.GetRec(i).GetStat();
			if(_state=="Alive")
				tempvec.push_back(accman.GetRec(i));
		}
		BrowseForm();
		int x,y;WhereXY(&x,&y);
		char temp[100]={0};
		int maxpage,page=1;
		int size=tempvec.size();
		maxpage=size/PAGENUMBER;
		if(size%PAGENUMBER)
			maxpage++;
		GotoXY(36,9+PAGENUMBER);cout<<size;
		GotoXY(57,9+PAGENUMBER);
		sprintf(temp,"%d/%d",page,maxpage);
		cout<<temp<<ends;
		PrintPage(tempvec,maxpage,page);
		char ch;
		do{
			GotoXY(x,y);
			ch=getch();
			if(ch==-32||ch==0)
				ch=getch();
			CMessageBox::ShowMessage("");
			if((ch==75 || ch==73 ||ch==72) || (ch==77||ch==80||ch==81)||ch==71 || ch==79)
			{
				if(ChangePage(ch,maxpage,page))
				{
					PrintPage(tempvec,maxpage,page);
					GotoXY(57,9+PAGENUMBER);
					sprintf(temp,"%d/%d",page,maxpage);
					cout<<temp<<ends;
				}
				continue;
			}
			else if(isdigit(ch))
			{
				if(ch>'1')
				{
					CMessageBox::ShowMessage("Input must be in 0 to 2 !");
					continue;
				}
				switch(ch)
				{
				case '0':return;
				case '1':
					GotoXY(22,22);
					cout<<"Please input an account:";WhereXY(&x,&y);
					break;
				}
				break;
			}
			else if(ch==27)
			{
				return;
			}
			else
			{
				CMessageBox::ShowMessage("Input must be digit.");
				continue;
			}
		}while(1);
		int num;
		do{ 
			GotoXY(x,y);
			num=InputNum();
			if(num==-1)
				return;
			for (int i=0;i<accsize;i++)
			{
				if (num==tempvec[i].GetID())
				{
					break;
				}
			}
			if (i==accsize)
			{
				CMessageBox::ShowMessage("There is not this account !");
				continue;
			}
			else
				break;
		}while(1);
		//调用账户信息页面
		int act=accman.GetRec(num-1).ActAcc();
		if (act==1)
		{
			accman.GetRec(num-1).AddBalance();//充值
			continue;
		}
		else if (act==2)
		{
			accman.GetRec(num-1).Stop();//停用
			return;
		}
		else
		{
			return;//返回菜单
		}
	} while (1);
}
/************************************************************************/
/* 浏览账户信息菜单函数                                                */
/************************************************************************/
void CFormBrowseAccount::BrowseForm()
{
	CFormBase::load();
	string title("Browse member account");
	int len=title.length();
	GotoXY((80-len)/2,3);
	cout<<title<<endl;
	Print();
	GotoXY(22,17);
	cout<<"1.Select a member account";cout.flush();
	GotoXY(22,18);
	cout<<"0.Return to menu";cout.flush();
	GotoXY(22,20);
	cout<<"Please make a choice[0-1]:";
}
/************************************************************************/
/* 编号输入函数                                                         */
/************************************************************************/
int CFormBrowseAccount::InputNum()
{
	int x,y;
	WhereXY(&x,&y);
	string strno;
	int no,len;
	do 
	{
		GotoXY(x,y);
		CMessageBox::Clear(x,3);
		GetString(strno,3);
		len=strno.length();
		if(strno[len-1]==27)
		{
		//	CMessageBox::Clear(22,30);
			return -1;
		}
		if(!CMyString::CheckID(strno))
			continue;
		else
			no=CMyString::StrToInt(strno);
		return no;
	} while (1);
}

⌨️ 快捷键说明

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