CNAS取数仪器端升级
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

125 lignes
4.3KB

  1. using CnasLocalIDAL;
  2. using CnasSynchronousCommon;
  3. using CnasSynchrousModel;
  4. using SyncLocalDAL;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. namespace CnasSynchronusClient
  10. {
  11. public class LaboratoryTestBLL
  12. {
  13. public ILaboratoryTest laboratoryTest { get { return new LaboratoryTestDAL(); } }
  14. /// <summary>
  15. /// 读取本地数据库中存储的化验数据
  16. /// </summary>
  17. /// <returns></returns>
  18. public List<LaboratoryTest> GetLaboratoryTestData()
  19. {
  20. return laboratoryTest.GetAllLaboratoryTests();
  21. }
  22. /// <summary>
  23. /// 根据类型和最大日期获取数据(获取该日期后的数据)
  24. /// </summary>
  25. /// <param name="dict"></param>
  26. /// <returns></returns>
  27. public List<LaboratoryTest> GetLaboratoryTestDataByTypeAndDate(Dictionary<string,string> dict)
  28. {
  29. return laboratoryTest.GetLaboratoryTestsByTypeAndDate(dict);
  30. }
  31. /// <summary>
  32. /// 获取没有上传的所有数据
  33. /// </summary>
  34. /// <returns></returns>
  35. public List<LaboratoryTest> GetLaboratoryTestDataByNoUpLoad()
  36. {
  37. return laboratoryTest.GetLaboratoryTestsByNoUpLoad();
  38. }
  39. /// <summary>
  40. /// 保存化验数据(新增/修改/删除)
  41. /// </summary>
  42. /// <param name="laboratories"></param>
  43. /// <returns></returns>
  44. public ReturnValue<LaboratoryTest> SaveLaboratoryData(List<LaboratoryTest> laboratories)
  45. {
  46. ReturnValue<LaboratoryTest> returnValue = new ReturnValue<LaboratoryTest>();
  47. int addCount = 0;
  48. int updateCount = 0;
  49. int deleCount = 0;
  50. //逐行插入数据
  51. try
  52. {
  53. foreach (var item in laboratories)
  54. {
  55. if (item.OperationType==null) continue;
  56. switch (item.OperationType.ToLower())
  57. {
  58. case "add":
  59. addCount += laboratoryTest.InsertLaboratory(item);
  60. break;
  61. case "update":
  62. updateCount += laboratoryTest.UpdateLaboratory(item);
  63. break;
  64. case "delete":
  65. deleCount += laboratoryTest.DeleteLaboratory(item);
  66. break;
  67. }
  68. }
  69. returnValue.StrMsg = $"成功插入{addCount}条化验数据,更新{updateCount}条化验数据,删除{deleCount}条化验数据";
  70. }
  71. catch (Exception ex)
  72. {
  73. returnValue.StrErrorMsg = ex.Message;
  74. }
  75. return returnValue;
  76. }
  77. /// <summary>
  78. /// 保存一条化验数据(新增/修改/删除)
  79. /// </summary>
  80. /// <param name="laboratory"></param>
  81. /// <returns></returns>
  82. public ReturnValue<LaboratoryTest> SaveLaboratoryData(LaboratoryTest laboratory)
  83. {
  84. ReturnValue<LaboratoryTest> returnValue = new ReturnValue<LaboratoryTest>();
  85. int addCount = 0;
  86. int updateCount = 0;
  87. int deleCount = 0;
  88. //逐行插入数据
  89. try
  90. {
  91. if (laboratory.OperationType != null)
  92. {
  93. switch (laboratory.OperationType.ToLower())
  94. {
  95. case "add":
  96. addCount += laboratoryTest.InsertLaboratory(laboratory);
  97. break;
  98. case "update":
  99. updateCount += laboratoryTest.UpdateLaboratory(laboratory);
  100. break;
  101. case "delete":
  102. deleCount += laboratoryTest.DeleteLaboratory(laboratory);
  103. break;
  104. }
  105. }
  106. returnValue.StrMsg = $"成功插入{addCount}条化验数据,更新{updateCount}条化验数据,删除{deleCount}条化验数据";
  107. }
  108. catch (Exception ex)
  109. {
  110. returnValue.StrErrorMsg = ex.Message;
  111. }
  112. return returnValue;
  113. }
  114. }
  115. }