From 5f990b7fa4a92527115d317c930f6c6d37d9f595 Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Thu, 25 Jul 2024 15:58:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8D=AF=E5=93=81=E4=BF=A1=E6=81=AF=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E6=A0=A1=E9=AA=8C=E5=8F=8A=E8=8D=AF?= =?UTF-8?q?=E5=93=81=E5=9F=BA=E6=95=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/Models/DrugBase.cs | 8 +- .../ViewModels/AccountWindowViewModel.cs | 8 +- .../ViewModels/DrugListWindowViewModel.cs | 122 +++++++++++++++--- .../ViewModels/RoleManagerWindowViewModel.cs | 30 ++--- 4 files changed, 128 insertions(+), 40 deletions(-) diff --git a/DM_Weight/Models/DrugBase.cs b/DM_Weight/Models/DrugBase.cs index 694c073..542dc25 100644 --- a/DM_Weight/Models/DrugBase.cs +++ b/DM_Weight/Models/DrugBase.cs @@ -15,16 +15,16 @@ namespace DM_Weight.Models public class DrugBase:BindableBase { private int _baseId = 0; - [SugarColumn(ColumnName = "id", IsPrimaryKey = true)] + [SugarColumn(ColumnName = "baseid", IsPrimaryKey = true)] public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } } - private long _drugId = 0; + private string _drugId; [SugarColumn(ColumnName = "drugid")] - public long DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } } + public string DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } } private string _machineId = ""; [SugarColumn(ColumnName = "machine_id")] public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } } private int _baseQuantity = 0; - [SugarColumn(ColumnName = "base_quantity")] + [SugarColumn(ColumnName = "baseQuantity")] public int BaseQuantity { get=>_baseQuantity; set{ SetProperty(ref _baseQuantity, value); } } } diff --git a/DM_Weight/ViewModels/AccountWindowViewModel.cs b/DM_Weight/ViewModels/AccountWindowViewModel.cs index a2fb635..f6c6cc6 100644 --- a/DM_Weight/ViewModels/AccountWindowViewModel.cs +++ b/DM_Weight/ViewModels/AccountWindowViewModel.cs @@ -329,10 +329,10 @@ namespace DM_Weight.ViewModels ac.invoice_no as InvoiceNo, ac.manu_no as ManuNo,ac.eff_date as EffDate,di.drug_id,di.drug_name as DrugName,di.drug_spec as DrugSpec,di.manufactory as Manufactory,di.pack_unit,di.dosage,u1.user_name as OperatorName,u2.user_name as ReviewerName FROM account_book_g2 ac left join drug_info di on ac.drug_id=di.drug_id left join user_list u1 on ac.user_id1=u1.id left join user_list u2 on ac.user_id2=u2.id WHERE ac.machine_id='{p_machine_id}' and create_time>'{p_startDate}' AND create_time<'{p_endDate}' "; - if (!string.IsNullOrEmpty(drug_id)) - { - SQL += " AND ac.drug_id='" + drug_id + "' "; - } + //if (!string.IsNullOrEmpty(drug_id)) + //{ + // SQL += " AND ac.drug_id='" + drug_id + "' "; + //} if (type > 0) { if (type == 1) diff --git a/DM_Weight/ViewModels/DrugListWindowViewModel.cs b/DM_Weight/ViewModels/DrugListWindowViewModel.cs index 3bd2e25..65b3f7c 100644 --- a/DM_Weight/ViewModels/DrugListWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrugListWindowViewModel.cs @@ -207,7 +207,7 @@ namespace DM_Weight.ViewModels SqlSugarHelper.Db.Insertable(new DrugBase() { - DrugId = SelectedDrug.DrugId, + DrugId = SelectedDrug.DrugId.ToString(), MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1", BaseQuantity = SelectedDrug.drugBase.BaseQuantity }).ExecuteCommand(); @@ -258,11 +258,11 @@ namespace DM_Weight.ViewModels SqlSugarHelper.Db.Updateable(SelectedDrug).UpdateColumns(d => new { d.DrugName, d.Manufactory, d.PyCode, d.PackUnit, d.MaxStock, d.DrugSpec }).ExecuteCommand(); - if (SelectedDrug.drugBase == null) + if (SelectedDrug.drugBase == null || SelectedDrug.drugBase.BaseId == 0) { SqlSugarHelper.Db.Insertable(new DrugBase() { - DrugId = SelectedDrug.DrugId, + DrugId = SelectedDrug.DrugId.ToString(), MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1", BaseQuantity = SelectedDrug.drugBase.BaseQuantity }).ExecuteCommand(); @@ -276,8 +276,8 @@ namespace DM_Weight.ViewModels { SqlSugarHelper.Db.Insertable(new DrugBase() { - DrugId = SelectedDrug.DrugId, - MachineId = ConfigurationManager.AppSettings["machineId"]??"DM1", + DrugId = SelectedDrug.DrugId.ToString(), + MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1", BaseQuantity = SelectedDrug.drugBase.BaseQuantity }).ExecuteCommand(); } @@ -313,15 +313,69 @@ namespace DM_Weight.ViewModels { get => new DelegateCommand(() => { - if (!string.IsNullOrEmpty(SelectedManuno.EffDate) && !string.IsNullOrEmpty(SelectedManuno.ManuNo)) + try { - SelectedManuno.Id = Guid.NewGuid().ToString(); - SelectedManuno.DrugId = SelectedDrug.DrugId.ToString(); - SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd"); - SqlSugarHelper.Db.Insertable(SelectedManuno).ExecuteCommand(); - GetManuNos(); - } + if (!string.IsNullOrEmpty(SelectedManuno.EffDate) && !string.IsNullOrEmpty(SelectedManuno.ManuNo)) + { + string dt = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd"); + int repeatCount = SqlSugarHelper.Db.Queryable().Where(dm => dm.DrugId == SelectedDrug.DrugId.ToString() && dm.EffDate == dt && dm.ManuNo == SelectedManuno.ManuNo).Count(); + if (repeatCount > 0) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "批次重复,请勿重复添加!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + else + { + SelectedManuno.Id = Guid.NewGuid().ToString(); + SelectedManuno.DrugId = SelectedDrug.DrugId.ToString(); + SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd"); + int iResult = SqlSugarHelper.Db.Insertable(SelectedManuno).ExecuteCommand(); + AlertMsg alertMsg = new AlertMsg(); + if (iResult > 0) + { + alertMsg = new AlertMsg + { + Message = "保存成功!", + Type = MsgType.SUCCESS, + }; + } + else + { + alertMsg = new AlertMsg + { + Message = "保存失败!", + Type = MsgType.SUCCESS, + }; + } + _eventAggregator.GetEvent().Publish(alertMsg); + } + //GetManuNos(); + } + else + { + AlertMsg alertMsg = new AlertMsg + { + Message = "请输入批次及效期!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + + } + catch (Exception ex) + { + AlertMsg alertMsg = new AlertMsg + { + Message = $"添加失败{ex.Message}", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } }, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug); } @@ -329,9 +383,43 @@ namespace DM_Weight.ViewModels { get => new DelegateCommand(() => { - SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd"); - SqlSugarHelper.Db.Updateable(SelectedManuno).UpdateColumns(m => new { m.ManuNo, m.EffDate }).ExecuteCommand(); - GetManuNos(); + try + { + + string dt = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd"); + int repeatCount = SqlSugarHelper.Db.Queryable().Where(dm => dm.DrugId == SelectedDrug.DrugId.ToString() && dm.EffDate == dt && dm.ManuNo == SelectedManuno.ManuNo).Count(); + if (repeatCount > 0) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "批次重复,请勿重复添加!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + else + { + SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd"); + SqlSugarHelper.Db.Updateable(SelectedManuno).UpdateColumns(m => new { m.ManuNo, m.EffDate }).ExecuteCommand(); + GetManuNos(); + AlertMsg alertMsg = new AlertMsg + { + Message = "修改成功!", + Type = MsgType.SUCCESS, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + } + catch (Exception ex) + { + + AlertMsg alertMsg = new AlertMsg + { + Message = "修改失败!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } }, () => !string.IsNullOrEmpty(SelectedManuno.DrugId)).ObservesProperty(() => SelectedManuno); } @@ -369,10 +457,10 @@ namespace DM_Weight.ViewModels .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (di) => di.DrugBarcode.Contains(SearchValue)) //.Select(di => di) .ToPageList(PageNum, PageSize, ref totalCount); - foreach(DrugInfo di in DrugInfos) + foreach (DrugInfo di in DrugInfos) { - if(di.drugBase==null) + if (di.drugBase == null) { di.drugBase = new DrugBase(); } diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs index 36e1d43..91e55f3 100644 --- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs +++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs @@ -306,33 +306,33 @@ namespace DM_Weight.ViewModels PremissionName = "归还药品", PremissionPath = "ReturnDrugWindow2", }; - //PremissionDm huanyao2 = new PremissionDm - //{ - // Id = 32, - // PremissionName = "归还空瓶", - // PremissionPath = "ReturnEmptyWindow", - //}; PremissionDm huanyao2 = new PremissionDm { Id = 32, - PremissionName = "空瓶销毁", - PremissionPath = "ReturnEmptyDestoryWindow", + PremissionName = "归还空瓶", + PremissionPath = "ReturnEmptyWindow", }; + //PremissionDm huanyao2 = new PremissionDm + //{ + // Id = 32, + // PremissionName = "空瓶销毁", + // PremissionPath = "ReturnEmptyDestoryWindow", + //}; PremissionDm huanyao3 = new PremissionDm { Id = 33, PremissionName = "归还记录", PremissionPath = "ReturnRecordWindow", }; - PremissionDm surgery = new PremissionDm - { - Id = 17, - PremissionName = "手术核销", - PremissionPath = "SurgeryTakeWindow" - }; + //PremissionDm surgery = new PremissionDm + //{ + // Id = 17, + // PremissionName = "手术核销", + // PremissionPath = "SurgeryTakeWindow" + //}; huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1 ? huanyao11 : huanyao1); huanyaoChild.Add(huanyao2); - huanyaoChild.Add(surgery); + //huanyaoChild.Add(surgery); huanyaoChild.Add(huanyao3); huanyao.Children = huanyaoChild; defaultAll.Add(huanyao);