WD_RunProfileDataAccess.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using Dapper;
  3. using HNWD.Pregrant.Model;
  4. using System.Collections.Generic;
  5. namespace HNWD.Pregrant.DataAccess
  6. {
  7. public class WD_RunProfileDataAccess : GenericDataAccess<WD_RunProfile>
  8. {
  9. private WD_RunProfile wd_RunProfile = null;
  10. public WD_RunProfileExt ext = new WD_RunProfileExt();
  11. public WD_RunProfileDataAccess(WD_RunProfile wd_RunProfile)
  12. {
  13. this.wd_RunProfile = wd_RunProfile;
  14. }
  15. private WD_RunProfileDataAccess()
  16. {
  17. }
  18. private readonly static WD_RunProfileDataAccess wd_RunProfileDataAccess = new WD_RunProfileDataAccess();
  19. private readonly static object lockobj = new object();
  20. public static WD_RunProfileDataAccess GetInstance()
  21. {
  22. lock (lockobj)
  23. {
  24. return wd_RunProfileDataAccess;
  25. }
  26. }
  27. //public List<WD_RunProfile> Query()
  28. //{
  29. // string strSql = " select {0} from [WD_RunProfile] ";
  30. // ext.messageDataList = this.Query(strSql, new WD_RunProfile());
  31. // ext.messageDataList.ForEach(f => f.bSuccess = this.bSuccess);
  32. // ext.messageDataList.ForEach(f => f.Code = this.Code);
  33. // ext.messageDataList.ForEach(f => f.Message = this.Message);
  34. // ext.messageDataList.ForEach(f => f.Rows = this.Rows);
  35. // ext.bSuccess = this.bSuccess;
  36. // ext.Code = this.Code;
  37. // ext.Message = this.Message;
  38. // ext.Rows = this.Rows;
  39. // return ext.messageDataList;
  40. //}
  41. public List<WD_RunProfile> QueryAll()
  42. {
  43. string strSql = " select {0} from [WD_RunProfile] ";
  44. ext.messageDataList = this.Query(strSql, new WD_RunProfile());
  45. ext.messageDataList.ForEach(f => f.bSuccess = this.bSuccess);
  46. ext.messageDataList.ForEach(f => f.Code = this.Code);
  47. ext.messageDataList.ForEach(f => f.Message = this.Message);
  48. ext.messageDataList.ForEach(f => f.Rows = this.Rows);
  49. ext.bSuccess = this.bSuccess;
  50. ext.Code = this.Code;
  51. ext.Message = this.Message;
  52. ext.Rows = this.Rows;
  53. return ext.messageDataList;
  54. }
  55. public List<WD_RunProfile> QueryByPartID(string partid)
  56. {
  57. string strSql = " select {0} from [WD_RunProfile] WHERR PARTID = " + partid ;
  58. ext.messageDataList = this.Query(strSql, new WD_RunProfile());
  59. ext.messageDataList.ForEach(f => f.bSuccess = this.bSuccess);
  60. ext.messageDataList.ForEach(f => f.Code = this.Code);
  61. ext.messageDataList.ForEach(f => f.Message = this.Message);
  62. ext.messageDataList.ForEach(f => f.Rows = this.Rows);
  63. ext.bSuccess = this.bSuccess;
  64. ext.Code = this.Code;
  65. ext.Message = this.Message;
  66. ext.Rows = this.Rows;
  67. return ext.messageDataList;
  68. }
  69. public void UpdateVol()
  70. {
  71. this.wd_RunProfile.BroadcastVol = string.IsNullOrEmpty(this.wd_RunProfile.BroadcastVol) ? "0" : this.wd_RunProfile.BroadcastVol;
  72. int nVol = Convert.ToInt32(this.wd_RunProfile.BroadcastVol);
  73. if (nVol >= 0 && nVol <= 100)
  74. {
  75. string strSql = " update [WD_RunProfile] SET BroadcastVol={0} ";
  76. strSql = string.Format(strSql, this.wd_RunProfile.BroadcastVol);
  77. this.Execute(strSql, this.wd_RunProfile);
  78. }
  79. }
  80. /// <summary>
  81. /// 更新LED标识
  82. /// </summary>
  83. /// <param name="invalid">是否无效</param>
  84. public void UpdateLedFlag(string invalid)
  85. {
  86. string strSql = " update [WD_RunProfile] SET LEDDeviceFlag={0} ";
  87. strSql = string.Format(strSql, invalid);
  88. this.Execute(strSql, this.wd_RunProfile);
  89. }
  90. }
  91. }