VisaCustomerFamilyService.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 VisaCustomerFamilyService
  11. {
  12. List<VisaCustomerFamily> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<VisaCustomerFamily>.excuteSql(new VisaCustomerFamily(), "VisaCustomerFamily", sql, CommandType.Text, param);
  15. }
  16. VisaCustomerFamily excuteType(string sql, params SqlParameter[] param)
  17. {
  18. //查询结果放入对象集合
  19. List<VisaCustomerFamily> hdList = excuteSql(sql, param);
  20. //判断集合是否为空
  21. if (hdList == null || hdList.Count == 0)
  22. //返回null
  23. return null;
  24. //返回单个对象
  25. return hdList[0];
  26. }
  27. //增Add
  28. public bool Add(VisaCustomerFamily Dov)
  29. {
  30. string sql = "insert into VisaCustomerFamily values(@DCId,@Appellation,@Name,@BirthDay,@BirthPlace,@Politics,@Client,@Address,@IsEu,@NameSnd,@BirthDaySnd,@Nationality,@IDCard,@Reletionship,@IsUSA);SELECT @@IDENTITY";
  31. SqlParameter[] parameter = new SqlParameter[]{
  32. new SqlParameter("@DCId",Dov.DCId),
  33. new SqlParameter("@Appellation",Dov.Appellation),
  34. new SqlParameter("@Name",Dov.Name),
  35. new SqlParameter("@BirthDay",Dov.BirthDay),
  36. new SqlParameter("@BirthPlace",Dov.BirthPlace),
  37. new SqlParameter("@Politics",Dov.Politics),
  38. new SqlParameter("@Client",Dov.Client),
  39. new SqlParameter("@Address",Dov.Address),
  40. new SqlParameter("@IsEu",Dov.IsEu),
  41. new SqlParameter("@NameSnd",Dov.NameSnd),
  42. new SqlParameter("@BirthDaySnd",Dov.BirthDaySnd),
  43. new SqlParameter("@Nationality",Dov.Nationality),
  44. new SqlParameter("@IDCard",Dov.IDCard),
  45. new SqlParameter("@Reletionship",Dov.Reletionship),
  46. new SqlParameter("@IsUSA",Dov.IsUSA)
  47. };
  48. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  49. return true;
  50. return false;
  51. }
  52. //改Update
  53. public bool Edit(VisaCustomerFamily Dov)
  54. {
  55. string sql = "update VisaCustomerFamily set DCId=@DCId,Appellation=@Appellation,Name=@Name,BirthDay=@BirthDay,BirthPlace=@BirthPlace,Politics=@Politics,Client=@Client,Address=@Address,IsEu=@IsEu,NameSnd=@NameSnd,BirthDaySnd=@BirthDaySnd,Nationality=@Nationality,IDCard=@IDCard,Reletionship=@Reletionship,IsUSA=@IsUSA where Id = @Id";
  56. SqlParameter[] parameter = new SqlParameter[]{
  57. new SqlParameter("@DCId",Dov.DCId),
  58. new SqlParameter("@Appellation",Dov.Appellation),
  59. new SqlParameter("@Name",Dov.Name),
  60. new SqlParameter("@BirthDay",Dov.BirthDay),
  61. new SqlParameter("@BirthPlace",Dov.BirthPlace),
  62. new SqlParameter("@Politics",Dov.Politics),
  63. new SqlParameter("@Client",Dov.Client),
  64. new SqlParameter("@Address",Dov.Address),
  65. new SqlParameter("@IsEu",Dov.IsEu),
  66. new SqlParameter("@NameSnd",Dov.NameSnd),
  67. new SqlParameter("@BirthDaySnd",Dov.BirthDaySnd),
  68. new SqlParameter("@Nationality",Dov.Nationality),
  69. new SqlParameter("@IDCard",Dov.IDCard),
  70. new SqlParameter("@Reletionship",Dov.Reletionship),
  71. new SqlParameter("@IsUSA",Dov.IsUSA),
  72. new SqlParameter("@Id",Dov.Id)
  73. };
  74. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  75. return true;
  76. return false;
  77. }
  78. public bool del(int DCID)
  79. {
  80. if (SqlHelper.ExecuteNonQuery("delete from VisaCustomerFamily where DCId=@DCId", CommandType.Text, new SqlParameter("@DCId", DCID)) > 0)
  81. return true;
  82. return false;
  83. }
  84. /// <summary>
  85. /// 根据客户表id查询所有家庭成员
  86. /// </summary>
  87. /// <param name="DCID"></param>
  88. /// <returns></returns>
  89. public List<VisaCustomerFamily> GetAllById(int DCID)
  90. {
  91. return excuteSql("select * from VisaCustomerFamily where DCId=@DCId order by Id", new SqlParameter("@DCId", DCID));
  92. }
  93. public List<VisaCustomerFamily> GetNotEUByDCID(int DCID)
  94. {
  95. return excuteSql("select * from VisaCustomerFamily where DCId=@DCId and IsEu=0 order by Id", new SqlParameter("@DCId", DCID));
  96. }
  97. public List<VisaCustomerFamily> GetEUByDCID(int DCID)
  98. {
  99. return excuteSql("select * from VisaCustomerFamily where DCId=@DCId and IsEu=1 order by Id", new SqlParameter("@DCId", DCID));
  100. }
  101. public VisaCustomerFamily GetByID(int id)
  102. {
  103. return excuteType("select * from VisaCustomerFamily where Id=@Id", new SqlParameter("@Id", id));
  104. }
  105. }
  106. }