CustomerVisaInfoService.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 CustomerVisaInfoService
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<CustomerVisaInfo> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<CustomerVisaInfo>.excuteSql(new CustomerVisaInfo(), "CustomerVisaInfo", 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. CustomerVisaInfo excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<CustomerVisaInfo> vList = excuteSql(sql, param);
  32. //判断集合是否为空
  33. if (vList == null || vList.Count == 0)
  34. //返回null
  35. return null;
  36. //返回单个对象
  37. return vList[0];
  38. }
  39. /// <summary>
  40. /// 增加
  41. /// </summary>
  42. /// <returns></returns>
  43. public bool AddCustomerVisaInfo(CustomerVisaInfo c)
  44. {
  45. string sql = "insert into CustomerVisaInfo values(@DIId,@Name,@Sex,@PhoneNumber,@Dirthday,@NativePlace,@CardId,@PassportNo,@PassportsValidity,@UnitName,@Post,@UnitAddress,@HomeAddress,@FiveYearsAgo,@Operators,@OperatorDate,@VId,@IsDel,@Remark)";
  46. SqlParameter[] parameter = new SqlParameter[]{
  47. new SqlParameter("@DIId",c.DIId),
  48. new SqlParameter("@Name",c.Name),
  49. new SqlParameter("@Sex",c.Sex),
  50. new SqlParameter("@PhoneNumber",c.PhoneNumber),
  51. new SqlParameter("@Dirthday",c.Dirthday),
  52. new SqlParameter("@NativePlace",c.NativePlace),
  53. new SqlParameter("@CardId",c.CardId),
  54. new SqlParameter("@PassportNo",c.PassportNo),
  55. new SqlParameter("@PassportsValidity",c.PassportsValidity),
  56. new SqlParameter("@UnitName",c.UnitName),
  57. new SqlParameter("@Post",c.Post),
  58. new SqlParameter("@UnitAddress",c.UnitAddress),
  59. new SqlParameter("@HomeAddress",c.HomeAddress),
  60. new SqlParameter("@FiveYearsAgo",c.FiveYearsAgo),
  61. new SqlParameter("@Operators",c.Operators),
  62. new SqlParameter("@OperatorDate",c.OperatorDate),
  63. new SqlParameter("@VId",c.VId),
  64. new SqlParameter("@IsDel",c.IsDel),
  65. new SqlParameter("@Remark",c.Remark)
  66. };
  67. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  68. return true;
  69. return false;
  70. }
  71. /// <summary>
  72. /// 获取全部 - 分页
  73. /// </summary>
  74. /// <returns></returns>
  75. public List<CustomerVisaInfo> GetCustomerVisaInfo(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string visaClient, string arrayUsersId)
  76. {
  77. string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and Name like '%" + visaClient + "%' and Operators in (" + arrayUsersId + ")";
  78. return PageBase<CustomerVisaInfo>.excutePageSql(new CustomerVisaInfo(), "CustomerVisaInfo", "CustomerVisaInfo", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  79. }
  80. public bool Del(int id)
  81. {
  82. if (SqlHelper.ExecuteNonQuery("update CustomerVisaInfo set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  83. return true;
  84. return false;
  85. }
  86. /// <summary>
  87. /// 根据编号查询对象信息
  88. /// </summary>
  89. /// <param name="id">对象编号</param>
  90. /// <returns>返回空或者单个对象信息</returns>
  91. public CustomerVisaInfo GetCustomerVisaInfoById(int id,int diid)
  92. {
  93. //调用获取单个对象的方法
  94. return excuteType("select * from CustomerVisaInfo where id =@id and diid = @diid and isdel=0 order by id asc",new SqlParameter("@id",id), new SqlParameter("@diid", diid));
  95. }
  96. public CustomerVisaInfo GetCustomerVisaInfoByIdList(int id, int diid)
  97. {
  98. string sql = "select * from CustomerVisaInfo where id =@id and diid = @diid and isdel=0 order by id asc";
  99. SqlParameter[] parameter = new SqlParameter[]{
  100. new SqlParameter("@id",id),
  101. new SqlParameter("@diid",diid)
  102. };
  103. return excuteType(sql, parameter);
  104. }
  105. public List<CustomerVisaInfo> GetCustomerVisaInfoByDiidList(int diid)
  106. {
  107. string sql = "select * from CustomerVisaInfo where diid = @diid and isdel=0 order by id asc";
  108. SqlParameter[] parameter = new SqlParameter[]{
  109. new SqlParameter("@diid",diid)
  110. };
  111. return excuteSql(sql, parameter);
  112. }
  113. //public CustomerVisaInfo GetCustomerVisaInfoByDiidList(int diid)
  114. //{
  115. // string sql = "select * from CustomerVisaInfo where diid = @diid and isdel=0 order by id asc";
  116. // SqlParameter[] parameter = new SqlParameter[]{
  117. // new SqlParameter("@diid",diid)
  118. // };
  119. // return excuteType(sql, parameter);
  120. //}
  121. public CustomerVisaInfo GetCustomerVisaInfoByVIdList(int diid, int vid)
  122. {
  123. string sql = "select * from CustomerVisaInfo where DIId =@diid and VId = @vid and isdel=0 order by id asc";
  124. SqlParameter[] parameter = new SqlParameter[]{
  125. new SqlParameter("@DIId",diid),
  126. new SqlParameter("@VId",vid)
  127. };
  128. return excuteType(sql, parameter);
  129. }
  130. public CustomerVisaInfo GetCustomerVisaInfoByVisaClientList(string name)
  131. {
  132. string sql = "select * from CustomerVisaInfo where Name =@name and isdel=0 order by id desc";
  133. SqlParameter[] parameter = new SqlParameter[]{
  134. new SqlParameter("@Name",name)
  135. };
  136. return excuteType(sql, parameter);
  137. }
  138. /// <summary>
  139. /// 编辑
  140. /// </summary>
  141. /// <returns></returns>
  142. public bool EditCustomerVisaInfo(CustomerVisaInfo c)
  143. {
  144. string sql = "update CustomerVisaInfo set Name = @Name,Sex = @Sex,PhoneNumber = @PhoneNumber,Dirthday = @Dirthday,NativePlace = @NativePlace,CardId = @CardId,PassportNo = @PassportNo,PassportsValidity = @PassportsValidity,UnitName = @UnitName,Post = @Post,UnitAddress = @UnitAddress,HomeAddress = @HomeAddress,FiveYearsAgo = @FiveYearsAgo,Operators = @Operators,OperatorDate = @OperatorDate,VId = @VId,Remark = @Remark where Id = @Id";
  145. SqlParameter[] parameter = new SqlParameter[]{
  146. new SqlParameter("@Name",c.Name),
  147. new SqlParameter("@Sex",c.Sex),
  148. new SqlParameter("@PhoneNumber",c.PhoneNumber),
  149. new SqlParameter("@Dirthday",c.Dirthday),
  150. new SqlParameter("@NativePlace",c.NativePlace),
  151. new SqlParameter("@CardId",c.CardId),
  152. new SqlParameter("@PassportNo",c.PassportNo),
  153. new SqlParameter("@PassportsValidity",c.PassportsValidity),
  154. new SqlParameter("@UnitName",c.UnitName),
  155. new SqlParameter("@Post",c.Post),
  156. new SqlParameter("@UnitAddress",c.UnitAddress),
  157. new SqlParameter("@HomeAddress",c.HomeAddress),
  158. new SqlParameter("@FiveYearsAgo",c.FiveYearsAgo),
  159. new SqlParameter("@Operators",c.Operators),
  160. new SqlParameter("@OperatorDate",c.OperatorDate),
  161. new SqlParameter("@VId",c.VId),
  162. new SqlParameter("@Remark",c.Remark),
  163. new SqlParameter("@Id",c.Id)
  164. };
  165. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  166. return true;
  167. return false;
  168. }
  169. }
  170. }