DeleClientNeedsService.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 DeleClientNeedsService
  11. {
  12. List<DeleClientNeeds> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<DeleClientNeeds>.excuteSql(new DeleClientNeeds(), "DeleClientNeeds", sql, CommandType.Text, param);
  15. }
  16. DeleClientNeeds excuteType(string sql, params SqlParameter[] param)
  17. {
  18. //查询结果放入对象集合
  19. List<DeleClientNeeds> hdList = excuteSql(sql, param);
  20. //判断集合是否为空
  21. if (hdList == null || hdList.Count == 0)
  22. //返回null
  23. return null;
  24. //返回单个对象
  25. return hdList[0];
  26. }
  27. /// <summary>
  28. /// 根据ID查询
  29. /// </summary>
  30. /// <returns></returns>
  31. public DeleClientNeeds GetById(int id)
  32. {
  33. return excuteType("select * from DeleClientNeeds where Isdel=0 and Id=" + id);
  34. }
  35. public List<DeleClientNeeds> GetAll()
  36. {
  37. return excuteSql("select * from DeleClientNeeds where Isdel=0 ");
  38. }
  39. public DeleClientNeeds GetByDIId(int DIID)
  40. {
  41. return excuteType("select * from DeleClientNeeds where Isdel=0 and Diid=" + DIID);
  42. }
  43. //增Add
  44. public bool Add(DeleClientNeeds Dov)
  45. {
  46. string sql = "insert into DeleClientNeeds values(@Diid,@OffActPlace,@OffActLetter,@TransNeed,@TranLanguage,@TranScene,@VisaNeeds,"
  47. + "@Hobby,@CarNeeds,@GuideNeeds,@MealNeeds,@CheckInTime,@HotelLevel,@HotelPosition,@RoomNum,@NeedsRemark,@OPer,@OPdate,@Isdel);SELECT @@IDENTITY";
  48. SqlParameter[] parameter = new SqlParameter[]{
  49. new SqlParameter("@Diid",Dov.Diid),
  50. new SqlParameter("@OffActPlace",Dov.OffActPlace),
  51. new SqlParameter("@OffActLetter",Dov.OffActLetter),
  52. new SqlParameter("@TransNeed",Dov.TransNeed),
  53. new SqlParameter("@TranLanguage",Dov.TranLanguage),
  54. new SqlParameter("@TranScene",Dov.TranScene),
  55. new SqlParameter("@VisaNeeds",Dov.VisaNeeds),
  56. new SqlParameter("@Hobby",Dov.Hobby),
  57. new SqlParameter("@CarNeeds",Dov.CarNeeds),
  58. new SqlParameter("@GuideNeeds",Dov.GuideNeeds),
  59. new SqlParameter("@MealNeeds",Dov.MealNeeds),
  60. new SqlParameter("@CheckInTime",Dov.CheckInTime),
  61. new SqlParameter("@HotelLevel",Dov.HotelLevel),
  62. new SqlParameter("@HotelPosition",Dov.HotelPosition),
  63. new SqlParameter("@RoomNum",Dov.RoomNum),
  64. new SqlParameter("@NeedsRemark",Dov.NeedsRemark),
  65. new SqlParameter("@OPer",Dov.OPer),
  66. new SqlParameter("@OPdate",Dov.OPdate),
  67. new SqlParameter("@Isdel",Dov.Isdel)
  68. };
  69. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  70. return true;
  71. return false;
  72. }
  73. //改Update
  74. public bool Edit(DeleClientNeeds Dov)
  75. {
  76. string sql = "update DeleClientNeeds set Diid=@Diid,OffActPlace=@OffActPlace,TransNeed=@TransNeed,TranLanguage=@TranLanguage,TranScene=@TranScene,"
  77. + "OffActLetter=@OffActLetter,VisaNeeds=@VisaNeeds,Hobby=@Hobby,CarNeeds=@CarNeeds,"
  78. + "GuideNeeds=@GuideNeeds,MealNeeds=@MealNeeds,CheckInTime=@CheckInTime,HotelLevel=@HotelLevel,"
  79. + "HotelPosition=@HotelPosition,RoomNum=@RoomNum,NeedsRemark=@NeedsRemark,OPer=@OPer,OPdate=@OPdate,Isdel=@Isdel where Id = @Id";
  80. SqlParameter[] parameter = new SqlParameter[]{
  81. new SqlParameter("@Diid",Dov.Diid),
  82. new SqlParameter("@OffActPlace",Dov.OffActPlace),
  83. new SqlParameter("@OffActLetter",Dov.OffActLetter),
  84. new SqlParameter("@TransNeed",Dov.TransNeed),
  85. new SqlParameter("@TranLanguage",Dov.TranLanguage),
  86. new SqlParameter("@TranScene",Dov.TranScene),
  87. new SqlParameter("@VisaNeeds",Dov.VisaNeeds),
  88. new SqlParameter("@Hobby",Dov.Hobby),
  89. new SqlParameter("@CarNeeds",Dov.CarNeeds),
  90. new SqlParameter("@GuideNeeds",Dov.GuideNeeds),
  91. new SqlParameter("@MealNeeds",Dov.MealNeeds),
  92. new SqlParameter("@CheckInTime",Dov.CheckInTime),
  93. new SqlParameter("@HotelLevel",Dov.HotelLevel),
  94. new SqlParameter("@HotelPosition",Dov.HotelPosition),
  95. new SqlParameter("@RoomNum",Dov.RoomNum),
  96. new SqlParameter("@NeedsRemark",Dov.NeedsRemark),
  97. new SqlParameter("@OPer",Dov.OPer),
  98. new SqlParameter("@OPdate",Dov.OPdate),
  99. new SqlParameter("@Isdel",Dov.Isdel),
  100. new SqlParameter("@Id",Dov.Id)
  101. };
  102. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  103. return true;
  104. return false;
  105. }
  106. //删
  107. public bool delOA(int id)
  108. {
  109. if (SqlHelper.ExecuteNonQuery("update DeleClientNeeds set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  110. return true;
  111. return false;
  112. }
  113. public List<DeleClientNeeds> GetByNameAndPhone(string name, string Phone)
  114. {
  115. return excuteSql("select * from DeleClientNeeds where Isdel=0 and Name='" + name + "' and Phone='" + Phone + "'");
  116. }
  117. }
  118. }