|
- using CnasLocalIDAL;
- using CnasSynchronousCommon;
- using CnasSynchrousModel;
- using SyncLocalDAL;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- namespace CnasSynchronusClient
- {
- public class LaboratoryTestBLL
- {
- public ILaboratoryTest laboratoryTest { get { return new LaboratoryTestDAL(); } }
-
- /// <summary>
- /// 读取本地数据库中存储的化验数据
- /// </summary>
- /// <returns></returns>
- public List<LaboratoryTest> GetLaboratoryTestData()
- {
- return laboratoryTest.GetAllLaboratoryTests();
- }
-
- /// <summary>
- /// 根据类型和最大日期获取数据(获取该日期后的数据)
- /// </summary>
- /// <param name="dict"></param>
- /// <returns></returns>
- public List<LaboratoryTest> GetLaboratoryTestDataByTypeAndDate(Dictionary<string,string> dict)
- {
- return laboratoryTest.GetLaboratoryTestsByTypeAndDate(dict);
- }
-
- /// <summary>
- /// 获取没有上传的所有数据
- /// </summary>
- /// <returns></returns>
- public List<LaboratoryTest> GetLaboratoryTestDataByNoUpLoad()
- {
- return laboratoryTest.GetLaboratoryTestsByNoUpLoad();
- }
-
- /// <summary>
- /// 保存化验数据(新增/修改/删除)
- /// </summary>
- /// <param name="laboratories"></param>
- /// <returns></returns>
- public ReturnValue<LaboratoryTest> SaveLaboratoryData(List<LaboratoryTest> laboratories)
- {
- ReturnValue<LaboratoryTest> returnValue = new ReturnValue<LaboratoryTest>();
- int addCount = 0;
- int updateCount = 0;
- int deleCount = 0;
-
- //逐行插入数据
- try
- {
- foreach (var item in laboratories)
- {
- if (item.OperationType==null) continue;
- switch (item.OperationType.ToLower())
- {
- case "add":
- addCount += laboratoryTest.InsertLaboratory(item);
- break;
- case "update":
- updateCount += laboratoryTest.UpdateLaboratory(item);
- break;
- case "delete":
- deleCount += laboratoryTest.DeleteLaboratory(item);
- break;
- }
- }
-
- returnValue.StrMsg = $"成功插入{addCount}条化验数据,更新{updateCount}条化验数据,删除{deleCount}条化验数据";
- }
- catch (Exception ex)
- {
- returnValue.StrErrorMsg = ex.Message;
- }
- return returnValue;
- }
-
- /// <summary>
- /// 保存一条化验数据(新增/修改/删除)
- /// </summary>
- /// <param name="laboratory"></param>
- /// <returns></returns>
- public ReturnValue<LaboratoryTest> SaveLaboratoryData(LaboratoryTest laboratory)
- {
- ReturnValue<LaboratoryTest> returnValue = new ReturnValue<LaboratoryTest>();
- int addCount = 0;
- int updateCount = 0;
- int deleCount = 0;
-
- //逐行插入数据
- try
- {
- if (laboratory.OperationType != null)
- {
- switch (laboratory.OperationType.ToLower())
- {
- case "add":
- addCount += laboratoryTest.InsertLaboratory(laboratory);
- break;
- case "update":
- updateCount += laboratoryTest.UpdateLaboratory(laboratory);
- break;
- case "delete":
- deleCount += laboratoryTest.DeleteLaboratory(laboratory);
- break;
- }
- }
- returnValue.StrMsg = $"成功插入{addCount}条化验数据,更新{updateCount}条化验数据,删除{deleCount}条化验数据";
- }
- catch (Exception ex)
- {
- returnValue.StrErrorMsg = ex.Message;
- }
- return returnValue;
- }
- }
- }
|