DeleOverViewServices.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. namespace DAL
  9. {
  10. public class DeleOverViewServices
  11. {
  12. /// <summary>
  13. /// 查询所有数据
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<DeleOverView> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<DeleOverView>.excuteSql(new DeleOverView(), "DeleOverView", sql, CommandType.Text, param);
  21. }
  22. /// <summary>
  23. /// 获取单个对象
  24. /// </summary>
  25. /// <param name="sql">sql语句</param>
  26. /// <param name="param">可变参数数组</param>
  27. /// <returns>返回空或者单个对象</returns>
  28. DeleOverView excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<DeleOverView> ctggdList = excuteSql(sql, param);
  32. //判断集合是否为空
  33. if (ctggdList == null || ctggdList.Count == 0)
  34. //返回null
  35. return null;
  36. //返回单个对象
  37. return ctggdList[0];
  38. }
  39. //增Add
  40. public bool AddDeleOverView(DeleOverView Dov)
  41. {
  42. string sql = "insert into DeleOverView values(@Diid,@BaoPi,@GongWu,@JiPiao,@JiuDian,@DiJie,@Oper,@OpTime,@IsDel);SELECT @@IDENTITY";
  43. SqlParameter[] parameter = new SqlParameter[]{
  44. new SqlParameter("@Diid",Dov.Diid),
  45. new SqlParameter("@BaoPi",Dov.BaoPi),
  46. new SqlParameter("@GongWu",Dov.GongWu),
  47. new SqlParameter("@JiPiao",Dov.JiPiao),
  48. new SqlParameter("@JiuDian",Dov.JiuDian),
  49. new SqlParameter("@DiJie",Dov.DiJie),
  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 DelDeleOverView(int id)
  60. {
  61. if (SqlHelper.ExecuteNonQuery("update DeleOverView 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 EditDeleOverView(DeleOverView Dov)
  67. {
  68. string sql = "update DeleOverView set Diid=@Diid,BaoPi=@BaoPi,GongWu=@GongWu,JiPiao=@JiPiao,JiuDian=@JiuDian,DiJie=@DiJie,Oper=@Oper,OpTime=@OpTime,Isdel=@Isdel where Id = @Id";
  69. SqlParameter[] parameter = new SqlParameter[]{
  70. new SqlParameter("@Diid",Dov.Diid),
  71. new SqlParameter("@BaoPi",Dov.BaoPi),
  72. new SqlParameter("@GongWu",Dov.GongWu),
  73. new SqlParameter("@JiPiao",Dov.JiPiao),
  74. new SqlParameter("@JiuDian",Dov.JiuDian),
  75. new SqlParameter("@DiJie",Dov.DiJie),
  76. new SqlParameter("@Oper",Dov.Oper),
  77. new SqlParameter("@OpTime",Dov.OpTime),
  78. new SqlParameter("@IsDel",Dov.IsDel),
  79. new SqlParameter("@Id",Dov.Id)
  80. };
  81. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  82. return true;
  83. return false;
  84. }
  85. //查Select
  86. /// <summary>
  87. /// 根据团组ID查询数据
  88. /// </summary>
  89. /// <param name="Diid">根据团组ID</param>
  90. /// <returns>返回空或者单个对象信息</returns>
  91. public DeleOverView GetDeleOverViewByDIID(int Diid)
  92. {
  93. //调用获取单个对象的方法
  94. return excuteType("select * from DeleOverView where Diid = @Diid", new SqlParameter("@Diid", Diid));
  95. }
  96. }
  97. }