DailyManagementService.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8. namespace DAL
  9. {
  10. /// <summary>
  11. /// 日报管理数据访问类
  12. /// </summary>
  13. public class DailyManagementService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<DailyManagement> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<DailyManagement>.excuteSql(new DailyManagement(), "DailyManagement", sql, CommandType.Text, param);
  24. }
  25. /// <summary>
  26. /// 获取单个对象
  27. /// </summary>
  28. /// <param name="sql">sql语句</param>
  29. /// <param name="param">可变参数数组</param>
  30. /// <returns>返回空或者单个对象</returns>
  31. DailyManagement excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<DailyManagement> dmList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (dmList == null || dmList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return dmList[0];
  41. }
  42. /// <summary>
  43. /// 根据编号查询对象信息
  44. /// </summary>
  45. /// <param name="id">对象编号</param>
  46. /// <returns>返回空或者单个对象信息</returns>
  47. public DailyManagement GetDailyManagementByID(int id)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteType("select * from DailyManagement where Id = @id", new SqlParameter("@id", id));
  51. }
  52. /// <summary>
  53. /// 根据条件查询条件获取 - 分页
  54. /// </summary>
  55. /// <param name="pageIndex"></param>
  56. /// <param name="sumPage"></param>
  57. /// <param name="totalRecord"></param>
  58. /// <param name="dataType"></param>
  59. /// <param name="name"></param>
  60. /// <returns></returns>
  61. public List<DailyManagement> GetAll(int pageIndex, out int sumPage, out int totalRecord, string dailyDate,int userid)
  62. {
  63. string sqlwhere = " IsDel = 0 and userid = " + userid + "";
  64. if (!string.IsNullOrEmpty(dailyDate))
  65. sqlwhere += " and DailyDate = '" + dailyDate + "'";
  66. return PageBase<DailyManagement>.excutePageSql(new DailyManagement(), "DailyManagement", "DailyManagement", "*", "id desc", sqlwhere, 15, pageIndex, out sumPage, out totalRecord);
  67. }
  68. /// <summary>
  69. /// 根据条件查询条件获取审核数据 - 分页
  70. /// </summary>
  71. /// <param name="pageIndex"></param>
  72. /// <param name="sumPage"></param>
  73. /// <param name="totalRecord"></param>
  74. /// <param name="dataType"></param>
  75. /// <param name="name"></param>
  76. /// <returns></returns>
  77. public List<DailyManagement> GetAll(int pageIndex, out int sumPage, out int totalRecord, string dailyDate, string userid,string audit)
  78. {
  79. string sqlwhere = " IsDel = 0 and userid in (" + userid.Remove(userid.Length - 1) + ") and isAudit=" + audit + "";
  80. if (!string.IsNullOrEmpty(dailyDate))
  81. sqlwhere += " and DailyDate = '" + dailyDate + "'";
  82. return PageBase<DailyManagement>.excutePageSql(new DailyManagement(), "DailyManagement", "DailyManagement", "*", "id desc", sqlwhere, 15, pageIndex, out sumPage, out totalRecord);
  83. }
  84. /// <summary>
  85. /// 根据条件查询条件获取审核数据 - 分页 - 总经理
  86. /// </summary>
  87. /// <param name="pageIndex"></param>
  88. /// <param name="sumPage"></param>
  89. /// <param name="totalRecord"></param>
  90. /// <param name="dataType"></param>
  91. /// <param name="name"></param>
  92. /// <returns></returns>
  93. public List<DailyManagement> GetAll(int pageIndex, out int sumPage, out int totalRecord, string dailyDate, string userid, string audit, string usersidddl)
  94. {
  95. string sqlwhere = " IsDel = 0 and userid in (" + userid.Remove(userid.Length - 1) + ") and isAudit=" + audit + " and userid = " + usersidddl + "";
  96. if (!string.IsNullOrEmpty(dailyDate))
  97. sqlwhere += " and DailyDate = '" + dailyDate + "'";
  98. return PageBase<DailyManagement>.excutePageSql(new DailyManagement(), "DailyManagement", "DailyManagement", "*", "id desc", sqlwhere, 15, pageIndex, out sumPage, out totalRecord);
  99. }
  100. /// <summary>
  101. /// 新增
  102. /// </summary>
  103. /// <param name="sdt">对象</param>
  104. public bool AddDailyManagement(DailyManagement dm)
  105. {
  106. string sql = "insert into DailyManagement values(@DailyDate,@WorkTitle,@WorkHours,@CompletionRate,@WorkContent,@UserId,@Dates,@IsAudit,@AuditUserId,@AuditDate,@IsDel)";
  107. SqlParameter[] parameter = new SqlParameter[]{
  108. new SqlParameter("@DailyDate",dm.DailyDate),
  109. new SqlParameter("@WorkTitle",dm.WorkTitle),
  110. new SqlParameter("@WorkHours",dm.WorkHours),
  111. new SqlParameter("@CompletionRate",dm.CompletionRate),
  112. new SqlParameter("@WorkContent",dm.WorkContent),
  113. new SqlParameter("@UserId",dm.UserId),
  114. new SqlParameter("@Dates",dm.Dates),
  115. new SqlParameter("@IsAudit",dm.IsAudit),
  116. new SqlParameter("@AuditUserId",dm.AuditUserId),
  117. new SqlParameter("@AuditDate",dm.AuditDate),
  118. new SqlParameter("@IsDel",dm.IsDel)
  119. };
  120. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  121. return true;
  122. return false;
  123. }
  124. /// <summary>
  125. /// 新增
  126. /// </summary>
  127. /// <param name="sdt">对象</param>
  128. public bool EditDailyManagement(DailyManagement dm)
  129. {
  130. string sql = "update DailyManagement set DailyDate = @DailyDate,WorkTitle = @WorkTitle,WorkHours = @WorkHours,CompletionRate = @CompletionRate,WorkContent = @WorkContent,UserId = @UserId,Dates = @Dates,IsAudit = @IsAudit,AuditUserId = @AuditUserId,AuditDate = @AuditDate where id = @Id";
  131. SqlParameter[] parameter = new SqlParameter[]{
  132. new SqlParameter("@DailyDate",dm.DailyDate),
  133. new SqlParameter("@WorkTitle",dm.WorkTitle),
  134. new SqlParameter("@WorkHours",dm.WorkHours),
  135. new SqlParameter("@CompletionRate",dm.CompletionRate),
  136. new SqlParameter("@WorkContent",dm.WorkContent),
  137. new SqlParameter("@UserId",dm.UserId),
  138. new SqlParameter("@Dates",dm.Dates),
  139. new SqlParameter("@IsAudit",dm.IsAudit),
  140. new SqlParameter("@AuditUserId",dm.AuditUserId),
  141. new SqlParameter("@AuditDate",dm.AuditDate),
  142. new SqlParameter("@Id",dm.Id)
  143. };
  144. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  145. return true;
  146. return false;
  147. }
  148. /// <summary>
  149. /// 删除
  150. /// </summary>
  151. /// <param name="calendarDate"></param>
  152. /// <returns></returns>
  153. public bool DelDailyManagement(int id)
  154. {
  155. if (SqlHelper.ExecuteNonQuery("update DailyManagement set isDel = 1 where id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  156. return true;
  157. return false;
  158. }
  159. /// <summary>
  160. /// 审核通过
  161. /// </summary>
  162. /// <param name="calendarDate"></param>
  163. /// <returns></returns>
  164. public bool updateAuditDailyManagement(int id)
  165. {
  166. if (SqlHelper.ExecuteNonQuery("update DailyManagement set isAudit = 1 where id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  167. return true;
  168. return false;
  169. }
  170. public DailyManagement GetDMByDate(string DailyDate,int userid)
  171. {
  172. //调用获取单个对象的方法
  173. return excuteType("select * from DailyManagement where Isdel=0 and DailyDate=@DailyDate and UserId=@userid", new SqlParameter("@DailyDate", DailyDate), new SqlParameter("@userid", userid));
  174. }
  175. }
  176. }