NBDevManufacturerService.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using LeaRun.Application.Entity.NBManage;
  2. using LeaRun.Data;
  3. using LeaRun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace LeaRun.Application.Service.NBManage
  11. {
  12. public class NBDevManufacturerService
  13. {
  14. SqlHelper sqlHelper = new SqlHelper("NBDB");
  15. /// <summary>
  16. /// 保存NBDevManufacturer 设备厂商
  17. /// </summary>
  18. /// <param name="entity"></param>
  19. /// <returns> </returns>
  20. public bool SaveNBDevManufacturer(NBDevManufacturerEntity entity)
  21. {
  22. try
  23. {
  24. string insertSql = DataHelper.ModelToInsertSql<NBDevManufacturerEntity>(entity, "RMRS_NBDevManufacturer");
  25. return sqlHelper.ExecuteNoParams(insertSql, CommandType.Text) > 0;
  26. }
  27. catch (Exception)
  28. {
  29. throw;
  30. }
  31. }
  32. /// <summary>
  33. /// 更新NBDevManufacturer
  34. /// </summary>
  35. /// <param name="entity"></param>
  36. /// <returns></returns>
  37. public bool UpdateNBDevManufacturer(NBDevManufacturerEntity entity)
  38. {
  39. try
  40. {
  41. string updateSql = DataHelper.ModelToUpdateSql<NBDevManufacturerEntity>(entity, "RMRS_NBDevManufacturer");
  42. return sqlHelper.ExecuteNoParams(updateSql, CommandType.Text) > 0;
  43. }
  44. catch (Exception)
  45. {
  46. throw;
  47. }
  48. }
  49. /// <summary>
  50. /// 删除NBDevManufacturer
  51. /// </summary>
  52. /// <param name="NBDevManufacturerID"></param>
  53. /// <returns>3 不可删除 1 删除成功 0删除失败</returns>
  54. public int DeleteNBDevManufacturer(string NBDevManufacturerID)
  55. {
  56. try
  57. {
  58. //判断次类型下有无表
  59. string sqlMeter = "SELECT * FROM RMRS_MeterInfo WHERE NBDevManufacturer = " + NBDevManufacturerID;
  60. DataTable dtMeter = sqlHelper.ExecuteDataTable(sqlMeter, CommandType.Text, null);
  61. if (dtMeter.Rows.Count > 0)
  62. {
  63. return 3;
  64. }
  65. string delSql = "DELETE FROM RMRS_NBDevManufacturer WHERE NBDevManufacturerID = " + NBDevManufacturerID;
  66. return sqlHelper.ExecuteNoParams(delSql, CommandType.Text) > 0 ? 1 : 0;
  67. }
  68. catch (Exception)
  69. {
  70. throw;
  71. }
  72. }
  73. /// <summary>
  74. /// 获取NBDevManufacturer
  75. /// </summary>
  76. /// <param name="NBDevManufacturerID"></param>
  77. /// <returns></returns>
  78. public NBDevManufacturerEntity GetEntityById(string NBDevManufacturerID)
  79. {
  80. try
  81. {
  82. string sqlNBDevManufacturer = "SELECT * FROM RMRS_NBDevManufacturer WHERE NBDevManufacturerID = " + NBDevManufacturerID;
  83. DataTable dtResult = sqlHelper.ExecuteDataTable(sqlNBDevManufacturer, CommandType.Text, null);
  84. List<NBDevManufacturerEntity> lists = DataHelper.DataTableToT<NBDevManufacturerEntity>(dtResult);
  85. if (lists != null)
  86. {
  87. return lists[0];
  88. }
  89. return new NBDevManufacturerEntity();
  90. }
  91. catch (Exception)
  92. {
  93. throw;
  94. }
  95. }
  96. }
  97. }