鄂尔多斯-招源科技

T_Sys_Department.cs 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace CallCenterApi.BLL
  8. {
  9. /// <summary>
  10. /// T_Sys_Department
  11. /// </summary>
  12. public partial class T_Sys_Department
  13. {
  14. private readonly DAL.T_Sys_Department dal = new DAL.T_Sys_Department();
  15. public T_Sys_Department()
  16. { }
  17. #region BasicMethod
  18. /// <summary>
  19. /// 是否存在该记录
  20. /// </summary>
  21. public bool Exists(int F_DeptId)
  22. {
  23. return dal.Exists(F_DeptId);
  24. }
  25. /// <summary>
  26. /// 增加一条数据
  27. /// </summary>
  28. public int Add(Model.T_Sys_Department model)
  29. {
  30. return dal.Add(model);
  31. }
  32. /// <summary>
  33. /// 更新一条数据
  34. /// </summary>
  35. public bool Update(Model.T_Sys_Department model)
  36. {
  37. return dal.Update(model);
  38. }
  39. /// <summary>
  40. /// 删除一条数据
  41. /// </summary>
  42. public bool Delete(int F_DeptId)
  43. {
  44. return dal.Delete(F_DeptId);
  45. }
  46. /// <summary>
  47. /// 删除一条数据
  48. /// </summary>
  49. public bool DeleteList(string F_DeptIdlist)
  50. {
  51. return dal.DeleteList(F_DeptIdlist);
  52. }
  53. /// <summary>
  54. /// 得到一个对象实体
  55. /// </summary>
  56. public Model.T_Sys_Department GetModel(int F_DeptId)
  57. {
  58. return dal.GetModel(F_DeptId);
  59. }
  60. /// <summary>
  61. /// 得到一个对象实体
  62. /// </summary>
  63. public Model.T_Sys_Department GetModel(string deptName)
  64. {
  65. return dal.GetModel(deptName);
  66. }
  67. /// <summary>
  68. /// 获得数据列表
  69. /// </summary>
  70. public DataSet GetList(string strWhere)
  71. {
  72. return dal.GetList(strWhere);
  73. }
  74. /// <summary>
  75. /// 获得前几行数据
  76. /// </summary>
  77. public DataSet GetList(int Top, string strWhere, string filedOrder)
  78. {
  79. return dal.GetList(Top, strWhere, filedOrder);
  80. }
  81. /// <summary>
  82. /// 获得数据列表
  83. /// </summary>
  84. public List<Model.T_Sys_Department> GetModelList(string strWhere)
  85. {
  86. DataSet ds = dal.GetList(strWhere);
  87. return DataTableToList(ds.Tables[0]);
  88. }
  89. /// <summary>
  90. /// 获得数据列表
  91. /// </summary>
  92. public List<Model.T_Sys_Department> DataTableToList(DataTable dt)
  93. {
  94. List<Model.T_Sys_Department> modelList = new List<Model.T_Sys_Department>();
  95. int rowsCount = dt.Rows.Count;
  96. if (rowsCount > 0)
  97. {
  98. Model.T_Sys_Department model;
  99. for (int n = 0; n < rowsCount; n++)
  100. {
  101. model = dal.DataRowToModel(dt.Rows[n]);
  102. if (model != null)
  103. {
  104. modelList.Add(model);
  105. }
  106. }
  107. }
  108. return modelList;
  109. }
  110. /// <summary>
  111. /// 递归查询
  112. /// </summary>
  113. public List<Model.T_Sys_DepartmentLevel> DataTableToListForLevel(DataTable dt)
  114. {
  115. List<Model.T_Sys_DepartmentLevel> modelList = new List<Model.T_Sys_DepartmentLevel>();
  116. int rowsCount = dt.Rows.Count;
  117. if (rowsCount > 0)
  118. {
  119. Model.T_Sys_DepartmentLevel model;
  120. foreach (DataRow row in dt.Rows)
  121. {
  122. model = new Model.T_Sys_DepartmentLevel();
  123. model.DeptId = row["F_DeptId"] == DBNull.Value ? 0 : Convert.ToInt32(row["F_DeptId"]);
  124. model.ParentId = row["F_ParentId"] == DBNull.Value ? 0 : Convert.ToInt32(row["F_ParentId"]);
  125. model.DeptName = row["F_DeptName"] == DBNull.Value ? "" : row["F_DeptName"].ToString();
  126. model.DeptCode = row["F_DeptCode"] == DBNull.Value ? "" : row["F_DeptCode"].ToString();
  127. model.Layer = row["F_Layer"] == DBNull.Value ? 0 : Convert.ToInt32(row["F_Layer"]);
  128. model.Level = row["lvl"] == DBNull.Value ? 0 : Convert.ToInt32(row["lvl"]);
  129. modelList.Add(model);
  130. }
  131. }
  132. return modelList;
  133. }
  134. /// <summary>
  135. /// 获得数据列表
  136. /// </summary>
  137. public DataSet GetAllList()
  138. {
  139. return GetList("");
  140. }
  141. /// <summary>
  142. /// 分页获取数据列表
  143. /// </summary>
  144. public int GetRecordCount(string strWhere)
  145. {
  146. return dal.GetRecordCount(strWhere);
  147. }
  148. /// <summary>
  149. /// 分页获取数据列表
  150. /// </summary>
  151. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  152. {
  153. return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
  154. }
  155. #endregion BasicMethod
  156. #region ExtensionMethod
  157. /// <summary>
  158. /// 更新部门编号
  159. /// </summary>
  160. public bool UpdateDeptCode(string deptcode, int deptid)
  161. {
  162. return dal.UpdateDeptCode(deptcode, deptid);
  163. }
  164. #endregion ExtensionMethod
  165. }
  166. }