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

📄 homeda.cs

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

namespace HouseDA
{
	/// <summary>
	/// HomeDA 的摘要说明。
	/// </summary>
	public class HomeDA:CommonDA
	{
		private SqlConnection _con;
		private ConDA _cons;
		private SqlCommand _cmd;
		private SqlDataAdapter _adapter;
		private DataSet _ds;
		private HouseBE.Home _home;
		private ArrayList list;
        
		public HouseBE.Home home
		{
			set
			{
				this._home=value;
			}
			get
			{
				return this._home;
			}
		}
		public HomeDA()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			this._cons=new ConDA();
			this._con=this._cons._con;
		}
		#region CommonDA 成员

		public DataSet select()
		{
			// TODO:  添加 HomeDA.select 实现
			try
			{
				this._adapter=new SqlDataAdapter("select * from Homes",this._con);
				this._ds=new DataSet();
				this._adapter.Fill(this._ds,"Finance");
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			return this._ds;
		}
		
		public ArrayList getMes()
		{
			this.list=new ArrayList();
			try
			{
				this._con.Open();
				string str="select * from HomesView";
				this._cmd=this._con.CreateCommand();
				this._cmd.CommandText=str;
				SqlDataReader dr=this._cmd.ExecuteReader();
				while(dr.Read())
				{
					this._home=new Home();
					this._home.getLPName=dr.GetValue(0).ToString();
					this._home.HomeTotalPrice=Convert.ToInt32(dr.GetValue(1).ToString());
					this._home.Remark=dr.GetValue(2).ToString();
					this._home.HomeFloor=Convert.ToInt32(dr.GetValue(3).ToString());
					this._home.HomeFormat=dr.GetValue(4).ToString();
					this._home.Hometypes=dr.GetValue(5).ToString();
					this._home.HomeCell=Convert.ToInt32(dr.GetValue(6).ToString());
					this._home.HomeChao=dr.GetValue(7).ToString();
					this._home.HomeArea=Convert.ToInt32(dr.GetValue(8).ToString());
					this._home.HomePrice=Convert.ToInt32(dr.GetValue(9).ToString());
					this._home.getHouseNO=dr.GetValue(10).ToString();
					this._home.HomeNO=dr.GetValue(11).ToString();
					this._home.State=dr.GetValue(12).ToString();
					this.list.Add(this._home);
				}

			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw;
			}
			finally
			{
				this._con.Close();
			}
			return this.list;
		}
		public void insert()
		{
			// TODO:  添加 HomeDA.insert 实现
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandType=CommandType.StoredProcedure;
			this._cmd.CommandText="proc_Homes";
			this._cmd.Parameters.Add("@LpName",this._home.getLPName);
			this._cmd.Parameters.Add("@HouseNO",this._home.getHouseNO);
			this._cmd.Parameters.Add("@HomeNO",this._home.HomeNO);
			this._cmd.Parameters.Add("@HomeFloor",this._home.HomeFloor);
			this._cmd.Parameters.Add("@HomeFormat",this.home.HomeFormat);
			this._cmd.Parameters.Add("@HomeTypes",this.home.Hometypes);
			this._cmd.Parameters.Add("@HomeCell",this.home.HomeCell);
			this._cmd.Parameters.Add("@HomeChao",this.home.HomeChao);
			this._cmd.Parameters.Add("@HomeArea",this.home.HomeArea);
			this._cmd.Parameters.Add("@HomePrice",this.home.HomePrice);
			this._cmd.Parameters.Add("@HomeTotalPrice",this.home.HomeTotalPrice);
			this._cmd.Parameters.Add("@Remark",this.home.Remark);
			this._cmd.Parameters.Add("@State",this.home.State);
			try
			{
				this._con.Open();
				this._cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			finally
			{
				this._con.Close();
			}
		}

		public void update()
		{
			// TODO:  添加 HomeDA.update 实现
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandText="update Homes set HouseID=@HouseID,HomeNO=@HomeNO,HomeFloor=@HomeFloor,HomeFormat=@HomeFormat,Hometypes=@Hometypes,HomeCell=@HomeCell,HomeChao=@HomeChao,HomeArea=@HomeArea,HomePrice=@HomePrice,HomeTotalPrice=@HomeTotalPrice,Remark=@Remark,State=@State where HomeID=@HomeID ";
			this._cmd.Parameters.Add("@HouseID",this._home.HouseID);
			this._cmd.Parameters.Add("@HomeNO",this._home.HomeNO);
			this._cmd.Parameters.Add("@HomeFloor",this._home.HomeFloor);
			this._cmd.Parameters.Add("@HomeFormat",this.home.HomeFormat);
			this._cmd.Parameters.Add("@Hometypes",this.home.Hometypes);
			this._cmd.Parameters.Add("@HomeCell",this.home.HomeCell);
			this._cmd.Parameters.Add("@HomeChao",this.home.HomeChao);
			this._cmd.Parameters.Add("@HomeArea",this.home.HomeArea);
			this._cmd.Parameters.Add("@HomePrice",this.home.HomePrice);
			this._cmd.Parameters.Add("@HomeTotalPrice",this.home.HomeTotalPrice);
			this._cmd.Parameters.Add("@Remark",this.home.Remark);
			this._cmd.Parameters.Add("@State",this.home.State);
			this._cmd.Parameters.Add("@HomeID",this.home.HomeID);
			try
			{
				this._con.Open();
				this._cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			finally
			{
				this._con.Close();
			}
		}

		public void delete()
		{
			// TODO:  添加 HomeDA.delete 实现
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandText="delete from Homes where HomeID=@HomeID";
			this._cmd.Parameters.Add("@HomeID",this.home.HomeID);
			try
			{
				this._con.Open();
				this._cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			finally
			{
				this._con.Close();
			}
		}

		#endregion
		public DataSet selectByTag(string tag)
		{  
			this._adapter=new SqlDataAdapter("select HomeNO from Homes where HouseID="+tag+"",this._con);
			this._ds=new DataSet();
			this._adapter.Fill(this._ds,"Homes");
			return  this._ds;
		}
		//退定的方法
		public void NotDesine()
		{
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandText="update Homes set State=@State where HouseID=@HomeID ";
			this._cmd.Parameters.Add("@State","未售");
			this._cmd.Parameters.Add("@HomeID",this.home.HomeID);
			try
			{
				this._con.Open();
				this._cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			finally
			{
				this._con.Close();
			}
		}

		//预定的方法
		public void Sale(string EmployeeName,string HouseNO,string ClientName)
		{
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandType=CommandType.StoredProcedure;
			this._cmd.CommandText="proc_insertDstine";
			this._cmd.Parameters.Add("@EmployeeName",EmployeeName);  
			this._cmd.Parameters.Add("@HouseNO",HouseNO);
			this._cmd.Parameters.Add("@ClientName",ClientName); 
		
			try
			{
				this._con.Open();
				this._cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw ex;
			}
			finally
			{
				this._con.Close();
			}

		}
		//销售的方法
		public void SaleHouse(string EmployeeName,string ClientName,string BargainNO,string SellFashion,string  SellDate,string TotalMoney,string HomeNO)
		{
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandType=CommandType.StoredProcedure;
			this._cmd.CommandText="proc_SaleHouse";
			this._cmd.Parameters.Add("@EmployeeName",EmployeeName);
			this._cmd.Parameters.Add("@ClientName",ClientName);
			this._cmd.Parameters.Add("@BargainNO",BargainNO);
			this._cmd.Parameters.Add("@SellFashion",SellFashion);
			this._cmd.Parameters.Add("@SellDate",@SellDate);
			this._cmd.Parameters.Add("@TotalMoney",int.Parse(TotalMoney));
			this._cmd.Parameters.Add("@HomeNO",@HomeNO);
			
			try
			{
				this._con.Open();
				this._cmd.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw  ex;
			}
			finally
			{
				this._con.Close();
			}
		}
		public DataSet selectID(string house)
		{
			this._adapter=new SqlDataAdapter("select HouseID from Homes where HomeNO='"+house+"'",this._con);
			this._ds=new DataSet();
			this._adapter.Fill(this._ds,"HouseID");
			return this._ds;
		}
		public DataSet SelectSateByTag(string house)
		{
		  this._adapter=new SqlDataAdapter("select state from Homes where HomeNO='"+house+"'",this._con);
		  this._ds=new DataSet();
		  this._adapter.Fill(this._ds,"house");
		  return this._ds;
		}
	}
}

⌨️ 快捷键说明

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