TranslatorService.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 TranslatorService
  11. {
  12. List<Translator> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<Translator>.excuteSql(new Translator(), "Translator", sql, CommandType.Text, param);
  15. }
  16. Translator excuteType(string sql, params SqlParameter[] param)
  17. {
  18. //查询结果放入对象集合
  19. List<Translator> 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(Translator Dov)
  29. {
  30. string sql = "insert into Translator values(@OA_Oper,@Name,@Back,@Resume,@Language,@Tel,@Certificate,@knowRelations,@Shorthand,@Suit,@List,"
  31. + "@SuitScore,@ShortHandScore,@AbilityScore,@TimeScore,@LinkUpScore,@QualityScore,@StrainScore,@MeetScore,@CertificateScore,@Oper,@Opdate,@Isdel);SELECT @@IDENTITY";
  32. SqlParameter[] parameter = new SqlParameter[]{
  33. new SqlParameter("@OA_Oper",Dov.OA_Oper),
  34. new SqlParameter("@Name",Dov.Name),
  35. new SqlParameter("@Back",Dov.Back),
  36. new SqlParameter("@Resume",Dov.Resume),
  37. new SqlParameter("@Language",Dov.Language),
  38. new SqlParameter("@Tel",Dov.Tel),
  39. new SqlParameter("@Certificate",Dov.Certificate),
  40. new SqlParameter("@knowRelations",Dov.knowRelations),
  41. new SqlParameter("@Shorthand",Dov.Shorthand),
  42. new SqlParameter("@Suit",Dov.Suit),
  43. new SqlParameter("@List",Dov.List),
  44. new SqlParameter("@SuitScore",Dov.SuitScore),
  45. new SqlParameter("@ShortHandScore",Dov.ShortHandScore),
  46. new SqlParameter("@AbilityScore",Dov.AbilityScore),
  47. new SqlParameter("@TimeScore",Dov.TimeScore),
  48. new SqlParameter("@LinkUpScore",Dov.LinkUpScore),
  49. new SqlParameter("@QualityScore",Dov.QualityScore),
  50. new SqlParameter("@StrainScore",Dov.StrainScore),
  51. new SqlParameter("@MeetScore",Dov.MeetScore),
  52. new SqlParameter("@CertificateScore",Dov.CertificateScore),
  53. new SqlParameter("@Oper",Dov.Oper),
  54. new SqlParameter("@Opdate",Dov.Opdate),
  55. new SqlParameter("@Isdel",Dov.Isdel)
  56. };
  57. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  58. return true;
  59. return false;
  60. }
  61. //改Update
  62. public bool Edit(Translator Dov)
  63. {
  64. string sql = "update Translator set OA_Oper=@OA_Oper,Name=@Name,Back=@Back,Resume=@Resume,Language=@Language,Tel=@Tel,Certificate=@Certificate,knowRelations=@knowRelations,"
  65. + "Shorthand=@Shorthand,Suit=@Suit,List=@List,SuitScore=@SuitScore,ShortHandScore=@ShortHandScore,AbilityScore=@AbilityScore,"
  66. + "TimeScore=@TimeScore,LinkUpScore=@LinkUpScore,QualityScore=@QualityScore,StrainScore=@StrainScore,MeetScore=@MeetScore,CertificateScore=@CertificateScore,"
  67. + "Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id";
  68. SqlParameter[] parameter = new SqlParameter[]{
  69. new SqlParameter("@OA_Oper",Dov.OA_Oper),
  70. new SqlParameter("@Name",Dov.Name),
  71. new SqlParameter("@Back",Dov.Back),
  72. new SqlParameter("@Resume",Dov.Resume),
  73. new SqlParameter("@Language",Dov.Language),
  74. new SqlParameter("@Tel",Dov.Tel),
  75. new SqlParameter("@Certificate",Dov.Certificate),
  76. new SqlParameter("@knowRelations",Dov.knowRelations),
  77. new SqlParameter("@Shorthand",Dov.Shorthand),
  78. new SqlParameter("@Suit",Dov.Suit),
  79. new SqlParameter("@List",Dov.List),
  80. new SqlParameter("@SuitScore",Dov.SuitScore),
  81. new SqlParameter("@ShortHandScore",Dov.ShortHandScore),
  82. new SqlParameter("@AbilityScore",Dov.AbilityScore),
  83. new SqlParameter("@TimeScore",Dov.TimeScore),
  84. new SqlParameter("@LinkUpScore",Dov.LinkUpScore),
  85. new SqlParameter("@QualityScore",Dov.QualityScore),
  86. new SqlParameter("@StrainScore",Dov.StrainScore),
  87. new SqlParameter("@MeetScore",Dov.MeetScore),
  88. new SqlParameter("@CertificateScore",Dov.CertificateScore),
  89. new SqlParameter("@Oper",Dov.Oper),
  90. new SqlParameter("@Opdate",Dov.Opdate),
  91. new SqlParameter("@Isdel",Dov.Isdel),
  92. new SqlParameter("@Id",Dov.Id)
  93. };
  94. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  95. return true;
  96. return false;
  97. }
  98. //删
  99. public bool delOA(int id)
  100. {
  101. if (SqlHelper.ExecuteNonQuery("update Translator set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  102. return true;
  103. return false;
  104. }
  105. /// <summary>
  106. /// 查找所有数据 - 分页
  107. /// </summary>
  108. /// <returns></returns>
  109. public List<Translator> GetAllTranslator(int pageIndex, out int sumPage, out int totalRecord, string Name, string Language, string List)
  110. {
  111. string sqlwhere = "IsDel = 0 and Name like '%" + Name + "%' and Language like '%" + Language + "%'";
  112. if (List != "全部")
  113. {
  114. sqlwhere += " And List like '%" + List + "%'";
  115. }
  116. return PageBase<Translator>.excutePageSql(new Translator(), "Translator", "Translator", "*", "id asc", sqlwhere, 20, pageIndex, out sumPage, out totalRecord);
  117. }
  118. public Translator getById(int id)
  119. {
  120. return excuteType("select * from Translator where Isdel=0 and Id=@id", new SqlParameter("@id", id));
  121. }
  122. /// <summary>
  123. /// 验证数据是否已存在
  124. /// </summary>
  125. /// <param name="name"></param>
  126. /// <param name="Tel"></param>
  127. /// <returns></returns>
  128. public Translator getByNameAndTel(string name, string Tel)
  129. {
  130. return excuteType("select * from Translator where Isdel=0 and name=" + name + " and Tel=" + Tel);
  131. }
  132. }
  133. }