From 386befcadeb03ad19bf6427fe4de58ffcd3b1d9d Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Thu, 8 Aug 2024 16:54:03 +0800 Subject: [PATCH] =?UTF-8?q?drug=5Fid=E7=B1=BB=E5=9E=8B=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BAstring=20=E6=B7=BB=E5=8A=A0=E4=BA=A4=E6=8E=A5=E6=9F=9C?= =?UTF-8?q?=E8=A1=A5=E8=8D=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/Models/AccountBookG2.cs | 2 +- DM_Weight/Models/ChannelStock.cs | 2 +- DM_Weight/Port/PortUtil.cs | 101 ++++++++ .../ViewModels/AddSurgeryDialogViewModel.cs | 10 +- .../ViewModels/AddToJiaoJieDialogViewModel.cs | 129 +++++++---- .../ViewModels/AddToJiaoJieWindowViewModel.cs | 216 ++++++++++++++++-- .../ViewModels/ApplyInStockWindowViewModel.cs | 10 +- .../DrawerAddDrugWindowViewModel.cs | 10 +- .../DrawerTakeDrugWindowViewModel.cs | 10 +- .../ViewModels/InvoiceAddDialogViewModel.cs | 10 +- .../ViewModels/InvoiceTakeDialogViewModel.cs | 10 +- .../ViewModels/OrderReturnDialogViewModel.cs | 10 +- .../OrderTakeAllDrugDialogViewModel.cs | 10 +- .../ViewModels/OrderTakeDialogViewModel.cs | 12 +- .../ViewModels/ReturnDrugDialogViewModel.cs | 10 +- .../ViewModels/SelfAddDialogViewModel.cs | 10 +- .../ViewModels/SelfTakeDialogViewModel.cs | 10 +- .../ViewModels/StockListWindowViewModel.cs | 5 +- .../ViewModels/SurgeryTakeDialogViewModel.cs | 10 +- DM_Weight/Views/AddToJiaoJieWindow.xaml | 20 +- 20 files changed, 476 insertions(+), 131 deletions(-) diff --git a/DM_Weight/Models/AccountBookG2.cs b/DM_Weight/Models/AccountBookG2.cs index 2511025..74ede11 100644 --- a/DM_Weight/Models/AccountBookG2.cs +++ b/DM_Weight/Models/AccountBookG2.cs @@ -20,7 +20,7 @@ namespace DM_Weight.Models /// 药品id /// [SugarColumn(ColumnName = "drug_id")] - public int DrugId { get; set; } + public string DrugId { get; set; } /// /// 1领入2发出3日结4总结5转结 diff --git a/DM_Weight/Models/ChannelStock.cs b/DM_Weight/Models/ChannelStock.cs index e94496a..6ec86bc 100644 --- a/DM_Weight/Models/ChannelStock.cs +++ b/DM_Weight/Models/ChannelStock.cs @@ -109,7 +109,7 @@ namespace DM_Weight.Models [SugarColumn(IsIgnore = true)] public string Location { - get => DrawerNo + "-" + ColNo; + get => ColNo==0? DrawerNo + "号交接柜" : DrawerNo + "-" + ColNo; } private int _addQuantity = 0; [SugarColumn(IsIgnore = true)] diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs index 4eb50ce..b9a68b3 100644 --- a/DM_Weight/Port/PortUtil.cs +++ b/DM_Weight/Port/PortUtil.cs @@ -29,6 +29,7 @@ using System.Runtime.InteropServices; using DM_Weight.Common; using System.Net; using System.Text.RegularExpressions; +using Newtonsoft.Json.Linq; namespace DM_Weight.Port { @@ -128,7 +129,107 @@ namespace DM_Weight.Port DrawerNo = 0; ColNos = new int[] { }; } + #region 开抽屉 + /// + /// 打开抽屉 + /// + /// + /// + public async Task OpenAllDrawer() + { + byte[] buffer = await OpenDrawer(); + int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray(); + logger.Info($"OpenDrawer{string.Join(",", r)}"); + if (DrawerState(r)) + { + statue = 1; + // 返回消息 抽屉已经打开 + _eventAggregator.GetEvent().Publish(new util.DeviceMsg() + { + EventType = util.EventType.DRAWEROPEN, + WindowName = WindowName, + }); + logger.Info($"抽屉【{DrawerNo}】打开成功"); + // 查询抽屉状态 + await Task.Delay(200); + } + else + { + string _WindowName = WindowName; + // 重新初始化数据 + ResetData(); + // 返回消息 抽屉打开失败 + _eventAggregator.GetEvent().Publish(new util.DeviceMsg() + { + EventType = util.EventType.OPENERROR, + WindowName = WindowName, + Message = $"抽屉【{DrawerNo}】打开失败" + }); + logger.Info($"抽屉【{DrawerNo}】打开失败"); + } + } + /// + /// 查询抽屉状态 + /// + /// + /// + public async Task GetAllDrawerLockState() + { + try + { + + if (Operate) + { + // 查询抽屉状态 + byte[] buffer = await CheckDrawerStatus(); + + int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray(); + + logger.Info($"GetAllDrawerLockState{string.Join(",", r)}"); + int[] subArray=new int[8]; + for(int i=0;i<8;i++) + { + subArray[i] = r[2 + i]; + } + bool state= subArray.All(r => r > 0); + if(state) + { + //抽屉全部关闭 + + string _WindowName = WindowName; + // 重新初始化数据 + ResetData(); + // 返回消息 抽屉已经关闭 + _eventAggregator.GetEvent().Publish(new util.DeviceMsg() + { + EventType = util.EventType.DRAWERCLOSE, + WindowName = _WindowName, + }); + logger.Info($"抽屉【{DrawerNo}】已关闭"); + } + else + { + // 继续监听抽屉状态 + await Task.Delay(200); + GetAllDrawerLockState(); + } + + } + + } + catch (Exception ex) + { + _eventAggregator.GetEvent().Publish(new util.DeviceMsg() + { + EventType = util.EventType.OPENERROR, + WindowName = WindowName, + Message = $"GetDrawerStatus异常:{ex.Message}" + }); + logger.Info($"GetDrawerStatus异常:{ex.Message}"); + } + } + #endregion public async void Start() { diff --git a/DM_Weight/ViewModels/AddSurgeryDialogViewModel.cs b/DM_Weight/ViewModels/AddSurgeryDialogViewModel.cs index 5e0ac9e..5120dd9 100644 --- a/DM_Weight/ViewModels/AddSurgeryDialogViewModel.cs +++ b/DM_Weight/ViewModels/AddSurgeryDialogViewModel.cs @@ -752,7 +752,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(stock.DrugId), + DrugId = stock.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -770,7 +770,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(stock.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId)) + .Where(ab => ab.DrugId == stock.DrugId) .Where(ab => ab.ManuNo == stock.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -783,7 +783,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(stock.DrugId), + DrugId = stock.DrugId, Type = 3, ManuNo = stock.ManuNo, EffDate = stock.EffDate, @@ -805,7 +805,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(stock.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId)) + .Where(ab => ab.DrugId == stock.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -817,7 +817,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(stock.DrugId), + DrugId = stock.DrugId, Type = 4, YQuantity = 0, ManuStock = stock.ReturnQuantity, diff --git a/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs b/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs index 03558ea..d2fcb45 100644 --- a/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs +++ b/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs @@ -21,6 +21,42 @@ namespace DM_Weight.ViewModels public class AddToJiaoJieDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime { private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel)); + + + private List _channelStocks=new List(); + + public List ChannelStocks + { + get => _channelStocks; + set => SetProperty(ref _channelStocks, value); + } + /// + /// 交接柜的库位信息 + /// + private List _jiaojei_channelStocks; + + public List Jiaojie_ChannelStocks + { + get => _jiaojei_channelStocks; + set => SetProperty(ref _jiaojei_channelStocks, value); + } + /// + /// 交接柜的库位信息 + /// + private ChannelStock _jiaojei_cs; + + public ChannelStock Jiaojie_cs + { + get => _jiaojei_cs; + set => SetProperty(ref _jiaojei_cs, value); + } + private static readonly DateTime Jan1st1970 = new DateTime + (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + private IEnumerable> enumerable; + private IEnumerator> enumerator; + + public string Title => "交接柜补药"; public bool KeepAlive => false; @@ -41,21 +77,20 @@ namespace DM_Weight.ViewModels public void OnDialogOpened(IDialogParameters parameters) { _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent); - ChannelStocks = parameters.GetValue>("ChannelStocks"); + Jiaojie_ChannelStocks = parameters.GetValue>("ChannelStocks"); + + for (int i = 0; i < Jiaojie_ChannelStocks.Count; i++) + { + ChannelStock copy = TransExpV2.Trans(Jiaojie_ChannelStocks[i]); + ChannelStocks.Add(copy); + } + ChannelStocks = Jiaojie_ChannelStocks.GroupBy(cs => cs.DrugId).Select(g => new + { + DrugId = g.Key, + AddQuantity = g.Sum(s => s.AddQuantity) + }).Select(cs => new ChannelStock() { DrugId = cs.DrugId, AddQuantity = cs.AddQuantity }).ToList(); RequestData(); } - private List _channelStocks; - - public List ChannelStocks - { - get => _channelStocks; - set => SetProperty(ref _channelStocks, value); - } - private static readonly DateTime Jan1st1970 = new DateTime - (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - private IEnumerable> enumerable; - private IEnumerator> enumerator; private PortUtil _portUtil; IEventAggregator _eventAggregator; @@ -158,13 +193,13 @@ namespace DM_Weight.ViewModels .Includes(cs => cs.DrugInfo) .Where(cs => cs.Quantity > 0) .Where(cs => cs.DrawerType == 1) - .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")) + .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")) .Where(cs => cs.DrugId == ChannelStocks[i].DrugId) .OrderBy(cs => cs.EffDate) .OrderBy(cs => cs.DrawerNo) .ToList(); int total = HasQChannels.Sum(it => it.Quantity); - int TakeQ = ChannelStocks[i].Quantity; + int TakeQ = ChannelStocks[i].AddQuantity; // 说明数量足够 if (total >= TakeQ) { @@ -189,30 +224,30 @@ namespace DM_Weight.ViewModels { msg.Add($"药品【{ChannelStocks[i].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】"); } - if (msg.Count > 0) - { - RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); - //MessageBox.Show(string.Join("\n", msg)); - DialogParameters dialogParameters = new DialogParameters(); - dialogParameters.Add("msgInfo", msg); - DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog"); - } - else + } + if (msg.Count > 0) + { + RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); + //MessageBox.Show(string.Join("\n", msg)); + DialogParameters dialogParameters = new DialogParameters(); + dialogParameters.Add("msgInfo", msg); + DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog"); + + } + else + { + channelStocks.Sort((a, b) => { - channelStocks.Sort((a, b) => + if ((a.DrawerNo - b.DrawerNo) == 0) { - if ((a.DrawerNo - b.DrawerNo) == 0) - { - return a.ColNo - b.ColNo; - } - return a.DrawerNo - b.DrawerNo; - }); - ChannelStocks = channelStocks; + return a.ColNo - b.ColNo; + } + return a.DrawerNo - b.DrawerNo; + }); + ChannelStocks = channelStocks; - } - } } public DelegateCommand OpenDrawer @@ -295,15 +330,25 @@ namespace DM_Weight.ViewModels Id = it.Id, }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand(); - // 更新数据 交接柜 库存信息 - SqlSugarHelper.Db.Updateable(new ChannelStock() + //更新 交接柜 库存信息 + List jiaojie = Jiaojie_ChannelStocks.Where(cs=>cs.DrugId== it.DrugId).ToList(); + if(jiaojie!=null&&jiaojie.Count>0) { - Quantity = it.Quantity - it.TakeQuantity, - ManuNo = it.ManuNo, - EffDate = it.EffDate, - Id = it.Id, - }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand(); - + for (int j = 0; j < jiaojie.Count; j++) + { + // 更新数据 交接柜 库存信息 + ChannelStock jiaojie_it = jiaojie[j]; + SqlSugarHelper.Db.Updateable(new ChannelStock() + { + Quantity = jiaojie_it.BaseQuantity, + //ManuNo = it.ManuNo, + //EffDate = it.EffDate, + Id = jiaojie_it.Id, + }).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity}).ExecuteCommand(); + } + } + + // 保存数据 出库记录 SqlSugarHelper.Db.Insertable(new MachineRecord() { diff --git a/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs b/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs index ea2c7d6..54a61b4 100644 --- a/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs +++ b/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs @@ -21,7 +21,13 @@ namespace DM_Weight.ViewModels { public class AddToJiaoJieWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime { - private readonly ILog logger = LogManager.GetLogger(typeof(AddToJiaoJieWindowViewModel)); + private readonly ILog logger = LogManager.GetLogger(typeof(AddToJiaoJieWindowViewModel)); + private static readonly DateTime Jan1st1970 = new DateTime + (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + public long CurrentTimeMillis() + { + return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds; + } public bool KeepAlive => false; public bool IsNavigationTarget(NavigationContext navigationContext) { @@ -109,7 +115,7 @@ namespace DM_Weight.ViewModels //_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1; //_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray(); _portUtil.DrawerNo = iDrawerNoLst[CurrentNum]; - _portUtil.Start(); + _portUtil.OpenAllDrawer(); } catch (Exception ex) @@ -145,7 +151,11 @@ namespace DM_Weight.ViewModels _portUtil.WindowName = "AddToJiaoJieWindow"; _portUtil.Operate = true; _portUtil.DrawerNo = iDrawerNoLst[CurrentNum]; - _portUtil.Start(); + _portUtil.OpenAllDrawer(); + } + else + { + _portUtil.GetAllDrawerLockState(); } break; // 抽屉关闭 @@ -184,13 +194,190 @@ namespace DM_Weight.ViewModels } //完成按钮 - //public DelegateCommand AddFinish - //{ - // get => new DelegateCommand(() => - // { - - // }); - //} + public DelegateCommand AddFinish + { + get => new DelegateCommand(() => + { + if(ChannelStocks.FindAll(cs=>cs.ChannelLst.IsSelected).Count<=0) + { + + AlertMsg alertMsg = new AlertMsg + { + Message = "请选择药箱", + Type = MsgType.SUCCESS, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + return; + } + List jiaojieStocks = new List(); + List cs = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList(); + for (int i = 0; i < cs.Count; i++) + { + ChannelStock copy = TransExpV2.Trans(cs[i]); + jiaojieStocks.Add(copy); + } + csList = jiaojieStocks.FindAll(cs => cs.ChannelLst.IsSelected).GroupBy(cs => cs.DrugId).Select(g => new + { + DrugId = g.Key, + AddQuantity = g.Sum(s => s.AddQuantity) + }).Select(cs => new ChannelStock() { DrugId = cs.DrugId, AddQuantity = cs.AddQuantity }).ToList(); + + List channelStocks = new List(); + List msg = new List(); + for (int i = 0; i < csList.Count; i++) + { + List HasQChannels = SqlSugarHelper.Db.Queryable() + .Includes(cs => cs.DrugInfo) + .Where(cs => cs.Quantity > 0) + .Where(cs => cs.DrawerType == 1) + .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")) + .Where(cs => cs.DrugId == csList[i].DrugId) + .OrderBy(cs => cs.EffDate) + .OrderBy(cs => cs.DrawerNo) + .ToList(); + int total = HasQChannels.Sum(it => it.Quantity); + int TakeQ = csList[i].AddQuantity; + // 说明数量足够 + if (total >= TakeQ) + { + for (int j = 0; TakeQ > 0; j++) + { + ChannelStock stock = HasQChannels[j]; + if (TakeQ > stock.Quantity) + { + stock.TakeQuantity = stock.Quantity; + channelStocks.Add(stock); + TakeQ -= stock.Quantity; + } + else + { + stock.TakeQuantity = TakeQ; + channelStocks.Add(stock); + TakeQ = 0; + } + } + } + else + { + msg.Add($"药品【{ChannelStocks[i].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】"); + } + + } + if (msg.Count > 0) + { + DialogParameters dialogParameters = new DialogParameters(); + dialogParameters.Add("msgInfo", msg); + DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog"); + return; + + } + else + { + channelStocks.Sort((a, b) => + { + if ((a.DrawerNo - b.DrawerNo) == 0) + { + return a.ColNo - b.ColNo; + } + return a.DrawerNo - b.DrawerNo; + }); + } + List record = channelStocks.FindAll(it => it.TakeQuantity > 0).ToList(); + if (record.Count > 0) + { + string InvoiceId = "AddJiaoJie_" + CurrentTimeMillis(); + var f = SqlSugarHelper.Db.UseTran(() => + { + for (int i = 0; i < record.Count; i++) + { + ChannelStock it = record[i]; + // 更新数据 库存信息 + SqlSugarHelper.Db.Updateable(new ChannelStock() + { + Quantity = it.Quantity - it.TakeQuantity, + ManuNo = it.ManuNo, + EffDate = it.EffDate, + Id = it.Id, + }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand(); + + //更新 交接柜 库存信息 + List jiaojie = jiaojieStocks.Where(cs => cs.DrugId == it.DrugId).ToList(); + if (jiaojie != null && jiaojie.Count > 0) + { + for (int j = 0; j < jiaojie.Count; j++) + { + // 更新数据 交接柜 库存信息 + ChannelStock jiaojie_it = jiaojie[j]; + SqlSugarHelper.Db.Updateable(new ChannelStock() + { + Quantity = jiaojie_it.BaseQuantity, + //ManuNo = it.ManuNo, + //EffDate = it.EffDate, + Id = jiaojie_it.Id, + }).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).ExecuteCommand(); + } + } + + + // 保存数据 出库记录 + SqlSugarHelper.Db.Insertable(new MachineRecord() + { + MachineId = it.MachineId, + DrawerNo = it.DrawerNo, + ColNo = it.ColNo, + DrugId = it.DrugId, + ManuNo = it.ManuNo, + EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, + Operator = HomeWindowViewModel.Operator?.Id, + Reviewer = HomeWindowViewModel.Reviewer?.Id, + OperationTime = DateTime.Now, + Quantity = it.TakeQuantity, + Type = 2, + InvoiceId = InvoiceId + }).ExecuteCommand(); + } + return true; + }); + if (f.Data) + { + // 更新屏显库存 + List singleChannels = record.FindAll(it => it.BoardType != 5); + if (singleChannels.Count > 0) + { + singleChannels.ForEach(it => + { + _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); + }); + } + AlertMsg alertMsg = new AlertMsg + { + Message = "补药完成,库存已更新", + Type = MsgType.SUCCESS, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + RequestData(); + } + if (!f.IsSuccess) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "补药操作失败,库存更新失败!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + } + else + { + AlertMsg alertMsg = new AlertMsg + { + Message = "补药数量有误", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + }); + } //取消 public DelegateCommand CancleAdd @@ -210,11 +397,14 @@ namespace DM_Weight.ViewModels { get => new DelegateCommand(async () => { - csList = ChannelStocks.FindAll(cs => cs.IsSelected == true).GroupBy(cs => cs.DrugId).Select(g => new { - DrugId = g.Key, Quantity = g.Sum(s => s.Quantity) - }).Select(cs=>new ChannelStock() { DrugId=cs.DrugId,Quantity=cs.Quantity}).ToList(); + //选中channelStock.channel_list的isSelected则选中channelStock的isSelected + //var o= ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList(); + //csList = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).GroupBy(cs => cs.DrugId).Select(g => new { + // DrugId = g.Key, AddQuantity = g.Sum(s => s.AddQuantity) + //}).Select(cs=>new ChannelStock() { DrugId=cs.DrugId,AddQuantity=cs.AddQuantity }).ToList(); + csList= ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList(); if (csList != null && csList.Count>0) { diff --git a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs index 6d84af0..36150cb 100644 --- a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs +++ b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs @@ -654,7 +654,7 @@ namespace DM_Weight.ViewModels int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = dept, OrderNo = SelectDrugPleaseClaim.PleaseNo, @@ -673,7 +673,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); @@ -686,7 +686,7 @@ namespace DM_Weight.ViewModels { //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type=3, ManuNo=it.ManuNo, EffDate=it.EffDate, @@ -709,7 +709,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -721,7 +721,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.AddQuantity, diff --git a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs index 81ad5a2..253454d 100644 --- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs @@ -224,7 +224,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -242,7 +242,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -255,7 +255,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -277,7 +277,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -289,7 +289,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.AddQuantity, diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs index 7c79563..05b61e9 100644 --- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs @@ -223,7 +223,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 2, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -241,7 +241,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -254,7 +254,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -276,7 +276,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -288,7 +288,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.TakeQuantity, diff --git a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs index 97bd037..5976aeb 100644 --- a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs @@ -294,7 +294,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -312,7 +312,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -325,7 +325,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -347,7 +347,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -359,7 +359,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.AddQuantity, diff --git a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs index 7b58c76..807a007 100644 --- a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs @@ -356,7 +356,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 2, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -374,7 +374,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -387,7 +387,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -409,7 +409,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -421,7 +421,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.TakeQuantity, diff --git a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs index c73471e..28f9012 100644 --- a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs +++ b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs @@ -354,7 +354,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -372,7 +372,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -385,7 +385,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -407,7 +407,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -419,7 +419,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.ReturnQuantity, diff --git a/DM_Weight/ViewModels/OrderTakeAllDrugDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeAllDrugDialogViewModel.cs index 68fe70e..690ad55 100644 --- a/DM_Weight/ViewModels/OrderTakeAllDrugDialogViewModel.cs +++ b/DM_Weight/ViewModels/OrderTakeAllDrugDialogViewModel.cs @@ -468,7 +468,7 @@ namespace DM_Weight.ViewModels //保存账册 int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(orderDetail.DrugId), + DrugId = orderDetail.DrugId, Type = 2, Department = orderInfo.DeptName, OrderNo = orderDetail.OrderNo, @@ -487,7 +487,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString())) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(orderDetail.DrugId)) + .Where(ab => ab.DrugId == orderDetail.DrugId) .Where(ab => ab.ManuNo == cs.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -500,7 +500,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(orderDetail.DrugId), + DrugId = orderDetail.DrugId, Type = 3, ManuNo = cs.ManuNo, EffDate = cs.EffDate, @@ -522,7 +522,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString())) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(orderDetail.DrugId)) + .Where(ab => ab.DrugId == orderDetail.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -534,7 +534,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(orderDetail.DrugId), + DrugId = orderDetail.DrugId, Type = 4, YQuantity = 0, ManuStock = orderDetail.Quantity, diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs index 5bace18..2d518de 100644 --- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs @@ -375,7 +375,7 @@ namespace DM_Weight.ViewModels //保存账册 int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 2, Department = OrderInfo.DeptName, OrderNo = OrderInfo.OrderNo, @@ -394,7 +394,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -407,7 +407,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -428,8 +428,8 @@ namespace DM_Weight.ViewModels //修改凌晨生成的日结存与总结存数据 AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) - .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.Type == 4) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -441,7 +441,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.TakeQuantity, diff --git a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs index 533e6ee..3ae3979 100644 --- a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs +++ b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs @@ -275,7 +275,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(ChannelStock.DrugId), + DrugId = ChannelStock.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -293,7 +293,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(ChannelStock.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId)) + .Where(ab => ab.DrugId == ChannelStock.DrugId) .Where(ab => ab.ManuNo == ChannelStock.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -306,7 +306,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(ChannelStock.DrugId), + DrugId = ChannelStock.DrugId, Type = 3, ManuNo = ChannelStock.ManuNo, EffDate = ChannelStock.EffDate, @@ -328,7 +328,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(ChannelStock.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId)) + .Where(ab => ab.DrugId == ChannelStock.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -340,7 +340,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(ChannelStock.DrugId), + DrugId = ChannelStock.DrugId, Type = 4, YQuantity = 0, ManuStock = ChannelStock.ReturnQuantity, diff --git a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs index 9d50c7e..ea7a474 100644 --- a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs +++ b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs @@ -283,7 +283,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -301,7 +301,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -314,7 +314,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -336,7 +336,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -349,7 +349,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.AddQuantity, diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs index d00f066..9f8e962 100644 --- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs @@ -260,7 +260,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 2, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -278,7 +278,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -291,7 +291,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -313,7 +313,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -325,7 +325,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.TakeQuantity, diff --git a/DM_Weight/ViewModels/StockListWindowViewModel.cs b/DM_Weight/ViewModels/StockListWindowViewModel.cs index 9fc1f9d..b3b7596 100644 --- a/DM_Weight/ViewModels/StockListWindowViewModel.cs +++ b/DM_Weight/ViewModels/StockListWindowViewModel.cs @@ -198,11 +198,12 @@ namespace DM_Weight.ViewModels ChannelStocks.Clear(); List q = SqlSugarHelper.Db.Queryable() - .Includes(di => di.channelStocks.Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3") && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList()) + .Includes(di => di.channelStocks.Where(cs => cs.DrawerType == 1).Where(cs => (cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")|| cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5")) && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList()) .WhereIF(!String.IsNullOrEmpty(SearchValue), di => di.DrugName == SearchValue) - .Where(di => di.channelStocks.Any(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3") && cs.DrugId != null)) + .Where(di => di.channelStocks.Any(cs => (cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")|| cs.MachineId.Equals(ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5")) && cs.DrugId != null)) .OrderBy(cs => cs.DrugId) .ToList(); + Drugs = q; } diff --git a/DM_Weight/ViewModels/SurgeryTakeDialogViewModel.cs b/DM_Weight/ViewModels/SurgeryTakeDialogViewModel.cs index 7207f54..1b033fc 100644 --- a/DM_Weight/ViewModels/SurgeryTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/SurgeryTakeDialogViewModel.cs @@ -673,7 +673,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(stock.DrugId), + DrugId = stock.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -691,7 +691,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(stock.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId)) + .Where(ab => ab.DrugId == stock.DrugId) .Where(ab => ab.ManuNo == stock.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -704,7 +704,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(stock.DrugId), + DrugId = stock.DrugId, Type = 3, ManuNo = stock.ManuNo, EffDate = stock.EffDate, @@ -726,7 +726,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(stock.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId)) + .Where(ab => ab.DrugId == stock.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -738,7 +738,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(stock.DrugId), + DrugId = stock.DrugId, Type = 4, YQuantity = 0, ManuStock = stock.ReturnQuantity, diff --git a/DM_Weight/Views/AddToJiaoJieWindow.xaml b/DM_Weight/Views/AddToJiaoJieWindow.xaml index bb1d866..9146aa7 100644 --- a/DM_Weight/Views/AddToJiaoJieWindow.xaml +++ b/DM_Weight/Views/AddToJiaoJieWindow.xaml @@ -34,7 +34,7 @@