TravelUsersAndDiidService.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Models;
  9. namespace DAL
  10. {
  11. /// <summary>
  12. /// 雷怡 2021-10-12 11:52
  13. /// 外部行程用户关联团组行程Diid表数据访问层
  14. /// </summary>
  15. public class TravelUsersAndDiidService
  16. {
  17. List<TravelUsersAndDiid> excuteSql(string sql, params SqlParameter[] param)
  18. {
  19. return ServiceBase<TravelUsersAndDiid>.excuteSql(new TravelUsersAndDiid(), "TravelUsersAndDiid", sql, CommandType.Text, param);
  20. }
  21. TravelUsersAndDiid excuteType(string sql, params SqlParameter[] param)
  22. {
  23. //查询结果放入对象集合
  24. List<TravelUsersAndDiid> hdList = excuteSql(sql, param);
  25. TravelUsersAndDiid tuad = new TravelUsersAndDiid();
  26. //判断集合是否为空
  27. if (hdList == null || hdList.Count == 0)
  28. {
  29. return tuad;
  30. }
  31. //返回单个对象
  32. return hdList[0];
  33. }
  34. /// <summary>
  35. /// 雷怡 2021-10-14 15:55
  36. /// 增Add
  37. /// </summary>
  38. /// <param name="Dov"></param>
  39. /// <returns></returns>
  40. public bool Add(TravelUsersAndDiid tuad)
  41. {
  42. string sql = "insert into TravelUsersAndDiid values(@TravelUsersId,@Diid,@Oper,@OperDate,@Isdel);SELECT @@IDENTITY";
  43. SqlParameter[] parameter = new SqlParameter[]{
  44. new SqlParameter("@TravelUsersId",tuad.TravelUsersId),
  45. new SqlParameter("@Diid",tuad.Diid),
  46. new SqlParameter("@Oper",tuad.Oper),
  47. new SqlParameter("@OperDate",tuad.OperDate),
  48. new SqlParameter("@Isdel",tuad.Isdel)
  49. };
  50. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  51. return true;
  52. return false;
  53. }
  54. /// <summary>
  55. /// 雷怡 2021-10-25 11:43
  56. /// 通过行程用户id 查询
  57. /// </summary>
  58. /// <param name="Dov"></param>
  59. /// <returns></returns>
  60. public List<TravelUsersAndDiid> GetByTravelUsersId(int TravelUsersId)
  61. {
  62. string sql = "select * from TravelUsersAndDiid where Isdel = 0 and TravelUsersId = " + TravelUsersId;
  63. return excuteSql(sql);
  64. }
  65. /// <summary>
  66. /// 雷怡 2021-10-14 15:55
  67. /// 删除 Del
  68. /// </summary>
  69. /// <param name="Dov"></param>
  70. /// <returns></returns>
  71. public bool Del(int id)
  72. {
  73. string sql = "update TravelUsersAndDiid set Isdel = 1 where Id ="+id;
  74. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, null) > 0)
  75. return true;
  76. return false;
  77. }
  78. }
  79. }