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

📄 jiaoyi.cs

📁 实现ATM模拟
💻 CS
字号:
//张波
//版权所有,请勿模仿

using System;
using server.数据访问层;

namespace server.实体层
{
	public class JiaoYi
	{
		string id;//用户帐户
		public string Id
		{
			get{ return id;}
			set{id = value;}
		}
	
		double balance;//用户余额
		public double Balance
		{
			get{ return balance;}
			set{balance = value;}
		}

		public string Pwd;//用户密码
		public string pwassword
		{
			get{return Pwd;}
			set{Pwd=value;}
		}
		public JiaoYi(string id,double balance)
		{
			this.id = id;
			this.balance = balance;
		}

		public JiaoYi()
		{
		}

		public double QueryBalance()
		{
			//通过调用ExecuteScaler方法查询用户余额
			string sql1 = string.Format("select balance from Account where Id = {0}",this.id);
			this.balance = Convert.ToDouble(数据访问层.DBC.ExecuteScaler(sql1));
			return this.balance;//返回查询的余额
		}

		public bool QueryAccountExists()
		{
			//通过调用ExecuteScaler方法查询用户余额是否存在
			//返回bool型
			string sql2 = string.Format("select balance from Account where Id = {0}",this.id);
			if(数据访问层.DBC.ExecuteScaler(sql2) != null)
			{
				return true;//如果存在返回true
			}
			else
			{
				return false;//如果不存在放回false
			}
		}

	
		public bool SetMoney(double money)
		{
			//通过调用ExecuteUpdate方法向数据库里添加用户存入的金额
			this.balance += money;
			string sql3  = string.Format("update Account set balance = balance + {0} where Id = {1}",money,this.id);
			return 数据访问层.DBC.ExecuteUpdate(sql3);
			
		
		}

		public bool GetMoney(double money)
		{
			//通过调用ExecuteUpdate方法根据用户取出的金额,改变数据库里用户的余额
			double i=QueryBalance();
			//判断用户取的金额是否可以取出
			if(	(i-money)>0)
			{
				this.balance-=money;
				string sql4  = string.Format("update Account set balance = balance - {0} where Id = {1}",money,this.id);
				return 数据访问层.DBC.ExecuteUpdate(sql4);
					
			}
			else
			{
				return false;
			}
		}
		public bool denglu(string id,string pwd)
		{
			//通过用户输入,调用ExecuteCommand方法查询用户帐户是否存在
			string sql5="select * from Account where Id='"+id+"' and password='"+pwd+"'";
			return 数据访问层.DBC.ExecuteCommand(sql5);
		}
	}
}

⌨️ 快捷键说明

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