DeleClientService.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. using Models;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Linq;
  8. using System.Text;
  9. namespace DAL
  10. {
  11. public class DeleClientService
  12. {
  13. List<DeleClient> excuteSql(string sql, params SqlParameter[] param)
  14. {
  15. return ServiceBase<DeleClient>.excuteSql(new DeleClient(), "DeleClient", sql, CommandType.Text, param);
  16. }
  17. DeleClient excuteType(string sql, params SqlParameter[] param)
  18. {
  19. //查询结果放入对象集合
  20. List<DeleClient> 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. /// 根据ID查询
  30. /// </summary>
  31. /// <returns></returns>
  32. public DeleClient GetById(int id)
  33. {
  34. return excuteType("select * from DeleClient where Isdel=0 and Id=" + id);
  35. }
  36. /// <summary>
  37. /// 根据姓和名查询
  38. /// </summary>
  39. /// <param name="LastName">姓</param>
  40. /// <param name="FirstName">名</param>
  41. /// <returns></returns>
  42. public DeleClient GetByName(string LastName, string FirstName)
  43. {
  44. return excuteType("select * from DeleClient where Isdel=0 and LastName='" + LastName + "' and Name='" + FirstName + "';");
  45. }
  46. /// <summary>
  47. /// 根据姓和名查询
  48. /// </summary>
  49. /// <param name="LastName">姓</param>
  50. /// <param name="FirstName">名</param>
  51. /// <returns></returns>
  52. public DeleClient GetByDiidAndName(int Diid, string LastName, string FirstName)
  53. {
  54. return excuteType("select * from DeleClient where Isdel=0 and Diid=" + Diid + " and LastName='" + LastName + "' and Name='" + FirstName + "';");
  55. }
  56. /// <summary>
  57. /// 查询所有
  58. /// </summary>
  59. /// <returns></returns>
  60. public List<DeleClient> GetAll()
  61. {
  62. return excuteSql("select * from DeleClient where Isdel=0 ");
  63. }
  64. /// <summary>
  65. /// 按团组查询所有
  66. /// </summary>
  67. /// <param name="DIID"></param>
  68. /// <returns></returns>
  69. public List<DeleClient> GetAll(int DIID)
  70. {
  71. return excuteSql("select * from DeleClient where Isdel=0 and Diid=" + DIID + " order by Id");
  72. }
  73. /// <summary>
  74. /// 按团组编号查询所有
  75. /// </summary>
  76. /// <param name="DIID"></param>
  77. /// <returns></returns>
  78. public List<DeleClient> GetByDiid(int DIID)
  79. {
  80. return excuteSql("select * from DeleClient where Isdel=0 and Diid=" + DIID);
  81. }
  82. /// <summary>
  83. /// 按团组编号查询所有
  84. /// </summary>
  85. /// <param name="DIID"></param>
  86. /// <returns></returns>
  87. public List<DeleClient> GetByDiid(int DIID, int typeId)
  88. {
  89. return excuteSql("select * from DeleClient where Isdel=0 and Diid=" + DIID + " and Type=" + typeId);
  90. }
  91. /// <summary>
  92. /// 按团组查询所有
  93. /// </summary>
  94. /// <param name="DIID"></param>
  95. /// <returns></returns>
  96. public List<DeleClient> GetAll(int DIID, String airtype)
  97. {
  98. return excuteSql("select * from DeleClient where Isdel=0 and Diid=" + DIID + " and AirType='" + airtype + "'");
  99. }
  100. //增Add
  101. public bool Add(DeleClient Dov)
  102. {
  103. string sql = "insert into DeleClient values(@Diid,@Name,@LastName,@Pinyin,@Company,@GroupUnit,@Job,@Phone,@Sex,@IDcard,@PassprotType,@PassportNo,@passportCountry,@IssuePlace,@IssueDate,@ExpiryDate,"
  104. + "@Birthday,@AirType,@AirRemark,@RoomType,@Remark,@OPer,@OPdate,@Isdel);SELECT @@IDENTITY";
  105. SqlParameter[] parameter = new SqlParameter[]{
  106. new SqlParameter("@Diid",Dov.Diid),
  107. new SqlParameter("@Name",Dov.Name),
  108. new SqlParameter("@LastName",Dov.LastName),
  109. new SqlParameter("@Pinyin",Dov.Pinyin),
  110. new SqlParameter("@Company",Dov.Company),
  111. new SqlParameter("@GroupUnit",Dov.GroupUnit),
  112. new SqlParameter("@Job",Dov.Job),
  113. new SqlParameter("@Phone",Dov.Phone),
  114. new SqlParameter("@Sex",Dov.Sex),
  115. new SqlParameter("@IDcard",Dov.IDcard),
  116. new SqlParameter("@PassprotType",Dov.PassprotType),
  117. new SqlParameter("@PassportNo",Dov.PassportNo),
  118. new SqlParameter("@passportCountry",Dov.passportCountry),
  119. new SqlParameter("@IssuePlace",Dov.IssuePlace),
  120. new SqlParameter("@IssueDate",Dov.IssueDate),
  121. new SqlParameter("@ExpiryDate",Dov.ExpiryDate),
  122. new SqlParameter("@Birthday",Dov.Birthday),
  123. new SqlParameter("@AirType",Dov.AirType),
  124. new SqlParameter("@AirRemark",Dov.AirRemark),
  125. new SqlParameter("@RoomType",Dov.RoomType),
  126. new SqlParameter("@Remark",Dov.Remark),
  127. new SqlParameter("@OPer",Dov.OPer),
  128. new SqlParameter("@OPdate",Dov.OPdate),
  129. new SqlParameter("@Isdel",Dov.Isdel)
  130. };
  131. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  132. return true;
  133. return false;
  134. }
  135. //改Update
  136. public bool Edit(DeleClient Dov)
  137. {
  138. string sql = "update DeleClient set Diid=@Diid,Name=@Name,LastName=@LastName,Pinyin=@Pinyin,Company=@Company,Job=@Job,Phone=@Phone,Sex=@Sex,IDcard=@IDcard,PassprotType=@PassprotType," +
  139. "PassportNo=@PassportNo,passportCountry=@passportCountry,IssuePlace=@IssuePlace,IssueDate=@IssueDate,ExpiryDate=@ExpiryDate,Birthday=@Birthday,AirType=@AirType,AirRemark=@AirRemark,RoomType=@RoomType," +
  140. "Remark=@Remark,OPer=@OPer,OPdate=@OPdate,Isdel=@Isdel,GroupUnit=@GroupUnit where Id=@Id";
  141. SqlParameter[] parameter = new SqlParameter[]{
  142. new SqlParameter("@Diid",Dov.Diid),
  143. new SqlParameter("@Name",Dov.Name),
  144. new SqlParameter("@LastName",Dov.LastName),
  145. new SqlParameter("@Pinyin",Dov.Pinyin),
  146. new SqlParameter("@Company",Dov.Company),
  147. new SqlParameter("@GroupUnit",Dov.GroupUnit),
  148. new SqlParameter("@Job",Dov.Job),
  149. new SqlParameter("@Phone",Dov.Phone),
  150. new SqlParameter("@Sex",Dov.Sex),
  151. new SqlParameter("@IDcard",Dov.IDcard),
  152. new SqlParameter("@PassprotType",Dov.PassprotType),
  153. new SqlParameter("@PassportNo",Dov.PassportNo),
  154. new SqlParameter("@passportCountry",Dov.passportCountry),
  155. new SqlParameter("@IssuePlace",Dov.IssuePlace),
  156. new SqlParameter("@IssueDate",Dov.IssueDate),
  157. new SqlParameter("@ExpiryDate",Dov.ExpiryDate),
  158. new SqlParameter("@Birthday",Dov.Birthday),
  159. new SqlParameter("@AirType",Dov.AirType),
  160. new SqlParameter("@AirRemark",Dov.AirRemark),
  161. new SqlParameter("@RoomType",Dov.RoomType),
  162. new SqlParameter("@Remark",Dov.Remark),
  163. new SqlParameter("@OPer",Dov.OPer),
  164. new SqlParameter("@OPdate",Dov.OPdate),
  165. new SqlParameter("@Isdel",Dov.Isdel),
  166. new SqlParameter("@Id",Dov.Id)
  167. };
  168. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  169. return true;
  170. return false;
  171. }
  172. /// <summary>
  173. /// orc识别修改
  174. /// </summary>
  175. /// <param name="Dov"></param>
  176. /// <returns></returns>
  177. public bool DeleUpd_ORC(DeleClient Dov)
  178. {
  179. string sql = "update DeleClient PassportNo=@PassportNo,passportCountry=@passportCountry,IssuePlace=@IssuePlace," +
  180. "IssueDate=@IssueDate,ExpiryDate=@ExpiryDate,OPer=@OPer,OPdate=@OPdate,Isdel=@Isdel where Id = @Id";
  181. SqlParameter[] parameter = new SqlParameter[]{
  182. new SqlParameter("@PassportNo",Dov.PassportNo),
  183. new SqlParameter("@passportCountry",Dov.passportCountry),
  184. new SqlParameter("@IssuePlace",Dov.IssuePlace),
  185. new SqlParameter("@IssueDate",Dov.IssueDate),
  186. new SqlParameter("@ExpiryDate",Dov.ExpiryDate),
  187. new SqlParameter("@OPer",Dov.OPer),
  188. new SqlParameter("@OPdate",Dov.OPdate),
  189. new SqlParameter("@Isdel",Dov.Isdel),
  190. new SqlParameter("@Id",Dov.Id)
  191. };
  192. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  193. return true;
  194. return false;
  195. }
  196. //删
  197. public bool delOA(int id)
  198. {
  199. if (SqlHelper.ExecuteNonQuery("update DeleClient set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  200. return true;
  201. return false;
  202. }
  203. public DeleClient GetByNameAndPhone(string name, string Phone)
  204. {
  205. return excuteType("select * from DeleClient where Isdel=0 and Name='" + name + "' and Phone='" + Phone + "'");
  206. }
  207. public DeleClient GetByNamesAndPhoneOrId(int diid, string LastName, string name, string Phone, string IdCard)
  208. {
  209. return excuteType("select * from DeleClient where diid=" + diid + " and (((Isdel=0 and LastName='" + LastName + "' and Name='" + name + "') or Phone='" + Phone + "') or IDcard='" + IdCard + "')");
  210. }
  211. public DeleClient GetByNamesAndPhoneOrId(string LastName, string name, string Phone, string IdCard)
  212. {
  213. return excuteType("select * from DeleClient where ((Isdel=0 and LastName='" + LastName + "' and Name='" + name + "') or Phone='" + Phone + "') or IDcard='" + IdCard + "'");
  214. }
  215. public bool updTelAndIdcard(DeleClient Dov)
  216. {
  217. string sql = "update DeleClient set Phone=@Phone,IDcard=@IDcard,OPer=@OPer,OPdate=@OPdate,Isdel=@Isdel where Id=@Id";
  218. SqlParameter[] parameter = new SqlParameter[]{
  219. new SqlParameter("@Phone",Dov.Phone),
  220. new SqlParameter("@IDcard",Dov.IDcard),
  221. new SqlParameter("@OPer",Dov.OPer),
  222. new SqlParameter("@OPdate",Dov.OPdate),
  223. new SqlParameter("@Isdel",Dov.Isdel),
  224. new SqlParameter("@Id",Dov.Id)
  225. };
  226. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  227. return true;
  228. return false;
  229. }
  230. /// <summary>
  231. /// 根据团号查询舱位类型
  232. /// 20210827 贾文滔
  233. /// </summary>
  234. /// <param name="diid"></param>
  235. /// <returns></returns>
  236. public List<string> GetAirSeatType(int diid)
  237. {
  238. DataTable dt = SqlHelper.TransferProcedure("[dbo].[GetAirSeatType]", CommandType.StoredProcedure, new SqlParameter("@diid", diid));
  239. List<string> AirTypeList = new List<string>();
  240. if (dt != null && dt.Rows.Count > 0)
  241. {
  242. try
  243. {
  244. foreach (DataRow row in dt.Rows)
  245. {
  246. AirTypeList.Add(row["AirType"].ToString());
  247. }
  248. return AirTypeList;
  249. }
  250. catch
  251. {
  252. return null;
  253. }
  254. }
  255. else
  256. {
  257. return null;
  258. }
  259. }
  260. public bool AddS(List<DeleClient> Dlist)
  261. {
  262. SqlCommand cmd = SqlHelper.createCon().CreateCommand();
  263. cmd.Connection.Open();
  264. SqlTransaction trans = cmd.Connection.BeginTransaction();
  265. try
  266. {
  267. foreach (DeleClient Dov in Dlist)
  268. {
  269. string sql = "insert into DeleClient values(@Diid,@Name,@LastName,@Pinyin,@Company,@Job,@Phone,@Sex,@IDcard,@PassprotType,@PassportNo,@passportCountry,@IssuePlace,@IssueDate,@ExpiryDate,"
  270. + "@Birthday,@AirType,@AirRemark,@RoomType,@Remark,@OPer,@OPdate,@Isdel);SELECT @@IDENTITY";
  271. SqlParameter[] parameter = new SqlParameter[]{
  272. new SqlParameter("@Diid",Dov.Diid),
  273. new SqlParameter("@Name",Dov.Name),
  274. new SqlParameter("@LastName",Dov.LastName),
  275. new SqlParameter("@Pinyin",Dov.Pinyin),
  276. new SqlParameter("@Company",Dov.Company),
  277. new SqlParameter("@Job",Dov.Job),
  278. new SqlParameter("@Phone",Dov.Phone),
  279. new SqlParameter("@Sex",Dov.Sex),
  280. new SqlParameter("@IDcard",Dov.IDcard),
  281. new SqlParameter("@PassprotType",Dov.PassprotType),
  282. new SqlParameter("@PassportNo",Dov.PassportNo),
  283. new SqlParameter("@passportCountry",Dov.passportCountry),
  284. new SqlParameter("@IssuePlace",Dov.IssuePlace),
  285. new SqlParameter("@IssueDate",Dov.IssueDate),
  286. new SqlParameter("@ExpiryDate",Dov.ExpiryDate),
  287. new SqlParameter("@Birthday",Dov.Birthday),
  288. new SqlParameter("@AirType",Dov.AirType),
  289. new SqlParameter("@AirRemark",Dov.AirRemark),
  290. new SqlParameter("@RoomType",Dov.RoomType),
  291. new SqlParameter("@Remark",Dov.Remark),
  292. new SqlParameter("@OPer",Dov.OPer),
  293. new SqlParameter("@OPdate",Dov.OPdate),
  294. new SqlParameter("@Isdel",Dov.Isdel)
  295. };
  296. cmd.CommandText = sql;
  297. cmd.ExecuteNonQuery();
  298. }
  299. trans.Commit();
  300. cmd.Connection.Close();
  301. return true;
  302. }
  303. catch
  304. {
  305. trans.Rollback();
  306. cmd.Connection.Close();
  307. return false;
  308. }
  309. }
  310. /// <summary>
  311. /// 修改组团单位
  312. /// </summary>
  313. /// <param name="Dov"></param>
  314. /// <returns></returns>
  315. public bool DropCompanyEdit(string id, string DropCompany)
  316. {
  317. string sql = "update DeleClient set GroupUnit=@DropCompany where id in("+id+")";
  318. SqlParameter[] parameter = new SqlParameter[]{
  319. new SqlParameter("@DropCompany",DropCompany),
  320. };
  321. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  322. return true;
  323. return false;
  324. }
  325. }
  326. }