📄 lpmessageda.cs
字号:
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using HouseBE;
namespace HouseDA
{
/// <summary>
/// LPMessageDA 的摘要说明。
/// </summary>
public class LPMessageDA:CommonDA
{
private SqlConnection _con;
private ConDA _cons;
private SqlCommand _cmd;
private SqlDataAdapter _adapter;
private DataSet _ds;
private HouseBE.LPMessage _lpmessage;
private ArrayList list=null;
public HouseBE.LPMessage lpmessage
{
set
{
this._lpmessage=value;
}
get
{
return this._lpmessage;
}
}
public LPMessageDA()
{
//
// TODO: 在此处添加构造函数逻辑
//
this._cons=new ConDA();
this._con=this._cons._con;
}
#region CommonDA 成员
public DataSet select()
{
// TODO: 添加 LPMessageDA.select 实现
try
{
this._adapter=new SqlDataAdapter("select * from LPMessage",this._con);
this._ds=new DataSet();
this._adapter.Fill(this._ds,"LPMessage");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
return this._ds;
}
public void insert()
{
// TODO: 添加 LPMessageDA.insert 实现
this._cmd=this._con.CreateCommand();
this._cmd.CommandText="insert into LPMessage values(@LPName,@CellCount,@FloorCount,@HouseCount,@Opendatetime,@Remark) ";
this._cmd.Parameters.Add("@LPName",this._lpmessage.LPName);
this._cmd.Parameters.Add("@CellCount",this._lpmessage.CellCount);
this._cmd.Parameters.Add("@FloorCount",this._lpmessage.FloorCount);
this._cmd.Parameters.Add("@HouseCount",this._lpmessage.HouseCount);
this._cmd.Parameters.Add("@Opendatetime",this._lpmessage.Opendatetime);
this._cmd.Parameters.Add("@Remark",this._lpmessage.Remark);
try
{
this._con.Open();
this._cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
}
public void update()
{
// TODO: 添加 LPMessageDA.update 实现
this._cmd=this._con.CreateCommand();
this._cmd.CommandText="update LPMessage set LPName=@LPName,CellCount=@CellCount,FloorCount=@FloorCount,HouseCount=@HouseCount,Opendatetime=@Opendatetime,Remark=@Remark where LPID=@LPID";
this._cmd.Parameters.Add("@LPName",this._lpmessage.LPName);
this._cmd.Parameters.Add("@CellCount",this._lpmessage.CellCount);
this._cmd.Parameters.Add("@FloorCount",this._lpmessage.FloorCount);
this._cmd.Parameters.Add("@HouseCount",this._lpmessage.HouseCount);
this._cmd.Parameters.Add("@Opendatetime",this._lpmessage.Opendatetime);
this._cmd.Parameters.Add("@Remark",this._lpmessage.Remark);
this._cmd.Parameters.Add("@LPID",this._lpmessage.LPID);
try
{
this._con.Open();
this._cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
finally
{
this._con.Close();
}
}
//调用存储过程
public void delete()
{
// TODO: 添加 LPMessageDA.delete 实现
this._cmd=this._con.CreateCommand();
this._cmd.CommandType=CommandType.StoredProcedure;
this._cmd.CommandText="proc_LPMessage";
this._cmd.Parameters.Add("@LPID",this._lpmessage.LPID);
try
{
this._con.Open();
this._cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
finally
{
this._con.Close();
}
}
#endregion
//查询ID的方法
public DataSet selectByTag(string tag)
{
this._adapter=new SqlDataAdapter("select HouseID,HouseNO from House where LPID="+tag+" ",this._con);
this._ds=new DataSet();
this._adapter.Fill(this._ds,"House");
return this._ds;
}
//查询出所有的楼房信息
public ArrayList GetTotal()
{
this.list=new ArrayList();
try
{
this._con.Open();
string str="select * from LPMessage";
SqlCommand cmd=this._con.CreateCommand();
cmd.CommandText=str;
SqlDataReader reads=cmd.ExecuteReader();
while(reads.Read())
{
this._lpmessage=new LPMessage();
this._lpmessage.LPID=Convert.ToInt32(reads.GetValue(0).ToString());
this._lpmessage.LPName=reads.GetValue(1).ToString();
this._lpmessage.CellCount=Convert.ToInt32(reads.GetValue(2).ToString());
this._lpmessage.FloorCount=Convert.ToInt32(reads.GetValue(3).ToString());
this._lpmessage.HouseCount=Convert.ToInt32(reads.GetValue(4).ToString());
this._lpmessage.Opendatetime=reads.GetValue(5).ToString();
this._lpmessage.Remark=reads.GetValue(6).ToString();
this.list.Add(this._lpmessage);
}
return this.list;
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
finally
{
this._con.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -