diff --git a/DM_Weight/Models/ChannelList.cs b/DM_Weight/Models/ChannelList.cs index e0ad1a7..877f632 100644 --- a/DM_Weight/Models/ChannelList.cs +++ b/DM_Weight/Models/ChannelList.cs @@ -94,7 +94,8 @@ namespace DM_Weight.Models /// /// 默认值: 1 /// - [SugarColumn(IsIgnore = true)] + //[SugarColumn(IsIgnore = true)] + [SugarColumn(ColumnName = "state")] public int? State { get; set; } [SugarColumn(IsIgnore = true)] diff --git a/DM_Weight/ViewModels/AdditionWindowViewModel.cs b/DM_Weight/ViewModels/AdditionWindowViewModel.cs index c36429a..39619dd 100644 --- a/DM_Weight/ViewModels/AdditionWindowViewModel.cs +++ b/DM_Weight/ViewModels/AdditionWindowViewModel.cs @@ -33,7 +33,7 @@ namespace DM_Weight.ViewModels get => channelStocks; set => SetProperty(ref channelStocks, value); } - List selectedStock=new List(); + List selectedStock = new List(); private object _finishStatus = Visibility.Collapsed; public object FinishStatus { @@ -107,40 +107,62 @@ namespace DM_Weight.ViewModels { get => new DelegateCommand(() => { - //更新 交接柜 库存信息 - if (selectedStock != null && selectedStock.Count > 0) + var f = SqlSugarHelper.Db.UseTran(() => { - for (int j = 0; j < selectedStock.Count; j++) + //更新 交接柜 库存信息 + if (selectedStock != null && selectedStock.Count > 0) { - // 更新数据 交接柜 库存信息 - ChannelStock jiaojie_it = selectedStock[j]; - SqlSugarHelper.Db.Updateable(new ChannelStock() + for (int j = 0; j < selectedStock.Count; j++) { - Quantity = jiaojie_it.BaseQuantity, - //ManuNo = it.ManuNo, - //EffDate = it.EffDate, - Id = jiaojie_it.Id, - }).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).ExecuteCommand(); - } - - List jiaojie = selectedStock.GroupBy(cs => cs.DrawerNo).Select(cs => cs.FirstOrDefault()).ToList(); - if (jiaojie != null && jiaojie.Count > 0) - { - for (int j = 0; j < jiaojie.Count; j++) - { - ChannelStock jiaojie_it = jiaojie[j]; - //更新交接柜状态为 已取药未入库 - SqlSugarHelper.Db.Updateable(new ChannelList() + // 更新数据 交接柜 库存信息 + ChannelStock jiaojie_it = selectedStock[j]; + SqlSugarHelper.Db.Updateable(new ChannelStock() { - State = 0, - Id = jiaojie_it.ChannelLst.Id - }).UpdateColumns(it => it.State).ExecuteCommand(); + Quantity = jiaojie_it.BaseQuantity, + //ManuNo = it.ManuNo, + //EffDate = it.EffDate, + Id = jiaojie_it.Id, + }).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).ExecuteCommand(); + } + + List jiaojie = selectedStock.GroupBy(cs => cs.DrawerNo).Select(cs => cs.FirstOrDefault()).ToList(); + if (jiaojie != null && jiaojie.Count > 0) + { + for (int j = 0; j < jiaojie.Count; j++) + { + ChannelStock jiaojie_it = jiaojie[j]; + ChannelList jiaojieList = new ChannelList(); + jiaojieList.State = 0; + jiaojieList.Id = jiaojie_it.ChannelLst.Id; + //更新交接柜状态为 已取药未入库 + var result = SqlSugarHelper.Db.Updateable(jiaojieList) + .UpdateColumns(it => new { it.State, it.Id }).ExecuteCommand(); + } } } + }); + if (f.Data) + { + RequestData(); + AlertMsg alertMsg = new AlertMsg + { + Message = "操作完成", + Type = MsgType.SUCCESS, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + if (!f.IsSuccess) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "操作失败!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); } }); } - + //刷新 public DelegateCommand QueryCommand { diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs index a16b86b..7596224 100644 --- a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs @@ -536,7 +536,7 @@ namespace DM_Weight.ViewModels OrderNo = oi.OrderNo, PatientId = oi.PatientId, Pharmacy = oi.Pharmacy, - State = 1, + State = 2, Operator = HomeWindowViewModel.Operator?.Nickname, }); } @@ -591,28 +591,29 @@ namespace DM_Weight.ViewModels //.Select(cl => cl.BelongUser).First(); RejectionReport rejectionReport = SqlSugarHelper.Db.Queryable().Where(rp => rp.DrugId == cs.DrugId && rp.DrawerNo == cs.DrawerNo).OrderByDescending(rp => rp.SendDate).First(); + if (rejectionReport != null) + { + //发药信息 + //RejectionReport rejectionReport = new RejectionReport(); + //rejectionReport.SendDate = SendMachineRecord.OperationTime; + //rejectionReport.SendUser = SendMachineRecord.Operator.ToString(); + //rejectionReport.ReceiveUser = retUser; + rejectionReport.RealNum = cs.BaseQuantity; - //发药信息 - //RejectionReport rejectionReport = new RejectionReport(); - //rejectionReport.SendDate = SendMachineRecord.OperationTime; - //rejectionReport.SendUser = SendMachineRecord.Operator.ToString(); - //rejectionReport.ReceiveUser = retUser; - rejectionReport.RealNum = cs.BaseQuantity; + //还药信息 + rejectionReport.InfactNum = cs.BaseQuantity - oi._OrderDetail.Quantity; + rejectionReport.EmptyNum = oi._OrderDetail.Quantity; + rejectionReport.ReturnTime = DateTime.Now.ToString(); + rejectionReport.ReturnUser = rejectionReport.SendUser; + rejectionReport.ReturnReceiveUser = rejectionReport.ReceiveUser;// SendMachineRecord.Operator.ToString(); + rejectionReport.DrugId = oi._OrderDetail.DrugId; + rejectionReport.DrugName = oi._OrderDetail.DrugInfo.DrugName; + rejectionReport.DrugSpec = oi._OrderDetail.DrugInfo.DrugSpec; - //还药信息 - rejectionReport.InfactNum = cs.BaseQuantity - oi._OrderDetail.Quantity; - rejectionReport.EmptyNum = oi._OrderDetail.Quantity; - rejectionReport.ReturnTime = DateTime.Now.ToString(); - rejectionReport.ReturnUser = rejectionReport.SendUser; - rejectionReport.ReturnReceiveUser = rejectionReport.ReceiveUser;// SendMachineRecord.Operator.ToString(); - rejectionReport.DrugId = oi._OrderDetail.DrugId; - rejectionReport.DrugName = oi._OrderDetail.DrugInfo.DrugName; - rejectionReport.DrugSpec = oi._OrderDetail.DrugInfo.DrugSpec; - - rejectionReport.OperationTime = DateTime.Now; - - int iRejectionReport = SqlSugarHelper.Db.Updateable(rejectionReport).ExecuteCommand(); + rejectionReport.OperationTime = DateTime.Now; + int iRejectionReport = SqlSugarHelper.Db.Updateable(rejectionReport).ExecuteCommand(); + } #endregion } @@ -726,6 +727,7 @@ namespace DM_Weight.ViewModels Type = MsgType.SUCCESS, }; _eventAggregator.GetEvent().Publish(alertMsg); + RequestData(); } if (!f.IsSuccess) {