AirTicketBlackCodeService.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 AirTicketBlackCodeService
  11. {
  12. List<AirTicketBlackCode> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<AirTicketBlackCode>.excuteSql(new AirTicketBlackCode(), "AirTicketBlackCode", sql, CommandType.Text, param);
  15. }
  16. AirTicketBlackCode excuteType(string sql, params SqlParameter[] param)
  17. {
  18. //查询结果放入对象集合
  19. List<AirTicketBlackCode> hdList = excuteSql(sql, param);
  20. //判断集合是否为空
  21. if (hdList == null || hdList.Count == 0)
  22. //返回null
  23. return null;
  24. //返回单个对象
  25. return hdList[0];
  26. }
  27. //增Add
  28. public bool Add(AirTicketBlackCode Dov)
  29. {
  30. string sql = "insert into AirTicketBlackCode values(@Diid,@LeaveCode,@BlackCode,@ReturnCode,@Price,@NowPrice,@BCPrice,@ECPrice,@Oper,@Opdate,@Isdel);SELECT @@IDENTITY";
  31. SqlParameter[] parameter = new SqlParameter[]{
  32. new SqlParameter("@Diid",Dov.Diid),
  33. new SqlParameter("@LeaveCode",Dov.LeaveCode),
  34. new SqlParameter("@BlackCode",Dov.BlackCode),
  35. new SqlParameter("@ReturnCode",Dov.ReturnCode),
  36. new SqlParameter("@Price",Dov.Price),
  37. new SqlParameter("@NowPrice",Dov.NowPrice),
  38. new SqlParameter("@BCPrice",Dov.BCPrice),
  39. new SqlParameter("@ECPrice",Dov.ECPrice),
  40. new SqlParameter("@OPer",Dov.OPer),
  41. new SqlParameter("@Opdate",Dov.Opdate),
  42. new SqlParameter("@Isdel",Dov.Isdel)
  43. };
  44. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  45. return true;
  46. return false;
  47. }
  48. //改Update
  49. public bool Edit(AirTicketBlackCode Dov)
  50. {
  51. string sql = "update AirTicketBlackCode set Did=@Diid,LeaveCode=@LeaveCode,BlackCode=@BlackCode,"
  52. + "ReturnCode=@ReturnCode,Price=@Price,NowPrice=@NowPrice,BCPrice=@BCPrice,ECPrice=@ECPrice,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id";
  53. SqlParameter[] parameter = new SqlParameter[]{
  54. new SqlParameter("@Diid",Dov.Diid),
  55. new SqlParameter("@LeaveCode",Dov.LeaveCode),
  56. new SqlParameter("@BlackCode",Dov.BlackCode),
  57. new SqlParameter("@ReturnCode",Dov.ReturnCode),
  58. new SqlParameter("@Price",Dov.Price),
  59. new SqlParameter("@NowPrice",Dov.NowPrice),
  60. new SqlParameter("@BCPrice",Dov.BCPrice),
  61. new SqlParameter("@ECPrice",Dov.ECPrice),
  62. new SqlParameter("@OPer",Dov.OPer),
  63. new SqlParameter("@Opdate",Dov.Opdate),
  64. new SqlParameter("@Isdel",Dov.Isdel),
  65. new SqlParameter("@Id",Dov.Id)
  66. };
  67. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  68. return true;
  69. return false;
  70. }
  71. //删
  72. public bool delOA(int id)
  73. {
  74. if (SqlHelper.ExecuteNonQuery("update AirTicketBlackCode set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  75. return true;
  76. return false;
  77. }
  78. /// <summary>
  79. /// 查找所有数据 - 分页
  80. /// </summary>
  81. /// <returns></returns>
  82. public List<AirTicketBlackCode> GetAll(int diid)
  83. {
  84. return excuteSql("select * from AirTicketBlackCode where Isdel=0 and Did=" + diid + " order by Id");
  85. }
  86. public AirTicketBlackCode getById(int id)
  87. {
  88. return excuteType("select * from AirTicketBlackCode where Isdel=0 and Id=@id", new SqlParameter("@id", id));
  89. }
  90. public AirTicketBlackCode getByDiid(int diid)
  91. {
  92. return excuteType("select * from AirTicketBlackCode where Isdel=0 and did=@diid", new SqlParameter("@diid", diid));
  93. }
  94. }
  95. }