CostTypeHotelNumberService.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data.SqlClient;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace DAL
  10. {
  11. public class CostTypeHotelNumberService
  12. {
  13. List<CostTypeHotelNumber> excuteSql(string sql, params SqlParameter[] param)
  14. {
  15. return ServiceBase<CostTypeHotelNumber>.excuteSql(new CostTypeHotelNumber(), "CostTypeHotelNumber", sql, CommandType.Text, param);
  16. }
  17. CostTypeHotelNumber excuteType(string sql, params SqlParameter[] param)
  18. {
  19. //查询结果放入对象集合
  20. List<CostTypeHotelNumber> hdList = excuteSql(sql, param);
  21. //判断集合是否为空
  22. if (hdList == null || hdList.Count == 0)
  23. {
  24. return null;
  25. }
  26. //返回单个对象
  27. return hdList[0];
  28. }
  29. public CostTypeHotelNumber GetByDiid(int diid)
  30. {
  31. return this.excuteType("select * from CostTypeHotelNumber where isdel = 0 and diid = " + diid);
  32. }
  33. public bool DelByid(int id)
  34. {
  35. if (SqlHelper.ExecuteNonQuery("update CostTypeHotelNumber set Isdel= 1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  36. return true;
  37. return false;
  38. }
  39. public bool Update(CostTypeHotelNumber costType)
  40. {
  41. string sql = "update CostTypeHotelNumber set ASGR=@ASGR,BSGR=@BSGR,ATBR=@ATBR,BTBR=@BTBR,AJSES=@AJSES,BJSES=@BJSES,ASUITE=@ASUITE,BSUITE=@BSUITE where id = @id";
  42. SqlParameter[] parameter = new SqlParameter[]{
  43. new SqlParameter("@ASGR",costType.ASGR),
  44. new SqlParameter("@BSGR",costType.BSGR),
  45. new SqlParameter("@ATBR",costType.ATBR),
  46. new SqlParameter("@BTBR",costType.BTBR),
  47. new SqlParameter("@AJSES",costType.AJSES),
  48. new SqlParameter("@BJSES",costType.BJSES),
  49. new SqlParameter("@ASUITE",costType.ASUITE),
  50. new SqlParameter("@BSUITE",costType.BSUITE),
  51. new SqlParameter("@id",costType.id),
  52. };
  53. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  54. return true;
  55. return false;
  56. }
  57. public bool insert(CostTypeHotelNumber costType)
  58. {
  59. string sql = "insert into CostTypeHotelNumber values (@ASGR,@BSGR,@ATBR,@BTBR,@AJSES,@BJSES,@ASUITE,@BSUITE,@diid,0)";
  60. SqlParameter[] parameter = new SqlParameter[]{
  61. new SqlParameter("@ASGR",costType.ASGR),
  62. new SqlParameter("@BSGR",costType.BSGR),
  63. new SqlParameter("@ATBR",costType.ATBR),
  64. new SqlParameter("@BTBR",costType.BTBR),
  65. new SqlParameter("@AJSES",costType.AJSES),
  66. new SqlParameter("@BJSES",costType.BJSES),
  67. new SqlParameter("@ASUITE",costType.ASUITE),
  68. new SqlParameter("@BSUITE",costType.BSUITE),
  69. new SqlParameter("@diid",costType.DIID),
  70. };
  71. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  72. return true;
  73. return false;
  74. }
  75. }
  76. }