diff --git a/DM_Weight/App.config b/DM_Weight/App.config index a8bf66e..9d4738d 100644 --- a/DM_Weight/App.config +++ b/DM_Weight/App.config @@ -3,7 +3,7 @@ - + - - + + \ No newline at end of file diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs index 269d384..cb6ba5e 100644 --- a/DM_Weight/App.xaml.cs +++ b/DM_Weight/App.xaml.cs @@ -280,6 +280,9 @@ namespace DM_Weight containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); + //报表修改药品 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); logger.Info("结束APP-RegisterTypes"); diff --git a/DM_Weight/ViewModels/AddReportDateViewModel.cs b/DM_Weight/ViewModels/AddReportDateViewModel.cs index 9ab0f03..97d472b 100644 --- a/DM_Weight/ViewModels/AddReportDateViewModel.cs +++ b/DM_Weight/ViewModels/AddReportDateViewModel.cs @@ -1,4 +1,5 @@ -using DM_Weight.Models; +using DM_Weight.Common; +using DM_Weight.Models; using DM_Weight.msg; using DM_Weight.Port; using DM_Weight.Report; @@ -8,9 +9,11 @@ using Prism.Commands; using Prism.Events; using Prism.Mvvm; using Prism.Regions; +using Prism.Services.Dialogs; using System; using System.Collections; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Configuration; using System.Linq; using System.Text; @@ -63,8 +66,9 @@ namespace DM_Weight.ViewModels //查询9种药品 - private List _rejectionReportList = new List();//= staticRejectionReportList; - public List RejectionReportList + IDialogService _dialogService; + private ObservableCollection _rejectionReportList = new ObservableCollection();//= staticRejectionReportList; + public ObservableCollection RejectionReportList { get => _rejectionReportList; set @@ -198,9 +202,10 @@ namespace DM_Weight.ViewModels // } //} IEventAggregator _eventAggregator; - public AddReportDateViewModel(IEventAggregator eventAggregator) + public AddReportDateViewModel(IEventAggregator eventAggregator, IDialogService DialogService) { _eventAggregator = eventAggregator; + _dialogService = DialogService; //vm = this; } @@ -375,7 +380,29 @@ namespace DM_Weight.ViewModels } } } + //修改药品 + public DelegateCommand EditDrugName + { + get => new DelegateCommand(async () => + { + // 此处延时1毫秒,等待页面渲染 + await Task.Delay(TimeSpan.FromMilliseconds(1)); + DialogParameters dialogParameters = new DialogParameters(); + //dialogParameters.Add("orderInfo", SelectedOrder); + DialogServiceExtensions.ShowDialogHost(_dialogService, "ReportDrugNameDialog", dialogParameters, DoDialogResult, "RootDialog"); + }); + } + private void DoDialogResult(IDialogResult dialogResult) + { + // 委托 被动执行 被子窗口执行 + // dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态 + //if(dialogResult.Result == ButtonResult.OK) + //{ + GetAllDrugInfos(); + //} + //MessageBox.Show("返回值:" + dialogResult.Result.ToString()); + } public DelegateCommand Download { get => new DelegateCommand(() => @@ -383,158 +410,6 @@ namespace DM_Weight.ViewModels GridReportUtil.RejectionReport(StartDate, EndDate); }); } - ////发药数据添加 - //public DelegateCommand AddSendReportDateCommand - //{ - // get => new DelegateCommand(() => - // { - // if (SelectedDrug != null) - // { - // int iRet=SqlSugarHelper.Db.Insertable(new RejectionReport() - // { - // SendDate = DateTime.Parse(RejReport.SendDate.ToString("yyyy-MM-dd HH:mm")), - // SendUser = SendUser.Nickname, - // ReceiveUser = SendUserCheck.Nickname,//Jiaojie_ChannelStocks - // RealNum= RejReport.RealNum, - // DrugId = SelectedDrug.DrugId, - // DrugName = SelectedDrug.DrugName, - // DrugSpec = SelectedDrug.DrugSpec, - // BaseNum = SelectedDrug.drugBase.BaseQuantity + "支",//总基数 - // OperationTime=DateTime.Now, - - // }).ExecuteCommand(); - // if (iRet > 0) - // { - // AlertMsg alertMsg = new AlertMsg - // { - // Message = "保存成功", - // Type = MsgType.INFO - // }; - // _eventAggregator.GetEvent().Publish(alertMsg); - - // } - // else - // { - // 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 AddReturnReportDateCommand - //{ - // get => new DelegateCommand(() => - // { - // if (SelectedDrug != null) - // { - // int iRet= SqlSugarHelper.Db.Insertable(new RejectionReport() - // { - // ReturnTime = DateTime.Parse(RejReport.ReturnTime).ToString("yyyy-MM-dd HH:mm"), - // ReturnUser = User.UserName, - // ReturnReceiveUser = UserCheck.Nickname,//Jiaojie_ChannelStocks - // InfactNum= RejReport.InfactNum, - // EmptyNum= RejReport.EmptyNum, - // DrugId = SelectedDrug.DrugId, - // DrugName = SelectedDrug.DrugName, - // DrugSpec = SelectedDrug.DrugSpec, - // BaseNum = SelectedDrug + "支", - // }).ExecuteCommand(); - // if (iRet > 0) - // { - // AlertMsg alertMsg = new AlertMsg - // { - // Message = "保存成功", - // Type = MsgType.INFO - // }; - // _eventAggregator.GetEvent().Publish(alertMsg); - - // } - // else - // { - // 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 AddUseReportDateCommand - //{ - // get => new DelegateCommand(() => - // { - // if (SelectedDrug != null) - // { - // int iRet= SqlSugarHelper.Db.Insertable(new RejectionReport() - // { - // //ReturnTime = DateTime.Parse(RejReport.ReturnTime).ToString("yyyy-MM-dd HH:mm"), - // AddUser = User.UserName, - // AddCheckUser = UserCheck.Nickname,//Jiaojie_ChannelStocks - // UseBottle = RejReport.UseBottle, - // UseOrderNo = RejReport.UseOrderNo, - // UseAdd=RejReport.UseAdd, - // DrugId = SelectedDrug.DrugId, - // DrugName = SelectedDrug.DrugName, - // DrugSpec = SelectedDrug.DrugSpec, - // BaseNum = SelectedDrug + "支", - // }).ExecuteCommand(); - // if(iRet>0) - // { - // AlertMsg alertMsg = new AlertMsg - // { - // Message = "保存成功", - // Type = MsgType.INFO - // }; - // _eventAggregator.GetEvent().Publish(alertMsg); - - // } - // else - // { - // 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 AddReportDateCommand { get => new DelegateCommand(() => @@ -554,12 +429,12 @@ namespace DM_Weight.ViewModels SendDate = SendDate, SendUser = SendUser.Nickname, ReceiveUser = SendUserCheck.Nickname,//Jiaojie_ChannelStocks - RealNum = report.RealNum, + RealNum = report.RealNum, //实发、实物、空安瓿三个值一样,要求写一个即可避免他们重复输入 ReturnTime = ReturnTime, ReturnUser = ReturnUser.UserName, ReturnReceiveUser = ReturnUserCheck.Nickname,//Jiaojie_ChannelStocks - InfactNum = report.InfactNum, - EmptyNum = report.EmptyNum, + InfactNum = report.RealNum, + EmptyNum = report.RealNum, AddUser = AddUser.UserName, AddCheckUser = AddUserCheck.Nickname,//Jiaojie_ChannelStocks UseBottle = report.UseBottle, @@ -652,11 +527,12 @@ namespace DM_Weight.ViewModels string str = "SELECT d.drug_id,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,d.manufactory,d.max_stock,CONCAT(drug_name,' / ',drug_spec,' / ',manufactory) as drug_name_spec,db.baseQuantity as PyCode FROM `drug_info` d left join drug_base db on d.drug_id=db.drugid and db.machine_id='DM3'"; if (ConfigurationManager.AppSettings["DrugNames"] != null) { - str += " where d.drug_name in (" + ConfigurationManager.AppSettings["DrugNames"] + ")"; + str += " where d.drug_id in (" + CommonClass.ReadAppSetting("DrugNames") + ")"; } List DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList(); if (DrugInfos != null && DrugInfos.Count > 0) { + RejectionReportList.Clear(); for (int i = 0; i < DrugInfos.Count; i++) { RejectionReport report = new RejectionReport(); diff --git a/DM_Weight/ViewModels/ReportDrugNameDialogViewModel.cs b/DM_Weight/ViewModels/ReportDrugNameDialogViewModel.cs new file mode 100644 index 0000000..c598bb5 --- /dev/null +++ b/DM_Weight/ViewModels/ReportDrugNameDialogViewModel.cs @@ -0,0 +1,169 @@ +using DM_Weight.Common; +using DM_Weight.Models; +using DM_Weight.Port; +using DM_Weight.util; +using Prism.Commands; +using Prism.Mvvm; +using Prism.Regions; +using Prism.Services.Dialogs; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Unity; + +namespace DM_Weight.ViewModels +{ + public class ReportDrugNameDialogViewModel : BindableBase, IRegionMemberLifetime, IDialogAware + { + private string? _reportDrugName; + public string? ReportDrugName + { + get => _reportDrugName; + set => SetProperty(ref _reportDrugName, value); + } + private DrugInfo? _leftDrug; + public DrugInfo? LeftDrug + { + get => _leftDrug; + set => SetProperty(ref _leftDrug, value); + } + private ObservableCollection _rightDrugNameList = new ObservableCollection(); + + public ObservableCollection RightDrugNameList + { + get => _rightDrugNameList; + set => SetProperty(ref _rightDrugNameList, value); + } + + private DrugInfo? _rightDrugName; + public DrugInfo? RightDrugName + { + get => _rightDrugName; + set => SetProperty(ref _rightDrugName, value); + } + + public static ObservableCollection defaultAll = new ObservableCollection(); + private ObservableCollection _allPremissions = defaultAll; + + public event Action RequestClose; + + public ObservableCollection AllPremissions + { + get => _allPremissions; + set => SetProperty(ref _allPremissions, value); + } + + public bool KeepAlive => false; + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + void RequestData() + { + AllPremissions = new ObservableCollection(); + string str = "SELECT d.drug_id,CONCAT(drug_name,' / ',drug_spec,' / ',manufactory) as drug_name_spec FROM `drug_info` d left join drug_base db on d.drug_id=db.drugid and db.machine_id='DM3'"; + if (ConfigurationManager.AppSettings["DrugNames"] != null) + { + str += " where d.drug_id not in (" + CommonClass.ReadAppSetting("DrugNames") + ")"; + } + List DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugId).ToList(); + + AllPremissions.AddRange(DrugInfos); + + + string strRight = "SELECT d.drug_id,CONCAT(drug_name,' / ',drug_spec,' / ',manufactory) as drug_name_spec FROM `drug_info` d left join drug_base db on d.drug_id=db.drugid and db.machine_id='DM3'"; + if (ConfigurationManager.AppSettings["DrugNames"] != null) + { + strRight += " where d.drug_id in (" + CommonClass.ReadAppSetting("DrugNames")+ ")"; + } + List DrugInfosRight = SqlSugarHelper.Db.SqlQueryable(strRight).OrderBy(di => di.DrugId).ToList(); + RightDrugNameList.AddRange(DrugInfosRight); + } + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + } + + public void OnDialogOpened(IDialogParameters parameters) + { + //查询报表中的药品名称 + RequestData(); + } + + public DelegateCommand RightSelectedItemChangedCommand + { + get => new DelegateCommand((DrugInfo _selected) => + { + RightDrugName = _selected; + }); + } + public DelegateCommand ToRight => new DelegateCommand(() => + { + if (LeftDrug != null) + { + RightDrugNameList.Insert(0, LeftDrug); + AllPremissions.RemoveAt(AllPremissions.ToList().FindIndex(it => it.DrugId == LeftDrug.DrugId)); + } + }); + public DelegateCommand ToLeft => new DelegateCommand(() => + { + if (RightDrugName != null) + { + AllPremissions.Insert(0, RightDrugName); + RightDrugNameList.RemoveAt(RightDrugNameList.ToList().FindIndex(it => it.DrugId == RightDrugName.DrugId)); + } + }); + public DelegateCommand LeftSelectedItemChangedCommand + { + get => new DelegateCommand((DrugInfo _selected) => + { + LeftDrug = _selected; + }); + } + + //保存 + public DelegateCommand AddRole + { + get=>new DelegateCommand(()=> + { + if(RightDrugNameList!=null&& RightDrugNameList.Count>0) + { + string strDrugInfo = string.Empty; + for (int i = 0; i < RightDrugNameList.Count; i++) + { + strDrugInfo +="'"+ RightDrugNameList[i].DrugId+"',"; + } + if (!string.IsNullOrEmpty(strDrugInfo)) + { + strDrugInfo = strDrugInfo.Substring(0, strDrugInfo.Length - 1); + CommonClass.SaveAppSetting("DrugNames", strDrugInfo); + // 关闭当前窗口 + RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); + } + } + }); + } + + public string Title => ""; + public DelegateCommand BtnCloseCommand + { + get => new DelegateCommand(() => + { + //DialogParameters parameters = new DialogParameters(); + //parameters.Add("",); + // 关闭当前窗口 + RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); + }); + } + } +} diff --git a/DM_Weight/Views/AddReportDate.xaml b/DM_Weight/Views/AddReportDate.xaml index 74b2e02..e309794 100644 --- a/DM_Weight/Views/AddReportDate.xaml +++ b/DM_Weight/Views/AddReportDate.xaml @@ -41,6 +41,15 @@ Style="{StaticResource MaterialDesignOutlinedDatePicker}" /> + + + + + + + + + + + + + + + + + + +