VisaService.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Security.Cryptography;
  9. using System.Web.UI.WebControls;
  10. namespace DAL
  11. {
  12. /// <summary>
  13. /// 签证数据访问类
  14. /// </summary>
  15. public class VisaService
  16. {
  17. /// <summary>
  18. /// 查询所有
  19. /// </summary>
  20. /// <param name="sql">sql语句</param>
  21. /// <param name="param">可变参数数组</param>
  22. /// <returns>返回集合</returns>
  23. List<Visa> excuteSql(string sql, params SqlParameter[] param)
  24. {
  25. return ServiceBase<Visa>.excuteSql(new Visa(), "Visa", sql, CommandType.Text, param);
  26. }
  27. /// <summary>
  28. /// 获取单个对象
  29. /// </summary>
  30. /// <param name="sql">sql语句</param>
  31. /// <param name="param">可变参数数组</param>
  32. /// <returns>返回空或者单个对象</returns>
  33. Visa excuteType(string sql, params SqlParameter[] param)
  34. {
  35. //查询结果放入对象集合
  36. List<Visa> vList = excuteSql(sql, param);
  37. //判断集合是否为空
  38. if (vList == null || vList.Count == 0)
  39. //返回null
  40. return null;
  41. //返回单个对象
  42. return vList[0];
  43. }
  44. /// <summary>
  45. /// 根据编号查询对象信息
  46. /// </summary>
  47. /// <param name="id">对象编号</param>
  48. /// <returns>返回空或者单个对象信息</returns>
  49. public Visa GetVisaByID(int id)
  50. {
  51. //调用获取单个对象的方法
  52. return excuteType("select * from Visa where Id = @id and isdel=0", new SqlParameter("@id", id));
  53. }
  54. /// <summary>
  55. /// 查询团组签证费用
  56. /// 20210916 贾文滔
  57. /// </summary>
  58. /// <param name="diid"></param>
  59. /// <returns></returns>
  60. public List<Visa> GetVisaByDIID(int diid)
  61. {
  62. //调用获取单个对象的方法
  63. return excuteSql("select * from Visa where DIId = @Diid and isdel=0", new SqlParameter("@Diid", diid));
  64. }
  65. /// <summary>
  66. /// 查询团组签证费用
  67. /// 20210916 贾文滔
  68. /// </summary>
  69. /// <param name="diid"></param>
  70. /// <returns></returns>
  71. public List<Visa> GetVisaByDIIDAndUserId(int diid,int UserId)
  72. {
  73. //调用获取单个对象的方法
  74. return excuteSql("select * from Visa where DIId = @Diid and Operator="+UserId+" and isdel=0", new SqlParameter("@Diid", diid));
  75. }
  76. /// <summary>
  77. /// 获取全部 - 分页
  78. /// </summary>
  79. /// <returns></returns>
  80. public List<Visa> GetVisa(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string visaClient, string arrayUsersId)
  81. {
  82. string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and VisaClient like '%" + visaClient + "%' and Operator in (" + arrayUsersId + ")";
  83. return PageBase<Visa>.excutePageSql(new Visa(), "Visa", "Visa", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  84. }
  85. /// <summary>
  86. /// 增加
  87. /// </summary>
  88. /// <returns></returns>
  89. public bool AddVisa(Visa v, out int id)
  90. {
  91. string sql = "insert into Visa values(@DIId,@VisaClient,@VisaPrice,@VisaCurrency,@IsThird,@VisaAttachment,@Remark,@Operator,@OperatorDate," +
  92. "@IsDel,@PassengerType,@VisaNumber,@VisaFreeNumber);SELECT @@IDENTITY";
  93. SqlParameter[] parameter = new SqlParameter[]{
  94. new SqlParameter("@DIId",v.DIId),
  95. new SqlParameter("@VisaClient",v.VisaClient),
  96. new SqlParameter("@VisaPrice",v.VisaPrice),
  97. new SqlParameter("@VisaCurrency",v.VisaCurrency),
  98. new SqlParameter("@IsThird",v.IsThird),
  99. new SqlParameter("@VisaAttachment",v.VisaAttachment),
  100. new SqlParameter("@Remark",v.Remark),
  101. new SqlParameter("@Operator",v.Operators),
  102. new SqlParameter("@OperatorDate",v.OperatorsDate),
  103. new SqlParameter("@IsDel",v.IsDel),
  104. new SqlParameter("@PassengerType",v.PassengerType),
  105. new SqlParameter("@VisaNumber",v.VisaNumber),
  106. new SqlParameter("@VisaFreeNumber",v.VisaFreeNumber),
  107. };
  108. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  109. if (obj > 0)
  110. {
  111. id = obj;
  112. return true;
  113. }
  114. id = 0;
  115. return false;
  116. }
  117. /// <summary>
  118. /// 编辑
  119. /// </summary>
  120. /// <returns></returns>
  121. public bool EditVisa(Visa v)
  122. {
  123. string sql = "update Visa set DIId = @DIId,VisaClient = @VisaClient,VisaPrice = @VisaPrice,VisaCurrency = @VisaCurrency,"
  124. +"IsThird=@IsThird,VisaAttachment = @VisaAttachment,Remark = @Remark,"
  125. + "Operator = @Operator,OperatorDate = @OperatorDate,PassengerType=@PassengerType,VisaNumber=@VisaNumber,VisaFreeNumber=@VisaFreeNumber" +
  126. " where Id = @Id";
  127. SqlParameter[] parameter = new SqlParameter[]{
  128. new SqlParameter("@DIId",v.DIId),
  129. new SqlParameter("@VisaClient",v.VisaClient),
  130. new SqlParameter("@VisaPrice",v.VisaPrice),
  131. new SqlParameter("@VisaCurrency",v.VisaCurrency),
  132. new SqlParameter("@IsThird",v.IsThird),
  133. new SqlParameter("@VisaAttachment",v.VisaAttachment),
  134. new SqlParameter("@Remark",v.Remark),
  135. new SqlParameter("@Operator",v.Operators),
  136. new SqlParameter("@OperatorDate",v.OperatorsDate),
  137. new SqlParameter("@Id",v.Id),
  138. new SqlParameter("@PassengerType",v.PassengerType),
  139. new SqlParameter("@VisaNumber",v.VisaNumber),
  140. new SqlParameter("@VisaFreeNumber",v.VisaFreeNumber),
  141. };
  142. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  143. return true;
  144. return false;
  145. }
  146. /// <summary>
  147. /// 删除
  148. /// </summary>
  149. /// <param name="id"></param>
  150. /// <returns></returns>
  151. public bool DelVisa(int id)
  152. {
  153. if (SqlHelper.ExecuteNonQuery("update Visa set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  154. return true;
  155. return false;
  156. }
  157. /// <summary>
  158. /// LiuChengYi 2014/5/9
  159. /// 用作微信平台上签证进图查询
  160. /// </summary>
  161. /// <param name="tourCode"></param>
  162. /// <returns></returns>
  163. public DataTable VisasProgress(string tourCode)
  164. {
  165. SqlParameter[] pars =
  166. {
  167. new SqlParameter("@tourCode",tourCode)
  168. };
  169. return SqlHelper.TransferProcedure("VisasProgress_Weixin", CommandType.StoredProcedure, pars);
  170. }
  171. }
  172. }