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

📄 loginda.cs

📁 实现房产销售的房屋管理 客户管理 并且在客户管理中实现了对预定客户和已购房客户的查询和修改
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using HouseBE;
namespace HouseDA
{
	/// <summary>
	/// Login 的摘要说明。
	/// </summary>
	public class LoginDA
	{
		private bool _isLogin=false;
		private SqlConnection _con;
		private ConDA cons=new ConDA();
		private HouseBE.Login _login;
		
		public HouseBE.Login logins
		{
			set
			{
			  this._login=value;
			}
			get
			{
			  return this._login;
			}
		}
		public LoginDA()
		{
			this._con=cons._con;
		}
		public bool Logins()
		{
		   string  ishave="select * from login where LoginName=@name and LoginPwd=@pwd";
		   SqlCommand cmd=this._con.CreateCommand();
		   cmd.CommandText=ishave;
		   cmd.Parameters.Add("@name",this._login.LoginName);
		   cmd.Parameters.Add("@pwd",this._login.LoginPwd);
			try
			{
				this._con.Open();
				SqlDataReader reader=cmd.ExecuteReader();
				if(reader.Read())
				{
					this._isLogin=true;
				}
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			finally
			{
			 this._con.Close();
			}
			return this._isLogin;
		}
		public void insert()
		{
		   SqlCommand cmd=this._con.CreateCommand();
           cmd.CommandText="insert into login values(@LoginName,@LoginPwd)";
		   cmd.Parameters.Add("@LoginName",this._login.LoginName);
		   cmd.Parameters.Add("@LoginPwd",this._login.LoginPwd);

			try
			{
				this._con.Open();
				cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);			
				throw ex;
			}
			finally
			{
			 this._con.Close();
			}
		}
		public void update()
		{
			SqlCommand cmd=this._con.CreateCommand();
			cmd.CommandText="update login set LoginPwd=@LoginPwd where LoginName=@LoginName";
			cmd.Parameters.Add("@LoginPwd",this._login.LoginPwd);
			cmd.Parameters.Add("@LoginName",this._login.LoginName);

			try
			{
				this._con.Open();
				cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);			
				throw ex;
			}
			finally
			{
			 this._con.Close();
			}
			
		}
		public DataSet load()
		{
		   DataSet ds=new DataSet();
		   SqlDataAdapter adpter=new SqlDataAdapter("select LoginName from Login",this._con);
		   adpter.Fill(ds,"Login");
		   return ds;
		}
	}
}

⌨️ 快捷键说明

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