DeleFileService.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. 
  2. using Models;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Linq;
  8. using System.Text;
  9. namespace DAL
  10. {
  11. public class DeleFileService
  12. {
  13. /// <summary>
  14. /// 查询所有数据
  15. /// </summary>
  16. /// <param name="sql">sql语句</param>
  17. /// <param name="param">可变参数数组</param>
  18. /// <returns>返回集合</returns>
  19. List<DeleFile> excuteSql(string sql, params SqlParameter[] param)
  20. {
  21. return ServiceBase<DeleFile>.excuteSql(new DeleFile(), "DeleFile", sql, CommandType.Text, param);
  22. }
  23. /// <summary>
  24. /// 获取单个对象
  25. /// </summary>
  26. /// <param name="sql">sql语句</param>
  27. /// <param name="param">可变参数数组</param>
  28. /// <returns>返回空或者单个对象</returns>
  29. DeleFile excuteType(string sql, params SqlParameter[] param)
  30. {
  31. //查询结果放入对象集合
  32. List<DeleFile> ctggdList = excuteSql(sql, param);
  33. //判断集合是否为空
  34. if (ctggdList == null || ctggdList.Count == 0)
  35. //返回null
  36. return null;
  37. //返回单个对象
  38. return ctggdList[0];
  39. }
  40. //增Add
  41. public bool AddDeleQZ(DeleFile Dov)
  42. {
  43. string sql = "insert into DeleFile values(@Diid,@Category,@Kind,@FileName,@FilePath,@Oper,@OpTime,@IsDel);SELECT @@IDENTITY";
  44. SqlParameter[] parameter = new SqlParameter[]{
  45. new SqlParameter("@Diid",Dov.Diid),
  46. new SqlParameter("@Category",Dov.Category),
  47. new SqlParameter("@Kind",Dov.Kind),
  48. new SqlParameter("@FileName",Dov.FileName),
  49. new SqlParameter("@FilePath",Dov.FilePath),
  50. new SqlParameter("@Oper",Dov.Oper),
  51. new SqlParameter("@OpTime",Dov.OpTime),
  52. new SqlParameter("@IsDel",Dov.IsDel)
  53. };
  54. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  55. return true;
  56. return false;
  57. }
  58. //删Delete
  59. public bool DelDeleQZ(int id)
  60. {
  61. if (SqlHelper.ExecuteNonQuery("update DeleFile set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  62. return true;
  63. return false;
  64. }
  65. //改Update
  66. public bool EditDeleQZ(DeleFile Dov)
  67. {
  68. string sql = "update DeleFile set Diid=@Diid,Category=@Category,Kind=@Kind,FileName=@FileName,FilePath=@FilePath,Oper=@Oper,OpTime=@OpTime,Isdel=@Isdel where Id = @Id";
  69. SqlParameter[] parameter = new SqlParameter[]{
  70. new SqlParameter("@Diid",Dov.Diid),
  71. new SqlParameter("@Category",Dov.Category),
  72. new SqlParameter("@Kind",Dov.Kind),
  73. new SqlParameter("@FileName",Dov.FileName),
  74. new SqlParameter("@FilePath",Dov.FilePath),
  75. new SqlParameter("@Oper",Dov.Oper),
  76. new SqlParameter("@OpTime",Dov.OpTime),
  77. new SqlParameter("@IsDel",Dov.IsDel),
  78. new SqlParameter("@Id",Dov.Id)
  79. };
  80. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  81. return true;
  82. return false;
  83. }
  84. /// <summary>
  85. /// 根据团组id,附件一级类别查询数据
  86. /// </summary>
  87. /// <param name="diid">团组id</param>
  88. /// <param name="category">附件一级类别</param>
  89. /// <returns></returns>
  90. public DeleFile GetByDC(int diid, string category)
  91. {
  92. //调用获取单个对象的方法
  93. return excuteType("select * from DeleFile where IsDel=0 and Diid=@diid and Category=@category", new SqlParameter("@diid", diid), new SqlParameter("@category", category));
  94. }
  95. /// <summary>
  96. /// 根据团组id,附件一级类别查询数据
  97. /// </summary>
  98. /// <param name="diid">团组id</param>
  99. /// <param name="category">附件一级类别</param>
  100. /// <returns></returns>
  101. public List<DeleFile> GetLByDC(int diid, string category)
  102. {
  103. //调用获取单个对象的方法
  104. return excuteSql("select * from DeleFile where IsDel=0 and Diid=@diid and Category=@category", new SqlParameter("@diid", diid), new SqlParameter("@category", category));
  105. }
  106. /// <summary>
  107. /// 根据团组id,附件一级类别查询数据
  108. /// </summary>
  109. /// <param name="diid">团组id</param>
  110. /// <param name="category">附件一级类别</param>
  111. /// <returns></returns>
  112. public List<DeleFile> GetLByDCKS(int diid, string category, int kind)
  113. {
  114. //调用获取单个对象的方法
  115. return excuteSql("select * from DeleFile where IsDel=0 and Diid=@diid and Category=@category and Kind=@Kind", new SqlParameter("@diid", diid), new SqlParameter("@category", category), new SqlParameter("@Kind", kind));
  116. }
  117. /// <summary>
  118. ///根据团组id,附件一级类别,附件二级类别查询数据
  119. /// </summary>
  120. /// <param name="diid">团组id</param>
  121. /// <param name="category">附件一级类别</param>
  122. /// <param name="kind">附件二级类别</param>
  123. /// <returns></returns>
  124. public DeleFile GetByDCK(int diid, string category, int kind)
  125. {
  126. //调用获取单个对象的方法
  127. return excuteType("select * from DeleFile where IsDel=0 and Diid=@diid and Category=@category and Kind=@Kind", new SqlParameter("@diid", diid), new SqlParameter("@category", category), new SqlParameter("@Kind", kind));
  128. }
  129. /// <summary>
  130. ///根据id,附件查询数据
  131. /// </summary>
  132. /// <param name="Id">id</param>
  133. /// <returns></returns>
  134. public DeleFile GetById(int Id)
  135. {
  136. //调用获取单个对象的方法
  137. return excuteType("select * from DeleFile where IsDel=0 and Id=@Id", new SqlParameter("@Id", Id));
  138. }
  139. /// <summary>
  140. /// 根据团组id查询所有附件
  141. /// </summary>
  142. /// <param name="diid">团组id</param>
  143. /// <returns></returns>
  144. public List<DeleFile> GetByDiid(int diid)
  145. {
  146. //调用获取单个对象的方法
  147. return excuteSql("select * from DeleFile where IsDel=0 and Diid=@diid ", new SqlParameter("@diid", diid));
  148. }
  149. }
  150. }