DelegationEnDataService.cs 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 DelegationEnDataService
  11. {
  12. List<DelegationEnData> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<DelegationEnData>.excuteSql(new DelegationEnData(), "DelegationEnData", sql, CommandType.Text, param);
  15. }
  16. DelegationEnData excuteType(string sql, params SqlParameter[] param)
  17. {
  18. //查询结果放入对象集合
  19. List<DelegationEnData> 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(DelegationEnData Dov)
  29. {
  30. string sql = "insert into DelegationEnData values(@Area,@Job,@JobEn,@DelegationSetting,@DelegationSettingEn,@Oper,@Opdate,@Isdel);SELECT @@IDENTITY";
  31. SqlParameter[] parameter = new SqlParameter[]{
  32. new SqlParameter("@Area",Dov.Area),
  33. new SqlParameter("@Job",Dov.Job),
  34. new SqlParameter("@JobEn",Dov.JobEn),
  35. new SqlParameter("@DelegationSetting",Dov.DelegationSetting),
  36. new SqlParameter("@DelegationSettingEn",Dov.DelegationSettingEn),
  37. new SqlParameter("@Oper",Dov.Oper),
  38. new SqlParameter("@Opdate",Dov.Opdate),
  39. new SqlParameter("@Isdel",Dov.Isdel)
  40. };
  41. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  42. return true;
  43. return false;
  44. }
  45. //改Update
  46. public bool Edit(DelegationEnData Dov)
  47. {
  48. string sql = "update DelegationEnData set Area=@Area,Job=@Job,JobEn=@JobEn,DelegationSetting=@DelegationSetting,"
  49. + "DelegationSettingEn=@DelegationSettingEn,Oper=@Oper,Opdate=@Opdate,Isdel=@Isdel where Id = @Id";
  50. SqlParameter[] parameter = new SqlParameter[]{
  51. new SqlParameter("@Area",Dov.Area),
  52. new SqlParameter("@Job",Dov.Job),
  53. new SqlParameter("@JobEn",Dov.JobEn),
  54. new SqlParameter("@DelegationSetting",Dov.DelegationSetting),
  55. new SqlParameter("@DelegationSettingEn",Dov.DelegationSettingEn),
  56. new SqlParameter("@Oper",Dov.Oper),
  57. new SqlParameter("@Opdate",Dov.Opdate),
  58. new SqlParameter("@Isdel",Dov.Isdel),
  59. new SqlParameter("@Id",Dov.Id)
  60. };
  61. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  62. return true;
  63. return false;
  64. }
  65. //删
  66. public bool delOA(int id)
  67. {
  68. if (SqlHelper.ExecuteNonQuery("update DelegationEnData set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  69. return true;
  70. return false;
  71. }
  72. /// <summary>
  73. /// 查找所有数据 - 分页
  74. /// </summary>
  75. /// <returns></returns>
  76. public List<DelegationEnData> GetAllAskData(int pageIndex, out int sumPage, out int totalRecord, string Area, string Job)
  77. {
  78. string sqlwhere = "IsDel = 0 and Area like '%" + Area + "%' and Job like '%" + Job + "%'";
  79. return PageBase<DelegationEnData>.excutePageSql(new DelegationEnData(), "DelegationEnData", "DelegationEnData", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  80. }
  81. public DelegationEnData getById(int id)
  82. {
  83. return excuteType("select * from DelegationEnData where Isdel=0 and Id=@id", new SqlParameter("@id", id));
  84. }
  85. }
  86. }