CheckBoxServcies.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Text;
  7. using Models;
  8. namespace DAL
  9. {
  10. public class CheckBoxServcies
  11. {
  12. List<CheckBoxs> excuteSql(string sql, params SqlParameter[] param)
  13. {
  14. return ServiceBase<CheckBoxs>.excuteSql(new CheckBoxs(), "CheckBoxs", sql, CommandType.Text, param);
  15. }
  16. CheckBoxs excuteType(string sql, params SqlParameter[] param)
  17. {
  18. //查询结果放入对象集合
  19. List<CheckBoxs> hdList = excuteSql(sql, param);
  20. //判断集合是否为空
  21. if (hdList == null || hdList.Count == 0)
  22. //返回null
  23. return null;
  24. //返回单个对象
  25. return hdList[0];
  26. }
  27. /// <summary>
  28. /// 增Add
  29. /// </summary>
  30. /// <param name="Dov"></param>
  31. /// <returns></returns>
  32. public bool Add(CheckBoxs cb)
  33. {
  34. string sql = "insert into CheckBoxs values(@Diid,@cbType,@cbValues,@Oper,@OPDate,@Isdel);SELECT @@IDENTITY";
  35. SqlParameter[] parameter = new SqlParameter[]{
  36. new SqlParameter("@Diid",cb.Diid),
  37. new SqlParameter("@cbType",cb.cbType),
  38. new SqlParameter("@cbValues",cb.cbValues),
  39. new SqlParameter("@Oper",cb.Oper),
  40. new SqlParameter("@OPDate",cb.OPDate),
  41. new SqlParameter("@Isdel",cb.Isdel)
  42. };
  43. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  44. return true;
  45. return false;
  46. }
  47. /// <summary>
  48. /// 修改
  49. /// </summary>
  50. /// <param name="Dov"></param>
  51. /// <returns></returns>
  52. public bool Edit(CheckBoxs cb)
  53. {
  54. string sql = "update CheckBoxs set Diid=@Diid,cbType=@cbType,cbValues=@cbValues ,Oper=@Oper,OPDate =@OPDate,"
  55. + "Isdel=@Isdel where Id = @Id";
  56. SqlParameter[] parameter = new SqlParameter[]{
  57. new SqlParameter("@Diid",cb.Diid),
  58. new SqlParameter("@cbType",cb.cbType),
  59. new SqlParameter("@cbValues",cb.cbValues),
  60. new SqlParameter("@Oper",cb.Oper),
  61. new SqlParameter("@OPDate",cb.OPDate),
  62. new SqlParameter("@Isdel",cb.Isdel),
  63. new SqlParameter("@Id",cb.Id)
  64. };
  65. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  66. return true;
  67. return false;
  68. }
  69. /// <summary>
  70. /// 删
  71. /// </summary>
  72. /// <param name="id"></param>
  73. /// <returns></returns>
  74. public bool del(int id)
  75. {
  76. if (SqlHelper.ExecuteNonQuery("update CheckBoxs set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  77. return true;
  78. return false;
  79. }
  80. /// <summary>
  81. /// 根据diid查询
  82. /// </summary>
  83. /// <param name="diid"></param>
  84. /// <returns></returns>
  85. public List<CheckBoxs> GetByDiid( string diid)
  86. {
  87. string sql = "select * from CheckBoxs where Diid=@diid and Isdel = 0";
  88. SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@diid", diid) };
  89. return excuteSql(sql, parameter);
  90. }
  91. /// <summary>
  92. /// 根据 diid 和 checktype 查询
  93. /// </summary>
  94. /// <param name="diid">diid</param>
  95. /// <param name="cbType">
  96. /// top
  97. /// left
  98. /// right
  99. /// </param>
  100. /// <returns></returns>
  101. public List<CheckBoxs> GetByDiidAndCheckType(string diid,string cbType)
  102. {
  103. string sql = "select * from CheckBoxs where Diid=@diid and cbType=@cbType and Isdel = 0";
  104. SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@diid", diid), new SqlParameter("@cbType", cbType) };
  105. return excuteSql(sql, parameter);
  106. }
  107. }
  108. }