using System; using System.Collections.Generic; using System.Data; using DSWeb.SoftMng.Model; // ReSharper disable once CheckNamespace namespace DSWeb.SoftMng.BLL { //sys_message public partial class sys_messageBLL { private readonly DAL.sys_messageDAL dal = new DAL.sys_messageDAL(); #region Method /// /// 是否存在该记录 /// public bool Exists(string GID) { return dal.Exists(GID); } /// /// 增加一条数据 /// public int Add(sys_message model) { return dal.Add(model); } /// /// 更新一条数据 /// public int Update(sys_message model) { return dal.Update(model); } /// /// 删除一条数据 /// public int Delete(string GID) { return dal.Delete(GID); } /// /// 按条件批量删除(有风险) /// public int DeleteListWhere(string strWhere) { return dal.DeleteListWhere(strWhere); } /// /// 得到一个对象实体 /// public sys_message GetModel(string GID) { DataSet ds = dal.GetModel(GID); if (ds.Tables.Count > 0) { var dt = ds.Tables[0]; if (dt.Rows.Count > 0) { var dr = dt.Rows[0]; return DataRowToModel(dr); } return null; } return null; } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { return dal.GetList(strWhere); } /// /// 获得前几行数据 /// public DataSet GetList(int Top, string strWhere, string filedOrder) { return dal.GetList(Top, strWhere, filedOrder); } /// /// 获得数据列表 /// public List GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); return DataTableToList(ds.Tables[0]); } /// /// 获得数据列表 /// public List DataTableToList(DataTable dt) { List modelList = new List(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { for (int n = 0; n < rowsCount; n++) { var model = DataRowToModel(dt.Rows[n]); modelList.Add(model); } } return modelList; } /// /// 获得数据 /// public sys_message DataRowToModel(DataRow dr) { var model = new sys_message(); model.GID = dr["GID"].ToString(); if (dr["TYPE"].ToString() != "") model.TYPE = int.Parse(dr["TYPE"].ToString()); model.TASKURL = dr["TASKURL"].ToString(); model.TASKID = dr["TASKID"].ToString(); if (dr["ISDELETE"].ToString() != "") { if ((dr["ISDELETE"].ToString() == "1") || (dr["ISDELETE"].ToString().ToLower() == "true")) model.ISDELETE = true; else model.ISDELETE = false; } model.DELETEUSER = dr["DELETEUSER"].ToString(); if (dr["DELETETIME"].ToString() != "") model.DELETETIME = DateTime.Parse(dr["DELETETIME"].ToString()); if (dr["NUMBER"].ToString() != "") model.NUMBER = int.Parse(dr["NUMBER"].ToString()); if (dr["RECVTYPE"].ToString() != "") model.RECVTYPE = int.Parse(dr["RECVTYPE"].ToString()); if (dr["ISSEND"].ToString() != "") { if ((dr["ISSEND"].ToString() == "1") || (dr["ISSEND"].ToString().ToLower() == "true")) model.ISSEND = true; else model.ISSEND = false; } model.NAME = dr["NAME"].ToString(); model.DESCRIPTION = dr["DESCRIPTION"].ToString(); if (dr["CREATETIME"].ToString() != "") model.CREATETIME = DateTime.Parse(dr["CREATETIME"].ToString()); if (dr["ISREAD"].ToString() != "") { if ((dr["ISREAD"].ToString() == "1") || (dr["ISREAD"].ToString().ToLower() == "true")) model.ISREAD = true; else model.ISREAD = false; } if (dr["READCOUNT"].ToString() != "") model.READCOUNT = int.Parse(dr["READCOUNT"].ToString()); model.MESSAGECONTENT = dr["MESSAGECONTENT"].ToString(); if (dr["LASTREADTIME"].ToString() != "") model.LASTREADTIME = DateTime.Parse(dr["LASTREADTIME"].ToString()); model.RECEIVER = dr["RECEIVER"].ToString(); return model; } /// /// 获得数据列表 /// public DataSet GetAllList() { return GetList(""); } /// /// 分页获取数据列表 /// /// /// /// /// /// public List GetModelList(int startIndex, int limit, string strWhere, string orderby) { int endIndex = startIndex + limit; DataSet ds = dal.GetListByPage(strWhere, orderby, startIndex, endIndex); return DataTableToList(ds.Tables[0]); } /// /// 获取记录总数 /// public int GetRecordCount(string strWhere) { return dal.GetRecordCount(strWhere); } #endregion } }