public class Category { private Database db; public Category() { db = DatabaseFactory.CreateDatabase(); } private string _ClassID; private string _ClassName; private int _Sort; private string _LogoImage; private string _ClassDetails; private byte[] _DateMark; /**//// <summary> /// 类别ID /// </summary> public string ClassID { set{_ClassID = value;} get{return _ClassID;} } /**//// <summary> /// 类别名称 /// </summary> public string ClassName { set{_ClassName = value;} get{return _ClassName;} } /**//// <summary> /// 排序值 /// </summary> public int Sort { set{_Sort = value;} get{return _Sort;} } /**//// <summary> /// 类别图片 /// </summary> public string LogoImage { set{_LogoImage = value;} get{return _LogoImage;} } /**//// <summary> /// 类别说明 /// </summary> public string ClassDetails { set{_ClassDetails = value;} get{return _ClassDetails;} } /**//// <summary> /// 最后修改时间 /// </summary> public byte[] DateMark { set{_DateMark = value;} get{return _DateMark;} } /**//// <summary> /// 获取Category对象集合 /// </summary> /// <returns>返回所有对象集合</returns> public IList GetCategoryList() { IList il = new ArrayList(); DBCommandWrapper dw = db.GetStoredProcCommandWrapper("CategoryGetList_p"); IDataReader dr = db.ExecuteReader(dw); while(dr.Read()) { Category obj = new Category(); obj.ClassID = Convert.ToString(dr["ClassID"]); obj.ClassName = Convert.ToString(dr["ClassName"]); obj.Sort = Convert.ToInt32(dr["Sort"]); obj.LogoImage = Convert.ToString(dr["LogoImage"]); obj.ClassDetails = Convert.ToString(dr["ClassDetails"]); obj.DateMark = (byte[])(dr["DateMark"]); il.Add(obj); } return il; } /**//// <summary> /// 对Category对象的简单查询操作 /// </summary> /// <param name="ClassID">类别ID</param> /// <returns>返回Category对象</returns> public Category GetCategoryByClassID(string ClassID) { bool HasData = false; Category obj = new Category(); DBCommandWrapper dw = db.GetStoredProcCommandWrapper("CategoryGet_p"); dw.AddInParameter("@ClassID",DbType.String,ClassID); IDataReader dr = db.ExecuteReader(dw); while(dr.Read()) { obj.ClassID = Convert.ToString(dr["ClassID"]); obj.ClassName = Convert.ToString(dr["ClassName"]); obj.Sort = Convert.ToInt32(dr["Sort"]); obj.LogoImage = Convert.ToString(dr["LogoImage"]); obj.ClassDetails = Convert.ToString(dr["ClassDetails"]); obj.DateMark = (byte[])(dr["DateMark"]); HasData = true; } dr.Close(); if(!HasData) return null; else return obj; } /**//// <summary> /// 对Category对象的插入操作 /// </summary> /// <param name="obj">Category对象</param> /// <returns>返回影响行数</returns> public int InsertCategory(Category obj,out string newid) { DBCommandWrapper dw = db.GetStoredProcCommandWrapper("CategoryInsert_p"); dw.AddInParameter("@ClassID",DbType.String,obj.ClassID); dw.AddOutParameter("@NewID",DbType.String,6); dw.AddInParameter("@ClassName",DbType.String,obj.ClassName); dw.AddInParameter("@Sort",DbType.Int32,obj.Sort); dw.AddInParameter("@LogoImage",DbType.String,obj.LogoImage); dw.AddInParameter("@ClassDetails",DbType.String,obj.ClassDetails); dw.AddOutParameter("@RowCount",DbType.Int32,4); db.ExecuteNonQuery(dw); int rlt = Convert.ToInt32(dw.GetParameterValue("@RowCount")); newid = Convert.ToString(dw.GetParameterValue("@NewID")); db.ClearParameterCache(); dw.Dispose(); return rlt; } /**//// <summary> /// 对Category对象的更新操作 /// </summary> /// <param name="obj">Category对象</param> /// <returns>返回影响行数</returns> public int UpdateCategory(Category obj) { DBCommandWrapper dw = db.GetStoredProcCommandWrapper("CategoryUpdate_p"); dw.AddInParameter("@ClassID",DbType.String,obj.ClassID); dw.AddInParameter("@ClassName",DbType.String,obj.ClassName); dw.AddInParameter("@Sort",DbType.Int32,obj.Sort); dw.AddInParameter("@LogoImage",DbType.String,obj.LogoImage); dw.AddInParameter("@ClassDetails",DbType.String,obj.ClassDetails); dw.AddInParameter("@DateMark",DbType.Binary,obj.DateMark); dw.AddOutParameter("@RowCount",DbType.Int32,4); db.ExecuteNonQuery(dw); int rlt = Convert.ToInt32(dw.GetParameterValue("@RowCount")); db.ClearParameterCache(); dw.Dispose(); return rlt; } /**//// <summary> /// 对Category对象的删除操作 /// </summary> /// <param name="obj">Category对象</param> /// <returns>返回影响行数</returns> public int DeleteCategory(Category obj) { DBCommandWrapper dw = db.GetStoredProcCommandWrapper("CategoryDelete_p"); dw.AddInParameter("@ClassID",DbType.String,obj.ClassID); dw.AddInParameter("@DateMark",DbType.Binary,obj.DateMark); dw.AddOutParameter("@RowCount",DbType.Int32,4); db.ExecuteNonQuery(dw); int rlt = Convert.ToInt32(dw.GetParameterValue("@RowCount")); db.ClearParameterCache(); dw.Dispose(); return rlt; } }