mic_screen_rules_DAL.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using PaintDotNet.Base;
  2. using PaintDotNet.DbOpreate.DbIDal;
  3. using PaintDotNet.DbOpreate.DbModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Transactions;
  10. namespace PaintDotNet.DbOpreate.DbCodeFirstDAL
  11. {
  12. class mic_screen_rules_DAL : Imic_screen_rules
  13. {
  14. #region 基础功能
  15. /// <summary>
  16. /// 添加信息
  17. /// <param name="model">实体</param>
  18. /// </summary>
  19. /// <returns></returns>
  20. public bool Add(mic_screen_rules model)
  21. {
  22. using (DBEntities dbEntity = new DBEntities())
  23. {
  24. dbEntity.mic_screen_rules_market.Add(model);
  25. int recordsAffected;
  26. recordsAffected = dbEntity.SaveChanges();
  27. return recordsAffected > 0;
  28. }
  29. }
  30. /// <summary>
  31. /// 删除信息
  32. /// <param name="id">主键</param>
  33. /// </summary>
  34. /// <returns></returns>
  35. public bool Del(int id)
  36. {
  37. using (DBEntities dbEntity = new DBEntities())
  38. {
  39. var info = dbEntity.mic_screen_rules_market.SingleOrDefault(m => m.id == id);
  40. if (info != null)
  41. {
  42. dbEntity.mic_screen_rules_market.Remove(info);
  43. dbEntity.SaveChanges();
  44. }
  45. else
  46. {
  47. return false;
  48. }
  49. return true;
  50. }
  51. }
  52. /// <summary>
  53. /// 获得信息
  54. /// <param name="id">主键</param>
  55. /// </summary>
  56. /// <returns></returns>
  57. public mic_screen_rules FindDefault(int id)
  58. {
  59. using (DBEntities dbEntity = new DBEntities())
  60. {
  61. return dbEntity.mic_screen_rules_market.Where(m => m.id == id).FirstOrDefault();
  62. }
  63. }
  64. /// <summary>
  65. /// 更新信息
  66. /// <param name="model">实体</param>
  67. /// </summary>
  68. /// <returns></returns>
  69. public bool Update(mic_screen_rules model)
  70. {
  71. using (DBEntities dbEntity = new DBEntities())
  72. {
  73. var info = dbEntity.mic_screen_rules_market.SingleOrDefault(m => m.id == model.id);
  74. info.id = model.id;//主键ID
  75. info.delete_flag = model.delete_flag;
  76. info.max_resolution = model.max_resolution;
  77. info.point_pitch = model.point_pitch;
  78. info.screen_width = model.screen_width;
  79. info.size = model.size;
  80. int recordsAffected;
  81. recordsAffected = dbEntity.SaveChanges();
  82. return recordsAffected > 0;
  83. }
  84. }
  85. /// <summary>
  86. /// 获得所有信息
  87. /// </summary>
  88. /// <returns></returns>
  89. public List<mic_screen_rules> FindAll()
  90. {
  91. using (DBEntities dbEntity = new DBEntities())
  92. {
  93. return dbEntity.mic_screen_rules_market.Where(m => m.delete_flag == 2).ToList().OrderByDescending(m => m.id).ToList();
  94. }
  95. }
  96. #endregion 基础功能
  97. }
  98. }