diff --git a/DM_Weight/ViewModels/AccountWindowViewModel.cs b/DM_Weight/ViewModels/AccountWindowViewModel.cs index ab62790..8ef0764 100644 --- a/DM_Weight/ViewModels/AccountWindowViewModel.cs +++ b/DM_Weight/ViewModels/AccountWindowViewModel.cs @@ -254,7 +254,8 @@ namespace DM_Weight.ViewModels for (int i = 0; i < channelStockList.Count; i++) { - int Count = accountList.Where(cs => cs.DrugId == channelStockList[i].DrugId).Count(); + string drugId = channelStockList[i].DrugId; + int Count = accountList.Where(cs => cs.DrugId == drugId).Count(); if (Count <= 0) { @@ -263,12 +264,12 @@ namespace DM_Weight.ViewModels } else { - inQuantity = accountList.Where(cs => cs.DrugId == channelStockList[i].DrugId).Sum(cs => cs.InQuantity); - outQuantity = accountList.Where(cs => cs.DrugId == channelStockList[i].DrugId).Sum(cs => cs.OutQuantity); + inQuantity = accountList.Where(cs => cs.DrugId == drugId).Sum(cs => cs.InQuantity); + outQuantity = accountList.Where(cs => cs.DrugId == drugId).Sum(cs => cs.OutQuantity); } // 获取药品总库存 int channelStockQuantity = SqlSugarHelper.Db.Queryable() - .Where(cs => cs.DrugId.Equals(channelStockList[i].DrugId)).Sum(it => it.Quantity); + .Where(cs => cs.DrugId.Equals(drugId)).Sum(it => it.Quantity); //没有直接插入 // 保存数据 出/入库记录 string InvoiceId = "Account_" + CurrentTimeMillis(); @@ -277,7 +278,7 @@ namespace DM_Weight.ViewModels MachineId = channelStockList[i].MachineId, DrawerNo = 0,//channelStockList[i].DrawerNo, ColNo = 0,// channelStockList[i].ColNo,FV - DrugId = channelStockList[i].DrugId, + DrugId = drugId, ManuNo = "",//channelStockList[i].ManuNo, EffDate = null,// !String.IsNullOrEmpty(channelStockList[i].EffDate) ? DateTime.ParseExact(channelStockList[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, Operator = HomeWindowViewModel.Operator?.Id, diff --git a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs index ef6f52a..1d793a0 100644 --- a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs +++ b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs @@ -280,6 +280,24 @@ namespace DM_Weight.ViewModels item.DrugId = DrugInfo.DrugId.ToString(); //SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand(); SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand(); + + + + //插入channel_stock表数据 + SqlSugarHelper.Db.Insertable(new ChannelStock() + { + Quantity = 0, + Chnguid = item.Chnguid, + DrawerNo = item.DrawerNo, + ColNo = item.ColNo, + DrugId = item.DrugId, + DrawerType = item.DrawerType, + BoardType = item.BoardType, + Id = Guid.NewGuid().ToString(), + MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1" + }).ExecuteCommand(); + + GetChannelsByDrawerNo(); if (item.BoardType == 5) @@ -292,10 +310,10 @@ namespace DM_Weight.ViewModels await Task.Delay(200); _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo); await Task.Delay(200); - _portUtil.WriteChannelInfo(6, DrugManuNo.EffDate == null ? "" : DrugManuNo.EffDate, item.DrawerNo, item.ColNo); - await Task.Delay(200); - _portUtil.WriteChannelInfo(5, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo); - await Task.Delay(200); + //_portUtil.WriteChannelInfo(6, DrugManuNo.EffDate == null ? "" : DrugManuNo.EffDate, item.DrawerNo, item.ColNo); + //await Task.Delay(200); + //_portUtil.WriteChannelInfo(5, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo); + //await Task.Delay(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); } //_screenUtil.SetStockInfo(item, 1); @@ -462,6 +480,7 @@ namespace DM_Weight.ViewModels item.DrugInfo = null; //SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand(); SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand(); + SqlSugarHelper.Db.Updateable().SetColumns(it => new ChannelStock { DrugId = null, ManuNo = null, EffDate = null }).Where(it => it.Chnguid == item.Id).ExecuteCommand(); if (item.BoardType == 5) { // 清除显示屏库位信息 diff --git a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel .cs b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel .cs index c0af7f4..33fff54 100644 --- a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel .cs +++ b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel .cs @@ -21,6 +21,7 @@ using System.Threading; using System.Reflection.Metadata.Ecma335; using System.Windows.Threading; using System.Windows; +using System.Reflection.PortableExecutable; namespace DM_Weight.ViewModels { @@ -322,6 +323,23 @@ namespace DM_Weight.ViewModels } item.DrugId = DrugInfo.DrugId.ToString(); SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand(); + + int deleteNum = SqlSugarHelper.Db.Deleteable() + .Where(cs => cs.Chnguid.Equals(item.Id) && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"])).ExecuteCommand(); + //插入channel_stock表数据 + SqlSugarHelper.Db.Insertable(new ChannelStock() + { + Quantity = 0, + Chnguid = item.Id, + DrawerNo = item.DrawerNo, + ColNo = item.ColNo, + DrugId = item.DrugId, + DrawerType = item.DrawerType, + BoardType = item.BoardType, + Id = Guid.NewGuid().ToString(), + MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1" + }).ExecuteCommand(); + GetChannelsByDrawerNo(); if (item.BoardType == 5) diff --git a/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs b/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs index 700257d..0ffd42d 100644 --- a/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs +++ b/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs @@ -47,11 +47,11 @@ namespace DM_Weight.ViewModels get => new DelegateCommand(() => { - if (Channel != null && Channel.DrugId == null) + if (Channel != null &&string.IsNullOrEmpty(Channel.DrugId)) { DialogParameters dialogParameters = new DialogParameters(); dialogParameters.Add("DrawerNo", Channel.DrawerNo); - DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog"); + DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelNewDialog", dialogParameters, DoDialogResult, "RootDialog"); } else if(Channel != null && Channel.CanReturnQuantity > 0) {