VisaProgressService.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8. namespace DAL
  9. {
  10. public class VisaProgressService
  11. {
  12. /// <summary>
  13. /// 查询所有数据
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<VisaProgress> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<VisaProgress>.excuteSql(new VisaProgress(), "VisaProgress", sql, CommandType.Text, param);
  21. }
  22. /// <summary>
  23. /// 获取单个对象
  24. /// </summary>
  25. /// <param name="sql">sql语句</param>
  26. /// <param name="param">可变参数数组</param>
  27. /// <returns>返回空或者单个对象</returns>
  28. VisaProgress excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<VisaProgress> ctggdList = excuteSql(sql, param);
  32. //判断集合是否为空
  33. if (ctggdList == null || ctggdList.Count == 0)
  34. //返回null
  35. return null;
  36. //返回单个对象
  37. return ctggdList[0];
  38. }
  39. //增Add
  40. public bool AddDeleQZ(VisaProgress Dov)
  41. {
  42. string sql = "insert into VisaProgress values(@Diid,@Country,@GetData,@GetDataTime,@GetPassport,@GetPassportTime,"
  43. + "@FillData,@FillDataTime,@SendVisa,@SendVisaTime,@SignOut,@SignOutTime,@SendBackPassport,@SendBackPassporTime,"
  44. + "@Receiver,@Oper,@Opdate,@IsDel);SELECT @@IDENTITY";
  45. SqlParameter[] parameter = new SqlParameter[]{
  46. new SqlParameter("@Diid",Dov.Diid),
  47. new SqlParameter("@Country",Dov.Country),
  48. new SqlParameter("@GetData",Dov.GetData),
  49. new SqlParameter("@GetDataTime",Dov.GetDataTime),
  50. new SqlParameter("@GetPassport",Dov.GetPassport),
  51. new SqlParameter("@GetPassportTime",Dov.GetPassportTime),
  52. new SqlParameter("@FillData",Dov.FillData),
  53. new SqlParameter("@FillDataTime",Dov.FillDataTime),
  54. new SqlParameter("@SendVisa",Dov.SendVisa),
  55. new SqlParameter("@SendVisaTime",Dov.SendVisaTime),
  56. new SqlParameter("@SignOut",Dov.SignOut),
  57. new SqlParameter("@SignOutTime",Dov.SignOutTime),
  58. new SqlParameter("@SendBackPassport",Dov.SendBackPassport),
  59. new SqlParameter("@SendBackPassporTime",Dov.SendBackPassporTime),
  60. new SqlParameter("@Receiver",Dov.Receiver),
  61. new SqlParameter("@Oper",Dov.Oper),
  62. new SqlParameter("@Opdate",Dov.Opdate),
  63. new SqlParameter("@Isdel",Dov.Isdel)
  64. };
  65. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  66. return true;
  67. return false;
  68. }
  69. //删Delete
  70. public bool DelDeleQZ(int id)
  71. {
  72. if (SqlHelper.ExecuteNonQuery("update VisaProgress set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  73. return true;
  74. return false;
  75. }
  76. //改Update
  77. public bool EditDeleQZ(VisaProgress Dov)
  78. {
  79. string sql = "update VisaProgress set Diid=@Diid,Country=@Country,GetData=@GetData,GetDataTime=@GetDataTime,GetPassport=@GetPassport,"
  80. + "GetPassportTime=@GetPassportTime,FillData=@FillData,FillDataTime=@FillDataTime,SendVisa=@SendVisa,SendVisaTime=@SendVisaTime,"
  81. + "SignOut=@SignOut,SignOutTime=@SignOutTime,SendBackPassport=@SendBackPassport,SendBackPassporTime=@SendBackPassporTime,"
  82. + "Receiver=@Receiver,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id";
  83. SqlParameter[] parameter = new SqlParameter[]{
  84. new SqlParameter("@Diid",Dov.Diid),
  85. new SqlParameter("@Country",Dov.Country),
  86. new SqlParameter("@GetData",Dov.GetData),
  87. new SqlParameter("@GetDataTime",Dov.GetDataTime),
  88. new SqlParameter("@GetPassport",Dov.GetPassport),
  89. new SqlParameter("@GetPassportTime",Dov.GetPassportTime),
  90. new SqlParameter("@FillData",Dov.FillData),
  91. new SqlParameter("@FillDataTime",Dov.FillDataTime),
  92. new SqlParameter("@SendVisa",Dov.SendVisa),
  93. new SqlParameter("@SendVisaTime",Dov.SendVisaTime),
  94. new SqlParameter("@SignOut",Dov.SignOut),
  95. new SqlParameter("@SignOutTime",Dov.SignOutTime),
  96. new SqlParameter("@SendBackPassport",Dov.SendBackPassport),
  97. new SqlParameter("@SendBackPassporTime",Dov.SendBackPassporTime),
  98. new SqlParameter("@Receiver",Dov.Receiver),
  99. new SqlParameter("@Oper",Dov.Oper),
  100. new SqlParameter("@Opdate",Dov.Opdate),
  101. new SqlParameter("@Isdel",Dov.Isdel),
  102. new SqlParameter("@Id",Dov.Id)
  103. };
  104. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  105. return true;
  106. return false;
  107. }
  108. //查Select
  109. /// <summary>
  110. /// 根据ID查询数据
  111. /// </summary>
  112. /// <param name="Diid">根据ID</param>
  113. /// <returns>返回空或者单个对象信息</returns>
  114. public VisaProgress GetById(int Id)
  115. {
  116. //调用获取单个对象的方法
  117. return excuteType("select * from VisaProgress where IsDel=0 and Id=@Id", new SqlParameter("@Id", Id));
  118. }
  119. /// <summary>
  120. ///
  121. /// </summary>
  122. /// <param name="Diid">根据团组ID</param>
  123. /// <returns></returns>
  124. public List<VisaProgress> GetAllByDiid(int diid)
  125. {
  126. //调用获取单个对象的方法
  127. return excuteSql("select * from VisaProgress where IsDel=0 and Diid=@diid", new SqlParameter("@diid", diid));
  128. }
  129. List<Users> excuteUserSql(string sql, params SqlParameter[] param)
  130. {
  131. return ServiceBase<Users>.excuteSql(new Users(), "Users", sql, CommandType.Text, param);
  132. }
  133. public List<Users> GetByUser()
  134. {
  135. return excuteUserSql(" select * from Users where Post like '%酒店%' and IsDel=@isDel or Post like '%机票%' or Id=149", new SqlParameter("@isDel", 0));
  136. //return null;
  137. }
  138. }
  139. }