📄 calendarda.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using HouseBE;
namespace HouseDA
{
/// <summary>
/// CalendarDA 的摘要说明。
/// </summary>
///
public class CalendarDA:CommonDA
{
private SqlConnection _con;
private ConDA _cons;
private SqlCommand _cmd;
private SqlDataAdapter _adapter;
private DataSet _ds;
private HouseBE.Calendar _calendar;
public HouseBE.Calendar calendar
{
set
{
this._calendar=value;
}
get
{
return this._calendar;
}
}
public CalendarDA()
{
//
// TODO: 在此处添加构造函数逻辑
//
this._cons=new ConDA();
this._con=this._cons._con;
}
#region CommonDA 成员
public DataSet select()
{
// TODO: 添加 CalendarDA.select 实现
try
{
this._adapter=new SqlDataAdapter("select * from Calendar",this._con);
this._ds=new DataSet();
this._adapter.Fill(this._ds,"Calendar");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
return this._ds;
}
public void insert()
{
// TODO: 添加 CalendarDA.insert 实现
this._cmd=this._con.CreateCommand();
this._cmd.CommandText="insert into Calendar values(@CalendarDate,@CalendarTitle,@CalendarMessage)";
this._cmd.Parameters.Add("@CalendarDate",this._calendar.CalendarDate);
this._cmd.Parameters.Add("@CalendarTitle",this._calendar.CalendarTitle);
this._cmd.Parameters.Add("@CalendarMessage",this._calendar.CalendarMessage);
try
{
this._con.Open();
this._cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
finally
{
this._con.Close();
}
}
public void update()
{
// TODO: 添加 CalendarDA.update 实现
this._cmd=this._con.CreateCommand();
this._cmd.CommandText="update Calendar set CalendarDate= @CalendarDate,CalendarTitle=@CalendarTitle,CalendarMessage=@CalendarMessage where CalendarID=@CalendarID";
this._cmd.Parameters.Add("@CalendarDate",this._calendar.CalendarDate);
this._cmd.Parameters.Add("@CalendarTitle",this._calendar.CalendarTitle);
this._cmd.Parameters.Add("@CalendarMessage",this._calendar.CalendarMessage);
this._cmd.Parameters.Add("@CalendarID",this._calendar.CalendarID);
try
{
this._con.Open();
this._cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
finally
{
this._con.Close();
}
}
public void delete()
{
// TODO: 添加 CalendarDA.delete 实现
this._cmd=this._con.CreateCommand();
this._cmd.CommandType=CommandType.StoredProcedure;
this._cmd.CommandText="proc_Calendar";
this._cmd.Parameters.Add("@CalendarID",this._calendar.CalendarID);
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 + -