diff --git a/DM_Weight/Models/ChannelStock.cs b/DM_Weight/Models/ChannelStock.cs index be15bcc..092db7a 100644 --- a/DM_Weight/Models/ChannelStock.cs +++ b/DM_Weight/Models/ChannelStock.cs @@ -78,7 +78,7 @@ namespace DM_Weight.Models /// 默认值: 1 /// [SugarColumn(ColumnName = "drawer_type")] - public int DrawerType { get; set; } + public int DrawerType { get; set; } = 1; /// /// /// 默认值: 1 diff --git a/DM_Weight/ViewModels/AdditionWindowViewModel.cs b/DM_Weight/ViewModels/AdditionWindowViewModel.cs index e2f21c7..ff5a2cb 100644 --- a/DM_Weight/ViewModels/AdditionWindowViewModel.cs +++ b/DM_Weight/ViewModels/AdditionWindowViewModel.cs @@ -63,7 +63,8 @@ namespace DM_Weight.ViewModels IEventAggregator _eventAggregator; //private PortUtil _portUtil; SocketHelper _socketHelper; - + private static readonly DateTime Jan1st1970 = new DateTime + (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); public AdditionWindowViewModel(IEventAggregator eventAggregator, SocketHelper socketHelper) { //_dialogService = dialogService; @@ -316,7 +317,28 @@ namespace DM_Weight.ViewModels { State = 0 }).UpdateColumns(it => it.State).Where(it => it.DrawerNo == _ChannelList.DrawerNo).ExecuteCommand(); - + for (int i = 0; i < selectedStock.Count; i++) + { + string InvoiceId = "AddJiaoJieFromDM_" + CurrentTimeMillis(); + // 保存记录 + SqlSugarHelper.Db.Insertable(new MachineRecord() + { + MachineId = selectedStock[i].MachineId, + DrawerNo = selectedStock[i].DrawerNo, + ColNo = selectedStock[i].ColNo, + DrugId = selectedStock[i].DrugId, + ManuNo = selectedStock[i].ManuNo, + EffDate = !String.IsNullOrEmpty(selectedStock[i].EffDate) ? DateTime.ParseExact(selectedStock[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, + Operator = HomeWindowViewModel.Operator?.Id, + Reviewer = HomeWindowViewModel.Reviewer?.Id, + OperationTime = DateTime.Now, + Quantity = selectedStock[i].Quantity, + Type = 2, + InvoiceId = InvoiceId + //,StockQuantity = nowChannels.Sum(it => it.Quantity), + //CheckQuantity = it.CheckQuantity + }).ExecuteCommand(); + } //List jiaojie = selectedStock.GroupBy(cs => cs.DrugId).Select(cs => cs.FirstOrDefault()).ToList(); //if (jiaojie != null && jiaojie.Count > 0) //{ @@ -356,7 +378,10 @@ namespace DM_Weight.ViewModels } }); } - + public long CurrentTimeMillis() + { + return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds; + } //刷新 public DelegateCommand QueryCommand { diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs index a8a95fe..cfabe5e 100644 --- a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs @@ -511,7 +511,7 @@ namespace DM_Weight.ViewModels continue; } cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity; - cs.NeedNum = cs.NeedNum>0? cs.NeedNum + oi._OrderDetail.Quantity: cs.NeedNum; + cs.NeedNum = cs.NeedNum>0? cs.NeedNum + oi._OrderDetail.Quantity: oi._OrderDetail.Quantity; logger.Info($"更新手术间{cs.DrawerNo}药品{cs.DrugId}批次{cs.ManuNo}库存为{cs.Quantity},需补药数量为{cs.NeedNum}"); // 更新数据 库存信息 SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity, it.NeedNum }).ExecuteCommand(); diff --git a/DM_Weight/ViewModels/ExchangeWindowViewModel.cs b/DM_Weight/ViewModels/ExchangeWindowViewModel.cs index 246e0e5..4bf6570 100644 --- a/DM_Weight/ViewModels/ExchangeWindowViewModel.cs +++ b/DM_Weight/ViewModels/ExchangeWindowViewModel.cs @@ -218,12 +218,25 @@ namespace DM_Weight.ViewModels } private async void Remove() { - // 此处延时1毫秒,等待页面渲染 - await Task.Delay(TimeSpan.FromMilliseconds(1)); - //选中药箱号下的所有药品id - DialogParameters dialogParameters = new DialogParameters(); - dialogParameters.Add("csStock", _ChannelStock); - DialogServiceExtensions.ShowDialogHost(_dialogService, "RemoveDialog", dialogParameters, DoDialogResult, "RootDialog"); + if (_ChannelStock != null) + { + // 此处延时1毫秒,等待页面渲染 + await Task.Delay(TimeSpan.FromMilliseconds(1)); + //选中药箱号下的所有药品id + DialogParameters dialogParameters = new DialogParameters(); + dialogParameters.Add("csStock", _ChannelStock); + DialogServiceExtensions.ShowDialogHost(_dialogService, "RemoveDialog", dialogParameters, DoDialogResult, "RootDialog"); + } + else + { + AlertMsg alertMsg = new AlertMsg + { + Message = "请选择要移出的药品!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + return; + } } private void DoDialogResult(IDialogResult dialogResult) { diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs index 8c28ef0..e55a585 100644 --- a/DM_Weight/ViewModels/HomeWindowViewModel.cs +++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs @@ -25,6 +25,7 @@ using DM_Weight.msg; using DM_Weight.HIKVISION; using System.Threading; using System.Diagnostics; +using MaterialDesignThemes.Wpf; namespace DM_Weight.ViewModels { @@ -611,6 +612,10 @@ namespace DM_Weight.ViewModels stop(); System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { + if (DialogHost.IsDialogOpen("RootDialog")) + { + DialogHost.Close("RootDialog"); + } _regionManager.RequestNavigate("ContentRegion", "EmptyWindow"); _regionManager.RequestNavigate("MainRegion", "LoginWindow"); })); diff --git a/DM_Weight/Views/AdditionWindow.xaml b/DM_Weight/Views/AdditionWindow.xaml index a94a844..36da0f9 100644 --- a/DM_Weight/Views/AdditionWindow.xaml +++ b/DM_Weight/Views/AdditionWindow.xaml @@ -226,14 +226,14 @@ - + - + diff --git a/DM_Weight/Views/CheckOrderNewWindow.xaml b/DM_Weight/Views/CheckOrderNewWindow.xaml index 955b641..e8b9c57 100644 --- a/DM_Weight/Views/CheckOrderNewWindow.xaml +++ b/DM_Weight/Views/CheckOrderNewWindow.xaml @@ -182,10 +182,10 @@ - - - - --> - - - - + - +