using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; namespace CallCenterApi.BLL { /// ///文章类别表 /// public partial class article_category { // private readonly Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); //获得系统配置信息 private readonly DAL.article_category dal; public article_category() { dal = new DAL.article_category(); } #region 基本方法================================ /// /// 是否存在该记录 /// public bool Exists(int id) { return dal.Exists(id); } /// /// 增加一条数据 /// public int Add(Model.article_category model) { return dal.Add(model); } /// /// 更新一条数据 /// public bool Update(Model.article_category model) { return dal.Update(model); } /// /// 删除一条数据 /// public bool Delete(int id) { return dal.Delete(id); } /// /// 删除多条数据 /// public bool DeleteBatch(string where) { return dal.DeleteBatch(where); } /// /// 得到一个对象实体 /// public Model.article_category GetModel(int id) { return dal.GetModel(id); } /// /// 取得所有类别列表 /// /// 父ID /// 频道ID /// DataTable public DataTable GetList(int parent_id) { return dal.GetList(parent_id); } /// /// 取得该频道下所有类别列表 /// /// 父ID /// 频道名称 /// DataTable public DataTable GetList(int parent_id, string channel_name) { //int channel_id = new BLL.site_channel().GetChannelId(channel_name); return dal.GetList(parent_id); } public List DataTableToList(DataTable dt) { List list = new List(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { CallCenterApi.Model.article_category model; for (int n = 0; n < rowsCount; n++) { model = new Model.article_category(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["parentid"] != null && dt.Rows[n]["parentid"].ToString() != "") { model.parentid = int.Parse(dt.Rows[n]["parentid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["status"] != null && dt.Rows[n]["status"].ToString() != "") { model.status = int.Parse(dt.Rows[n]["status"].ToString()); } if (dt.Columns.Contains("parenttitle")) { if (dt.Rows[n]["parenttitle"] != null && dt.Rows[n]["parenttitle"].ToString() != "") { model.parenttitle = dt.Rows[n]["parenttitle"].ToString(); } } list.Add(model); } } return list; } #endregion #region 扩展方法================================ /// /// 取得指定类别下的列表(一层) /// /// 显示条数 /// 父ID /// 频道ID /// DataTable public DataTable GetChildList(int top, int parent_id, int channel_id) { return dal.GetChildList(top, parent_id); } /// /// 取得该频道指定类别下的列表 /// /// /// /// public DataTable GetChildList(int top, int parent_id, string channel_name) { // int channel_id = new BLL.site_channel().GetChannelId(channel_name); return dal.GetChildList(top, parent_id); } /// /// 返回类别名称 /// public string GetTitle(int id) { return dal.GetTitle(id); } /// /// 返回父节点的ID /// public int GetParentId(int id) { return dal.GetParentId(id); } /// /// 修改一列数据 /// public bool UpdateField(int id, string strValue) { return dal.UpdateField(id, strValue); } #endregion } }