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

📄 specsda.cs

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

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

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

		public void insert()
		{
			// TODO:  添加 SpecsDA.insert 实现
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandText="insert into Specs values(@SpecType,@Remark)";
			this._cmd.Parameters.Add("@SpecType",this._specs.SpecType);
			this._cmd.Parameters.Add("@Remark",this._specs.Remark);

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

		public void update()
		{
			// TODO:  添加 SpecsDA.update 实现
			this._cmd=this._con.CreateCommand();
			this._cmd.CommandText="update Specs set SpecType=@SpecType,Remark=@Remark where SpecID=@SpecID";
			this._cmd.Parameters.Add("@SpecType",this._specs.SpecType);
			this._cmd.Parameters.Add("@Remark",this._specs.Remark);
            this._cmd.Parameters.Add("@SpecID",this._specs.SpecID);

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

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

		#endregion
	}
}

⌨️ 快捷键说明

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