📄 categorymodel.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using DAC;
using Utils;
namespace Model
{
/// <summary>
/// CategoryModel 的摘要说明。
/// </summary>
public class CategoryModel : Model
{
public CategoryModel()
: base(new DSPhoto())
{
}
public CategoryModel(DataSet ds_)
: base(ds_)
{
}
#region Model 成员
override public DataTable Query(System.Collections.IDictionary queryParam)
{
DataSet ds = SqlHelper.ExecuteDataset(AlbumConfig.DBConnectionString, "QueryCategory", queryParam["OwnerID"]);
return ds.Tables[0];
}
override public System.Data.DataSet LoadByPrimaryKey(object pk)
{
//DSPhoto ds = new DSPhoto();
using (SqlConnection cn = new SqlConnection(AlbumConfig.DBConnectionString))
{
SqlParameter pkPara = new SqlParameter("@CategoryID", SqlDbType.Int, 4);
pkPara.Value = pk;
cn.Open();
SqlHelper.ExecuteDataset(ds, cn, CommandType.StoredProcedure, "SeleCategory", new string[]{"Category"}, pkPara);
return ds;
}
}
override public void Save(System.Data.DataSet ds)
{
if(!(ds is DSPhoto))
throw new ApplicationException("Expect a DSPhoto");
SqlHelper.ExecuteUpdate(ds.Tables["Category"], AlbumConfig.DBConnectionString, "InsCate", "UptCate", "DelCate");
}
override public System.Data.DataSet get_CurrentCollection()
{
return DataSet;
}
override public System.Data.DataRow get_CurrentItem()
{
DSPhoto ds = this.DataSet as DSPhoto;
if(ds == null)
throw new ApplicationException("Model had not Category data.");
return ds.Category.FindByCategoryID(this.CurrentID);
}
#endregion
public int CurrentID
{
get{ return _curID; }
set{ _curID = value; }
}
protected int _curID;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -