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

📄 atm.cpp

📁 本ATM软件为纯C++编写
💻 CPP
字号:
#include <iostream>
#include <string>
#include <conio.h> 
#include "Disply.h"
#include "CFile.h"
#include "CUserInfo.h"
#include "CControl.h"

using namespace std;

int g_nAccount=0;
/**************************************************
* 函数名: UserLoadSym
* 参数:  无
* 返回值:用户登录成功返回值为1 登录不成功返回值为0
* 功能:
*		该函数实现普通用户的登录
* 作者:		 孙玉猛
* 编写明细:  
*            完成时间	2009.01.02  Created  孙玉猛
			
**************************************************/
int UserLoadSym()//普通户用户登录系统
{

	int i=0,j=0,nNum=0,nFlag=0; 
	int nType=0;
	ifstream fin;
	char chOne; 
	C_File onefile;
	string strAccount, strPasswd;//接收用户输入的账号和密码
	CBalanceInfoData *ppBalanceInfoData=NULL;
	fin.open("User.ini");
	if (!fin.is_open())
	{
		cout <<"现无用户可以登录!"<<endl;
		return 0;
	}
	onefile.ReadBalanceInfo();//获取用户的帐户信息
	ppBalanceInfoData=onefile.pBalanceInfoData;
    cout<<"请输入账号:";
	cin>>strAccount;
	g_nAccount=atoi(strAccount.c_str());
	
	
	while(ppBalanceInfoData)
	{
		if (ppBalanceInfoData->UserBalanceInfo->GetAccountNum()==g_nAccount)			//账户存在
		{
			if (ppBalanceInfoData->UserBalanceInfo->GetFlag()==1)						//账户没被销户
			{
				nType=1;
				break;
			}
			if (ppBalanceInfoData->UserBalanceInfo->GetFlag()==0)						//账户被销户
			{
				break;
			}
			
		} 
		else
		{
			ppBalanceInfoData=ppBalanceInfoData->pNext;                         //节点后移
		}
	}
	if (nType == 0)
	{
		cout<<"账户不存在"<<endl;
		return 0;
	}
	if (nType == 1)
	{
		for (nNum=0; nNum < 3; nNum++)					//用户密码
		{
			strPasswd="";
		
			fflush(stdin);
			cout<<"请输入密码:";
			while ((chOne=_getch())!=13)         //接收用户输入密码
			{ 
				char chTemp = chOne;
				if (chTemp == 8 && i != 0)
				{
					int nLen = strPasswd.length();
					strPasswd[nLen-1] = 0;
					cout << '\b';
					cout <<' ';
					cout <<'\b';
				}
				if (chTemp != 8)
				{
					strPasswd+=chOne;//
					cout <<"*";
					i++;
				}
			} 
			
			
				if (strPasswd.compare(ppBalanceInfoData->UserBalanceInfo->GetPassWd())==0)//若密码输入正确
				{
					nFlag=1;//用户登陆成功
					break;
				} 
				else
				{
					cout<<endl<<"您输入的密码不正确!"<<endl;;
				}
			
			
	}
		if (nFlag==1)
		{
			return 1;
		}
	
	}
	
return 0;
	
	
													
}
/**************************************************
* 函数名: SuperLoadSym
* 参数:  无
* 返回值:用户登录成功返回2,用户登录不成功返回1
* 功能:
*		该函数实现管理员的登录,如果输入密码和用户名
*       正确则返回2,反之返回值为1
* 作者:		 孙玉猛
* 编写明细:  
*            完成时间	2009.01.02  Created  孙玉猛
			
**************************************************/
int SuperLoadSym()//操作员登录
{
	string strInputName,strName,password,password1,password2; 
	int i=0,j=0,nNum=0,nFlag=0; 
	char chOne,chTwo; 
	ifstream fin;
	fin.open("Super.ini");
	if (!fin.is_open())
	{
		cout <<"配置文件不存在!"<<endl;
		return 0;
	}
	fin>>strName>>password;//获取配置文件里面的用户名和密码
	fin.close();
	for (nNum=0; nNum < 3; nNum++)//用户输入用户名和密码
	{
		password1="";
		password2="";
		cout<<"请输入用户名:";
		cin>>strInputName;
		cout<<"请输入密码:";
		while ((chOne=_getch())!=13) //接收用户输入密码
		{ 
			char chTemp = chOne;
			if (chTemp == 8 && i != 0)
			{
				int nLen = password1.length();
				password1[nLen-1] = 0;
				cout << '\b';
				cout <<' ';
				cout <<'\b';
			}
			if (chTemp != 8)
			{
				password1+=chOne;//
				cout <<"*";
				i++;
			}
		} 
		fflush(stdin);
		cout<<endl<<"请确认密码:";
		while ((chTwo=_getch())!=13) //用户密码确认
		{ 
			char chTemp = chTwo;
			if (chTemp == 8 && j != 0)
			{
				int nLen = password2.length();
				password1[nLen-1] = 0;
				cout << '\b';
				cout <<' ';
				cout <<'\b';
			}
			if (chTemp != 8)
			{
				password2+=chTwo;//
				cout <<"*";
				j++;
			}
		} 
		fflush(stdin);
		if (password1.compare(password2)!=0)//判断两次输入的密码是否一致
		{
			cout<<endl<<"您输入的密码不一致,请重新输入!"<<endl;
		} 
		else 
		{
			if (password1.compare(password)==0)//若密码输入正确
			{
				if (strName.compare(strInputName)==0)
				{
					nFlag=1;//用户登陆成功
					break;
				} 
				else
				{
					cout<<endl<<"您输入的用户名不正确,请重新输入!"<<endl;
				}
			} 
			else
			{
				cout<<endl<<"您输入的密码不正确,请重新输入!"<<endl;;
			}
		
		}
	}//end for
	if (nFlag==0)
	{
		return 1;
	} 
	else
	{
		return 2;
	}
  
}
/**************************************************
* 函数名: SuperOperate
* 参数:  无
* 返回值:无
* 功能:
*		该函数实现管理员对用户帐户的管理,实现用户的
*       开户 销户 导入信息 导出信息等功能的
* 作者:		 孙玉猛
* 编写明细:  
*            完成时间	2009.01.02  Created  孙玉猛
			
**************************************************/
void SuperOperate()  //操作员对系统的操作
{
	string strInput;
	CControl p;
	system("cls");
	DisplySuperOperate();//显示操作员管理系统的界面
	while(1)
	{	
	
		cin>>strInput;
		if (strInput[0]=='0')
		{
			system("cls");
			break;	
		}
		else if (strInput[0]=='1')//操作员开户
		{
			system("cls");
			DisplyOpenAccount();
			p.openAccount();
			system("cls");
			DisplySuperOperate();
		}
		else if (strInput[0]=='2')//操作员销户
		{
			system("cls");
			DisplyDeleteAccount();
			p.DeleteAccount();
			system("cls");
			DisplySuperOperate();
		}
		else if (strInput[0]=='3')//操作员导入信息
		{
			system("cls");
			p.LeadInInfo();
			system("cls");
			DisplySuperOperate();
		}
		else if (strInput[0]=='4')//操作员导出信息
		{
			system("cls");
			p.LeadOutInfo();
			system("cls");
			DisplySuperOperate();
		}
		else
		{
			cout<<"你输入的不正确,请重新输入!"<<endl;
		    cout<<">>请选择:";
		}

	}

	

}
/**************************************************
* 函数名: UserOperat
* 参数:  无
* 返回值:无
* 功能:
*		该函数实现用户对自己帐户的操作,实现用户的
*       存款 取款 转账 查询余额 查询余额 查询业务清
*       单等功能
* 作者:		 闫先海
* 编写明细:  
*            完成时间 2009.01.02	Created	闫先海
*			 
*
**************************************************/
void UserOperate()//
{
	string  strInput;
	CControl p;
	p.setAccountNum(g_nAccount);
	system("cls");
	DisplyUserOperate();
	while(1)
	{
	
		cout<<">>请选择:";
		cin>>strInput;
		if (strInput=="0")//返回上一级菜单
		{
			break;	
		}
		else if (strInput=="1")//用户存款
		{
			system("cls");
			DisplyDeposit();
			p.Deposit();
			system("cls");
			DisplyUserOperate();
	
		
		}
		else if (strInput=="2")//用户取款
		{
			system("cls");
			DisplyWithdraw();
			p.WithDraw();
			system("cls");
			DisplyUserOperate();
		
		
		}
		else if (strInput=="3")//用户查询余额
		{
			system("cls");
			DisplyCheckBalance();
			p.CheckBalance();
			system("cls");
			DisplyUserOperate();
		
		
		}
		else if (strInput=="4")//用户转账
		{
			system("cls");
			DisplyTansferAccount();
			p.TransferAccount();
			system("cls");
			DisplyUserOperate();
		
		
		}
		else if (strInput=="5")//用户查询操作清单
		{
			system("cls");
			DisplyOperateInfo();
			p.CheckOperateInfo();
			system("cls");
			DisplyUserOperate();
		
		}
		else
			cout<<"你输入的不正确,请重新输入!"<<endl;
	}

}
/************************************
* Copyright (c) 2009,北京乐成有限公司
*
* 文件名称:main.cpp
* 摘要:
*		
*本项目节减、精选了储蓄综合业务平台,
*从中提取了储蓄柜台的最常用的功能:操
*作员登录、开户、销户、导入导出用户信
*息;用户登录、存款、取款、查询余额及
*查询清单等业务
************************************/

void main()
{
	string  nInput;
	DisplyWelcome();
	while(1)
	{
		cout<<"请选择:";
		cin>>nInput;
		if (nInput=="0")
		{
			break;
		} 
		else if (nInput=="1")
		{
			int i=SuperLoadSym();//操作员登录
			if (i==0||i==1)
			{
				break;
			} 
			else
			{
				SuperOperate();//操作员管理系统
				system("cls");
				DisplyWelcome();
			}
		}
		else if (nInput=="2")
		{
			
				int i=UserLoadSym();//普通用户登录
				if (i==0)
				{
					break;
				} 
				if (i==1)
				{
					UserOperate();//普通用户操作
					system("cls");
					DisplyWelcome();
				}
		}
		else if (nInput=="3")//显示帮助信息
		{
			system("cls");
			DisplyHelp();
			cout<<"按任意键返回...";
			getch();
			system("cls");
			DisplyWelcome();
		}
		else
		{
			cout<<"您输入的不正确,请重新输入!"<<endl;
		}
	}
	
}

⌨️ 快捷键说明

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