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

📄 employeeda.cs

📁 实现房产销售的房屋管理 客户管理 并且在客户管理中实现了对预定客户和已购房客户的查询和修改
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using HouseBE;

namespace HouseDA
{
	/// <summary>
	/// EmployeeDA 的摘要说明。
	/// </summary>
	public class EmployeeDA:CommonDA
	{
		private SqlConnection _con;
		private ConDA _cons;
		private SqlCommand _cmd;
		private SqlDataAdapter _adapter;
		private DataSet _ds;
		private HouseBE.Employee _employee;

		public HouseBE.Employee employee
		{
			set
			{
			  this._employee=value;
			}
			get
			{
			  return this._employee;
			}
		}
		public EmployeeDA()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
          this._cons=new ConDA();
			this._con=this._cons._con;
		}
		#region CommonDA 成员

		public DataSet select()
		{
			// TODO:  添加 EmployeeDA.select 实现
			try
			{
				this._adapter=new SqlDataAdapter("select * from VIEW_Employee",this._con);
				this._ds=new DataSet();
				this._adapter.Fill(this._ds,"Employee");
			}
			catch(Exception ex)
			{
			  Console.WriteLine(ex.Message);
			  throw ex;
			}
			return this._ds;
		}

		public void insert()
		{
			// TODO:  添加 EmployeeDA.insert 实现
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandText="insert into Employee(EmployeeName,BranchID,EmployeeAddress,EmployeeAge,EmployeeEDU,EmployeeSex,Reamark) values(@EmployeeName,@BranchID,@EmployeeAddress,@EmployeeAge,@EmployeeEDU,@EmployeeSex,@Reamark) ";
			this._cmd.Parameters.Add("@EmployeeName",this._employee.EmployeeName);
			this._cmd.Parameters.Add("@BranchID",this._employee.BranchName);
			this._cmd.Parameters.Add("@EmployeeAddress",this._employee.EmployeeAddress);
			this._cmd.Parameters.Add("@EmployeeAge",this._employee.EmployeeAge);
			this._cmd.Parameters.Add("@EmployeeEDU",this._employee.EmployeeEDU);
			this._cmd.Parameters.Add("@EmployeeSex",this._employee.EmployeeSex);
			this._cmd.Parameters.Add("@Reamark",this._employee.Reamark);

			try
			{
			  this._con.Open();
			  this._cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			finally
			{
			 this._con.Close();
			}
		}

		public void update()
		{
			// TODO:  添加 EmployeeDA.update 实现
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandText="update Employee set EmployeeName=@EmployeeName,BranchID=@BranchID,EmployeeAddress=@EmployeeAddress,EmployeeAge=@EmployeeAge,EmployeeEDU=@EmployeeEDU,EmployeeSex=@EmployeeSex,Reamark=@Reamark where EmployeeID=@EmployeeID ";
			this._cmd.Parameters.Add("@EmployeeName",this._employee.EmployeeName);
			this._cmd.Parameters.Add("@BranchID",this._employee.BranchName);
			this._cmd.Parameters.Add("@EmployeeAddress",this._employee.EmployeeAddress);
			this._cmd.Parameters.Add("@EmployeeAge",this._employee.EmployeeAge);
			this._cmd.Parameters.Add("@EmployeeEDU",this._employee.EmployeeEDU);
			this._cmd.Parameters.Add("@EmployeeSex",this._employee.EmployeeSex);
			this._cmd.Parameters.Add("@Reamark",this._employee.Reamark);
			this._cmd.Parameters.Add("@EmployeeID",this._employee.EmployeeID);
			try
			{
				this._con.Open();
				this._cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			finally
			{
				this._con.Close();
			}
		}

       //调用存储过程
		public void delete()
		{
			// TODO:  添加 EmployeeDA.delete 实现
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandType=CommandType.StoredProcedure;
			this._cmd.CommandText="proc_Employee";
			this._cmd.Parameters.Add("@EmployeeID",this._employee.EmployeeID);
			try
			{
				this._con.Open();
				this._cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			finally
			{
				this._con.Close();
			}
		}

		#endregion
		//查询ID的方法
		public DataSet selectByName(string name)
		{
			this._adapter=new SqlDataAdapter("select EmployeeID from Employee where EmployeeName="+name+"",this._con);
			this._ds=new DataSet();
			this._adapter.Fill(this._ds,"EmployeeID");
			return this._ds;
		}
	}
}

⌨️ 快捷键说明

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