BackwardTable_VisaService.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. public class BackwardTable_VisaService
  12. {
  13. List<BackwardTable_Visa> excuteSql(string sql, params SqlParameter[] param)
  14. {
  15. return ServiceBase<BackwardTable_Visa>.excuteSql(new BackwardTable_Visa(), "BackwardTable_Visa", sql, CommandType.Text, param);
  16. }
  17. BackwardTable_Visa excuteType(string sql, params SqlParameter[] param)
  18. {
  19. //查询结果放入对象集合
  20. List<BackwardTable_Visa> hdList = excuteSql(sql, param);
  21. //判断集合是否为空
  22. if (hdList == null || hdList.Count == 0)
  23. //返回null
  24. return null;
  25. //返回单个对象
  26. return hdList[0];
  27. }
  28. /// <summary>
  29. /// 增加
  30. /// </summary>
  31. /// <param name="c"></param>
  32. public bool Add(BackwardTable_Visa btv)
  33. {
  34. string sql = "insert into BackwardTable_Visa values(@BT_Diid,@BT_VisaCountry,@BT_BusinessType,@BT_VisaType,@BT_VisaTime,@BT_Oper,@BT_OperDate,@BT_Isdel)";
  35. SqlParameter[] parameter = new SqlParameter[]{
  36. new SqlParameter("@BT_Diid",btv.BT_Diid),
  37. new SqlParameter("@BT_VisaCountry",btv.BT_VisaCountry),
  38. new SqlParameter("@BT_BusinessType",btv.BT_BusinessType),
  39. new SqlParameter("@BT_VisaType",btv.BT_VisaType),
  40. new SqlParameter("@BT_VisaTime",btv.BT_VisaTime),
  41. new SqlParameter("@BT_Oper",btv.BT_Oper),
  42. new SqlParameter("@BT_OperDate",btv.BT_OperDate),
  43. new SqlParameter("@BT_Isdel",btv.BT_Isdel)
  44. };
  45. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  46. return true;
  47. return false;
  48. }
  49. /// <summary>
  50. /// 改Update
  51. /// </summary>
  52. /// <param name="Dov"></param>
  53. /// <returns></returns>
  54. public bool Update(BackwardTable_Visa btv)
  55. {
  56. string sql = "update BackwardTable_Visa set BT_Diid=@BT_Diid,BT_VisaCountry=@BT_VisaCountry,BT_BusinessType=@BT_BusinessType,BT_VisaType=@BT_VisaType,BT_VisaTime=@BT_VisaTime," +
  57. "BT_Oper=@BT_Oper,BT_OperDate=@BT_OperDate,BT_Isdel=@BT_Isdel where BT_Id = @BT_Id";
  58. SqlParameter[] parameter = new SqlParameter[]{
  59. new SqlParameter("@BT_Diid",btv.BT_Diid),
  60. new SqlParameter("@BT_VisaCountry",btv.BT_VisaCountry),
  61. new SqlParameter("@BT_BusinessType",btv.BT_BusinessType),
  62. new SqlParameter("@BT_VisaType",btv.BT_VisaType),
  63. new SqlParameter("@BT_VisaTime",btv.BT_VisaTime),
  64. new SqlParameter("@BT_Oper",btv.BT_Oper),
  65. new SqlParameter("@BT_OperDate",btv.BT_OperDate),
  66. new SqlParameter("@BT_Isdel",btv.BT_Isdel),
  67. new SqlParameter("@BT_Id",btv.BT_Id)
  68. };
  69. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  70. return true;
  71. return false;
  72. }
  73. /// <summary>
  74. /// 根据ID查询
  75. /// </summary>
  76. /// <param name="id"></param>
  77. /// <returns></returns>
  78. public List<BackwardTable_Visa> GetByDiid(int diid)
  79. {
  80. //调用获取单个对象的方法
  81. string sql = "select * from BackwardTable_Visa where BT_Diid=@BT_Diid and BT_Isdel=0";
  82. SqlParameter[] parameter = new SqlParameter[]{
  83. new SqlParameter("@BT_Diid", diid)
  84. };
  85. return excuteSql(sql, parameter);
  86. }
  87. public BackwardTable_Visa GetByDiidAndCountry(int diid, string country)
  88. {
  89. //调用获取单个对象的方法
  90. string sql = "select * from BackwardTable_Visa where BT_Diid=@BT_Diid and BT_VisaCountry=@BT_VisaCountry and BT_Isdel=0";
  91. SqlParameter[] parameter = new SqlParameter[]{
  92. new SqlParameter("@BT_Diid", diid),
  93. new SqlParameter("@BT_VisaCountry", country)
  94. };
  95. return excuteType(sql, parameter);
  96. }
  97. }
  98. }