From aade72f0cdb034586d24a29a9004d8a0fa67afdb Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Fri, 28 Jun 2024 10:37:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/App.config | 10 +- DM_Weight/App.xaml | 2 +- DM_Weight/App.xaml.cs | 46 +- DM_Weight/Common/CommonClass.cs | 23 + DM_Weight/Common/SelectableViewModel.cs | 55 ++ DM_Weight/Common/SimpleDateValidationRule.cs | 23 + DM_Weight/Converter/StatusConverter.cs | 12 + DM_Weight/Converter/TypeConverter.cs | 38 ++ DM_Weight/DM_Weight.csproj | 6 + DM_Weight/Finger/FingerprintUtil.cs | 12 +- DM_Weight/Port/PortUtil.cs | 32 +- DM_Weight/Report/GridReportUtil.cs | 68 ++- DM_Weight/ReportTemp/drug_take_check_in.grf | 387 ++++++++++++++ DM_Weight/ReportTemp/drug_take_check_in2.grf | 387 ++++++++++++++ .../ViewModels/CheckStockWindowViewModel.cs | 4 +- .../DrawerAddDrugWindowViewModel.cs | 4 +- .../DrawerTakeDrugWindowViewModel.cs | 4 +- .../ViewModels/DrugListWindowViewModel.cs | 4 +- DM_Weight/ViewModels/DrugTakeCheckIn.cs | 12 + .../DrugTakeCheckInWindowViewModel.cs | 150 ++++++ DM_Weight/ViewModels/HomeWindowViewModel.cs | 147 +++++- .../ViewModels/HomeWindowViewModel_New.cs | 473 ++++++++++++++++++ .../ViewModels/InvoiceInWindowViewModel.cs | 2 +- .../ViewModels/InvoiceOutWindowViewModel.cs | 2 +- .../MachineRecordWindowViewModel.cs | 22 +- .../OrderTakeDrugWindowViewModel.cs | 21 +- .../ViewModels/ReturnDrugDialogViewModel.cs | 100 ++-- .../ViewModels/ReturnDrugWindow2ViewModel.cs | 2 +- .../ViewModels/ReturnDrugWindowViewModel.cs | 18 +- .../ViewModels/ReturnEmptyDialogViewModel.cs | 69 ++- .../ViewModels/ReturnEmptyWindowViewModel.cs | 6 +- .../ViewModels/RoleManagerWindowViewModel.cs | 22 +- .../ViewModels/SelfAddWindowViewModel.cs | 13 +- .../ViewModels/StockListWindowViewModel.cs | 16 +- .../ViewModels/UserManagerWindowViewModel.cs | 4 +- DM_Weight/Views/Dialog/ReturnEmptyDialog.xaml | 20 +- DM_Weight/Views/DrugTakeCheckInWindow.xaml | 133 +++++ DM_Weight/Views/DrugTakeCheckInWindow.xaml.cs | 28 ++ DM_Weight/Views/HomeWindow.xaml | 9 +- DM_Weight/Views/HomeWindow_New.xaml | 139 +++++ DM_Weight/Views/HomeWindow_New.xaml.cs | 28 ++ DM_Weight/Views/MachineRecordWindow.xaml | 31 +- DM_Weight/Views/StockListWindow.xaml | 7 +- DM_Weight/select/Week.cs | 15 + 44 files changed, 2468 insertions(+), 138 deletions(-) create mode 100644 DM_Weight/Common/CommonClass.cs create mode 100644 DM_Weight/Common/SelectableViewModel.cs create mode 100644 DM_Weight/Common/SimpleDateValidationRule.cs create mode 100644 DM_Weight/Converter/TypeConverter.cs create mode 100644 DM_Weight/ReportTemp/drug_take_check_in.grf create mode 100644 DM_Weight/ReportTemp/drug_take_check_in2.grf create mode 100644 DM_Weight/ViewModels/DrugTakeCheckIn.cs create mode 100644 DM_Weight/ViewModels/DrugTakeCheckInWindowViewModel.cs create mode 100644 DM_Weight/ViewModels/HomeWindowViewModel_New.cs create mode 100644 DM_Weight/Views/DrugTakeCheckInWindow.xaml create mode 100644 DM_Weight/Views/DrugTakeCheckInWindow.xaml.cs create mode 100644 DM_Weight/Views/HomeWindow_New.xaml create mode 100644 DM_Weight/Views/HomeWindow_New.xaml.cs create mode 100644 DM_Weight/select/Week.cs diff --git a/DM_Weight/App.config b/DM_Weight/App.config index 3bfed60..bdc87a9 100644 --- a/DM_Weight/App.config +++ b/DM_Weight/App.config @@ -37,11 +37,11 @@ - + - + - + + \ No newline at end of file diff --git a/DM_Weight/App.xaml b/DM_Weight/App.xaml index ef8d445..704fc50 100644 --- a/DM_Weight/App.xaml +++ b/DM_Weight/App.xaml @@ -6,7 +6,7 @@ d1p1:Ignorable="d" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:DM_Weight" - xmlns:prism="http://prismlibrary.com/"> + xmlns:prism="http://prismlibrary.com/" Startup="PrismApplication_Startup"> diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs index 18b9c10..56c2b59 100644 --- a/DM_Weight/App.xaml.cs +++ b/DM_Weight/App.xaml.cs @@ -23,6 +23,8 @@ using log4net; using System.Windows.Interop; using System.Windows.Threading; using System.Timers; +using System.Diagnostics; +using System.Runtime.InteropServices; namespace DM_Weight { @@ -92,7 +94,7 @@ namespace DM_Weight // 串口工具 containerRegistry.RegisterSingleton(); // 指纹机工具 - //containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); // 组态屏工具 containerRegistry.RegisterSingleton(); @@ -111,6 +113,8 @@ namespace DM_Weight // 布局页面 containerRegistry.RegisterForNavigation(); + // 布局页面 + containerRegistry.RegisterForNavigation(); // 录入指纹模态框 containerRegistry.RegisterDialog(); @@ -181,7 +185,7 @@ namespace DM_Weight // 库存列表页面 containerRegistry.RegisterForNavigation(); // 药品列表页面 - // containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); #endregion @@ -207,5 +211,43 @@ namespace DM_Weight containerRegistry.RegisterForNavigation(); } + + private static void RaiseOtherProcess() + { + Process proc = Process.GetCurrentProcess(); + foreach (Process otherProc in Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName)) + { + if (proc.Id != otherProc.Id) + { + IntPtr hWnd = otherProc.MainWindowHandle; + if (IsIconic(hWnd)) + { + ShowWindowAsync(hWnd, 9); + } + SetForegroundWindow(hWnd); + break; + } + } + } + [DllImport("user32.dll")] + private static extern bool SetForegroundWindow(IntPtr hWnd); + [DllImport("user32.dll")] + private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + [DllImport("user32.dll")] + private static extern bool IsIconic(IntPtr hWnd); + + private void PrismApplication_Startup(object sender, StartupEventArgs e) + { + //获取欲启动程序名 + string processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName; + //检查程序是否已经启动,已经启动则显示提示退出程序 + if (System.Diagnostics.Process.GetProcessesByName(processName).Length > 1) + { + //系统在运行 + RaiseOtherProcess(); + Application.Current.Shutdown(); + return; + } + } } } diff --git a/DM_Weight/Common/CommonClass.cs b/DM_Weight/Common/CommonClass.cs new file mode 100644 index 0000000..e2a5759 --- /dev/null +++ b/DM_Weight/Common/CommonClass.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml; + +namespace DM_Weight.Common +{ + public class CommonClass + { + //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题 + public static string ReadAppSetting(string key) + { + string xPath = "/configuration/appSettings//add[@key='" + key + "']"; + XmlDocument doc = new XmlDocument(); + string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; + doc.Load(exeFileName + ".dll.config"); + XmlNode node = doc.SelectSingleNode(xPath); + return node.Attributes["value"].Value.ToString(); + } + } +} diff --git a/DM_Weight/Common/SelectableViewModel.cs b/DM_Weight/Common/SelectableViewModel.cs new file mode 100644 index 0000000..bd5cbc5 --- /dev/null +++ b/DM_Weight/Common/SelectableViewModel.cs @@ -0,0 +1,55 @@ +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.Common +{ + public class SelectableViewModel : BindableBase + { + private bool _isSelected; + private string? _name; + private string? _description; + private char _code; + private double _numeric; + private string? _food; + + public bool IsSelected + { + get => _isSelected; + set => SetProperty(ref _isSelected, value); + } + + public char Code + { + get => _code; + set => SetProperty(ref _code, value); + } + + public string? Name + { + get => _name; + set => SetProperty(ref _name, value); + } + + public string? Description + { + get => _description; + set => SetProperty(ref _description, value); + } + + public double Numeric + { + get => _numeric; + set => SetProperty(ref _numeric, value); + } + + public string? Food + { + get => _food; + set => SetProperty(ref _food, value); + } + } +} diff --git a/DM_Weight/Common/SimpleDateValidationRule.cs b/DM_Weight/Common/SimpleDateValidationRule.cs new file mode 100644 index 0000000..6040c50 --- /dev/null +++ b/DM_Weight/Common/SimpleDateValidationRule.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; + +namespace DM_Weight.Common +{ + public class SimpleDateValidationRule : ValidationRule + { + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + return DateTime.TryParse((value ?? "").ToString(), + CultureInfo.CurrentCulture, + DateTimeStyles.AssumeLocal | DateTimeStyles.AllowWhiteSpaces, + out _) + ? ValidationResult.ValidResult + : new ValidationResult(false, "请选择时间"); + } + } +} diff --git a/DM_Weight/Converter/StatusConverter.cs b/DM_Weight/Converter/StatusConverter.cs index 8a1a5d8..7eac268 100644 --- a/DM_Weight/Converter/StatusConverter.cs +++ b/DM_Weight/Converter/StatusConverter.cs @@ -73,6 +73,18 @@ namespace DM_Weight.Converter return Visibility.Collapsed; } } + //还空瓶页面退出按钮 + if(parameter.ToString().Equals("QuitBtnVisible")) + { + if (status == 0) + { + return Visibility.Visible; + } + else + { + return Visibility.Collapsed; + } + } return Visibility.Collapsed; } diff --git a/DM_Weight/Converter/TypeConverter.cs b/DM_Weight/Converter/TypeConverter.cs new file mode 100644 index 0000000..68da834 --- /dev/null +++ b/DM_Weight/Converter/TypeConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace DM_Weight.Converter +{ + internal class TypeConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + int mrType; + bool isType = int.TryParse(value.ToString(), out mrType); + //药品领取登记 + if (parameter!=null&& parameter.ToString().Equals("DragTakeCheckIn")) + { + if (mrType == 3) + { + return Visibility.Visible; + } + else + { + return Visibility.Collapsed; + } + } + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/DM_Weight/DM_Weight.csproj b/DM_Weight/DM_Weight.csproj index d205ffe..e6d4a0c 100644 --- a/DM_Weight/DM_Weight.csproj +++ b/DM_Weight/DM_Weight.csproj @@ -96,6 +96,12 @@ Always + + Always + + + Always + Always diff --git a/DM_Weight/Finger/FingerprintUtil.cs b/DM_Weight/Finger/FingerprintUtil.cs index 148cef7..0aae4d8 100644 --- a/DM_Weight/Finger/FingerprintUtil.cs +++ b/DM_Weight/Finger/FingerprintUtil.cs @@ -161,8 +161,16 @@ namespace DM_Weight.Finger bool result = false; // 取消其他操作 bool res2 = axCZKEM1.CancelOperation(); - // 删除源指纹 - bool res = axCZKEM1.DelUserTmp(machineNumber, Id, FingerIndex); + if (machineType == 1) + { + // 删除源指纹 + bool res = axCZKEM1.DelUserTmp(machineNumber, Id, FingerIndex); + } + else + { + // 删除源指纹 + bool res = axCZKEM1.SSR_DelUserTmp(machineNumber, Id.ToString(), FingerIndex); + } // 添加新指纹 result = axCZKEM1.StartEnrollEx(Id.ToString(), FingerIndex, 3); return result; diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs index 7399abf..18d8bf7 100644 --- a/DM_Weight/Port/PortUtil.cs +++ b/DM_Weight/Port/PortUtil.cs @@ -480,7 +480,7 @@ namespace DM_Weight.Port byte[] bytes = await CheckRecoverQuantity(); int[] r1 = bytes.Select(it => Convert.ToInt32(it)).ToArray(); - logger.Info($"回收箱查数返回{string.Join(",",r1)}"); + logger.Info($"回收箱查数返回{string.Join(",", r1)}"); // 返回消息库位关闭,放入空瓶数量 int[] quantitys = r1.Skip(3).Take(3).ToArray(); int index = ColNos[0] % 3 > 0 ? ColNos[0] % 3 - 1 : 2; @@ -651,19 +651,19 @@ namespace DM_Weight.Port byte[] buffer = new byte[length]; //try //{ - int _length = 0; - DateTime start = DateTime.Now; - DateTime end = DateTime.Now; - while (_length != length && end.Subtract(start).TotalMilliseconds < timeout) - { - _length = serialPort.BytesToRead; - end = DateTime.Now; - } - if (_length != length) - { - throw new TimeoutException($"串口【{serialPort.PortName}】交互超时"); - } - serialPort.Read(buffer, 0, length); + int _length = 0; + DateTime start = DateTime.Now; + DateTime end = DateTime.Now; + while (_length != length && end.Subtract(start).TotalMilliseconds < timeout) + { + _length = serialPort.BytesToRead; + end = DateTime.Now; + } + if (_length != length) + { + throw new TimeoutException($"串口【{serialPort.PortName}】交互超时"); + } + serialPort.Read(buffer, 0, length); //} //catch (Exception ex) //{ @@ -861,7 +861,7 @@ namespace DM_Weight.Port byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x0a, 0x00, 0x00, 0x00, 0x00, 0xee }; canBusSerial.Write(buffer, 0, 8); string msg = string.Empty; - logger.Info($"单支板有药位置亮灯指令:{string.Join(",",buffer)}"); + logger.Info($"单支板有药位置亮灯指令:{string.Join(",", buffer)}"); await Task.Delay(TimeSpan.FromMilliseconds(20)); } @@ -1154,7 +1154,7 @@ namespace DM_Weight.Port byte[] buffer = new byte[] { 0xAA, 0x9A, (byte)(ColNos[0] > 3 ? 2 : 1), 0x00, 0x00, 0x00, 0x00, 0xEE }; //byte[] buffer = new byte[] { 0xAA, 0x9A, 01,(byte)(ColNos[0] > 3 ? 2 : 1), 0x00, 0x00, 0x00,0xEE }; canBusSerial.Write(buffer, 0, 8); - logger.Info($"回收箱数量查询发{string.Join(",",buffer)}"); + logger.Info($"回收箱数量查询发{string.Join(",", buffer)}"); return await GetBufferByPort(canBusSerial, 8); } diff --git a/DM_Weight/Report/GridReportUtil.cs b/DM_Weight/Report/GridReportUtil.cs index 7600734..b5ce382 100644 --- a/DM_Weight/Report/GridReportUtil.cs +++ b/DM_Weight/Report/GridReportUtil.cs @@ -17,7 +17,7 @@ namespace DM_Weight.Report // 定义Grid++Report报表主对象 public static GridppReport Report = new GridppReport(); - public static string gridConnectionString = ConfigurationManager.AppSettings["gridConnectionString"]; + public static string gridConnectionString = ConfigurationManager.AppSettings["gridConnectionString"]; /** * 打印预览 * tempname: 模板文件名称 @@ -43,7 +43,7 @@ namespace DM_Weight.Report //{ // Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); //}); - string machine_id=(ConfigurationManager.AppSettings["machineId"] ?? "DM1"); + string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); string SQL = $@"SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate, di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manuFactory,di.`max_stock` AS baseQuantity, cl.`drug_id` AS drugId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` = '{machine_id}' AND cl.`drawer_type` = 1 ORDER BY cl.`drug_id`"; @@ -57,9 +57,9 @@ namespace DM_Weight.Report { DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1"); DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1); - string p_machine_id= (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); + string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); // 定义Grid++Report报表主对象 - GridppReport Report = new GridppReport(); + GridppReport Report = new GridppReport(); // 加载模板文件 Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "account_book_temp.grf"); string SQL = string.Empty; @@ -146,13 +146,67 @@ namespace DM_Weight.Report AND dmr.`machine_id` = '{p_machine_id}' AND dmr.`operation_time` > '{p_startDate}' AND dmr.`operation_time` < '{p_endDate}'"; } - + Report.DetailGrid.Recordset.ConnectionString = gridConnectionString; - Report.DetailGrid.Recordset.QuerySQL= SQL; + Report.DetailGrid.Recordset.QuerySQL = SQL; Report.PrintPreview(true); } + /// + /// 麻醉科精一、精二药品领取登记表 + /// + /// + /// + /// 麻醉科药品领取登记表按取药时间查询
精一固定5种药;精二固定4种药 + ///
+ ///
+ /// + /// + /// 1->精1;2->精2 + public static void PrintReportDrugTakeCheckIn(DateTime? startDate, DateTime? endDate,int type) + { + // 定义Grid++Report报表主对象 + GridppReport Report = new GridppReport(); + DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1"); + DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1); + string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); + string SQL = string.Empty; + Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() => + { + Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); + Report.ParameterByName("startDate").Value = startDate ?? DateTime.Now.AddYears(-10); + Report.ParameterByName("endDate").Value = endDate ?? DateTime.Now.AddDays(1); + }); + SQL = $@"SELECT operation_time,d.drug_name,manu_no,eff_date,quantity,u.User_name,ur.user_name reviewer,returnOptTime,u2.User_name returnUser,u2r.user_name returnReviewer,return_quantity1,return_quantity2 + from dm_machine_record AS mr + LEFT JOIN (SELECT operation_time returnOptTime,operator returnOperator,reviewer returnReviewer,drug_id returnDrug_id,get_id + FROM dm_machine_record) AS returnMr + ON mr.drug_id=returnMr.returnDrug_id AND returnMr.get_id=mr.id LEFT JOIN drug_info d on mr.drug_id=d.drug_id + LEFT JOIN user_list u on mr.operator=u.id + LEFT JOIN user_list ur on mr.reviewer=ur.id + LEFT JOIN user_list u2 on returnMr.returnOperator=u2.id + LEFT JOIN user_list u2r on returnMr.returnReviewer=u2r.id + WHERE mr.type=2 AND mr.`machine_id` = '{p_machine_id}' AND mr.`operation_time` > '{p_startDate}' AND mr.`operation_time` < '{p_endDate}' "; + if (type == 1) + { + // 加载模板文件 + Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "drug_take_check_in.grf"); + SQL += @" and mr.DRUG_ID IN('9131487','10826545','9112595','9132487','9087821')"; + } + else + { + // 加载模板文件 + Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "drug_take_check_in2.grf"); + SQL += @" and mr.DRUG_ID IN('95892862','1053979','9644264','12663789')"; + } + SQL+=" GROUP BY mr.operation_time, mr.drug_id, mr.operator, mr.machine_id"; + + Report.DetailGrid.Recordset.ConnectionString = gridConnectionString; + Report.DetailGrid.Recordset.QuerySQL = SQL; + + Report.PrintPreview(true); + } /** @@ -166,7 +220,7 @@ namespace DM_Weight.Report GridppReport Report = new GridppReport(); // 加载模板文件 Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//machine_log.grf"); - + // 加载数据 Report.ParameterByName("type").AsInteger = 1; Report.PrintPreview(true); diff --git a/DM_Weight/ReportTemp/drug_take_check_in.grf b/DM_Weight/ReportTemp/drug_take_check_in.grf new file mode 100644 index 0000000..1a9ff9d --- /dev/null +++ b/DM_Weight/ReportTemp/drug_take_check_in.grf @@ -0,0 +1,387 @@ +{ + "Version":"6.3.0.1", + "Font":{ + "Name":"宋体", + "Size":105000, + "Weight":400, + "Charset":134 + }, + "Printer":{ + "Oriention":"Landscape", + "TopMargin":0.3175, + "RightMargin":0.8996, + "BottomMargin":0.3969 + }, + "DetailGrid":{ + "CenterView":true, + "AppendBlankRow":true, + "Recordset":{ + "QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n dmr.`quantity` AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 1 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate", + "Field":[ + { + "Name":"日期", + "Type":"DateTime", + "Format":"yyyy/MM/dd HH:mm:ss", + "DBFieldName":"operation_time" + }, + { + "Name":"效期", + "Format":"yyyy/MM/dd HH:mm:ss", + "DBFieldName":"eff_date" + }, + { + "Name":"药品名称", + "DBFieldName":"drug_name" + }, + { + "Name":"取药数量", + "DBFieldName":"quantity" + }, + { + "Name":"领取人", + "DBFieldName":"User_name" + }, + { + "Name":"发药人", + "Format":"yyyy/MM/dd", + "DBFieldName":"reviewer" + }, + { + "Name":"还药时间", + "Type":"DateTime", + "Format":"yyyy/MM/dd HH:mm:ss", + "DBFieldName":"returnOptTime" + }, + { + "Name":"还药数量", + "DBFieldName":"return_quantity1" + }, + { + "Name":"还空瓶数量", + "Type":"Integer", + "DBFieldName":"return_quantity2" + }, + { + "Name":"还药人", + "DBFieldName":"returnUser" + }, + { + "Name":"收取人", + "DBFieldName":"returnReviewer" + }, + { + "Name":"批次", + "DBFieldName":"manu_no" + } + ] + }, + "Column":[ + { + "Name":"日期", + "Width":3.78354 + }, + { + "Name":"药品名称", + "Width":4.63021 + }, + { + "Name":"批次", + "Width":1.69333 + }, + { + "Name":"效期", + "Width":2.56646 + }, + { + "Name":"取药数量", + "Width":1.19063 + }, + { + "Name":"领取人", + "Width":1.61396 + }, + { + "Name":"发药人", + "Width":1.5875 + }, + { + "Name":"还药时间", + "Width":3.81 + }, + { + "Name":"还药数量", + "Width":1.05833 + }, + { + "Name":"还空瓶数量", + "Width":0.978958 + }, + { + "Name":"还药人", + "Width":1.37583 + }, + { + "Name":"收取人", + "Width":1.5875 + } + ], + "ColumnContent":{ + "Height":1.00542, + "ColumnContentCell":[ + { + "Column":"日期", + "TextAlign":"MiddleCenter", + "DataField":"日期" + }, + { + "Column":"药品名称", + "TextAlign":"MiddleCenter", + "DataField":"药品名称" + }, + { + "Column":"批次", + "TextAlign":"MiddleCenter", + "DataField":"批次" + }, + { + "Column":"效期", + "TextAlign":"MiddleCenter", + "DataField":"效期" + }, + { + "Column":"取药数量", + "TextAlign":"MiddleCenter", + "DataField":"取药数量" + }, + { + "Column":"领取人", + "TextAlign":"MiddleCenter", + "DataField":"领取人" + }, + { + "Column":"发药人", + "TextAlign":"MiddleCenter", + "DataField":"发药人" + }, + { + "Column":"还药时间", + "TextAlign":"MiddleCenter", + "DataField":"还药时间" + }, + { + "Column":"还药数量", + "TextAlign":"MiddleCenter", + "DataField":"还药数量" + }, + { + "Column":"还空瓶数量", + "TextAlign":"MiddleCenter", + "DataField":"还空瓶数量" + }, + { + "Column":"还药人", + "TextAlign":"MiddleCenter", + "DataField":"还药人" + }, + { + "Column":"收取人", + "TextAlign":"MiddleCenter", + "DataField":"收取人" + } + ] + }, + "ColumnTitle":{ + "Height":2.19604, + "RepeatStyle":"OnPage", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"日期", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"日期" + }, + { + "GroupTitle":false, + "Column":"药品名称", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"药品名称" + }, + { + "GroupTitle":false, + "Column":"批次", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"批次" + }, + { + "GroupTitle":false, + "Column":"效期", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"效期" + }, + { + "GroupTitle":false, + "Column":"取药数量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"取\r\n药\r\n数\r\n量" + }, + { + "GroupTitle":false, + "Column":"领取人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"领取人" + }, + { + "GroupTitle":false, + "Column":"发药人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"发药人" + }, + { + "GroupTitle":false, + "Column":"还药时间", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"还药时间" + }, + { + "GroupTitle":false, + "Column":"还药数量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"还\r\n药\r\n数\r\n量" + }, + { + "GroupTitle":false, + "Column":"还空瓶数量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"还\r\n空\r\n瓶\r\n数\r\n量" + }, + { + "GroupTitle":false, + "Column":"还药人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"还药人" + }, + { + "GroupTitle":false, + "Column":"收取人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"收取人" + } + ] + } + }, + "Parameter":[ + { + "Name":"startDate", + "DataType":"DateTime", + "Format":"yyyy-MM-dd hh:mm:ss", + "Value":"2023/1/1" + }, + { + "Name":"endDate", + "DataType":"DateTime", + "Format":"yyyy-MM-dd hh:mm:ss", + "Value":"2023/4/28 23:59:59" + }, + { + "Name":"machine_id", + "Value":"DM1" + } + ], + "ReportHeader":[ + { + "Name":"ReportHeader1", + "Height":1.79917, + "Control":[ + { + "Type":"MemoBox", + "Name":"MemoBox2", + "Left":7.80521, + "Top":0.211667, + "Width":10.3981, + "Height":1.19063, + "Font":{ + "Name":"宋体", + "Size":217500, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"麻醉科精一药品领取登记表" + } + ], + "RepeatOnPage":true + } + ] +} \ No newline at end of file diff --git a/DM_Weight/ReportTemp/drug_take_check_in2.grf b/DM_Weight/ReportTemp/drug_take_check_in2.grf new file mode 100644 index 0000000..77e28d6 --- /dev/null +++ b/DM_Weight/ReportTemp/drug_take_check_in2.grf @@ -0,0 +1,387 @@ +{ + "Version":"6.3.0.1", + "Font":{ + "Name":"宋体", + "Size":105000, + "Weight":400, + "Charset":134 + }, + "Printer":{ + "Oriention":"Landscape", + "TopMargin":0.3175, + "RightMargin":0.8996, + "BottomMargin":0.3969 + }, + "DetailGrid":{ + "CenterView":true, + "AppendBlankRow":true, + "Recordset":{ + "QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n dmr.`quantity` AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 1 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate", + "Field":[ + { + "Name":"日期", + "Type":"DateTime", + "Format":"yyyy/MM/dd HH:mm:ss", + "DBFieldName":"operation_time" + }, + { + "Name":"效期", + "Format":"yyyy/MM/dd HH:mm:ss", + "DBFieldName":"eff_date" + }, + { + "Name":"药品名称", + "DBFieldName":"drug_name" + }, + { + "Name":"取药数量", + "DBFieldName":"quantity" + }, + { + "Name":"领取人", + "DBFieldName":"User_name" + }, + { + "Name":"发药人", + "Format":"yyyy/MM/dd", + "DBFieldName":"reviewer" + }, + { + "Name":"还药时间", + "Type":"DateTime", + "Format":"yyyy/MM/dd HH:mm:ss", + "DBFieldName":"returnOptTime" + }, + { + "Name":"还药数量", + "DBFieldName":"return_quantity1" + }, + { + "Name":"还空瓶数量", + "Type":"Integer", + "DBFieldName":"return_quantity2" + }, + { + "Name":"还药人", + "DBFieldName":"returnUser" + }, + { + "Name":"收取人", + "DBFieldName":"returnReviewer" + }, + { + "Name":"批次", + "DBFieldName":"manu_no" + } + ] + }, + "Column":[ + { + "Name":"日期", + "Width":3.78354 + }, + { + "Name":"药品名称", + "Width":4.63021 + }, + { + "Name":"批次", + "Width":1.69333 + }, + { + "Name":"效期", + "Width":2.56646 + }, + { + "Name":"取药数量", + "Width":1.19063 + }, + { + "Name":"领取人", + "Width":1.61396 + }, + { + "Name":"发药人", + "Width":1.5875 + }, + { + "Name":"还药时间", + "Width":3.81 + }, + { + "Name":"还药数量", + "Width":1.05833 + }, + { + "Name":"还空瓶数量", + "Width":0.978958 + }, + { + "Name":"还药人", + "Width":1.37583 + }, + { + "Name":"收取人", + "Width":1.5875 + } + ], + "ColumnContent":{ + "Height":1.00542, + "ColumnContentCell":[ + { + "Column":"日期", + "TextAlign":"MiddleCenter", + "DataField":"日期" + }, + { + "Column":"药品名称", + "TextAlign":"MiddleCenter", + "DataField":"药品名称" + }, + { + "Column":"批次", + "TextAlign":"MiddleCenter", + "DataField":"批次" + }, + { + "Column":"效期", + "TextAlign":"MiddleCenter", + "DataField":"效期" + }, + { + "Column":"取药数量", + "TextAlign":"MiddleCenter", + "DataField":"取药数量" + }, + { + "Column":"领取人", + "TextAlign":"MiddleCenter", + "DataField":"领取人" + }, + { + "Column":"发药人", + "TextAlign":"MiddleCenter", + "DataField":"发药人" + }, + { + "Column":"还药时间", + "TextAlign":"MiddleCenter", + "DataField":"还药时间" + }, + { + "Column":"还药数量", + "TextAlign":"MiddleCenter", + "DataField":"还药数量" + }, + { + "Column":"还空瓶数量", + "TextAlign":"MiddleCenter", + "DataField":"还空瓶数量" + }, + { + "Column":"还药人", + "TextAlign":"MiddleCenter", + "DataField":"还药人" + }, + { + "Column":"收取人", + "TextAlign":"MiddleCenter", + "DataField":"收取人" + } + ] + }, + "ColumnTitle":{ + "Height":2.19604, + "RepeatStyle":"OnPage", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"日期", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"日期" + }, + { + "GroupTitle":false, + "Column":"药品名称", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"药品名称" + }, + { + "GroupTitle":false, + "Column":"批次", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"批次" + }, + { + "GroupTitle":false, + "Column":"效期", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"效期" + }, + { + "GroupTitle":false, + "Column":"取药数量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"取\r\n药\r\n数\r\n量" + }, + { + "GroupTitle":false, + "Column":"领取人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"领取人" + }, + { + "GroupTitle":false, + "Column":"发药人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"发药人" + }, + { + "GroupTitle":false, + "Column":"还药时间", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"还药时间" + }, + { + "GroupTitle":false, + "Column":"还药数量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"还\r\n药\r\n数\r\n量" + }, + { + "GroupTitle":false, + "Column":"还空瓶数量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"还\r\n空\r\n瓶\r\n数\r\n量" + }, + { + "GroupTitle":false, + "Column":"还药人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"还药人" + }, + { + "GroupTitle":false, + "Column":"收取人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"收取人" + } + ] + } + }, + "Parameter":[ + { + "Name":"startDate", + "DataType":"DateTime", + "Format":"yyyy-MM-dd hh:mm:ss", + "Value":"2023/1/1" + }, + { + "Name":"endDate", + "DataType":"DateTime", + "Format":"yyyy-MM-dd hh:mm:ss", + "Value":"2023/4/28 23:59:59" + }, + { + "Name":"machine_id", + "Value":"DM1" + } + ], + "ReportHeader":[ + { + "Name":"ReportHeader1", + "Height":1.79917, + "Control":[ + { + "Type":"MemoBox", + "Name":"MemoBox2", + "Left":7.80521, + "Top":0.211667, + "Width":10.3981, + "Height":1.19063, + "Font":{ + "Name":"宋体", + "Size":217500, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"麻醉科精二药品领取登记表" + } + ], + "RepeatOnPage":true + } + ] +} \ No newline at end of file diff --git a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs index d8b4da9..7562675 100644 --- a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs @@ -295,8 +295,8 @@ namespace DM_Weight.ViewModels public void OnNavigatedTo(NavigationContext navigationContext) { _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent); - FindDrawerCount(); - RequestData(); + FindDrawerCount(); + RequestData(); } diff --git a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs index ed5c451..494e02b 100644 --- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs @@ -293,8 +293,8 @@ namespace DM_Weight.ViewModels public void OnNavigatedTo(NavigationContext navigationContext) { _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent); - FindDrawerCount(); - RequestData(); + FindDrawerCount(); + RequestData(); } diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs index 8a293f3..becd47f 100644 --- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs @@ -301,8 +301,8 @@ namespace DM_Weight.ViewModels public void OnNavigatedTo(NavigationContext navigationContext) { _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent); - FindDrawerCount(); - RequestData(); + FindDrawerCount(); + RequestData(); } diff --git a/DM_Weight/ViewModels/DrugListWindowViewModel.cs b/DM_Weight/ViewModels/DrugListWindowViewModel.cs index 331ae97..02e5f69 100644 --- a/DM_Weight/ViewModels/DrugListWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrugListWindowViewModel.cs @@ -241,8 +241,8 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 public void OnNavigatedTo(NavigationContext navigationContext) { - //查询表格数据 - RequestData(); + //查询表格数据 + RequestData(); } void GetManuNos() diff --git a/DM_Weight/ViewModels/DrugTakeCheckIn.cs b/DM_Weight/ViewModels/DrugTakeCheckIn.cs new file mode 100644 index 0000000..8f8d68a --- /dev/null +++ b/DM_Weight/ViewModels/DrugTakeCheckIn.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.ViewModels +{ + internal class DrugTakeCheckIn + { + } +} diff --git a/DM_Weight/ViewModels/DrugTakeCheckInWindowViewModel.cs b/DM_Weight/ViewModels/DrugTakeCheckInWindowViewModel.cs new file mode 100644 index 0000000..eef122a --- /dev/null +++ b/DM_Weight/ViewModels/DrugTakeCheckInWindowViewModel.cs @@ -0,0 +1,150 @@ +using DM_Weight.Models; +using Prism.Commands; +using Prism.Mvvm; +using Prism.Regions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DM_Weight.Report; + +namespace DM_Weight.ViewModels +{ + public class DrugTakeCheckInWindowViewModel:BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime + { + private int _pageNum = 1; + public int PageNum + { + get => _pageNum; + set + { + SetProperty(ref _pageNum, value); + RequestData(); + } + } + + private int _pageCount = 1; + public int PageCount + { + get => _pageCount; + set + { + SetProperty(ref _pageCount, value); + } + } + + private int _pageSize = 8; + public int PageSize + { + get => _pageSize; + set + { + SetProperty(ref _pageSize, value); + } + } + + private int _totalCount = 0; + public int TotalCount + { + get => _totalCount; + set + { + SetProperty(ref _totalCount, value); + } + } + private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); + + public DateTime? StartDate + { + get => _startDate; + set + { + if (value != null) + { + SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0)); + } + else + { + SetProperty(ref _startDate, value); + } + RequestData(); + } + } + + private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); + + public DateTime? EndDate + { + get => _endDate; + set + { + if (value != null) + { + TimeSpan ershisi = new TimeSpan(23, 59, 59); + SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59)); + } + else + { + SetProperty(ref _endDate, value); + } + + RequestData(); + } + } + private List? machineRecords; + + public List? MachineRecords + { + get { return machineRecords; } + set { SetProperty(ref machineRecords, value); } + } + public bool KeepAlive => false; + + + public DelegateCommand Query + { + get => new DelegateCommand(() => + { + RequestData(); + }); + } + + public DelegateCommand Download + { + get => new DelegateCommand(() => + { + //GridReportUtil.PrintReportDrugTakeCheckIn(StartDate, EndDate); + + }); + } + private void RequestData() + { + + } + + public void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback) + { + continuationCallback(true); + } + + public void OnNavigatedTo(NavigationContext navigationContext) + { + Task.Factory.StartNew(() => + { + RequestData(); + }); + } + + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + public void OnNavigatedFrom(NavigationContext navigationContext) + { + + + } + } +} diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs index 615c1a8..3ad20b3 100644 --- a/DM_Weight/ViewModels/HomeWindowViewModel.cs +++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs @@ -21,6 +21,10 @@ using System.Timers; using Unity; using System.Windows.Threading; using Newtonsoft.Json.Linq; +using DM_Weight.msg; +using MaterialDesignThemes.Wpf; +using System.Windows.Media; +using DM_Weight.Common; namespace DM_Weight.ViewModels { @@ -31,8 +35,12 @@ namespace DM_Weight.ViewModels private readonly IDialogService _dialogService; private UserList? _userList; private UserList? _userList2; + //private bool ISTakeReturn; - private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1"); + private int loginMode = Convert.ToInt32(CommonClass.ReadAppSetting("loginMode")?.ToString() ?? "1"); + //获取可取药还药的时间段 + //string[] timeSpan = CommonClass.ReadAppSetting("TakeReturnTime").Split('-'); + //string weeksSpan = CommonClass.ReadAppSetting("TakeReturnWeek"); public bool MultiLogin { get => loginMode == 2; @@ -102,6 +110,10 @@ namespace DM_Weight.ViewModels { if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2")) { + //if (!ISTakeReturn) + //{ + // return; + //} if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1")) { _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2"); @@ -113,7 +125,14 @@ namespace DM_Weight.ViewModels } else { - _regionManager.RequestNavigate("ContentRegion", value.PremissionPath); + //if (value.PremissionPath.Equals("OrderTakeDrugWindow") && !ISTakeReturn) + //{ + // return; + //} + //else + { + _regionManager.RequestNavigate("ContentRegion", value.PremissionPath); + } } } } @@ -152,19 +171,38 @@ namespace DM_Weight.ViewModels } private void SelectionMethod(ListBox viewName) { + logger.Info($"用户【{Operator?.Nickname}】进入菜单点击事件"); + + //CheckTakeReturnTime(); + //PremissionDm premissionDm = viewName.SelectedItem as PremissionDm; + //if ((premissionDm.PremissionName == "取药" || premissionDm.PremissionName == "还药") && !ISTakeReturn) + //{ + // //AlertMsg alertMsg = new AlertMsg + // //{ + // // Message = $"当前时间不可操作{premissionDm.PremissionName}", + // // Type = MsgType.ERROR, + // //}; + // //_eventAggregator.GetEvent().Publish(alertMsg); + // SnackbarMessageQueue.Enqueue($"当前时间不可操作{premissionDm.PremissionName}"); + // viewName.SelectedItem = SelectedMenu; + // return; + //} + SelectedMenu = viewName.SelectedItem as PremissionDm; if (SelectedMenu.PremissionName == "退出") { - logger.Info($"用户【{Operator?.Nickname}】退出登录"); + //logger.Info($"用户【{Operator?.Nickname}】退出登录"); + logger.Info($"用户【{Operator?.Nickname}】退出登录;SelectionMethod{SelectedMenu.PremissionName}"); Operator = null; Reviewer = null; _regionManager.RequestNavigate("MainRegion", "LoginWindow"); } else { - //SelectedMenu.Children = SelectedMenu.Children; SelectedChildMenu = SelectedMenu.Children[0]; } + + logger.Info($"用户【{Operator?.Nickname}】结束菜单点击事件"); } public List PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } } @@ -182,12 +220,14 @@ namespace DM_Weight.ViewModels public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); } public bool KeepAlive => false; private PortUtil _portUtil; + //IEventAggregator _eventAggregator; public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container) { _portUtil = portUtil; _regionManager = iRegionManager; _dialogService = dialogService; _container = container; + //_eventAggregator = eventAggregator; } public DelegateCommand OpenFingerDialog @@ -199,6 +239,18 @@ namespace DM_Weight.ViewModels DialogServiceExtensions.ShowDialogHost(_dialogService, "FingerprintDialog", dialogParameters, DoDialogResult, "RootDialog"); }); } + //退出 + public DelegateCommand QuitCommand + { + get => new DelegateCommand(QuitAction); + } + private void QuitAction() + { + logger.Info($"用户【{Operator?.Nickname}】退出登录;{UserList.Nickname}"); + Operator = null; + Reviewer = null; + _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + } public DelegateCommand OpenRecoverCommand { @@ -253,11 +305,53 @@ namespace DM_Weight.ViewModels continuationCallback(true); } + private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3)); + public ISnackbarMessageQueue SnackbarMessageQueue + { + get => _snackbarMessageQueue; + set => SetProperty(ref _snackbarMessageQueue, value); + } + private SolidColorBrush _colorBrush=new SolidColorBrush((Color) ColorConverter.ConvertFromString("#b71c1c")); + + public SolidColorBrush SnackbarBackground + { + get => _colorBrush; + set => SetProperty(ref _colorBrush, value); + } //接收导航传过来的参数 public void OnNavigatedTo(NavigationContext navigationContext) { + //CheckTakeReturnTime(); + ////是否可操作取药还药定时 + //System.Timers.Timer TakeReturnTimer = new System.Timers.Timer(); + //TakeReturnTimer.Interval = 1000; + //TakeReturnTimer.Elapsed += (sender, e) => + //{ + // // 当前时间不可操作取药、还药 + // if (!CheckTakeReturnTime()) + // { + // if (SelectedMenu.PremissionName == "取药" || SelectedMenu.PremissionName == "还药") + // { + // SnackbarMessageQueue.Enqueue($"当前时间不可操作{SelectedMenu.PremissionName}"); + // //SelectedMenu = ISTakeReturn ? UserList.Role.Permissions[0] : UserList.Role.Permissions[1]; + // //SelectedChildMenu = SelectedMenu.Children[0]; + // //_regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath); + // //PremissionDmList = UserList.Role.Permissions; + // List premissions = UserList.Role.Permissions; + // SelectedMenu = ISTakeReturn ? premissions[0] : premissions[1]; + // SelectedChildMenu = SelectedMenu.Children[0]; + // System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => + // { + // _regionManager.RequestNavigate("ContentRegion", "SelfAddWindow"); + // })); + // } + // } + //}; + //TakeReturnTimer.Start(); + + //_portUtil.dateTime = DateTime.Now; //取出user UserList = navigationContext.Parameters.GetValue("operator"); Operator = UserList; @@ -273,9 +367,13 @@ namespace DM_Weight.ViewModels //SqlSugarHelper.Db.SqlQueryable(sql) //.ToTree(pd => pd.Children, pd => pd.ParentId, 0); + PremissionDmList = premissions; + //SelectedMenu = ISTakeReturn ? premissions[0] : premissions[1]; SelectedMenu = premissions[0]; SelectedChildMenu = SelectedMenu.Children[0]; + + FindDrawerCount(); int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0"); @@ -305,7 +403,46 @@ namespace DM_Weight.ViewModels timer.Start(); } } - + ///// + ///// 检查是否在可取药、还药操作时间段 + ///// + //private bool CheckTakeReturnTime() + //{ + // ISTakeReturn = true; + // //查询该时间段能否取药跟还药 + // DateTime dtNow = DateTime.Now; + // string weekNow = DateTime.Today.DayOfWeek.ToString("d"); + // string[] timeSpan = CommonClass.ReadAppSetting("TakeReturnTime").Split('-'); + // string weeksSpan = CommonClass.ReadAppSetting("TakeReturnWeek"); + // if (timeSpan != null && timeSpan.Length == 2&& weeksSpan.IndexOf(weekNow)>=0) + // { + // bool bStart = DateTime.TryParse(timeSpan[0], out DateTime startTime); + // bool bEnd = DateTime.TryParse(timeSpan[1], out DateTime endTime); + // if (bStart && bEnd) + // { + // if (endTime < startTime) + // { + // endTime = endTime.AddDays(1); + // } + // if (dtNow >= startTime && dtNow <= endTime) + // { + // ISTakeReturn = true; + // } + // else + // { + // ISTakeReturn = false; + // //AlertMsg alertMsg = new AlertMsg + // //{ + // // Message = $"当前时间不可操作{SelectedMenu.PremissionName}", + // // Type = MsgType.ERROR, + // //}; + // //_eventAggregator.GetEvent().Publish(alertMsg); + // //return; + // } + // } + // } + // return ISTakeReturn; + //} //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建 public bool IsNavigationTarget(NavigationContext navigationContext) { diff --git a/DM_Weight/ViewModels/HomeWindowViewModel_New.cs b/DM_Weight/ViewModels/HomeWindowViewModel_New.cs new file mode 100644 index 0000000..6f0f72c --- /dev/null +++ b/DM_Weight/ViewModels/HomeWindowViewModel_New.cs @@ -0,0 +1,473 @@ +using log4net; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using Prism.Regions; +using Prism.Services.Dialogs; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using DM_Weight.Models; +using DM_Weight.Port; +using DM_Weight.util; +using DM_Weight.Views; +using System.Timers; +using Unity; +using System.Windows.Threading; +using Newtonsoft.Json.Linq; +using DM_Weight.msg; +using MaterialDesignThemes.Wpf; +using System.Windows.Media; +using DM_Weight.Common; + +namespace DM_Weight.ViewModels +{ + public class HomeWindowViewModel_New : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime + { + + private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindowViewModel)); + private readonly IDialogService _dialogService; + private UserList? _userList; + private UserList? _userList2; + private bool ISTakeReturn; + + private int loginMode = Convert.ToInt32(CommonClass.ReadAppSetting("loginMode")?.ToString() ?? "1"); + //获取可取药还药的时间段 + //string[] timeSpan = CommonClass.ReadAppSetting("TakeReturnTime").Split('-'); + //string weeksSpan = CommonClass.ReadAppSetting("TakeReturnWeek"); + public bool MultiLogin + { + get => loginMode == 2; + } + + private PremissionDm? _selectedMenu; + + private PremissionDm? _selectedChildMenu; + + private List? _premissionDmList; + + public PremissionDm? SelectedChildMenu + { + get { return _selectedChildMenu; } + set + { + SetProperty(ref _selectedChildMenu, value); + } + } + + public PremissionDm? SelectedMenu + { + get { return _selectedMenu; } + set + { + //if (value != null) + //{ + // if (value.PremissionName == "退出") + // { + // logger.Info($"用户【{Operator?.Nickname}】退出登录"); + // Operator = null; + // Reviewer = null; + // _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + // } + // else + // { + // SelectedChildMenu = value.Children[0]; + // } + //} + SetProperty(ref _selectedMenu, value); + } + } + #region 父菜单查询 + private DelegateCommand _selectionCommon; + public DelegateCommand SelectionCommon + { + get => _selectionCommon ?? (_selectionCommon = new DelegateCommand(SelectionMethod)); + } + private void SelectionMethod(ListBox viewName) + { + logger.Info($"用户【{Operator?.Nickname}】进入菜单点击事件"); + + CheckTakeReturnTime(); + PremissionDm premissionDm = viewName.SelectedItem as PremissionDm; + if ((premissionDm.PremissionName == "取药" || premissionDm.PremissionName == "还药") && !ISTakeReturn) + { + //AlertMsg alertMsg = new AlertMsg + //{ + // Message = $"当前时间不可操作{premissionDm.PremissionName}", + // Type = MsgType.ERROR, + //}; + //_eventAggregator.GetEvent().Publish(alertMsg); + SnackbarMessageQueue.Enqueue($"当前时间不可操作{premissionDm.PremissionName}"); + viewName.SelectedItem = SelectedMenu; + return; + } + + SelectedMenu = viewName.SelectedItem as PremissionDm; + if (SelectedMenu.PremissionName == "退出") + { + //logger.Info($"用户【{Operator?.Nickname}】退出登录"); + logger.Info($"用户【{Operator?.Nickname}】退出登录;SelectionMethod{SelectedMenu.PremissionName}"); + Operator = null; + Reviewer = null; + _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + } + else + { + SelectedChildMenu = SelectedMenu.Children[0]; + } + + logger.Info($"用户【{Operator?.Nickname}】结束菜单点击事件"); + } + #endregion + + #region 子菜单查询 + + private DelegateCommand _selectionChildCommon; + public DelegateCommand SelectionChildCommon + { + get => _selectionChildCommon ?? (_selectionChildCommon = new DelegateCommand(SelectionChildMethod)); + } + private void SelectionChildMethod() + { + if (!_portUtil.Operate) + { + if (SelectedChildMenu != null) + { + if (SelectedChildMenu.PremissionPath.Equals("TakeRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 2); + _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + } + else if (SelectedChildMenu.PremissionPath.Equals("AddRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 1); + _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + } + else if (SelectedChildMenu.PremissionPath.Equals("ReturnRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 3); + _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + } + else if (SelectedChildMenu.PremissionPath.Equals("RetrunEmptyRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 3); + _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath, keys); + } + else if (SelectedChildMenu.PremissionPath.Equals("CheckRecordWindow")) + { + //定义传参变量 + NavigationParameters keys = new NavigationParameters(); + + //添加参数,键值对格式 + keys.Add("Type", 4); + _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); + } + else + { + if (SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow") || SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow2")) + { + if (!ISTakeReturn) + { + return; + } + if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1")) + { + _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2"); + } + else + { + _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow"); + } + } + else + { + if (SelectedChildMenu.PremissionPath.Equals("OrderTakeDrugWindow") && !ISTakeReturn) + { + return; + } + else + { + _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath); + } + } + } + } + SetProperty(ref _selectedChildMenu, SelectedChildMenu); + } + } + + #endregion + + + public List PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } } + + public UserList UserList { get { return _userList; } set { SetProperty(ref _userList, value); } } + public UserList UserList2 { get { return _userList2; } set { SetProperty(ref _userList2, value); } } + + public static UserList? Operator; + public static UserList? Reviewer; + + IRegionManager _regionManager; + IUnityContainer _container; + + private bool _is16Drawer; + public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); } + public bool KeepAlive => false; + private PortUtil _portUtil; + //IEventAggregator _eventAggregator; + public HomeWindowViewModel_New(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container) + { + _portUtil = portUtil; + _regionManager = iRegionManager; + _dialogService = dialogService; + _container = container; + //_eventAggregator = eventAggregator; + } + + public DelegateCommand OpenFingerDialog + { + get => new DelegateCommand((string Type) => + { + DialogParameters dialogParameters = new DialogParameters(); + dialogParameters.Add("User", Type.Equals("Operator") ? Operator : Reviewer); + DialogServiceExtensions.ShowDialogHost(_dialogService, "FingerprintDialog", dialogParameters, DoDialogResult, "RootDialog"); + }); + } + //退出 + public DelegateCommand QuitCommand + { + get => new DelegateCommand(QuitAction); + } + private void QuitAction() + { + logger.Info($"用户【{Operator?.Nickname}】退出登录;{UserList.Nickname}"); + Operator = null; + Reviewer = null; + _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + } + + public DelegateCommand OpenRecoverCommand + { + get => new DelegateCommand(async () => + { + try + { + _portUtil.WindowName = "HomeWindow"; + _portUtil.Operate = true; + await _portUtil.OpenStorage(); + _portUtil.ResetData(); + + } + catch (Exception ex) + { + logger.Info($"OpenRecoverCommand异常{ex.Message}"); + } + }); + } + + public DelegateCommand OpenEditPasswordDialog + { + get => new DelegateCommand((string Type) => + { + DialogParameters dialogParameters = new DialogParameters(); + dialogParameters.Add("EditPass", true); + dialogParameters.Add("User", Type.Equals("Operator") ? Operator : Reviewer); + DialogServiceExtensions.ShowDialogHost(_dialogService, "EditUserDialog", dialogParameters, DoDialogResult, "RootDialog"); + }); + } + private void DoDialogResult(IDialogResult dialogResult) + { + // 委托 被动执行 被子窗口执行 + // dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态 + if (dialogResult.Result == ButtonResult.OK) + { + + } + } + + public void FindDrawerCount() + { + int count = SqlSugarHelper.Db.Queryable().Where(cs => cs.DrawerType != 3) + .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count(); + + Is16Drawer = count == 16; + } + + //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作 + public void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback) + { + continuationCallback(true); + } + + private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3)); + public ISnackbarMessageQueue SnackbarMessageQueue + { + get => _snackbarMessageQueue; + set => SetProperty(ref _snackbarMessageQueue, value); + } + private SolidColorBrush _colorBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c")); + + public SolidColorBrush SnackbarBackground + { + get => _colorBrush; + set => SetProperty(ref _colorBrush, value); + } + //接收导航传过来的参数 + public void OnNavigatedTo(NavigationContext navigationContext) + { + CheckTakeReturnTime(); + //是否可操作取药还药定时 + System.Timers.Timer TakeReturnTimer = new System.Timers.Timer(); + TakeReturnTimer.Interval = 1000; + TakeReturnTimer.Elapsed += (sender, e) => + { + // 当前时间不可操作取药、还药 + if (!CheckTakeReturnTime()) + { + if (SelectedMenu.PremissionName == "取药" || SelectedMenu.PremissionName == "还药") + { + SnackbarMessageQueue.Enqueue($"当前时间不可操作{SelectedMenu.PremissionName}"); + //SelectedMenu = ISTakeReturn ? UserList.Role.Permissions[0] : UserList.Role.Permissions[1]; + //SelectedChildMenu = SelectedMenu.Children[0]; + //_regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath); + //PremissionDmList = UserList.Role.Permissions; + + List premissions = UserList.Role.Permissions; + + SelectedMenu = ISTakeReturn ? premissions[0] : premissions[1]; + SelectedChildMenu = SelectedMenu.Children[0]; + System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => + { + _regionManager.RequestNavigate("ContentRegion", "SelfAddWindow"); + })); + } + } + }; + TakeReturnTimer.Start(); + + _portUtil.dateTime = DateTime.Now; + //取出user + UserList = navigationContext.Parameters.GetValue("operator"); + Operator = UserList; + logger.Info($"发药人【{Operator.Nickname}】登录"); + if (navigationContext.Parameters.ContainsKey("reviewer")) + { + UserList2 = navigationContext.Parameters.GetValue("reviewer"); + Reviewer = UserList2; + logger.Info($"审核人【{Reviewer.Nickname}】登录"); + } + + List premissions = UserList.Role.Permissions; + + //SqlSugarHelper.Db.SqlQueryable(sql) + //.ToTree(pd => pd.Children, pd => pd.ParentId, 0); + + PremissionDmList = premissions; + SelectedMenu = ISTakeReturn ? premissions[0] : premissions[1]; + SelectedChildMenu = SelectedMenu.Children[0]; + + + FindDrawerCount(); + + int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0"); + if (autoExit > 0) + { + Timer timer = new Timer(); + timer.Interval = 1000; + timer.Elapsed += (sender, e) => + { + // 串口无人操作 + if (!_portUtil.Operate) + { + // 30秒内无人操作鼠标键盘 + if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit) + { + logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录"); + Operator = null; + Reviewer = null; + Application.Current.Dispatcher.Invoke(() => + { + _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + timer.Stop(); + }); + } + } + }; + timer.Start(); + } + } + /// + /// 检查是否在可取药、还药操作时间段 + /// + private bool CheckTakeReturnTime() + { + ISTakeReturn = true; + //查询该时间段能否取药跟还药 + DateTime dtNow = DateTime.Now; + string weekNow = DateTime.Today.DayOfWeek.ToString("d"); + string[] timeSpan = CommonClass.ReadAppSetting("TakeReturnTime").Split('-'); + string weeksSpan = CommonClass.ReadAppSetting("TakeReturnWeek"); + if (timeSpan != null && timeSpan.Length == 2 && weeksSpan.IndexOf(weekNow) >= 0) + { + bool bStart = DateTime.TryParse(timeSpan[0], out DateTime startTime); + bool bEnd = DateTime.TryParse(timeSpan[1], out DateTime endTime); + if (bStart && bEnd) + { + if (endTime < startTime) + { + endTime = endTime.AddDays(1); + } + if (dtNow >= startTime && dtNow <= endTime) + { + ISTakeReturn = true; + } + else + { + ISTakeReturn = false; + //AlertMsg alertMsg = new AlertMsg + //{ + // Message = $"当前时间不可操作{SelectedMenu.PremissionName}", + // Type = MsgType.ERROR, + //}; + //_eventAggregator.GetEvent().Publish(alertMsg); + //return; + } + } + } + return ISTakeReturn; + } + //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建 + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + //这个方法用于拦截请求 + public void OnNavigatedFrom(NavigationContext navigationContext) + { + + } + } +} diff --git a/DM_Weight/ViewModels/InvoiceInWindowViewModel.cs b/DM_Weight/ViewModels/InvoiceInWindowViewModel.cs index 7f3cd61..229db20 100644 --- a/DM_Weight/ViewModels/InvoiceInWindowViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceInWindowViewModel.cs @@ -366,7 +366,7 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 现在是在此处初始化了表格数据 public void OnNavigatedTo(NavigationContext navigationContext) { - RequestData(); + RequestData(); } //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建 diff --git a/DM_Weight/ViewModels/InvoiceOutWindowViewModel.cs b/DM_Weight/ViewModels/InvoiceOutWindowViewModel.cs index 5a8ad09..2a83157 100644 --- a/DM_Weight/ViewModels/InvoiceOutWindowViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceOutWindowViewModel.cs @@ -252,7 +252,7 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 现在是在此处初始化了表格数据 public void OnNavigatedTo(NavigationContext navigationContext) { - RequestData(); + RequestData(); } //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建 diff --git a/DM_Weight/ViewModels/MachineRecordWindowViewModel.cs b/DM_Weight/ViewModels/MachineRecordWindowViewModel.cs index 49e121e..3347d65 100644 --- a/DM_Weight/ViewModels/MachineRecordWindowViewModel.cs +++ b/DM_Weight/ViewModels/MachineRecordWindowViewModel.cs @@ -151,7 +151,23 @@ namespace DM_Weight.ViewModels }); } - + public DelegateCommand DragTakeCheckInCommand + { + get => new DelegateCommand(() => + { + GridReportUtil.PrintReportDrugTakeCheckIn(StartDate, EndDate,1); + }); + } + + + public DelegateCommand DragTakeCheckIn2Command + { + get => new DelegateCommand(() => + { + GridReportUtil.PrintReportDrugTakeCheckIn(StartDate, EndDate,2); + }); + } + void ReportInitialize() { @@ -170,8 +186,8 @@ namespace DM_Weight.ViewModels //取出Type决定页面显示内容 Type = navigationContext.Parameters.GetValue("Type"); - //查询表格数据 - RequestData(); + //查询表格数据 + RequestData(); } diff --git a/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs index 1768039..2d4d5d6 100644 --- a/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs @@ -15,12 +15,14 @@ using DM_Weight.select; using DM_Weight.util; using DM_Weight.msg; using Prism.Events; +using log4net.Repository.Hierarchy; +using log4net; namespace DM_Weight.ViewModels { public class OrderTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime { - + private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDrugWindowViewModel)); private int _pageNum = 1; public int PageNum { @@ -72,6 +74,8 @@ namespace DM_Weight.ViewModels public OrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator) { + + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入OrderTakeDrugWindowViewModel构造函数"); _dialogService = DialogService; _eventAggregator = eventAggregator; } @@ -244,8 +248,21 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 现在是在此处初始化了表格数据 public void OnNavigatedTo(NavigationContext navigationContext) { + + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入OrderTakeDrugWindowViewModel.OnNavigatedTo函数"); + _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent); - RequestData(); + Task.Factory.StartNew(() => + { + + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入OnNavigatedTo请求数据线程"); + RequestData(); + + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】结束OnNavigatedTo请求数据线程"); + }); + + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】结束OrderTakeDrugWindowViewModel.OnNavigatedTo函数"); + } //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建 diff --git a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs index 2eda931..b23ace2 100644 --- a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs +++ b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs @@ -88,7 +88,7 @@ namespace DM_Weight.ViewModels { logger.Error(e); } - + break; // 打开失败 case EventType.OPENERROR: @@ -176,12 +176,12 @@ namespace DM_Weight.ViewModels List queryData = SqlSugarHelper.Db.Queryable() .Where(cs => cs.DrugId == MachineRecord.DrugId) .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")) - .WhereIF(MachineRecord.ManuNo != null,cs => cs.ManuNo == MachineRecord.ManuNo) + .WhereIF(MachineRecord.ManuNo != null, cs => cs.ManuNo == MachineRecord.ManuNo) .OrderBy(cs => cs.DrawerNo) .OrderBy(cs => cs.ColNo) .ToList(); ChannelStocks = queryData; - if(ChannelStocks.Count > 0) + if (ChannelStocks.Count > 0) { ChannelStock = ChannelStocks[0]; } @@ -202,7 +202,8 @@ namespace DM_Weight.ViewModels _portUtil.ColNos = new int[] { ChannelStock.ColNo }; _portUtil.DrawerNo = ChannelStock.DrawerNo; _portUtil.Start(); - } else + } + else { AlertMsg alertMsg = new AlertMsg { @@ -224,51 +225,64 @@ namespace DM_Weight.ViewModels { get => new DelegateCommand(() => { + if (MachineRecord.ReturnQuantity2>0&&(MachineRecord.CanReturnQuantity - ReturnQuantity) != 0) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "归还数目与实际数目不符", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + IsFinishClick = false; + return; + } + IsFinishClick = true; string InvoiceId = "RETURN_" + CurrentTimeMillis(); + var f = SqlSugarHelper.Db.UseTran(() => + { + + // 更新数据 库存信息 + SqlSugarHelper.Db.Updateable(new ChannelStock() { - - // 更新数据 库存信息 - SqlSugarHelper.Db.Updateable(new ChannelStock() - { - Quantity = ChannelStock.Quantity + ReturnQuantity, - Id = ChannelStock.Id, - }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand(); + Quantity = ChannelStock.Quantity + ReturnQuantity, + Id = ChannelStock.Id, + }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand(); - // 获取更新完库存后的药品库存 - List nowChannels = SqlSugarHelper.Db.Queryable() - .Where(cs => cs.MachineId.Equals(ChannelStock.MachineId)) - .Where(cs => cs.DrugId.Equals(ChannelStock.DrugId)) - .Where(cs => cs.DrawerType == 1) - .ToList(); - // 更新数据 取药记录 设置还药数量、状态 - SqlSugarHelper.Db.Updateable(new MachineRecord() - { - ReturnQuantity1 = MachineRecord.ReturnQuantity1 + ReturnQuantity, - Id = MachineRecord.Id, - Status = (MachineRecord.CanReturnQuantity - ReturnQuantity) == 0 ? 2 : 1, - }).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand(); + // 获取更新完库存后的药品库存 + List nowChannels = SqlSugarHelper.Db.Queryable() + .Where(cs => cs.MachineId.Equals(ChannelStock.MachineId)) + .Where(cs => cs.DrugId.Equals(ChannelStock.DrugId)) + .Where(cs => cs.DrawerType == 1) + .ToList(); + // 更新数据 取药记录 设置还药数量、状态 + SqlSugarHelper.Db.Updateable(new MachineRecord() + { + ReturnQuantity1 = MachineRecord.ReturnQuantity1 + ReturnQuantity, + Id = MachineRecord.Id, + Status = (MachineRecord.CanReturnQuantity - ReturnQuantity) == 0 ? 2 : 1, + }).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand(); - // 保存数据 还药记录 - SqlSugarHelper.Db.Insertable(new MachineRecord() - { - MachineId = ChannelStock.MachineId, - DrawerNo = ChannelStock.DrawerNo, - ColNo = ChannelStock.ColNo, - DrugId = ChannelStock.DrugId, - ManuNo = ChannelStock.ManuNo, - EffDate = !String.IsNullOrEmpty(ChannelStock.EffDate) ? DateTime.ParseExact(ChannelStock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, - Operator = HomeWindowViewModel.Operator?.Id, - OperationTime = DateTime.Now, - Quantity = ReturnQuantity, - Type = 31, - InvoiceId = InvoiceId, - GetId = MachineRecord.Id, - StockQuantity = nowChannels.Sum(it => it.Quantity) - }).ExecuteCommand(); - return true; - }); + // 保存数据 还药记录 + SqlSugarHelper.Db.Insertable(new MachineRecord() + { + MachineId = ChannelStock.MachineId, + DrawerNo = ChannelStock.DrawerNo, + ColNo = ChannelStock.ColNo, + DrugId = ChannelStock.DrugId, + ManuNo = ChannelStock.ManuNo, + EffDate = !String.IsNullOrEmpty(ChannelStock.EffDate) ? DateTime.ParseExact(ChannelStock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, + Operator = HomeWindowViewModel.Operator?.Id, + OperationTime = DateTime.Now, + Quantity = ReturnQuantity, + Type = 31, + InvoiceId = InvoiceId, + GetId = MachineRecord.Id, + StockQuantity = nowChannels.Sum(it => it.Quantity) + }).ExecuteCommand(); + return true; + }); if (f.Data) { // 更新屏显库存 diff --git a/DM_Weight/ViewModels/ReturnDrugWindow2ViewModel.cs b/DM_Weight/ViewModels/ReturnDrugWindow2ViewModel.cs index 207c0bb..a8c07bc 100644 --- a/DM_Weight/ViewModels/ReturnDrugWindow2ViewModel.cs +++ b/DM_Weight/ViewModels/ReturnDrugWindow2ViewModel.cs @@ -236,7 +236,7 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 现在是在此处初始化了表格数据 public void OnNavigatedTo(NavigationContext navigationContext) { - RequestData(); + RequestData(); } //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建 diff --git a/DM_Weight/ViewModels/ReturnDrugWindowViewModel.cs b/DM_Weight/ViewModels/ReturnDrugWindowViewModel.cs index 90a184b..e8cd02c 100644 --- a/DM_Weight/ViewModels/ReturnDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/ReturnDrugWindowViewModel.cs @@ -12,12 +12,13 @@ using DM_Weight.Models; using DM_Weight.select; using DM_Weight.util; using SqlSugar; +using log4net; namespace DM_Weight.ViewModels { public class ReturnDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime { - + private readonly ILog logger = LogManager.GetLogger(typeof(ReturnDrugWindowViewModel)); IDialogService _dialogService; private DelegateCommand _rowSelected; @@ -26,6 +27,7 @@ namespace DM_Weight.ViewModels public ReturnDrugWindowViewModel(IDialogService DialogService) { + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入ReturnDrugWindowViewModel构造函数"); _dialogService = DialogService; } //刷新 @@ -191,7 +193,10 @@ namespace DM_Weight.ViewModels .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (mr) => mr.DrugInfo.DrugName.Contains(SearchValue)) .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (mr) => mr.DrugInfo.PyCode.Contains(SearchValue)) .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (mr) => mr.DrugInfo.DrugBarcode.Contains(SearchValue)) - .OrderBy(mr => mr.OperationTime,OrderByType.Desc) + .OrderBy(mr => mr.Operator != HomeWindowViewModel.Operator.Id) + .OrderBy(mr => mr.Operator) + .OrderBy(mr =>mr.OperationTime,OrderByType.Desc) + .ToList(); MachineRecords = queryData; } @@ -199,7 +204,14 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 现在是在此处初始化了表格数据 public void OnNavigatedTo(NavigationContext navigationContext) { - RequestData(); + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入OnNavigatedTo请求数据线程"); + Task.Factory.StartNew(() => + { + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入OnNavigatedTo请求数据线程"); + RequestData(); + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】结束OnNavigatedTo请求数据线程"); + }); + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】结束OnNavigatedTo请求数据线程"); } //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建 diff --git a/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs b/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs index 7f8dbcd..1fa61a2 100644 --- a/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs +++ b/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs @@ -184,6 +184,7 @@ namespace DM_Weight.ViewModels .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")) .Where(mr => mr.Type == 2) .Where(mr => mr.Status != 2) + .Where(mr=>mr.ReturnQuantity2<=0) .OrderBy(mr => mr.OperationTime,OrderByType.Desc) .OrderBy(mr => mr.Id) .ToList(); @@ -194,6 +195,17 @@ namespace DM_Weight.ViewModels { get => new DelegateCommand(() => { + int iCount= MachineRecords.FindAll(it => it.IsSelected).ToList().Count; + if(iCount > 1||iCount<=0) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "请选择且仅选择一条要归还数据记录", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + return; + } if (ChannelStock != null) { if (Status == 0) @@ -233,11 +245,14 @@ namespace DM_Weight.ViewModels { if (MachineRecords != null) { + bool bSelect= MachineRecordStock.IsSelected; + MachineRecords.ForEach(mr => mr.IsSelected = false); + MachineRecords = MachineRecords.Select(x => { if (x.Id == MachineRecordStock.Id) { - x.IsSelected = !x.IsSelected; + x.IsSelected = !bSelect; } return x; }).ToList(); @@ -256,8 +271,8 @@ namespace DM_Weight.ViewModels { IsFinishClick = true; List records = MachineRecords.FindAll(it => it.IsSelected).ToList(); - if (records.Count > 0 && records.Sum(it => it.Quantity - it.ReturnQuantity1) == ReturnQuantity) - { + //if (records.Count > 0 && records.Sum(it => it.Quantity - it.ReturnQuantity1) == ReturnQuantity) + //{ string InvoiceId = "RETURN_" + CurrentTimeMillis(); var f = SqlSugarHelper.Db.UseTran(() => { @@ -282,9 +297,9 @@ namespace DM_Weight.ViewModels // 更新数据 取药记录 设置还药数量、状态 SqlSugarHelper.Db.Updateable(new MachineRecord() { - ReturnQuantity2 = _MachineRecord.Quantity - _MachineRecord.ReturnQuantity1, + ReturnQuantity2 =ReturnQuantity, // _MachineRecord.Quantity - _MachineRecord.ReturnQuantity1, Id = _MachineRecord.Id, - Status = 2, + Status = (_MachineRecord.Quantity - ReturnQuantity) == 0 ? 2 : 1,// 2, }).UpdateColumns(it => new { it.ReturnQuantity2, it.Status }).ExecuteCommand(); // 保存数据 还药空瓶记录 @@ -336,17 +351,18 @@ namespace DM_Weight.ViewModels } Status = 0; IsFinishClick = false; - RequestClose?.Invoke(new DialogResult(ButtonResult.OK)); - } else - { - AlertMsg alertMsg = new AlertMsg - { - Message = "归还数目与实际数目不符", - Type = MsgType.ERROR, - }; - _eventAggregator.GetEvent().Publish(alertMsg); - IsFinishClick = false; - } + //RequestClose?.Invoke(new DialogResult(ButtonResult.OK)); + //} + //else + //{ + // AlertMsg alertMsg = new AlertMsg + // { + // Message = "归还数目与实际数目不符", + // Type = MsgType.ERROR, + // }; + // _eventAggregator.GetEvent().Publish(alertMsg); + // IsFinishClick = false; + //} }, () => !IsFinishClick && ReturnQuantity > 0).ObservesProperty(() => IsFinishClick).ObservesProperty(() => ReturnQuantity); } @@ -365,7 +381,28 @@ namespace DM_Weight.ViewModels Status = 0; }); } + /// + /// 继续归还 + /// + public DelegateCommand ContinueCommand + { + get => new DelegateCommand(() => + { + }); + } + /// + /// 退出 + /// + public DelegateCommand QuitCommand + { + get => new DelegateCommand(() => + { + Status = 0; + // 关闭当前窗口 + RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); + }); + } public DelegateCommand BtnCloseCommand { get => new DelegateCommand(() => diff --git a/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs b/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs index 727a6a3..a462246 100644 --- a/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs +++ b/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs @@ -100,7 +100,7 @@ namespace DM_Weight.ViewModels //还空瓶只能选择一条进行归还 AlertMsg alertMsg = new AlertMsg { - Message = "请选择一条可归还数量不为0的数据进行归还", + Message = "请选择一条且可归还数量不为0的数据进行归还", Type = MsgType.ERROR, }; _eventAggregator.GetEvent().Publish(alertMsg); @@ -287,8 +287,8 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 public void OnNavigatedTo(NavigationContext navigationContext) { - //查询表格数据 - RequestData(); + //查询表格数据 + RequestData(); } void RequestData() diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs index 619a102..8709f83 100644 --- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs +++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs @@ -111,7 +111,7 @@ namespace DM_Weight.ViewModels else { - if (p.Id != 6) + if (p != null && p.Children != null && it != null && it.Children != null && p.Id != 6) { it.Children.ToList().ForEach(it3 => { @@ -127,7 +127,7 @@ namespace DM_Weight.ViewModels AllPremissions.RemoveAt(index); } } - else + else if(index>=0) { AllPremissions.RemoveAt(index); } @@ -350,13 +350,13 @@ namespace DM_Weight.ViewModels defaultAll.Add(sysset); #endregion #region 退出菜单 - PremissionDm logout = new PremissionDm - { - Id = 6, - PremissionName = "退出", - PremissionImage = "/Images/TbExit.png", - }; - defaultAll.Add(logout); + //PremissionDm logout = new PremissionDm + //{ + // Id = 6, + // PremissionName = "退出", + // PremissionImage = "/Images/TbExit.png", + //}; + //defaultAll.Add(logout); #endregion } @@ -684,8 +684,8 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 public void OnNavigatedTo(NavigationContext navigationContext) { - //查询表格数据 - RequestData(); + //查询表格数据 + RequestData(); } diff --git a/DM_Weight/ViewModels/SelfAddWindowViewModel.cs b/DM_Weight/ViewModels/SelfAddWindowViewModel.cs index 0d32a55..98fc0ba 100644 --- a/DM_Weight/ViewModels/SelfAddWindowViewModel.cs +++ b/DM_Weight/ViewModels/SelfAddWindowViewModel.cs @@ -14,11 +14,14 @@ using DM_Weight.select; using DM_Weight.util; using Prism.Events; using DM_Weight.msg; +using log4net.Repository.Hierarchy; +using log4net; namespace DM_Weight.ViewModels { public class SelfAddWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime { + private readonly ILog logger = LogManager.GetLogger(typeof(SelfAddWindowViewModel)); IDialogService _dialogService; IEventAggregator _eventAggregator; @@ -48,6 +51,7 @@ namespace DM_Weight.ViewModels public SelfAddWindowViewModel(IDialogService DialogService,IEventAggregator eventAggregator) { + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入SelfAddWindowViewModel构造函数"); _dialogService = DialogService; _eventAggregator = eventAggregator; } @@ -183,7 +187,14 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 现在是在此处初始化了表格数据 public void OnNavigatedTo(NavigationContext navigationContext) { - RequestChannelData(); + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入OnNavigatedTo请求数据线程"); + Task.Factory.StartNew(() => + { + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入OnNavigatedTo请求数据线程"); + RequestChannelData(); + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】结束OnNavigatedTo请求数据线程"); + }); + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】结束OnNavigatedTo请求数据线程"); } //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建 diff --git a/DM_Weight/ViewModels/StockListWindowViewModel.cs b/DM_Weight/ViewModels/StockListWindowViewModel.cs index 18b26d3..31098b7 100644 --- a/DM_Weight/ViewModels/StockListWindowViewModel.cs +++ b/DM_Weight/ViewModels/StockListWindowViewModel.cs @@ -16,11 +16,13 @@ using DM_Weight.select; using DM_Weight.util; using System.ComponentModel; using System.Windows.Data; +using log4net; namespace DM_Weight.ViewModels { public class StockListWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime { + private readonly ILog logger = LogManager.GetLogger(typeof(StockListWindowViewModel)); public static List StaticSelects = new() { @@ -89,6 +91,7 @@ namespace DM_Weight.ViewModels IDialogService _dialogService; public StockListWindowViewModel(IDialogService dialogService) { + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入StockListWindowViewModel构造函数"); _dialogService = dialogService; } private ChannelStock? _selectedChannel; @@ -171,8 +174,8 @@ namespace DM_Weight.ViewModels .OrderBy(cs => cs.ColNo) .ToList(); - ICollectionView vw = CollectionViewSource.GetDefaultView(q); - vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo")); + //ICollectionView vw = CollectionViewSource.GetDefaultView(q); + //vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo")); ChannelStocks = q; } @@ -180,7 +183,14 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 现在是在此处初始化了表格数据 public void OnNavigatedTo(NavigationContext navigationContext) { - RequestData(); + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入OnNavigatedTo请求数据线程"); + Task.Factory.StartNew(() => + { + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】进入OnNavigatedTo请求数据线程"); + RequestData(); + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】结束OnNavigatedTo请求数据线程"); + }); + logger.Info($"用户【{HomeWindowViewModel.Operator?.Nickname}】结束OnNavigatedTo请求数据线程"); } diff --git a/DM_Weight/ViewModels/UserManagerWindowViewModel.cs b/DM_Weight/ViewModels/UserManagerWindowViewModel.cs index 2ecadba..01e789b 100644 --- a/DM_Weight/ViewModels/UserManagerWindowViewModel.cs +++ b/DM_Weight/ViewModels/UserManagerWindowViewModel.cs @@ -164,8 +164,8 @@ namespace DM_Weight.ViewModels //接收导航传过来的参数 public void OnNavigatedTo(NavigationContext navigationContext) { - //查询表格数据 - RequestData(); + //查询表格数据 + RequestData(); } diff --git a/DM_Weight/Views/Dialog/ReturnEmptyDialog.xaml b/DM_Weight/Views/Dialog/ReturnEmptyDialog.xaml index 04394f2..90a3072 100644 --- a/DM_Weight/Views/Dialog/ReturnEmptyDialog.xaml +++ b/DM_Weight/Views/Dialog/ReturnEmptyDialog.xaml @@ -143,7 +143,7 @@ - + @@ -196,6 +196,24 @@ Content="归还" Command="{Binding OpenDrawer}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DM_Weight/Views/DrugTakeCheckInWindow.xaml.cs b/DM_Weight/Views/DrugTakeCheckInWindow.xaml.cs new file mode 100644 index 0000000..0d2c350 --- /dev/null +++ b/DM_Weight/Views/DrugTakeCheckInWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace DM_Weight.Views +{ + /// + /// DrugTakeCheckInWindow.xaml 的交互逻辑 + /// + public partial class DrugTakeCheckInWindow : UserControl + { + public DrugTakeCheckInWindow() + { + InitializeComponent(); + } + } +} diff --git a/DM_Weight/Views/HomeWindow.xaml b/DM_Weight/Views/HomeWindow.xaml index 68f9654..e001ab2 100644 --- a/DM_Weight/Views/HomeWindow.xaml +++ b/DM_Weight/Views/HomeWindow.xaml @@ -97,6 +97,11 @@ CommandParameter="Operator" Foreground="{DynamicResource MaterialDesignLightForeground}" Header="修改密码" /> + @@ -120,9 +125,11 @@ + +