状态转换添加 //确认核销、刷新
录像机添加监测日志 channel_stock添加dm_machine_record表id值 drug_info表添加药品类型字段 machinerecord添加已核销数量、核销数量 orderinfo添加machineId 添加SurgicalSchedule实体 添加SurgicalScheduleDetail实体 添加手术核销、还空瓶销毁页面
This commit is contained in:
		
							parent
							
								
									17a6ddd0da
								
							
						
					
					
						commit
						0d2d10deab
					
				| 
						 | 
					@ -33,7 +33,7 @@
 | 
				
			||||||
		<!-- 登录顺序,指定先登录的人的名称有效值,只有在登录模式等于2时才会生效; 发药人:【operator】审核人:【reviewer】 -->
 | 
							<!-- 登录顺序,指定先登录的人的名称有效值,只有在登录模式等于2时才会生效; 发药人:【operator】审核人:【reviewer】 -->
 | 
				
			||||||
		<add key="firstLogin" value="operator" />
 | 
							<add key="firstLogin" value="operator" />
 | 
				
			||||||
		<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
 | 
							<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
 | 
				
			||||||
		<add key="returnDrugMode" value="1" />
 | 
							<add key="returnDrugMode" value="2" />
 | 
				
			||||||
		<!-- 自动退出时间,单位秒,为0时不自动退出 -->
 | 
							<!-- 自动退出时间,单位秒,为0时不自动退出 -->
 | 
				
			||||||
		<add key="autoExit" value="0"/>
 | 
							<add key="autoExit" value="0"/>
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
| 
						 | 
					@ -60,7 +60,7 @@
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		<!--是否有冰箱抽屉0无,1有一个,2两个-->
 | 
							<!--是否有冰箱抽屉0无,1有一个,2两个-->
 | 
				
			||||||
		<add key="hasFridge" value="1"/>
 | 
							<add key="hasFridge" value="0"/>
 | 
				
			||||||
		<!-- 冰箱的串口号 -->
 | 
							<!-- 冰箱的串口号 -->
 | 
				
			||||||
		<add key="FridgePortPath" value="COM7" />
 | 
							<add key="FridgePortPath" value="COM7" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,6 +44,7 @@ namespace DM_Weight
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected override Window CreateShell()
 | 
					        protected override Window CreateShell()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Info("进入APP-CreateShell");
 | 
				
			||||||
            //UI线程未捕获异常处理事件
 | 
					            //UI线程未捕获异常处理事件
 | 
				
			||||||
            this.DispatcherUnhandledException += OnDispatcherUnhandledException;
 | 
					            this.DispatcherUnhandledException += OnDispatcherUnhandledException;
 | 
				
			||||||
            //Task线程内未捕获异常处理事件
 | 
					            //Task线程内未捕获异常处理事件
 | 
				
			||||||
| 
						 | 
					@ -51,6 +52,7 @@ namespace DM_Weight
 | 
				
			||||||
            //多线程异常
 | 
					            //多线程异常
 | 
				
			||||||
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
 | 
					            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            logger.Info("进入APP-CreateShell-2");
 | 
				
			||||||
            return Container.Resolve<MainWindow>();
 | 
					            return Container.Resolve<MainWindow>();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,6 +88,8 @@ namespace DM_Weight
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
 | 
					        protected override void RegisterTypes(IContainerRegistry containerRegistry)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            logger.Info("进入APP-RegisterTypes");
 | 
				
			||||||
            // 注入日志
 | 
					            // 注入日志
 | 
				
			||||||
            XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
 | 
					            XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
 | 
				
			||||||
            //containerRegistry.RegisterInstance<ILog>(LogManager.GetLogger(""));
 | 
					            //containerRegistry.RegisterInstance<ILog>(LogManager.GetLogger(""));
 | 
				
			||||||
| 
						 | 
					@ -95,7 +99,7 @@ namespace DM_Weight
 | 
				
			||||||
            // 指纹机工具
 | 
					            // 指纹机工具
 | 
				
			||||||
            containerRegistry.RegisterSingleton<FingerprintUtil>();
 | 
					            containerRegistry.RegisterSingleton<FingerprintUtil>();
 | 
				
			||||||
            // 组态屏工具
 | 
					            // 组态屏工具
 | 
				
			||||||
            containerRegistry.RegisterSingleton<ScreenUtil>();
 | 
					            //containerRegistry.RegisterSingleton<ScreenUtil>();
 | 
				
			||||||
            // 录像机
 | 
					            // 录像机
 | 
				
			||||||
            containerRegistry.RegisterSingleton<CHKFunction>();
 | 
					            containerRegistry.RegisterSingleton<CHKFunction>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,6 +148,14 @@ namespace DM_Weight
 | 
				
			||||||
            containerRegistry.RegisterDialog<MultiOrderTakeDialog>();
 | 
					            containerRegistry.RegisterDialog<MultiOrderTakeDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<MultiOrderTakeDialog,MultiOrderTakeDialogViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<MultiOrderTakeDialog,MultiOrderTakeDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //手术排程
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<SurgeryTakeWindow, SurgeryTakeWindowViewModel>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<SurgeryTakeDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<SurgeryTakeDialog, SurgeryTakeDialogViewModel>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<AddSurgeryDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<AddSurgeryDialog, AddSurgeryDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #region 加药
 | 
					            #region 加药
 | 
				
			||||||
| 
						 | 
					@ -189,12 +201,18 @@ namespace DM_Weight
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<OrderReturnDialog, OrderReturnDialogViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<OrderReturnDialog, OrderReturnDialogViewModel>();
 | 
				
			||||||
            // 还空瓶页面
 | 
					            // 还空瓶页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ReturnEmptyWindow, ReturnEmptyWindowViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<ReturnEmptyWindow, ReturnEmptyWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //空瓶销毁页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<ReturnEmptyDestoryWindow, ReturnEmptyDestoryWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 归还空瓶模态框
 | 
					            // 归还空瓶模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<ReturnEmptyDialog>();
 | 
					            containerRegistry.RegisterDialog<ReturnEmptyDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ReturnEmptyDialog, ReturnEmptyDialogViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<ReturnEmptyDialog, ReturnEmptyDialogViewModel>();
 | 
				
			||||||
            // 空瓶销毁模态框
 | 
					            // 空瓶销毁模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<DestoryEmptyDialog>();
 | 
					            containerRegistry.RegisterDialog<DestoryEmptyDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<DestoryEmptyDialog, DestoryEmptyDialogViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<DestoryEmptyDialog, DestoryEmptyDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #region 库存管理
 | 
					            #region 库存管理
 | 
				
			||||||
| 
						 | 
					@ -245,6 +263,8 @@ namespace DM_Weight
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            logger.Info("结束APP-RegisterTypes");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,6 +73,18 @@ namespace DM_Weight.Converter
 | 
				
			||||||
                    return Visibility.Collapsed;
 | 
					                    return Visibility.Collapsed;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            //确认核销、刷新
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("ConfirmVsRefresh"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (status == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Visible;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Collapsed;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return Visibility.Collapsed;
 | 
					            return Visibility.Collapsed;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,142 +32,200 @@ namespace DM_Weight.HIKVISION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public CHKFunction()
 | 
					        public CHKFunction()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Info("CHKFunction");
 | 
				
			||||||
            HIKInit();
 | 
					            HIKInit();
 | 
				
			||||||
            HIKLogin();
 | 
					            HIKLogin();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool HIKInit()
 | 
					        public bool HIKInit()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            m_bInitSDK = CHCNetSDK.NET_DVR_Init();
 | 
					            try
 | 
				
			||||||
            if (m_bInitSDK == false)
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //MessageBox.Show("NET_DVR_Init error!");
 | 
					
 | 
				
			||||||
                //return;
 | 
					
 | 
				
			||||||
                logger.Info("NET_DVR_Init error!");
 | 
					                logger.Info("HIKInit");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                m_bInitSDK = CHCNetSDK.NET_DVR_Init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"HIKInit-{m_bInitSDK}");
 | 
				
			||||||
 | 
					                if (m_bInitSDK == false)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //MessageBox.Show("NET_DVR_Init error!");
 | 
				
			||||||
 | 
					                    //return;
 | 
				
			||||||
 | 
					                    logger.Info("NET_DVR_Init error!");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //保存SDK日志 To save the SDK log
 | 
				
			||||||
 | 
					                    CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            catch (Exception ex)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //保存SDK日志 To save the SDK log
 | 
					                logger.Info($"HIKInit Exception:{ex.Message}");
 | 
				
			||||||
                CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return m_bInitSDK;
 | 
					            return m_bInitSDK;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public int HIKLogin()
 | 
					        public int HIKLogin()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            string ip = ReadApp.ReadAppSetting("HIKIP");
 | 
					            try
 | 
				
			||||||
            string port = ReadApp.ReadAppSetting("HIKPort");
 | 
					 | 
				
			||||||
            string userName = ReadApp.ReadAppSetting("HIKUser");
 | 
					 | 
				
			||||||
            string password = ReadApp.ReadAppSetting("HIKPassword");
 | 
					 | 
				
			||||||
            if (HKUserId < 0)
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info("HIKLogin");
 | 
				
			||||||
                struLogInfo = new CHCNetSDK.NET_DVR_USER_LOGIN_INFO();
 | 
					                string ip = ReadApp.ReadAppSetting("HIKIP");
 | 
				
			||||||
 | 
					                string port = ReadApp.ReadAppSetting("HIKPort");
 | 
				
			||||||
                //设备IP地址或者域名
 | 
					                string userName = ReadApp.ReadAppSetting("HIKUser");
 | 
				
			||||||
                byte[] byIP = System.Text.Encoding.Default.GetBytes(ip);
 | 
					                string password = ReadApp.ReadAppSetting("HIKPassword");
 | 
				
			||||||
                struLogInfo.sDeviceAddress = new byte[129];
 | 
					 | 
				
			||||||
                byIP.CopyTo(struLogInfo.sDeviceAddress, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //设备用户名
 | 
					 | 
				
			||||||
                byte[] byUserName = System.Text.Encoding.Default.GetBytes(userName);
 | 
					 | 
				
			||||||
                struLogInfo.sUserName = new byte[64];
 | 
					 | 
				
			||||||
                byUserName.CopyTo(struLogInfo.sUserName, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //设备密码
 | 
					 | 
				
			||||||
                byte[] byPassword = System.Text.Encoding.Default.GetBytes(password);
 | 
					 | 
				
			||||||
                struLogInfo.sPassword = new byte[64];
 | 
					 | 
				
			||||||
                byPassword.CopyTo(struLogInfo.sPassword, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                struLogInfo.wPort = ushort.Parse(port);//设备服务端口号
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //if (LoginCallBack == null)
 | 
					 | 
				
			||||||
                //{
 | 
					 | 
				
			||||||
                //    LoginCallBack = new CHCNetSDK.LOGINRESULTCALLBACK(cbLoginCallBack);//注册回调函数                    
 | 
					 | 
				
			||||||
                //}
 | 
					 | 
				
			||||||
                //struLogInfo.cbLoginResult = LoginCallBack;
 | 
					 | 
				
			||||||
                struLogInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                DeviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V40();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //登录设备 Login the device
 | 
					 | 
				
			||||||
                HKUserId = CHCNetSDK.NET_DVR_Login_V40(ref struLogInfo, ref DeviceInfo);
 | 
					 | 
				
			||||||
                if (HKUserId < 0)
 | 
					                if (HKUserId < 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    iLastErr = CHCNetSDK.NET_DVR_GetLastError();
 | 
					
 | 
				
			||||||
                    str = "NET_DVR_Login_V40 failed, error code= " + iLastErr; //登录失败,输出错误号
 | 
					                    struLogInfo = new CHCNetSDK.NET_DVR_USER_LOGIN_INFO();
 | 
				
			||||||
                    logger.Info(str);
 | 
					
 | 
				
			||||||
 | 
					                    //设备IP地址或者域名
 | 
				
			||||||
 | 
					                    byte[] byIP = System.Text.Encoding.Default.GetBytes(ip);
 | 
				
			||||||
 | 
					                    struLogInfo.sDeviceAddress = new byte[129];
 | 
				
			||||||
 | 
					                    byIP.CopyTo(struLogInfo.sDeviceAddress, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //设备用户名
 | 
				
			||||||
 | 
					                    byte[] byUserName = System.Text.Encoding.Default.GetBytes(userName);
 | 
				
			||||||
 | 
					                    struLogInfo.sUserName = new byte[64];
 | 
				
			||||||
 | 
					                    byUserName.CopyTo(struLogInfo.sUserName, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //设备密码
 | 
				
			||||||
 | 
					                    byte[] byPassword = System.Text.Encoding.Default.GetBytes(password);
 | 
				
			||||||
 | 
					                    struLogInfo.sPassword = new byte[64];
 | 
				
			||||||
 | 
					                    byPassword.CopyTo(struLogInfo.sPassword, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    struLogInfo.wPort = ushort.Parse(port);//设备服务端口号
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //if (LoginCallBack == null)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    LoginCallBack = new CHCNetSDK.LOGINRESULTCALLBACK(cbLoginCallBack);//注册回调函数                    
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                    //struLogInfo.cbLoginResult = LoginCallBack;
 | 
				
			||||||
 | 
					                    struLogInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    DeviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V40();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //登录设备 Login the device
 | 
				
			||||||
 | 
					                    HKUserId = CHCNetSDK.NET_DVR_Login_V40(ref struLogInfo, ref DeviceInfo);
 | 
				
			||||||
 | 
					                    if (HKUserId < 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        iLastErr = CHCNetSDK.NET_DVR_GetLastError();
 | 
				
			||||||
 | 
					                        str = "NET_DVR_Login_V40 failed, error code= " + iLastErr; //登录失败,输出错误号
 | 
				
			||||||
 | 
					                        logger.Info(str);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //登录成功
 | 
				
			||||||
 | 
					                        //MessageBox.Show("Login Success!");
 | 
				
			||||||
 | 
					                        logger.Info("Login Success!");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    //登录成功
 | 
					                    //注销登录 Logout the device
 | 
				
			||||||
                    //MessageBox.Show("Login Success!");
 | 
					                    if (m_lRealHandle >= 0)
 | 
				
			||||||
                    logger.Info("Login Success!");
 | 
					                    {
 | 
				
			||||||
                }
 | 
					                        //MessageBox.Show("Please stop live view firstly");
 | 
				
			||||||
 | 
					                        logger.Info("Please stop live view firstly");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (!CHCNetSDK.NET_DVR_Logout(HKUserId))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        iLastErr = CHCNetSDK.NET_DVR_GetLastError();
 | 
				
			||||||
 | 
					                        str = "NET_DVR_Logout failed, error code= " + iLastErr;
 | 
				
			||||||
 | 
					                        logger.Info(str);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    HKUserId = -1;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            catch (Exception ex)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //注销登录 Logout the device
 | 
					 | 
				
			||||||
                if (m_lRealHandle >= 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    //MessageBox.Show("Please stop live view firstly");
 | 
					 | 
				
			||||||
                    logger.Info("Please stop live view firstly");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (!CHCNetSDK.NET_DVR_Logout(HKUserId))
 | 
					                logger.Info($"HIKLogin Exception:{ex.Message}");
 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    iLastErr = CHCNetSDK.NET_DVR_GetLastError();
 | 
					 | 
				
			||||||
                    str = "NET_DVR_Logout failed, error code= " + iLastErr;
 | 
					 | 
				
			||||||
                    logger.Info(str);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                HKUserId = -1;
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return HKUserId;
 | 
					            return HKUserId;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void HIKLoginOut()
 | 
					        public void HIKLoginOut()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (m_lRealHandle >= 0)
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                bool stopRealPlay = CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
 | 
					
 | 
				
			||||||
                logger.Info($"录像机NET_DVR_StopRealPlay接口返回{stopRealPlay}");
 | 
					                if (m_lRealHandle >= 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool stopRealPlay = CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
 | 
				
			||||||
 | 
					                    logger.Info($"录像机NET_DVR_StopRealPlay接口返回{stopRealPlay}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (HKUserId >= 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool logout = CHCNetSDK.NET_DVR_Logout(HKUserId);
 | 
				
			||||||
 | 
					                    logger.Info($"录像机NET_DVR_Logout接口返回{logout}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (m_bInitSDK == true)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool cleanUp = CHCNetSDK.NET_DVR_Cleanup();
 | 
				
			||||||
 | 
					                    logger.Info($"录像机NET_DVR_Cleanup接口返回{cleanUp}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (HKUserId >= 0)
 | 
					            catch (Exception ex)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                bool logout = CHCNetSDK.NET_DVR_Logout(HKUserId);
 | 
					                logger.Info($"HIKLoginOut Exception{ex.Message}");
 | 
				
			||||||
                logger.Info($"录像机NET_DVR_Logout接口返回{logout}");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (m_bInitSDK == true)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                bool cleanUp = CHCNetSDK.NET_DVR_Cleanup();
 | 
					 | 
				
			||||||
                logger.Info($"录像机NET_DVR_Cleanup接口返回{cleanUp}");
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool HIKStartDVRRecord()
 | 
					        public bool HIKStartDVRRecord()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            bool isStart = CHCNetSDK.NET_DVR_StartDVRRecord(HKUserId, 0xffff, 0);
 | 
					            bool isStart = false;
 | 
				
			||||||
            logger.Info($"录像机NET_DVR_StartDVRRecord接口返回{isStart}");
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                isStart = CHCNetSDK.NET_DVR_StartDVRRecord(HKUserId, 0xffff, 0);
 | 
				
			||||||
 | 
					                logger.Info($"录像机NET_DVR_StartDVRRecord接口返回{isStart}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"HIKStartDVRRecord Exception{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            return isStart;
 | 
					            return isStart;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public bool HIKStopDVRRecord()
 | 
					        public bool HIKStopDVRRecord()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            bool isStop = CHCNetSDK.NET_DVR_StopDVRRecord(HKUserId, 0xffff);
 | 
					            bool isStop = false;
 | 
				
			||||||
            logger.Info($"录像机NET_DVR_StopDVRRecord接口返回{isStop}");
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                isStop = CHCNetSDK.NET_DVR_StopDVRRecord(HKUserId, 0xffff);
 | 
				
			||||||
 | 
					                logger.Info($"录像机NET_DVR_StopDVRRecord接口返回{isStop}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"HIKStopDVRRecord Exception{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            return isStop;
 | 
					            return isStop;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public void HIK_DVR_TIME()
 | 
					        public void HIK_DVR_TIME()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            UInt32 dwReturn = 0;
 | 
					            try
 | 
				
			||||||
            Int32 nSize = Marshal.SizeOf(m_struTimeCfg);
 | 
					 | 
				
			||||||
            IntPtr ptrTimeCfg = Marshal.AllocHGlobal(nSize);
 | 
					 | 
				
			||||||
            Marshal.StructureToPtr(m_struTimeCfg, ptrTimeCfg, false);
 | 
					 | 
				
			||||||
            if (CHCNetSDK.NET_DVR_GetDVRConfig(HKUserId, CHCNetSDK.NET_DVR_GET_TIMECFG, -1, ptrTimeCfg, (UInt32)nSize, ref dwReturn))
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                m_struTimeCfg = (CHCNetSDK.NET_DVR_TIME)Marshal.PtrToStructure(ptrTimeCfg, typeof(CHCNetSDK.NET_DVR_TIME));
 | 
					                UInt32 dwReturn = 0;
 | 
				
			||||||
                logger.Info($"录像机时间接口{Convert.ToString(m_struTimeCfg.dwYear)}- {Convert.ToString(m_struTimeCfg.dwMonth)}- {Convert.ToString(m_struTimeCfg.dwDay)}- {Convert.ToString(m_struTimeCfg.dwHour)}- {Convert.ToString(m_struTimeCfg.dwMinute)}- {Convert.ToString(m_struTimeCfg.dwSecond)}");
 | 
					                Int32 nSize = Marshal.SizeOf(m_struTimeCfg);
 | 
				
			||||||
 | 
					                IntPtr ptrTimeCfg = Marshal.AllocHGlobal(nSize);
 | 
				
			||||||
 | 
					                Marshal.StructureToPtr(m_struTimeCfg, ptrTimeCfg, false);
 | 
				
			||||||
 | 
					                if (CHCNetSDK.NET_DVR_GetDVRConfig(HKUserId, CHCNetSDK.NET_DVR_GET_TIMECFG, -1, ptrTimeCfg, (UInt32)nSize, ref dwReturn))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    m_struTimeCfg = (CHCNetSDK.NET_DVR_TIME)Marshal.PtrToStructure(ptrTimeCfg, typeof(CHCNetSDK.NET_DVR_TIME));
 | 
				
			||||||
 | 
					                    logger.Info($"录像机时间接口{Convert.ToString(m_struTimeCfg.dwYear)}- {Convert.ToString(m_struTimeCfg.dwMonth)}- {Convert.ToString(m_struTimeCfg.dwDay)}- {Convert.ToString(m_struTimeCfg.dwHour)}- {Convert.ToString(m_struTimeCfg.dwMinute)}- {Convert.ToString(m_struTimeCfg.dwSecond)}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"HIK_DVR_TIME Exception{ex.Message}");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,5 +187,9 @@ namespace DM_Weight.Models
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public DrugPleaseClaim PleaseClaim { get; set; }
 | 
					        public DrugPleaseClaim PleaseClaim { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //dm_machine_record表id值
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int? MachineRecordId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,7 @@ using System.Linq;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using System.Windows.Controls;
 | 
					using System.Windows.Controls;
 | 
				
			||||||
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
using SqlSugar;
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.Models
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
| 
						 | 
					@ -23,7 +24,7 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 主键
 | 
					        /// 主键
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "Applyid")]
 | 
					        [SugarColumn(ColumnName = "Applyid",IsPrimaryKey =true)]
 | 
				
			||||||
        public int Applyid { get; set; }
 | 
					        public int Applyid { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 药品请领单号
 | 
					        /// 药品请领单号
 | 
				
			||||||
| 
						 | 
					@ -114,5 +115,8 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        [Navigate(NavigateType.ManyToOne, nameof(DrugPleaseClaimId))]
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(DrugPleaseClaimId))]
 | 
				
			||||||
        public DrugPleaseClaim drugPleaseClaim { get; set; }
 | 
					        public DrugPleaseClaim drugPleaseClaim { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public List<DrugPleaseManuNo> ManuNoList { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,13 @@ namespace DM_Weight.Models
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "max_stock")]
 | 
					        [SugarColumn(ColumnName = "max_stock")]
 | 
				
			||||||
        public int? MaxStock { get; set; }
 | 
					        public int? MaxStock { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品类型
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName ="drug_type")]
 | 
				
			||||||
 | 
					        public string DrugType { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //[SugarColumn(IsIgnore=true)]
 | 
					        //[SugarColumn(IsIgnore=true)]
 | 
				
			||||||
        [Navigate(NavigateType.OneToMany, nameof(ChannelStock.DrugId), nameof(DrugId))]//BookA表中的studenId
 | 
					        [Navigate(NavigateType.OneToMany, nameof(ChannelStock.DrugId), nameof(DrugId))]//BookA表中的studenId
 | 
				
			||||||
        public List<ChannelStock> channelStocks { get; set; }
 | 
					        public List<ChannelStock> channelStocks { get; set; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,7 @@ using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
using SqlSugar;
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.Models
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
| 
						 | 
					@ -54,7 +55,8 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /// 批次(多条)
 | 
					        /// 批次(多条)
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "drug_manu_no")]
 | 
					        [SugarColumn(ColumnName = "drug_manu_no")]
 | 
				
			||||||
        public string DrugManuNo { get; set; }
 | 
					        [JsonProperty("drug_manu_no")]
 | 
				
			||||||
 | 
					        public string _DrugManuNos { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 备注1
 | 
					        /// 备注1
 | 
				
			||||||
| 
						 | 
					@ -124,5 +126,9 @@ namespace DM_Weight.Models
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        [Navigate(NavigateType.OneToOne, nameof(DrugId))]
 | 
					        [Navigate(NavigateType.OneToOne, nameof(DrugId))]
 | 
				
			||||||
        public DrugInfo DrugInfo { get; set; }
 | 
					        public DrugInfo DrugInfo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private List<DrugPleaseManuNo> manuNoList = new List<DrugPleaseManuNo>();
 | 
				
			||||||
 | 
					        //public List<DrugPleaseManuNo> ManuNoList { get=>manuNoList; set=>{ DrugManuNo}; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using SqlSugar;
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
| 
						 | 
					@ -9,7 +10,7 @@ using System.Threading.Tasks;
 | 
				
			||||||
namespace DM_Weight.Models
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    [SugarTable("dm_machine_record")]
 | 
					    [SugarTable("dm_machine_record")]
 | 
				
			||||||
    public class MachineRecord
 | 
					    public class MachineRecord : BindableBase
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 主键 
 | 
					        /// 主键 
 | 
				
			||||||
| 
						 | 
					@ -41,7 +42,7 @@ namespace DM_Weight.Models
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //[SugarColumn(ColumnName = "check_quantity")]
 | 
					        //[SugarColumn(ColumnName = "check_quantity")]
 | 
				
			||||||
        //public int? CheckQuantity { get; set; }
 | 
					        //public int? CheckQuantity { get; set; }
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 批号 
 | 
					        /// 批号 
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
| 
						 | 
					@ -106,14 +107,16 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /// 退药量 
 | 
					        /// 退药量 
 | 
				
			||||||
        /// 默认值: 0
 | 
					        /// 默认值: 0
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private int returnQuantity1;
 | 
				
			||||||
        [SugarColumn(ColumnName = "return_quantity1", IsOnlyIgnoreInsert = true)]
 | 
					        [SugarColumn(ColumnName = "return_quantity1", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
        public int ReturnQuantity1 { get; set; }
 | 
					        public int ReturnQuantity1 { get => returnQuantity1; set => SetProperty(ref returnQuantity1, value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 退空瓶量 
 | 
					        /// 退空瓶量 
 | 
				
			||||||
        /// 默认值: 0
 | 
					        /// 默认值: 0
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private int returnQuantity2;
 | 
				
			||||||
        [SugarColumn(ColumnName = "return_quantity2", IsOnlyIgnoreInsert = true)]
 | 
					        [SugarColumn(ColumnName = "return_quantity2", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
        public int ReturnQuantity2 { get; set; }
 | 
					        public int ReturnQuantity2 { get => returnQuantity2; set => SetProperty(ref returnQuantity2, value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 取药记录id 
 | 
					        /// 取药记录id 
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
| 
						 | 
					@ -124,8 +127,8 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /// 默认值: 0
 | 
					        /// 默认值: 0
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "is_destroy", IsOnlyIgnoreInsert = true)]
 | 
					        [SugarColumn(ColumnName = "is_destroy", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
        public int? IsDestroy { get; set; }      
 | 
					        public int? IsDestroy { get; set; }
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 销毁操作人 
 | 
					        /// 销毁操作人 
 | 
				
			||||||
        /// 默认值: 0
 | 
					        /// 默认值: 0
 | 
				
			||||||
| 
						 | 
					@ -145,10 +148,47 @@ namespace DM_Weight.Models
 | 
				
			||||||
        public int CanReturnQuantity
 | 
					        public int CanReturnQuantity
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => Quantity - ReturnQuantity1 - ReturnQuantity2;
 | 
					            get => Quantity - ReturnQuantity1 - ReturnQuantity2;
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public bool IsSelected { get; set; }
 | 
					        public bool IsSelected { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 已核销数量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private int hasCheckNum;
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int HasCheckNum
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => hasCheckNum;
 | 
				
			||||||
 | 
					            set => SetProperty(ref hasCheckNum, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int checkQuantity;
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 核销数量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int CheckQuantity
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => checkQuantity;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (value > Quantity - hasCheckNum)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    throw new ArgumentException("核销数量不能大于取药数量");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                //退空瓶
 | 
				
			||||||
 | 
					                ReturnQuantity2 = value + hasCheckNum;
 | 
				
			||||||
 | 
					                //退药量
 | 
				
			||||||
 | 
					                ReturnQuantity1 = Quantity - value - hasCheckNum;
 | 
				
			||||||
 | 
					                SetProperty(ref checkQuantity, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToMany, nameof(SurgicalScheduleDetail.GetRecordId))]
 | 
				
			||||||
 | 
					        public List<SurgicalScheduleDetail> _SurgicalScheduleDetailLst { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -184,6 +184,14 @@ namespace DM_Weight.Models
 | 
				
			||||||
        [SugarColumn(ColumnName = "apply_status")]
 | 
					        [SugarColumn(ColumnName = "apply_status")]
 | 
				
			||||||
        public int ApplyStatus { get;set; }
 | 
					        public int ApplyStatus { get;set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,176 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("surgical_schedule")]
 | 
				
			||||||
 | 
					    public class SurgicalSchedule
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术ID
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "operation_id")]
 | 
				
			||||||
 | 
					        public string OperationId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 患者id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "patient_id")]
 | 
				
			||||||
 | 
					        public string PatientId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 患者姓名
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "patient_name")]
 | 
				
			||||||
 | 
					        public string PName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 住院号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "hospital_no")]
 | 
				
			||||||
 | 
					        public string HospitalNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 床号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "bed_no")]
 | 
				
			||||||
 | 
					        public string BedNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 性别
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "sex")]
 | 
				
			||||||
 | 
					        public string Sex { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 年龄
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "age")]
 | 
				
			||||||
 | 
					        public string Age { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 出生日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "birthday")]
 | 
				
			||||||
 | 
					        public DateTime Birthday { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 身份证号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id_number")]
 | 
				
			||||||
 | 
					        public string IdNumber { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 住院病区
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ward_code")]
 | 
				
			||||||
 | 
					        public string WardCode { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 联系电话
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "link_tel")]
 | 
				
			||||||
 | 
					        public string LinkTel { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 联系地址
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "link_addr")]
 | 
				
			||||||
 | 
					        public string LinkAddr { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 入院日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "in_date")]
 | 
				
			||||||
 | 
					        public string Indate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 入院诊断
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "in_diagnosis")]
 | 
				
			||||||
 | 
					        public string Indiagnosis { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 医生姓名
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "doctor_name")]
 | 
				
			||||||
 | 
					        public string DoctorName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术间代码
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "op_room_code")]
 | 
				
			||||||
 | 
					        public string OpRoomCode { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术间名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "op_room_name")]
 | 
				
			||||||
 | 
					        public string OpRoomName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 麻醉医生编码
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ana_doctor_code")]
 | 
				
			||||||
 | 
					        public string AnaDoctorCode { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 麻醉医生姓名
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ana_doctor_name")]
 | 
				
			||||||
 | 
					        public string AnaDoctorName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术开始时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "begin_time")]
 | 
				
			||||||
 | 
					        public DateTime BeginTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术计划开始时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "schedule_time")]
 | 
				
			||||||
 | 
					        public DateTime ScheduleTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术完成时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "end_time")]
 | 
				
			||||||
 | 
					        public DateTime EndTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 数据插入时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "insert_time")]
 | 
				
			||||||
 | 
					        public DateTime InsertTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 最后一次更新时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "update_time")]
 | 
				
			||||||
 | 
					        public DateTime UpdateTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// HIS状态1:新开2:作废
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "his_state")]
 | 
				
			||||||
 | 
					        public int HisState { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///取药状态0未取1已取2已还
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "dm_status")]
 | 
				
			||||||
 | 
					        public int DmStatus { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "anaesthesia")]
 | 
				
			||||||
 | 
					        public string Anaesthesia { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToMany, nameof(SurgicalSchedule.OperationId))]
 | 
				
			||||||
 | 
					        public SurgicalScheduleDetail _SurgicalScheduleDetail { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,68 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("surgical_schedule_detail")]
 | 
				
			||||||
 | 
					    public class SurgicalScheduleDetail
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id",IsPrimaryKey =true)]
 | 
				
			||||||
 | 
					        public  int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "operation_id")]
 | 
				
			||||||
 | 
					        public string OperationId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 取药记录id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "get_record_id")]
 | 
				
			||||||
 | 
					        public int GetRecordId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 处方数量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "quantity")]
 | 
				
			||||||
 | 
					        public int Quantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 批次
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manu_no")]
 | 
				
			||||||
 | 
					        public string ManuNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 效期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "eff_date")]
 | 
				
			||||||
 | 
					        public string EffDate { get;set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 状态
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "status")]
 | 
				
			||||||
 | 
					        public int Status { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 操作人
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "insert_user_id")]
 | 
				
			||||||
 | 
					        public int? InsertUserId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -400,7 +400,7 @@
 | 
				
			||||||
	"Parameter":[
 | 
						"Parameter":[
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,7 +252,7 @@
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,7 +252,7 @@
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,7 +252,7 @@
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,7 +252,7 @@
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -602,7 +602,7 @@
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -314,7 +314,7 @@
 | 
				
			||||||
	"Parameter":[
 | 
						"Parameter":[
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -101,7 +101,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (msg.WindowName == "DrawerAddDrugWindow")
 | 
					            if (msg.WindowName == "AddDrugControl")
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                switch (msg.EventType)
 | 
					                switch (msg.EventType)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -140,10 +140,6 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (msg.WindowName == "AddDrugControl")
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -188,8 +184,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Status = 1;
 | 
					                Status = 1;
 | 
				
			||||||
                _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					                _portUtil.SpeakAsync($"正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    //List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
					                    //List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,949 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.select;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using MaterialDesignThemes.Wpf;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using Prism.Services.Dialogs;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Media;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class AddSurgeryDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string Title => "录入手术";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<MachineRecord> machineRecordList;
 | 
				
			||||||
 | 
					        public List<MachineRecord> MachineRecordList { get => machineRecordList; set => SetProperty(ref machineRecordList, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private SolidColorBrush _colorBrush;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public SolidColorBrush SnackbarBackground
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _colorBrush;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _colorBrush, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _snackbarMessageQueue;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string? _searchValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件 查询字段值
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? SearchValue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _searchValue; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _searchValue, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static List<OrderTakeSelect> StaticSelects = new()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "DrugName",
 | 
				
			||||||
 | 
					                Name = "药品名称"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "PyCode",
 | 
				
			||||||
 | 
					                Name = "拼音码"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "DrugBarcode",
 | 
				
			||||||
 | 
					                Name = "药品条码"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "DrugId",
 | 
				
			||||||
 | 
					                Name = "药品编码"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<OrderTakeSelect> Selects
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _selects; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _selects, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static List<Dictionary<int, string>> keyValuePairs = new List<Dictionary<int, string>>()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            new Dictionary<int, string>(){ {0,"男"} },new Dictionary<int, string>(){ { 1, "女" } }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        public List<Dictionary<int, string>> SexKeyValue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return keyValuePairs; }
 | 
				
			||||||
 | 
					            set { SetProperty(ref keyValuePairs, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Dictionary<int, string> _selectedSex = keyValuePairs[0];
 | 
				
			||||||
 | 
					        public Dictionary<int, string> SelectedSex
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _selectedSex;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _selectedSex, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private SurgicalSchedule surgicalSchedule = new SurgicalSchedule();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public SurgicalSchedule _SurgicalSchedule
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => surgicalSchedule;
 | 
				
			||||||
 | 
					            set => SetProperty(ref surgicalSchedule, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _totalCount = 0;
 | 
				
			||||||
 | 
					        public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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 = 5;
 | 
				
			||||||
 | 
					        public int PageSize
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _pageSize;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _pageSize, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int Status
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _status; set => SetProperty(ref _status, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        List<ChannelStock> ReturnStockLst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
				
			||||||
 | 
					        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件 查询字段
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public OrderTakeSelect SelectedItem
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _selectedItem; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _selectedItem, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private MachineRecord selectedRecord;
 | 
				
			||||||
 | 
					        public MachineRecord SelectedRecord { get => selectedRecord; set => SetProperty(ref selectedRecord, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Status == 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        public AddSurgeryDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            surgicalSchedule.ScheduleTime= DateTime.Now;
 | 
				
			||||||
 | 
					            _SurgicalSchedule.Indate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
 | 
				
			||||||
 | 
					            _dialogService = DialogService;
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public async void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int totalCount = 0;
 | 
				
			||||||
 | 
					            MachineRecordList = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
				
			||||||
 | 
					                .Includes<DrugInfo>(mr => mr.DrugInfo)
 | 
				
			||||||
 | 
					                .Includes<UserList>(mr => mr.User)
 | 
				
			||||||
 | 
					                .Includes<SurgicalScheduleDetail>(mr => mr._SurgicalScheduleDetailLst)
 | 
				
			||||||
 | 
					                .Where(mr => mr.Type == 2)
 | 
				
			||||||
 | 
					                .Where(mr => mr.Status < 2)
 | 
				
			||||||
 | 
					                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
 | 
					                //.WhereIF(QueryDate != null, mr => mr.OperationTime.ToString("yyyy-MM-dd") == QueryDate)
 | 
				
			||||||
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (mr) => mr.DrugInfo.DrugId.ToString().Contains(SearchValue))
 | 
				
			||||||
 | 
					                .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)
 | 
				
			||||||
 | 
					               .ToPageList(PageNum, PageSize, ref totalCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            MachineRecordList.ForEach(mr => mr.HasCheckNum = mr._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity));
 | 
				
			||||||
 | 
					            TotalCount = totalCount;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand BtnCloseCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 关闭当前窗口
 | 
				
			||||||
 | 
					                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 选中行事件
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand RowSelected
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (SelectedRecord != null && selectedRecord.Id != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    MachineRecordList = MachineRecordList.Select(x =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (x.Id == SelectedRecord.Id)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            x.IsSelected = !x.IsSelected;
 | 
				
			||||||
 | 
					                            if (x.IsSelected)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                if (SelectedRecord._SurgicalScheduleDetailLst != null && SelectedRecord._SurgicalScheduleDetailLst.Count > 0)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    //已经核销数
 | 
				
			||||||
 | 
					                                    int HasCheckNum = SelectedRecord._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity);
 | 
				
			||||||
 | 
					                                    x.CheckQuantity = SelectedRecord.Quantity - HasCheckNum;
 | 
				
			||||||
 | 
					                                    x.ReturnQuantity1 = SelectedRecord.Quantity - HasCheckNum - x.CheckQuantity;
 | 
				
			||||||
 | 
					                                    x.ReturnQuantity2 = HasCheckNum + x.CheckQuantity;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                else
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    x.CheckQuantity = SelectedRecord.Quantity;
 | 
				
			||||||
 | 
					                                    x.ReturnQuantity1 = 0;
 | 
				
			||||||
 | 
					                                    x.ReturnQuantity2 = SelectedRecord.Quantity;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                x.CheckQuantity = 0;
 | 
				
			||||||
 | 
					                                x.ReturnQuantity1 = 0;
 | 
				
			||||||
 | 
					                                x.ReturnQuantity2 = 0;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return x;
 | 
				
			||||||
 | 
					                    }).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 保存并核销
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand AddSurgeryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!string.IsNullOrEmpty(_SurgicalSchedule.OperationId))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //检查是否有该手术号,手术号不能重复
 | 
				
			||||||
 | 
					                   int iCount=  SqlSugarHelper.Db.Queryable<SurgicalSchedule>().Where(ss => ss.OperationId == _SurgicalSchedule.OperationId).Count();
 | 
				
			||||||
 | 
					                    if(iCount>0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                        SnackbarMessageQueue.Enqueue("该手术号已添加,请勿重复创建");
 | 
				
			||||||
 | 
					                        return;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    List<MachineRecord> RecordsLst = MachineRecordList.FindAll(rl => rl.IsSelected && rl.CheckQuantity > 0).ToList();
 | 
				
			||||||
 | 
					                    if (RecordsLst.Count > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        //string operationId = Guid.NewGuid().ToString();
 | 
				
			||||||
 | 
					                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Insertable(new SurgicalSchedule()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                PName = _SurgicalSchedule.PName,
 | 
				
			||||||
 | 
					                                Sex = SelectedSex.ContainsKey(0) is true ? SelectedSex[0] : SelectedSex[1],
 | 
				
			||||||
 | 
					                                Age = _SurgicalSchedule.Age,
 | 
				
			||||||
 | 
					                                IdNumber = _SurgicalSchedule.IdNumber,
 | 
				
			||||||
 | 
					                                OpRoomCode = _SurgicalSchedule.OpRoomCode,
 | 
				
			||||||
 | 
					                                OpRoomName = _SurgicalSchedule.OpRoomName,
 | 
				
			||||||
 | 
					                                OperationId = _SurgicalSchedule.OperationId,
 | 
				
			||||||
 | 
					                                ScheduleTime = _SurgicalSchedule.ScheduleTime,
 | 
				
			||||||
 | 
					                                InsertTime=DateTime.Now,
 | 
				
			||||||
 | 
					                                Indiagnosis=_SurgicalSchedule.Indiagnosis,
 | 
				
			||||||
 | 
					                                Indate=_SurgicalSchedule.Indate,
 | 
				
			||||||
 | 
					                                DmStatus = 1,
 | 
				
			||||||
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            for (int i = 0; i < RecordsLst.Count; i++)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Insertable(new SurgicalScheduleDetail()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    OperationId = _SurgicalSchedule.OperationId,
 | 
				
			||||||
 | 
					                                    GetRecordId = RecordsLst[i].Id,
 | 
				
			||||||
 | 
					                                    Quantity = RecordsLst[i].CheckQuantity,
 | 
				
			||||||
 | 
					                                    DrugId = RecordsLst[i].DrugId,
 | 
				
			||||||
 | 
					                                    ManuNo = RecordsLst[i].ManuNo,
 | 
				
			||||||
 | 
					                                    EffDate = RecordsLst[i].EffDate.ToString(),
 | 
				
			||||||
 | 
					                                    InsertUserId = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                int hasQuantity = RecordsLst[i]._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity);
 | 
				
			||||||
 | 
					                                int dmStatus = 0;
 | 
				
			||||||
 | 
					                                //已经全部挂上钩,修改dm_machine_record状态为完成
 | 
				
			||||||
 | 
					                                //if (hasQuantity + RecordsLst[i].CheckQuantity == RecordsLst[i].Quantity)
 | 
				
			||||||
 | 
					                                //{
 | 
				
			||||||
 | 
					                                //    dmStatus = 2;
 | 
				
			||||||
 | 
					                                //}
 | 
				
			||||||
 | 
					                                //else
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    dmStatus = 1;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    Status = dmStatus,
 | 
				
			||||||
 | 
					                                    Id = RecordsLst[i].Id
 | 
				
			||||||
 | 
					                                }).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.Id }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                        if (f.IsSuccess)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Message = "核销完成",
 | 
				
			||||||
 | 
					                                Type = MsgType.SUCCESS,
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                            // 关闭当前窗口
 | 
				
			||||||
 | 
					                            RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                            SnackbarMessageQueue.Enqueue("核销异常,未核销数据");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        int iRet = SqlSugarHelper.Db.Insertable(new SurgicalSchedule()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            PName = _SurgicalSchedule.PName,
 | 
				
			||||||
 | 
					                            Sex = SelectedSex.ContainsKey(0) is true ? SelectedSex[0] : SelectedSex[1],
 | 
				
			||||||
 | 
					                            Age = _SurgicalSchedule.Age,
 | 
				
			||||||
 | 
					                            IdNumber = _SurgicalSchedule.IdNumber,
 | 
				
			||||||
 | 
					                            OpRoomCode = _SurgicalSchedule.OpRoomCode,
 | 
				
			||||||
 | 
					                            OpRoomName = _SurgicalSchedule.OpRoomName,
 | 
				
			||||||
 | 
					                            OperationId = _SurgicalSchedule.OperationId,
 | 
				
			||||||
 | 
					                            ScheduleTime= _SurgicalSchedule.ScheduleTime,
 | 
				
			||||||
 | 
					                            Indiagnosis = _SurgicalSchedule.Indiagnosis,
 | 
				
			||||||
 | 
					                            Indate = _SurgicalSchedule.Indate,
 | 
				
			||||||
 | 
					                            InsertTime = DateTime.Now,
 | 
				
			||||||
 | 
					                            DmStatus = 0,
 | 
				
			||||||
 | 
					                            HisState=1
 | 
				
			||||||
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        if (iRet > 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Message = "手术录入成功,未核销药品",
 | 
				
			||||||
 | 
					                                Type = MsgType.SUCCESS,
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                            // 关闭当前窗口
 | 
				
			||||||
 | 
					                            RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                            SnackbarMessageQueue.Enqueue("手术录入失败");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue("手术号不能为空");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 全部归还(还药、还空瓶)
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand ReturnCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                List<MachineRecord> RecordsLst = MachineRecordList.FindAll(rl => rl.IsSelected && rl.CheckQuantity == 0).ToList();
 | 
				
			||||||
 | 
					                ReturnStockLst = new List<ChannelStock>();
 | 
				
			||||||
 | 
					                if (RecordsLst.Count > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //待还药的记录
 | 
				
			||||||
 | 
					                    List<MachineRecord> ReturnDrugLst = RecordsLst.Where(rl => rl.ReturnQuantity1 > 0).ToList();
 | 
				
			||||||
 | 
					                    //待还空瓶的记录
 | 
				
			||||||
 | 
					                    List<MachineRecord> ReturnEmptyLst = RecordsLst.Where(rl => rl.ReturnQuantity2 > 0).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    for (int i = 0; i < ReturnDrugLst.Count; i++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ChannelStock queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                                               .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
				
			||||||
 | 
					                                               .Where(cs => cs.DrugId == ReturnDrugLst[i].DrugId)
 | 
				
			||||||
 | 
					                                               .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
 | 
					                                               .Where(cs => cs.ManuNo == ReturnDrugLst[i].ManuNo)
 | 
				
			||||||
 | 
					                                               .OrderBy(cs => cs.Quantity).First();
 | 
				
			||||||
 | 
					                        if (queryData != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            queryData.AddQuantity = ReturnDrugLst[i].ReturnQuantity1;
 | 
				
			||||||
 | 
					                            queryData.MachineRecordId = ReturnDrugLst[i].Id;
 | 
				
			||||||
 | 
					                            ReturnStockLst.Add(queryData);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    for (int j = 0; j < ReturnEmptyLst.Count; j++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ChannelStock queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                                              .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
				
			||||||
 | 
					                                              .Where(cs => cs.DrugId == ReturnEmptyLst[j].DrugId)
 | 
				
			||||||
 | 
					                                              .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
 | 
					                                              //.Where(cs => cs.ManuNo == ReturnEmptyLst[j].ManuNo)
 | 
				
			||||||
 | 
					                                              .Where(cs => cs.DrawerType == 2)
 | 
				
			||||||
 | 
					                                              .OrderBy(cs => cs.Quantity).First();
 | 
				
			||||||
 | 
					                        if (queryData != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            queryData.ReturnQuantity = ReturnEmptyLst[j].ReturnQuantity2;
 | 
				
			||||||
 | 
					                            queryData.MachineRecordId = ReturnEmptyLst[j].Id;
 | 
				
			||||||
 | 
					                            ReturnStockLst.Add(queryData);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (ReturnStockLst != null && ReturnStockLst.Count > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ReturnStockLst = ReturnStockLst.OrderBy(cls => cls.DrawerNo).ToList();
 | 
				
			||||||
 | 
					                        //还药时AddQuantity有值;还空瓶时ReturnQuantity有值
 | 
				
			||||||
 | 
					                        enumerable = ReturnStockLst.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
				
			||||||
 | 
					                        enumerator = enumerable.GetEnumerator();
 | 
				
			||||||
 | 
					                        enumerator.MoveNext();
 | 
				
			||||||
 | 
					                        Status = 1;
 | 
				
			||||||
 | 
					                        OpenOneByOne();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                        SnackbarMessageQueue.Enqueue("选中数据未绑定库位,请先进行绑定库位");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue("未选中数据,或选中数据核销数量不为0");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 刷新
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand QueryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (msg.WindowName == "SurgeryTakeWindow")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
				
			||||||
 | 
					                int DrawerNo = grouping.Key;
 | 
				
			||||||
 | 
					                List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                switch (msg.EventType)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 抽屉打开
 | 
				
			||||||
 | 
					                    case EventType.DRAWEROPEN:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (channelStocks[0].process == 1)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                channelStocks.ForEach(it => it.process = 2);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 抽屉关闭
 | 
				
			||||||
 | 
					                    case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (channelStocks[0].process == 2)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                channelStocks.ForEach(it => it.process = 3);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
				
			||||||
 | 
					                            int DrawerNoBefore = groupingBefore.Key;
 | 
				
			||||||
 | 
					                            if (enumerator.MoveNext())
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
				
			||||||
 | 
					                                int DrawerNoAfter = groupingAfter.Key;
 | 
				
			||||||
 | 
					                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    Thread.Sleep(50);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                OpenOneByOne();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            // 已经全部取出
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Status = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                //保存数据
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                //TakeFinish();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 数量变化
 | 
				
			||||||
 | 
					                    case EventType.UPDATEQUANTITY:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 打开失败
 | 
				
			||||||
 | 
					                    case EventType.OPENERROR:
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = msg.Message,
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        Status = 0;
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void OpenOneByOne()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
				
			||||||
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            string drugName = channelStocks[0].DrugInfo.DrugName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int drugQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int emptyQuantity = channelStocks.Sum(cs => cs.ReturnQuantity);
 | 
				
			||||||
 | 
					            string speakTxt = $"正在打开{DrawerNo}号抽屉,请将{drugName}的";
 | 
				
			||||||
 | 
					            if (drugQuantity > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                speakTxt += $"{drugQuantity}个药放入抽屉!";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (emptyQuantity > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                speakTxt += $"{emptyQuantity}个空瓶放入抽屉!";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync(speakTxt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 发送取药数量
 | 
				
			||||||
 | 
					            //singleChannels.ForEach(it =>
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    try
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //        _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //    catch (Exception ex)
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            Message = $"打开抽屉异常{ex.Message}",
 | 
				
			||||||
 | 
					            //            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					            //        };
 | 
				
			||||||
 | 
					            //        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            _portUtil.WindowName = "SurgeryTakeWindow";
 | 
				
			||||||
 | 
					            _portUtil.BoardType = channelStocks.Count > 0 ? channelStocks[0].BoardType : 1;
 | 
				
			||||||
 | 
					            _portUtil.ColNos = channelStocks.Select(it => it.ColNo).ToArray();
 | 
				
			||||||
 | 
					            _portUtil.DrawerNo = DrawerNo;
 | 
				
			||||||
 | 
					            _portUtil.Start();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _isFinishClick = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsFinishClick { get => _isFinishClick; set => SetProperty(ref _isFinishClick, value); }
 | 
				
			||||||
 | 
					        //完成
 | 
				
			||||||
 | 
					        private void TakeFinish()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            IsFinishClick = true;
 | 
				
			||||||
 | 
					            bool bRet = false;
 | 
				
			||||||
 | 
					            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                for (int i = 0; i < ReturnStockLst.Count; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ChannelStock it = ReturnStockLst[i];
 | 
				
			||||||
 | 
					                    int quantity = 0;
 | 
				
			||||||
 | 
					                    if (it.AddQuantity > 0)  //还药
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        quantity = it.AddQuantity;
 | 
				
			||||||
 | 
					                        bRet = ReturnDrug(it);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        quantity = it.ReturnQuantity;
 | 
				
			||||||
 | 
					                        bRet = ReturnEmpty(it);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (!bRet)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    // 更新屏显库存
 | 
				
			||||||
 | 
					                    if (it.BoardType == 5)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + quantity);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "操作完成,库存已更新",
 | 
				
			||||||
 | 
					                        Type = MsgType.SUCCESS,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    // 关闭当前窗口
 | 
				
			||||||
 | 
					                    RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return bRet;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            if (!f.IsSuccess || !f.Data)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                SnackbarMessageQueue.Enqueue("库存更新失败!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            Status = 0;
 | 
				
			||||||
 | 
					            IsFinishClick = false;
 | 
				
			||||||
 | 
					            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 还药
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private bool ReturnDrug(ChannelStock stock)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    string InvoiceId = "RETURN_" + CurrentTimeMillis(); ;
 | 
				
			||||||
 | 
					                    MachineRecord recordInfo = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(rd => rd.Id == stock.MachineRecordId).First();
 | 
				
			||||||
 | 
					                    // 更新数据 库存信息
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Quantity = stock.Quantity + stock.AddQuantity,
 | 
				
			||||||
 | 
					                        Id = stock.Id,
 | 
				
			||||||
 | 
					                    }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    // 获取更新完库存后的药品库存
 | 
				
			||||||
 | 
					                    List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                        .Where(cs => cs.MachineId.Equals(stock.MachineId))
 | 
				
			||||||
 | 
					                        .Where(cs => cs.DrugId.Equals(stock.DrugId))
 | 
				
			||||||
 | 
					                        .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
 | 
					                        .ToList();
 | 
				
			||||||
 | 
					                    // 更新数据 取药记录 设置还药数量、状态 
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ReturnQuantity1 = recordInfo.ReturnQuantity1 + stock.AddQuantity,
 | 
				
			||||||
 | 
					                        Id = recordInfo.Id,
 | 
				
			||||||
 | 
					                        Status = (recordInfo.CanReturnQuantity - stock.AddQuantity) == 0 ? 2 : 1,
 | 
				
			||||||
 | 
					                    }).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // 保存数据 还药记录
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = stock.MachineId,
 | 
				
			||||||
 | 
					                        DrawerNo = stock.DrawerNo,
 | 
				
			||||||
 | 
					                        ColNo = stock.ColNo,
 | 
				
			||||||
 | 
					                        DrugId = stock.DrugId,
 | 
				
			||||||
 | 
					                        ManuNo = stock.ManuNo,
 | 
				
			||||||
 | 
					                        EffDate = !String.IsNullOrEmpty(stock.EffDate) ? DateTime.ParseExact(stock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Quantity = stock.AddQuantity,
 | 
				
			||||||
 | 
					                        Type = 31,
 | 
				
			||||||
 | 
					                        InvoiceId = InvoiceId,
 | 
				
			||||||
 | 
					                        GetId = stock.MachineRecordId
 | 
				
			||||||
 | 
					                        //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //保存账册
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        DrugId = Convert.ToInt32(stock.DrugId),
 | 
				
			||||||
 | 
					                        Type = 1,
 | 
				
			||||||
 | 
					                        Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
				
			||||||
 | 
					                        InvoiceNo = InvoiceId,
 | 
				
			||||||
 | 
					                        ManuNo = stock.ManuNo,
 | 
				
			||||||
 | 
					                        EffDate = stock.EffDate,
 | 
				
			||||||
 | 
					                        AddQuantity = stock.AddQuantity,
 | 
				
			||||||
 | 
					                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                        CreateTime = DateTime.Now
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    //修改凌晨生成的日结存数据
 | 
				
			||||||
 | 
					                    AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                    .Where(ab => ab.MachineId.Equals(stock.MachineId))
 | 
				
			||||||
 | 
					                    .Where(ab => ab.Type == 3)
 | 
				
			||||||
 | 
					                    .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId))
 | 
				
			||||||
 | 
					                    .Where(ab => ab.ManuNo == stock.ManuNo)
 | 
				
			||||||
 | 
					                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                    if (accountBookG2Day != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + stock.AddQuantity;
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
				
			||||||
 | 
					                        int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            DrugId = Convert.ToInt32(stock.DrugId),
 | 
				
			||||||
 | 
					                            Type = 3,
 | 
				
			||||||
 | 
					                            ManuNo = stock.ManuNo,
 | 
				
			||||||
 | 
					                            EffDate = stock.EffDate,
 | 
				
			||||||
 | 
					                            YQuantity = 0,
 | 
				
			||||||
 | 
					                            ManuStock = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                            TotalStock = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                            InvoiceNo = "日结存"
 | 
				
			||||||
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        if (iDayResult <= 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            logger.Info($"未写入日结存数据{stock.DrugId}-{stock.ManuNo}-{stock.EffDate}-{stock.AddQuantity}");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    //修改凌晨生成的总结存数据
 | 
				
			||||||
 | 
					                    AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                    .Where(ab => ab.MachineId.Equals(stock.MachineId))
 | 
				
			||||||
 | 
					                    .Where(ab => ab.Type == 4)
 | 
				
			||||||
 | 
					                    .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId))
 | 
				
			||||||
 | 
					                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                    if (accountBookG2Total != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + stock.AddQuantity;
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
				
			||||||
 | 
					                        int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            DrugId = Convert.ToInt32(stock.DrugId),
 | 
				
			||||||
 | 
					                            Type = 4,
 | 
				
			||||||
 | 
					                            YQuantity = 0,
 | 
				
			||||||
 | 
					                            ManuStock = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                            TotalStock = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                            InvoiceNo = "总结存"
 | 
				
			||||||
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        if (iTotalResult <= 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            logger.Info($"未写入总结存数据{stock.DrugId}-{stock.AddQuantity}");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                if (f.IsSuccess)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                throw;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 还空瓶
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private bool ReturnEmpty(ChannelStock stock)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string InvoiceId = "RETURN_" + CurrentTimeMillis();
 | 
				
			||||||
 | 
					            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 更新数据 库存信息
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Quantity = stock.Quantity + stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                    Id = stock.Id,
 | 
				
			||||||
 | 
					                }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 获取更新完库存后的药品库存
 | 
				
			||||||
 | 
					                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                    .Where(cs => cs.MachineId.Equals(stock.MachineId))
 | 
				
			||||||
 | 
					                    .Where(cs => cs.DrugId.Equals(stock.DrugId))
 | 
				
			||||||
 | 
					                    .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
 | 
					                    .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                MachineRecord recordInfo = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(rd => rd.Id == stock.MachineRecordId).First();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 更新数据 取药记录 设置还药数量、状态
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ReturnQuantity2 = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                    Id = recordInfo.Id,
 | 
				
			||||||
 | 
					                    Status = 2,
 | 
				
			||||||
 | 
					                }).UpdateColumns(it => new { it.ReturnQuantity2, it.Status }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 保存数据 还药空瓶记录
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    MachineId = stock.MachineId,
 | 
				
			||||||
 | 
					                    DrawerNo = stock.DrawerNo,
 | 
				
			||||||
 | 
					                    ColNo = stock.ColNo,
 | 
				
			||||||
 | 
					                    DrugId = stock.DrugId,
 | 
				
			||||||
 | 
					                    ManuNo = stock.ManuNo,
 | 
				
			||||||
 | 
					                    EffDate = !String.IsNullOrEmpty(stock.EffDate) ? DateTime.ParseExact(stock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
				
			||||||
 | 
					                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                    OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                    Quantity = stock.ReturnQuantity, //ReturnQuantity,
 | 
				
			||||||
 | 
					                    Type = 32,
 | 
				
			||||||
 | 
					                    InvoiceId = InvoiceId,
 | 
				
			||||||
 | 
					                    GetId = stock.MachineRecordId
 | 
				
			||||||
 | 
					                    //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!f.IsSuccess || !f.Data)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public long CurrentTimeMillis()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 取消
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand CancleTake
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _portUtil.ResetData();
 | 
				
			||||||
 | 
					                Status = 0;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // 完成按钮
 | 
				
			||||||
 | 
					        public DelegateCommand TakeFinishCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(TakeFinish);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void DoDialogResult(IDialogResult dialogResult)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 委托   被动执行     被子窗口执行
 | 
				
			||||||
 | 
					            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
				
			||||||
 | 
					            //if(dialogResult.Result == ButtonResult.OK)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            // 关闭当前窗口
 | 
				
			||||||
 | 
					            //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -256,7 +256,18 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					            string strNames = string.Empty;
 | 
				
			||||||
 | 
					            foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                strNames += name;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int sumQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync($"正在打开{DrawerNo}号抽屉,请加药{strNames},数量共计{sumQuantity}");
 | 
				
			||||||
            List<ChannelStock> singleChannels = new List<ChannelStock>();
 | 
					            List<ChannelStock> singleChannels = new List<ChannelStock>();
 | 
				
			||||||
            for (int i = 0; i < channelStocks.Count; i++)
 | 
					            for (int i = 0; i < channelStocks.Count; i++)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -330,7 +341,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (SelectDrugPleaseClaim.GetQuantity == 1)
 | 
					                if (SelectDrugPleaseClaim.GetQuantity == 1)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (SelectDrugPleaseClaim.DrugManuNo is null)
 | 
					                    if (SelectDrugPleaseClaim._DrugManuNos is null)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
| 
						 | 
					@ -341,13 +352,12 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    //请领单里只有一种药
 | 
					                    //请领单里只有一种药
 | 
				
			||||||
                    List<DrugPleaseManuNo> drugManuInfoList = JsonConvert.DeserializeObject<List<DrugPleaseManuNo>>(SelectDrugPleaseClaim.DrugManuNo);
 | 
					                    List<DrugPleaseManuNo> drugManuInfoList = JsonConvert.DeserializeObject<List<DrugPleaseManuNo>>(SelectDrugPleaseClaim._DrugManuNos);
 | 
				
			||||||
                    drugManuInfoList.ForEach(dm => dm.DrugId = SelectDrugPleaseClaim.DrugId);
 | 
					                    drugManuInfoList.ForEach(dm => dm.DrugId = SelectDrugPleaseClaim.DrugId);
 | 
				
			||||||
                    for (int i = 0; i < drugManuInfoList.Count; i++)
 | 
					                    for (int i = 0; i < drugManuInfoList.Count; i++)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        DrugPleaseManuNo drugPleaseManuNo = drugManuInfoList[i];
 | 
					                        DrugPleaseManuNo drugPleaseManuNo = drugManuInfoList[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        ChannelStock q = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					                        ChannelStock q = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
                        .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
					                        .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
				
			||||||
                        .WhereIF(!string.IsNullOrEmpty(drugPleaseManuNo.EffDate), cs => cs.EffDate.Equals(drugPleaseManuNo.EffDate))
 | 
					                        .WhereIF(!string.IsNullOrEmpty(drugPleaseManuNo.EffDate), cs => cs.EffDate.Equals(drugPleaseManuNo.EffDate))
 | 
				
			||||||
| 
						 | 
					@ -383,7 +393,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        foreach (DrugPleaseClaim item in pleaseClaimList)
 | 
					                        foreach (DrugPleaseClaim item in pleaseClaimList)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            List<DrugPleaseManuNo> drugManuInfoList = JsonConvert.DeserializeObject<List<DrugPleaseManuNo>>(item.DrugManuNo);
 | 
					                            List<DrugPleaseManuNo> drugManuInfoList = JsonConvert.DeserializeObject<List<DrugPleaseManuNo>>(item._DrugManuNos);
 | 
				
			||||||
                            drugManuInfoList.ForEach(dm => dm.DrugId = item.DrugId);
 | 
					                            drugManuInfoList.ForEach(dm => dm.DrugId = item.DrugId);
 | 
				
			||||||
                            for (int i = 0; i < drugManuInfoList.Count; i++)
 | 
					                            for (int i = 0; i < drugManuInfoList.Count; i++)
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
| 
						 | 
					@ -453,7 +463,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (OrderDate != null)
 | 
					            if (OrderDate != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                sb.Append(" and i.do_date = @CreateTime ");
 | 
					                sb.Append(" and DATE_FORMAT(i.do_date,'%Y-%m-%d') = @CreateTime ");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (!String.IsNullOrEmpty(SearchValue))
 | 
					            if (!String.IsNullOrEmpty(SearchValue))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
using DM_Weight.Models;
 | 
					using DM_Weight.Models;
 | 
				
			||||||
using DM_Weight.select;
 | 
					using DM_Weight.select;
 | 
				
			||||||
using DM_Weight.util;
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
using Prism.Commands;
 | 
					using Prism.Commands;
 | 
				
			||||||
using Prism.Mvvm;
 | 
					using Prism.Mvvm;
 | 
				
			||||||
using Prism.Regions;
 | 
					using Prism.Regions;
 | 
				
			||||||
| 
						 | 
					@ -150,11 +151,27 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                           .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cd) => cd.drugInfo.PyCode.Contains(SearchValue))
 | 
					                           .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cd) => cd.drugInfo.PyCode.Contains(SearchValue))
 | 
				
			||||||
                           .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cd) => cd.drugInfo.DrugBarcode.Contains(SearchValue))
 | 
					                           .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cd) => cd.drugInfo.DrugBarcode.Contains(SearchValue))
 | 
				
			||||||
                           .WhereIF((_DrugPleaseState!=null&& _DrugPleaseState.StateValue>=0),(cd,dp)=>dp.State==_DrugPleaseState.StateValue)
 | 
					                           .WhereIF((_DrugPleaseState!=null&& _DrugPleaseState.StateValue>=0),(cd,dp)=>dp.State==_DrugPleaseState.StateValue)
 | 
				
			||||||
                           .GroupBy(cd=>cd.Applyid)
 | 
					                           .GroupBy(cd=>cd.DrugPleaseClaimId)
 | 
				
			||||||
 | 
					                           .GroupBy(cd => cd.DrugId)
 | 
				
			||||||
                           .OrderByDescending(cd => cd.Createdate)
 | 
					                           .OrderByDescending(cd => cd.Createdate)
 | 
				
			||||||
                           .OrderByDescending(cd => cd.DrugId)
 | 
					                           .OrderByDescending(cd => cd.DrugId)
 | 
				
			||||||
                           .ToList();
 | 
					                           .ToList();
 | 
				
			||||||
 | 
					            if (CollectDrugLst != null && CollectDrugLst.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                for (int i = 0; i < CollectDrugLst.Count; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    CollectDrugLst[i].ManuNoList = new List<DrugPleaseManuNo>();
 | 
				
			||||||
 | 
					                    DrugPleaseClaim drugManuNoStr = SqlSugarHelper.Db.Queryable<DrugPleaseClaim>().Where(dp => dp.PleaseNo == CollectDrugLst[i].DrugPleaseClaimId && dp.DrugId == CollectDrugLst[i].DrugId).First();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    CollectDrugLst[i].Quantity = drugManuNoStr.GetQuantity;
 | 
				
			||||||
 | 
					                    if (!string.IsNullOrEmpty(drugManuNoStr._DrugManuNos))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        CollectDrugLst[i].ManuNoList = JsonConvert.DeserializeObject<List<DrugPleaseManuNo>>(drugManuNoStr._DrugManuNos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 刷新
 | 
					        /// 刷新
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -175,7 +175,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
					                    SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        ApplyStatus = 1,
 | 
					                        ApplyStatus = 1,
 | 
				
			||||||
                        OrderNo = collectDrug.OrderNo
 | 
					                        OrderNo = collectDrug.OrderNo,
 | 
				
			||||||
 | 
					                        MachineId= ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
                    }).UpdateColumns(it => new { it.ApplyStatus }).Where(it => it.OrderNo == collectDrug.OrderNo).ExecuteCommand();
 | 
					                    }).UpdateColumns(it => new { it.ApplyStatus }).Where(it => it.OrderNo == collectDrug.OrderNo).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    //保存处方、请领申请中间表
 | 
					                    //保存处方、请领申请中间表
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -162,6 +162,39 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                RequestData();
 | 
					                RequestData();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        void RequestData_for_SurgicalShedule()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int totalCount = 0;
 | 
				
			||||||
 | 
					            List<CollectDrug> queryData = SqlSugarHelper.Db.Queryable<SurgicalSchedule>()
 | 
				
			||||||
 | 
					         .InnerJoin<SurgicalScheduleDetail>((oi, od) => oi.OperationId == od.OperationId)
 | 
				
			||||||
 | 
					         .InnerJoin<DrugInfo>((oi, od, di) => od.DrugId == di.DrugId.ToString())
 | 
				
			||||||
 | 
					         .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (oi, od, di) => di.DrugId.ToString() == SearchValue)
 | 
				
			||||||
 | 
					         .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (oi, od, di) => di.DrugName.Contains(SearchValue))
 | 
				
			||||||
 | 
					         .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (oi, od, di) => di.PyCode.Contains(SearchValue))
 | 
				
			||||||
 | 
					         .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (oi, od, di) => di.DrugBarcode.Contains(SearchValue))
 | 
				
			||||||
 | 
					         .Where(oi => oi.DmStatus == 1)
 | 
				
			||||||
 | 
					         .Where(oi => oi.HisState == 1)
 | 
				
			||||||
 | 
					         .GroupBy(oi => oi.ScheduleTime)
 | 
				
			||||||
 | 
					         .Select((oi, od, di) => new CollectDrug
 | 
				
			||||||
 | 
					         {
 | 
				
			||||||
 | 
					             PatientId = oi.PatientId,
 | 
				
			||||||
 | 
					             PName = oi.PName,
 | 
				
			||||||
 | 
					             Sex = oi.Sex,
 | 
				
			||||||
 | 
					             Age = oi.Age,
 | 
				
			||||||
 | 
					             IdNumber = oi.IdNumber,
 | 
				
			||||||
 | 
					             OrderNo = oi.OperationId,
 | 
				
			||||||
 | 
					             //DeptName = oi.DeptName,
 | 
				
			||||||
 | 
					             DrugName = di.DrugName,
 | 
				
			||||||
 | 
					             Quantity = od.Quantity,
 | 
				
			||||||
 | 
					             DrugSpec = di.DrugSpec,
 | 
				
			||||||
 | 
					             Manufactory = di.Manufactory,
 | 
				
			||||||
 | 
					             DrugId = di.DrugId.ToString(),
 | 
				
			||||||
 | 
					         }).ToList();
 | 
				
			||||||
 | 
					            CollectDrugs = queryData;
 | 
				
			||||||
 | 
					            TotalCount = totalCount;
 | 
				
			||||||
 | 
					            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        void RequestData()
 | 
					        void RequestData()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            int totalCount = 0;
 | 
					            int totalCount = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,12 +126,26 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Status = 1;
 | 
					                Status = 1;
 | 
				
			||||||
                _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
					                    List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    IEnumerable<string> strDrugName = ChannelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					                    string strNames = string.Empty;
 | 
				
			||||||
 | 
					                    foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            strNames += name + ";   ;";
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    int sumQuantity = ChannelStocks.Sum(cs => cs.AddQuantity);
 | 
				
			||||||
 | 
					                    _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请加药 {strNames} ,数量共计{sumQuantity}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    _portUtil.WindowName = "DrawerAddDrugWindow";
 | 
					                    _portUtil.WindowName = "DrawerAddDrugWindow";
 | 
				
			||||||
                    _portUtil.Operate = true;
 | 
					                    _portUtil.Operate = true;
 | 
				
			||||||
                    _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
					                    _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -136,8 +136,19 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                if (Status == 0)
 | 
					                if (Status == 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Status = 1;
 | 
					                    Status = 1;
 | 
				
			||||||
                    _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					                    //_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    IEnumerable<string> strDrugName = ChannelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					                    string strNames = string.Empty;
 | 
				
			||||||
 | 
					                    foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            strNames += name + ";";
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    int sumQuantity = ChannelStocks.Sum(cs => cs.TakeQuantity);
 | 
				
			||||||
 | 
					                    _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
					                    List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -360,12 +371,12 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
 | 
					            if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
 | 
					                count = SqlSugarHelper.Db.Queryable<ChannelList>().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();
 | 
					                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
 | 
					                count = SqlSugarHelper.Db.Queryable<ChannelStock>().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();
 | 
					                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            Is8Drawer = count < 9;
 | 
					            Is8Drawer = count < 9;
 | 
				
			||||||
            Is16Drawer = count >= 16;
 | 
					            Is16Drawer = count >= 16;
 | 
				
			||||||
| 
						 | 
					@ -386,7 +397,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                .Includes(cs => cs.DrugInfo)
 | 
					                .Includes(cs => cs.DrugInfo)
 | 
				
			||||||
                .Where(cs => cs.DrawerNo == DrawerNo)
 | 
					                .Where(cs => cs.DrawerNo == DrawerNo)
 | 
				
			||||||
                .Where(cs => cs.DrugId != null)
 | 
					                .Where(cs => cs.DrugId != null)
 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
                .Where(cs => cs.DrawerType == 1)
 | 
					                .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
                .Where(cs => cs.Quantity > 0)
 | 
					                .Where(cs => cs.Quantity > 0)
 | 
				
			||||||
                .OrderBy(cs => cs.ColNo)
 | 
					                .OrderBy(cs => cs.ColNo)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -132,7 +132,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        else
 | 
					                        else
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
					                            UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
				
			||||||
                            UserList.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
 | 
					                            UserList.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM3";
 | 
				
			||||||
                            // 插入
 | 
					                            // 插入
 | 
				
			||||||
                            SqlSugarHelper.Db.Insertable<UserList>(UserList).InsertColumns(u => new { u.Id, u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId, u.MachineId }).ExecuteCommand();
 | 
					                            SqlSugarHelper.Db.Insertable<UserList>(UserList).InsertColumns(u => new { u.Id, u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId, u.MachineId }).ExecuteCommand();
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
| 
						 | 
					@ -154,7 +154,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void GetAllRole()
 | 
					        void GetAllRole()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Roles = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).OrderBy(r => r.Id).ToList();
 | 
					            Roles = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM3")).OrderBy(r => r.Id).ToList();
 | 
				
			||||||
            RaisePropertyChanged("Roles");
 | 
					            RaisePropertyChanged("Roles");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -189,7 +189,18 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					
 | 
				
			||||||
 | 
					            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					            string strNames = string.Empty;
 | 
				
			||||||
 | 
					            foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    strNames += name + "  ;  ";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int sumQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请加药 {strNames} ,数量共计 {sumQuantity}个");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -266,7 +266,17 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					            string strNames = string.Empty;
 | 
				
			||||||
 | 
					            foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    strNames += name + "  ;  ";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int sumQuantity = channelStocks.Sum(cs => cs.TakeQuantity);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}"); 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,8 @@ using DM_Weight.Finger;
 | 
				
			||||||
using DM_Weight.Views;
 | 
					using DM_Weight.Views;
 | 
				
			||||||
using Unity;
 | 
					using Unity;
 | 
				
			||||||
using DM_Weight.HIKVISION;
 | 
					using DM_Weight.HIKVISION;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -30,7 +32,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //private PortUtil _portUtil;
 | 
					        //private PortUtil _portUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private ScreenUtil _screenUtil;
 | 
					        //private ScreenUtil _screenUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public SolidColorBrush Background
 | 
					        public SolidColorBrush Background
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -64,16 +66,17 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        IRegionManager _regionManager;
 | 
					        IRegionManager _regionManager;
 | 
				
			||||||
        IUnityContainer _container;
 | 
					        IUnityContainer _container;
 | 
				
			||||||
        private CHKFunction _cHKFunction;
 | 
					        private CHKFunction _cHKFunction;
 | 
				
			||||||
        public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, ScreenUtil screenUtil, CHKFunction cHKFunction)
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(PortUtil));
 | 
				
			||||||
 | 
					        public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, CHKFunction cHKFunction)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //_portUtil = portUtil;
 | 
					            //_portUtil = portUtil;
 | 
				
			||||||
            this.eventAggregator = eventAggregator;
 | 
					            this.eventAggregator = eventAggregator;
 | 
				
			||||||
            this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
 | 
					            this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
 | 
				
			||||||
            _screenUtil = screenUtil;
 | 
					 | 
				
			||||||
            _fingerprintUtil = fingerprintUtil;
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
            _regionManager = regionManager;
 | 
					            _regionManager = regionManager;
 | 
				
			||||||
            _container = container;
 | 
					            _container = container;
 | 
				
			||||||
            _cHKFunction = cHKFunction;
 | 
					            _cHKFunction = cHKFunction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
					            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,6 +84,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }));
 | 
					            }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void doMyPrismEvent2(AlertMsg msg)
 | 
					        void doMyPrismEvent2(AlertMsg msg)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -311,7 +311,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            //}
 | 
					            //}
 | 
				
			||||||
            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
					            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
				
			||||||
                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
					                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
				
			||||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
					                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
				
			||||||
                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
					                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
				
			||||||
                .WhereIF(!(OrderDepartment.DeptName.Equals("全部")), oi => oi.DeptName == OrderDepartment.DeptName)
 | 
					                .WhereIF(!(OrderDepartment.DeptName.Equals("全部")), oi => oi.DeptName == OrderDepartment.DeptName)
 | 
				
			||||||
                //.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
					                //.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -261,11 +261,24 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					            //_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            IEnumerable<string> strDrugName = singleChannels.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					            string strNames = string.Empty;
 | 
				
			||||||
 | 
					            foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    strNames += name;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int sumQuantity = singleChannels.Sum(cs => cs.ReturnQuantity);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync($"正在打开{DrawerNo}号抽屉,请加药{strNames},数量共计{sumQuantity}个");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 发送还药数量
 | 
					            // 发送还药数量
 | 
				
			||||||
            singleChannels.ForEach(it =>
 | 
					            singleChannels.ForEach(it =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -169,7 +169,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
					            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
				
			||||||
                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
					                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
				
			||||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
 | 
					                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
 | 
				
			||||||
                .Where(od => od.OrderNo == OrderInfo.OrderNo)
 | 
					                .Where(od => od.OrderNo == OrderInfo.OrderNo)
 | 
				
			||||||
                .ToList();
 | 
					                .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -183,7 +183,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
					                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
				
			||||||
                    .Where(cs => cs.Quantity > 0)
 | 
					                    .Where(cs => cs.Quantity > 0)
 | 
				
			||||||
                    .Where(cs => cs.DrawerType == 1)
 | 
					                    .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
					                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
					                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
				
			||||||
                    .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
					                    .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
				
			||||||
| 
						 | 
					@ -263,7 +263,19 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					            string strNames = string.Empty;
 | 
				
			||||||
 | 
					            foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    strNames += name+";";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int sumQuantity = channelStocks.Sum(cs => cs.TakeQuantity);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -195,7 +195,10 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Status = 1;
 | 
					                    Status = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    _portUtil.SpeakAsync("正在打开" + ChannelStock.DrawerNo + "号抽屉");
 | 
					                    //_portUtil.SpeakAsync("正在打开" + ChannelStock.DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    _portUtil.SpeakAsync($"正在打开 {ChannelStock.DrawerNo} 号抽屉,请加药 {MachineRecord.DrugInfo.DrugName} ,数量共计 {ReturnQuantity}个");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    _portUtil.WindowName = WindowName;
 | 
					                    _portUtil.WindowName = WindowName;
 | 
				
			||||||
                    _portUtil.BoardType = ChannelStock.BoardType;
 | 
					                    _portUtil.BoardType = ChannelStock.BoardType;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -216,7 +216,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            int totalCount = 0;
 | 
					            int totalCount = 0;
 | 
				
			||||||
            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
					            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
				
			||||||
                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
					                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
				
			||||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
					                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
				
			||||||
                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
					                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -184,7 +184,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                .Includes<UserList>(mr => mr.User)
 | 
					                .Includes<UserList>(mr => mr.User)
 | 
				
			||||||
                .Where(mr => mr.Type == 2)
 | 
					                .Where(mr => mr.Type == 2)
 | 
				
			||||||
                .Where(mr => mr.Status < 2)
 | 
					                .Where(mr => mr.Status < 2)
 | 
				
			||||||
                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
                //.WhereIF(QueryDate != null, mr => mr.OperationTime.ToString("yyyy-MM-dd") == QueryDate)
 | 
					                //.WhereIF(QueryDate != null, mr => mr.OperationTime.ToString("yyyy-MM-dd") == QueryDate)
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (mr) => mr.DrugInfo.DrugId.ToString().Contains(SearchValue))
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (mr) => mr.DrugInfo.DrugId.ToString().Contains(SearchValue))
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (mr) => mr.DrugInfo.DrugName.Contains(SearchValue))
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (mr) => mr.DrugInfo.DrugName.Contains(SearchValue))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,310 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Report;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ReturnEmptyDestoryWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private List<ChannelStock>? _channelStocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<ChannelStock>? Channels
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _channelStocks; }
 | 
				
			||||||
 | 
					            set { SetProperty(ref _channelStocks, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ChannelStock _channelStock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ChannelStock Channel
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _channelStock; }
 | 
				
			||||||
 | 
					            set { SetProperty(ref _channelStock, 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();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public ReturnEmptyDestoryWindowViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = dialogService;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand RowSelected
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (Channel != null && Channel.DrugId == null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                    dialogParameters.Add("DrawerNo", Channel.DrawerNo);
 | 
				
			||||||
 | 
					                    DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else if (Channel != null && Channel.CanReturnQuantity > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Channels = Channels.Select(x =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (x.Id == Channel.Id)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            x.IsSelected = !x.IsSelected;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return x;
 | 
				
			||||||
 | 
					                    }).ToList();
 | 
				
			||||||
 | 
					                    //DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                    //dialogParameters.Add("channel", Channel);
 | 
				
			||||||
 | 
					                    //DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<ChannelStock> csList = new List<ChannelStock>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //销毁
 | 
				
			||||||
 | 
					        public DelegateCommand DestoryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (Channels != null && Channels.Count > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    csList = Channels.FindAll(it => it.IsSelected && it.Quantity > 0).ToList();
 | 
				
			||||||
 | 
					                    if (csList != null && csList.Count > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					                        //DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                        //List<string> msg = new List<string>();
 | 
				
			||||||
 | 
					                        //msg.Add("确认");
 | 
				
			||||||
 | 
					                        //msg.Add("确认要销毁吗?");
 | 
				
			||||||
 | 
					                        //dialogParameters.Add("msgInfo", msg);
 | 
				
			||||||
 | 
					                        //DialogServiceExtensions.ShowDialogHost(_dialogService, "ConfirmMessageDialog", dialogParameters, DestoryDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            for (int i = 0; i < csList.Count; i++)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                ChannelStock channelStock = csList[i];
 | 
				
			||||||
 | 
					                                channelStock.Quantity = 0;
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable(channelStock).ExecuteCommand();
 | 
				
			||||||
 | 
					                                MachineRecord machines = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
				
			||||||
 | 
					                                 //.InnerJoin<ChannelStock>((mr, cs) => mr.DrugId == cs.DrugId)
 | 
				
			||||||
 | 
					                                 //.Where(mr => mr.DrugId.Contains(csList.Select(it => it.DrugId).ToList()) && mr.Type = 32)
 | 
				
			||||||
 | 
					                                 .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
 | 
					                                 .Where(mr => mr.DrugId == channelStock.DrugId)
 | 
				
			||||||
 | 
					                                 .Where(mr => mr.Type == 32)
 | 
				
			||||||
 | 
					                                 .First();
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable(machines).ReSetValue(mr =>
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    mr.IsDestroy = 1;
 | 
				
			||||||
 | 
					                                    mr.TakeUser = HomeWindowViewModel.Operator?.Id.ToString();
 | 
				
			||||||
 | 
					                                    mr.DestoryReviewerUser = HomeWindowViewModel.Reviewer?.Id.ToString();
 | 
				
			||||||
 | 
					                                }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            return true;
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                         
 | 
				
			||||||
 | 
					                        if (f.Data)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            RequestData();
 | 
				
			||||||
 | 
					                            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Message = "销毁完成",
 | 
				
			||||||
 | 
					                                Type = MsgType.SUCCESS,
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if (!f.IsSuccess)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Message = "销毁失败!",
 | 
				
			||||||
 | 
					                                Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = "未勾选要销毁的数据或勾选的数据库存为0",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "没有要操作销毁的数据",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //空瓶销毁(根据还的空瓶)
 | 
				
			||||||
 | 
					        public DelegateCommand DestoryEmptyCommand { get => new DelegateCommand(DestoryEmptyAction); }
 | 
				
			||||||
 | 
					        private void DestoryEmptyAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //List<ChannelStock> records = Channels.FindAll(it => it.IsSelected).ToList();
 | 
				
			||||||
 | 
					            //if (records.Count > 0)
 | 
				
			||||||
 | 
					            if (Channel != null && Channel.DrugId != null && Channel.Quantity > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                dialogParameters.Add("channel", Channel);
 | 
				
			||||||
 | 
					                DialogServiceExtensions.ShowDialogHost(_dialogService, "DestoryEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = "请选择有库存的数据",
 | 
				
			||||||
 | 
					                    Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void DoDialogResult(IDialogResult dialogResult)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 委托   被动执行     被子窗口执行
 | 
				
			||||||
 | 
					            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //导出回收销毁记录
 | 
				
			||||||
 | 
					        public DelegateCommand DownloadRecordCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                GridReportUtil.PrintEmptyDestoryReport(StartDate, EndDate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand Query
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
				
			||||||
 | 
					        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            continuationCallback(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接收导航传过来的参数
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //查询表格数据
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Channels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                .LeftJoin<DrugInfo>((cs, di) => cs.DrugId == di.DrugId.ToString())
 | 
				
			||||||
 | 
					                .Where((cs) => cs.DrawerType != 1).Where(cs => cs.MachineId == ConfigurationManager.AppSettings["machineId"])
 | 
				
			||||||
 | 
					                .Where(cs=>cs.Quantity>0)
 | 
				
			||||||
 | 
					                .Select((cs, di) => new ChannelStock
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    CanReturnQuantity = SqlFunc.Subqueryable<MachineRecord>().Where(mr => mr.DrugId == cs.DrugId && mr.MachineId == ConfigurationManager.AppSettings["machineId"]).Where(mr => mr.Type == 2).Where(mr => mr.Status != 2).Select(mr => SqlFunc.IsNull(SqlFunc.AggregateSumNoNull(mr.Quantity - mr.ReturnQuantity1 - mr.ReturnQuantity2), 0)),
 | 
				
			||||||
 | 
					                    DrugInfo = new DrugInfo
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        DrugId = di.DrugId,
 | 
				
			||||||
 | 
					                        DrugName = di.DrugName,
 | 
				
			||||||
 | 
					                        DrugSpec = di.DrugSpec,
 | 
				
			||||||
 | 
					                        Manufactory = di.Manufactory,
 | 
				
			||||||
 | 
					                        PackUnit = di.PackUnit,
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
 | 
					                    Quantity = cs.Quantity
 | 
				
			||||||
 | 
					                }, true)
 | 
				
			||||||
 | 
					                .OrderBy(cs => cs.DrawerNo)
 | 
				
			||||||
 | 
					                .OrderBy(cs => cs.ColNo)
 | 
				
			||||||
 | 
					                .ToList()
 | 
				
			||||||
 | 
					                ;
 | 
				
			||||||
 | 
					            _ = Channels.Count;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -206,6 +206,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                //quyaoChild.Add(mulityOrder);
 | 
					                //quyaoChild.Add(mulityOrder);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            quyaoChild.Add(quyao1);
 | 
					            quyaoChild.Add(quyao1);
 | 
				
			||||||
            quyaoChild.Add(quyao2);
 | 
					            quyaoChild.Add(quyao2);
 | 
				
			||||||
            quyaoChild.Add(quyao3);
 | 
					            quyaoChild.Add(quyao3);
 | 
				
			||||||
| 
						 | 
					@ -278,10 +279,10 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            jiayaoChild.Add(jiayao1);
 | 
					            jiayaoChild.Add(jiayao1);
 | 
				
			||||||
            jiayaoChild.Add(jiayao2);
 | 
					            jiayaoChild.Add(jiayao2);
 | 
				
			||||||
            jiayaoChild.Add(jiayao3);
 | 
					            jiayaoChild.Add(jiayao3);
 | 
				
			||||||
            jiayaoChild.Add(jiayao4);
 | 
					 | 
				
			||||||
            jiayaoChild.Add(jiayao6);
 | 
					            jiayaoChild.Add(jiayao6);
 | 
				
			||||||
            jiayaoChild.Add(jiayao7);
 | 
					            jiayaoChild.Add(jiayao7);
 | 
				
			||||||
            jiayaoChild.Add(jiayao8);
 | 
					            jiayaoChild.Add(jiayao8);
 | 
				
			||||||
 | 
					            jiayaoChild.Add(jiayao4);
 | 
				
			||||||
            jiayao.Children = jiayaoChild;
 | 
					            jiayao.Children = jiayaoChild;
 | 
				
			||||||
            defaultAll.Add(jiayao);
 | 
					            defaultAll.Add(jiayao);
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
| 
						 | 
					@ -305,11 +306,17 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                PremissionName = "归还药品",
 | 
					                PremissionName = "归还药品",
 | 
				
			||||||
                PremissionPath = "ReturnDrugWindow2",
 | 
					                PremissionPath = "ReturnDrugWindow2",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					            //PremissionDm huanyao2 = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 32,
 | 
				
			||||||
 | 
					            //    PremissionName = "归还空瓶",
 | 
				
			||||||
 | 
					            //    PremissionPath = "ReturnEmptyWindow",
 | 
				
			||||||
 | 
					            //}; 
 | 
				
			||||||
            PremissionDm huanyao2 = new PremissionDm
 | 
					            PremissionDm huanyao2 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = 32,
 | 
					                Id = 32,
 | 
				
			||||||
                PremissionName = "归还空瓶",
 | 
					                PremissionName = "空瓶销毁",
 | 
				
			||||||
                PremissionPath = "ReturnEmptyWindow",
 | 
					                PremissionPath = "ReturnEmptyDestoryWindow",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            PremissionDm huanyao3 = new PremissionDm
 | 
					            PremissionDm huanyao3 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -317,8 +324,15 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                PremissionName = "归还记录",
 | 
					                PremissionName = "归还记录",
 | 
				
			||||||
                PremissionPath = "ReturnRecordWindow",
 | 
					                PremissionPath = "ReturnRecordWindow",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm surgery = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 17,
 | 
				
			||||||
 | 
					                PremissionName = "手术核销",
 | 
				
			||||||
 | 
					                PremissionPath = "SurgeryTakeWindow"
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
            huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1 ? huanyao11 : huanyao1);
 | 
					            huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1 ? huanyao11 : huanyao1);
 | 
				
			||||||
            huanyaoChild.Add(huanyao2);
 | 
					            huanyaoChild.Add(huanyao2);
 | 
				
			||||||
 | 
					            huanyaoChild.Add(surgery);
 | 
				
			||||||
            huanyaoChild.Add(huanyao3);
 | 
					            huanyaoChild.Add(huanyao3);
 | 
				
			||||||
            huanyao.Children = huanyaoChild;
 | 
					            huanyao.Children = huanyaoChild;
 | 
				
			||||||
            defaultAll.Add(huanyao);
 | 
					            defaultAll.Add(huanyao);
 | 
				
			||||||
| 
						 | 
					@ -369,10 +383,10 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            kuguanChild.Add(kuguan1);
 | 
					            kuguanChild.Add(kuguan1);
 | 
				
			||||||
            kuguanChild.Add(kuguan2);
 | 
					            kuguanChild.Add(kuguan2);
 | 
				
			||||||
            kuguanChild.Add(kuguan3);
 | 
					 | 
				
			||||||
            kuguanChild.Add(kuguan4);
 | 
					            kuguanChild.Add(kuguan4);
 | 
				
			||||||
            kuguanChild.Add(kuguan5);
 | 
					 | 
				
			||||||
            kuguanChild.Add(kuguan6);
 | 
					            kuguanChild.Add(kuguan6);
 | 
				
			||||||
 | 
					            kuguanChild.Add(kuguan3);
 | 
				
			||||||
 | 
					            kuguanChild.Add(kuguan5);
 | 
				
			||||||
            kuguan.Children = kuguanChild;
 | 
					            kuguan.Children = kuguanChild;
 | 
				
			||||||
            defaultAll.Add(kuguan);
 | 
					            defaultAll.Add(kuguan);
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -183,8 +183,19 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					            //_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					            string strNames = string.Empty;
 | 
				
			||||||
 | 
					            foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    strNames += name;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int sumQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请加药 {strNames} ,数量共计 {sumQuantity}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
            _portUtil.WindowName = WindowName;
 | 
					            _portUtil.WindowName = WindowName;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -179,7 +179,18 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					            string strNames = string.Empty;
 | 
				
			||||||
 | 
					            foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!strNames.Contains(name))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    strNames += name+"  ;  ";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int sumQuantity = channelStocks.Sum(cs => cs.TakeQuantity);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync($"正在打开 {DrawerNo} 号抽屉,请取药 {strNames} ,数量共计 {sumQuantity}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -159,7 +159,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                .Where(cs => cs.DrugId != null)
 | 
					                .Where(cs => cs.DrugId != null)
 | 
				
			||||||
                .Where(cs => cs.DrawerType == 1)
 | 
					                .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
                .Where(cs => cs.Quantity > 0)
 | 
					                .Where(cs => cs.Quantity > 0)
 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -183,7 +183,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            //    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
					            //    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
				
			||||||
            //    .Where(cs => cs.DrawerType == 1)
 | 
					            //    .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
            //    .Where(cs =>cs.DrugId != null)
 | 
					            //    .Where(cs =>cs.DrugId != null)
 | 
				
			||||||
            //    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					            //    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //    .WhereIF(!String.IsNullOrEmpty(SearchValue),cs => cs.DrugInfo.DrugName == SearchValue)
 | 
					            //    .WhereIF(!String.IsNullOrEmpty(SearchValue),cs => cs.DrugInfo.DrugName == SearchValue)
 | 
				
			||||||
            //    .OrderBy(cs => cs.DrugId)
 | 
					            //    .OrderBy(cs => cs.DrugId)
 | 
				
			||||||
| 
						 | 
					@ -198,9 +198,9 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            ChannelStocks.Clear();
 | 
					            ChannelStocks.Clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<DrugInfo> q = SqlSugarHelper.Db.Queryable<DrugInfo>()
 | 
					            List<DrugInfo> q = SqlSugarHelper.Db.Queryable<DrugInfo>()
 | 
				
			||||||
                .Includes<ChannelStock>(di => di.channelStocks.Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList())
 | 
					                .Includes<ChannelStock>(di => di.channelStocks.Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3") && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList())
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue), di => di.DrugName == SearchValue)
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue), di => di.DrugName == SearchValue)
 | 
				
			||||||
              .Where(di => di.channelStocks.Any(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null))
 | 
					              .Where(di => di.channelStocks.Any(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3") && cs.DrugId != null))
 | 
				
			||||||
              .OrderBy(cs => cs.DrugId)
 | 
					              .OrderBy(cs => cs.DrugId)
 | 
				
			||||||
              .ToList();
 | 
					              .ToList();
 | 
				
			||||||
            Drugs = q;
 | 
					            Drugs = q;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,859 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.select;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using MaterialDesignThemes.Wpf;
 | 
				
			||||||
 | 
					using Newtonsoft.Json.Linq;
 | 
				
			||||||
 | 
					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.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Channels;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Media;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class SurgeryTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
				
			||||||
 | 
					        public string Title => "手术核销";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private SurgicalSchedule _surgicalSchedule;
 | 
				
			||||||
 | 
					        public SurgicalSchedule _SurgicalSchedule { get => _surgicalSchedule; set => SetProperty(ref _surgicalSchedule, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<MachineRecord> machineRecordList;
 | 
				
			||||||
 | 
					        public List<MachineRecord> MachineRecordList { get => machineRecordList; set => SetProperty(ref machineRecordList, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string? _searchValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件 查询字段值
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? SearchValue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _searchValue; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _searchValue, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static List<OrderTakeSelect> StaticSelects = new()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "DrugName",
 | 
				
			||||||
 | 
					                Name = "药品名称"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "PyCode",
 | 
				
			||||||
 | 
					                Name = "拼音码"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "DrugBarcode",
 | 
				
			||||||
 | 
					                Name = "药品条码"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "DrugId",
 | 
				
			||||||
 | 
					                Name = "药品编码"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<OrderTakeSelect> Selects
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _selects; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _selects, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _totalCount = 0;
 | 
				
			||||||
 | 
					        public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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 = 9;
 | 
				
			||||||
 | 
					        public int PageSize
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _pageSize;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _pageSize, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int Status
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _status; set => SetProperty(ref _status, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private SolidColorBrush _colorBrush;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public SolidColorBrush SnackbarBackground
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _colorBrush;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _colorBrush, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _snackbarMessageQueue;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        List<ChannelStock> ReturnStockLst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
				
			||||||
 | 
					        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件 查询字段
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public OrderTakeSelect SelectedItem
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _selectedItem; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _selectedItem, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private MachineRecord selectedRecord;
 | 
				
			||||||
 | 
					        public MachineRecord SelectedRecord { get => selectedRecord; set => SetProperty(ref selectedRecord, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        public SurgeryTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = DialogService;
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Status == 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					            SurgicalSchedule ss = parameters.GetValue<SurgicalSchedule>("SurgeryInfo");
 | 
				
			||||||
 | 
					            _SurgicalSchedule = ss;
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public async void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int totalCount = 0;
 | 
				
			||||||
 | 
					            MachineRecordList = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
				
			||||||
 | 
					                .Includes<DrugInfo>(mr => mr.DrugInfo)
 | 
				
			||||||
 | 
					                .Includes<UserList>(mr => mr.User)
 | 
				
			||||||
 | 
					                .Includes<SurgicalScheduleDetail>(mr => mr._SurgicalScheduleDetailLst)
 | 
				
			||||||
 | 
					                .Where(mr => mr.Type == 2)
 | 
				
			||||||
 | 
					                .Where(mr => mr.Status < 2)
 | 
				
			||||||
 | 
					                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
 | 
					                //.WhereIF(QueryDate != null, mr => mr.OperationTime.ToString("yyyy-MM-dd") == QueryDate)
 | 
				
			||||||
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (mr) => mr.DrugInfo.DrugId.ToString().Contains(SearchValue))
 | 
				
			||||||
 | 
					                .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)
 | 
				
			||||||
 | 
					               .ToPageList(PageNum, PageSize, ref totalCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            MachineRecordList.ForEach(mr => mr.HasCheckNum = mr._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity));
 | 
				
			||||||
 | 
					            TotalCount = totalCount;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand BtnCloseCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 关闭当前窗口
 | 
				
			||||||
 | 
					                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 选中行事件
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand RowSelected
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (SelectedRecord != null && selectedRecord.Id != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    MachineRecordList = MachineRecordList.Select(x =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (x.Id == SelectedRecord.Id)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            x.IsSelected = !x.IsSelected;
 | 
				
			||||||
 | 
					                            if (x.IsSelected)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                if (SelectedRecord._SurgicalScheduleDetailLst != null && SelectedRecord._SurgicalScheduleDetailLst.Count > 0)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    //已经核销数
 | 
				
			||||||
 | 
					                                    int HasCheckNum = SelectedRecord._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity);
 | 
				
			||||||
 | 
					                                    x.CheckQuantity = SelectedRecord.Quantity - HasCheckNum;
 | 
				
			||||||
 | 
					                                    x.ReturnQuantity1 = SelectedRecord.Quantity - HasCheckNum - x.CheckQuantity;
 | 
				
			||||||
 | 
					                                    x.ReturnQuantity2 = HasCheckNum + x.CheckQuantity;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                else
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    x.CheckQuantity = SelectedRecord.Quantity;
 | 
				
			||||||
 | 
					                                    x.ReturnQuantity1 = 0;
 | 
				
			||||||
 | 
					                                    x.ReturnQuantity2 = SelectedRecord.Quantity;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                x.CheckQuantity = 0;
 | 
				
			||||||
 | 
					                                x.ReturnQuantity1 = 0;
 | 
				
			||||||
 | 
					                                x.ReturnQuantity2 = 0;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return x;
 | 
				
			||||||
 | 
					                    }).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 确认核销
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand AddSurgeryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                List<MachineRecord> RecordsLst = MachineRecordList.FindAll(rl => rl.IsSelected && rl.CheckQuantity > 0).ToList();
 | 
				
			||||||
 | 
					                if (_SurgicalSchedule != null && RecordsLst.Count > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    string operationId = _SurgicalSchedule.OperationId;
 | 
				
			||||||
 | 
					                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Updateable(new SurgicalSchedule()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            DmStatus = 1,
 | 
				
			||||||
 | 
					                            Id = _SurgicalSchedule.Id
 | 
				
			||||||
 | 
					                        }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.Id }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        for (int i = 0; i < RecordsLst.Count; i++)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Insertable(new SurgicalScheduleDetail()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                OperationId = operationId,
 | 
				
			||||||
 | 
					                                GetRecordId = RecordsLst[i].Id,
 | 
				
			||||||
 | 
					                                Quantity = RecordsLst[i].CheckQuantity,
 | 
				
			||||||
 | 
					                                DrugId = RecordsLst[i].DrugId,
 | 
				
			||||||
 | 
					                                ManuNo = RecordsLst[i].ManuNo,
 | 
				
			||||||
 | 
					                                EffDate = RecordsLst[i].EffDate.ToString(),
 | 
				
			||||||
 | 
					                                InsertUserId = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            int hasQuantity = RecordsLst[i]._SurgicalScheduleDetailLst.Sum(sd => sd.Quantity);
 | 
				
			||||||
 | 
					                            int dmStatus = 0;
 | 
				
			||||||
 | 
					                            //已经全部挂上钩,修改dm_machine_record状态为完成
 | 
				
			||||||
 | 
					                            //if (hasQuantity + RecordsLst[i].CheckQuantity == RecordsLst[i].Quantity)
 | 
				
			||||||
 | 
					                            //{
 | 
				
			||||||
 | 
					                            //    dmStatus = 2;
 | 
				
			||||||
 | 
					                            //}
 | 
				
			||||||
 | 
					                            //else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                dmStatus = 1;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Status = dmStatus,
 | 
				
			||||||
 | 
					                                Id = RecordsLst[i].Id
 | 
				
			||||||
 | 
					                            }).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.Id }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                    if (f.IsSuccess)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = "核销完成",
 | 
				
			||||||
 | 
					                            Type = MsgType.SUCCESS,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        RequestData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        logger.Info($"核销异常");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                        SnackbarMessageQueue.Enqueue("核销异常!");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue("未选中数据,或选中数据核销数量为0");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 全部归还(还药、还空瓶)
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand ReturnCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                List<MachineRecord> RecordsLst = MachineRecordList.FindAll(rl => rl.IsSelected && rl.CheckQuantity == 0).ToList();
 | 
				
			||||||
 | 
					                ReturnStockLst = new List<ChannelStock>();
 | 
				
			||||||
 | 
					                if (RecordsLst.Count > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //待还药的记录
 | 
				
			||||||
 | 
					                    List<MachineRecord> ReturnDrugLst = RecordsLst.Where(rl => rl.ReturnQuantity1 > 0).ToList();
 | 
				
			||||||
 | 
					                    //待还空瓶的记录
 | 
				
			||||||
 | 
					                    List<MachineRecord> ReturnEmptyLst = RecordsLst.Where(rl => rl.ReturnQuantity2 > 0).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    for (int i = 0; i < ReturnDrugLst.Count; i++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ChannelStock queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                                               .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
				
			||||||
 | 
					                                               .Where(cs => cs.DrugId == ReturnDrugLst[i].DrugId)
 | 
				
			||||||
 | 
					                                               .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
 | 
					                                               .Where(cs => cs.ManuNo == ReturnDrugLst[i].ManuNo)
 | 
				
			||||||
 | 
					                                               .OrderBy(cs => cs.Quantity).First();
 | 
				
			||||||
 | 
					                        if (queryData != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            queryData.AddQuantity = ReturnDrugLst[i].ReturnQuantity1;
 | 
				
			||||||
 | 
					                            queryData.MachineRecordId = ReturnDrugLst[i].Id;
 | 
				
			||||||
 | 
					                            ReturnStockLst.Add(queryData);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    for (int j = 0; j < ReturnEmptyLst.Count; j++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ChannelStock queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                                              .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
				
			||||||
 | 
					                                              .Where(cs => cs.DrugId == ReturnEmptyLst[j].DrugId)
 | 
				
			||||||
 | 
					                                              .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
 | 
					                                              //.Where(cs => cs.ManuNo == ReturnEmptyLst[j].ManuNo)
 | 
				
			||||||
 | 
					                                              .Where(cs => cs.DrawerType == 2)
 | 
				
			||||||
 | 
					                                              .OrderBy(cs => cs.Quantity).First();
 | 
				
			||||||
 | 
					                        if (queryData != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            queryData.ReturnQuantity = ReturnEmptyLst[j].ReturnQuantity2;
 | 
				
			||||||
 | 
					                            queryData.MachineRecordId = ReturnEmptyLst[j].Id;
 | 
				
			||||||
 | 
					                            ReturnStockLst.Add(queryData);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (ReturnStockLst != null && ReturnStockLst.Count > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ReturnStockLst = ReturnStockLst.OrderBy(cls => cls.DrawerNo).ToList();
 | 
				
			||||||
 | 
					                        //还药时AddQuantity有值;还空瓶时ReturnQuantity有值
 | 
				
			||||||
 | 
					                        enumerable = ReturnStockLst.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
				
			||||||
 | 
					                        enumerator = enumerable.GetEnumerator();
 | 
				
			||||||
 | 
					                        enumerator.MoveNext();
 | 
				
			||||||
 | 
					                        Status = 1;
 | 
				
			||||||
 | 
					                        OpenOneByOne();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                        SnackbarMessageQueue.Enqueue("选中数据未绑定库位,请先进行绑定库位");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue("未选中数据,或选中数据核销数量不为0");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 刷新
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand QueryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (msg.WindowName == "SurgeryTakeWindow")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
				
			||||||
 | 
					                int DrawerNo = grouping.Key;
 | 
				
			||||||
 | 
					                List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                switch (msg.EventType)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 抽屉打开
 | 
				
			||||||
 | 
					                    case EventType.DRAWEROPEN:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (channelStocks[0].process == 1)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                channelStocks.ForEach(it => it.process = 2);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 抽屉关闭
 | 
				
			||||||
 | 
					                    case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (channelStocks[0].process == 2)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                channelStocks.ForEach(it => it.process = 3);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
				
			||||||
 | 
					                            int DrawerNoBefore = groupingBefore.Key;
 | 
				
			||||||
 | 
					                            if (enumerator.MoveNext())
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
				
			||||||
 | 
					                                int DrawerNoAfter = groupingAfter.Key;
 | 
				
			||||||
 | 
					                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    Thread.Sleep(50);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                OpenOneByOne();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            // 已经全部取出
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Status = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                //保存数据
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                //TakeFinish();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 数量变化
 | 
				
			||||||
 | 
					                    case EventType.UPDATEQUANTITY:
 | 
				
			||||||
 | 
					                        if (Status == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    // 打开失败
 | 
				
			||||||
 | 
					                    case EventType.OPENERROR:
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = msg.Message,
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        Status = 0;
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void OpenOneByOne()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
				
			||||||
 | 
					            int DrawerNo = grouping.Key;
 | 
				
			||||||
 | 
					            List<ChannelStock> channelStocks = grouping.ToList();
 | 
				
			||||||
 | 
					            channelStocks.ForEach(it => it.process = 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            IEnumerable<string> strDrugName = channelStocks.Select(cs => cs.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					            string strNames = string.Empty;
 | 
				
			||||||
 | 
					            foreach (string name in strDrugName)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                strNames += name;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					             
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int drugQuantity = channelStocks.Sum(cs => cs.AddQuantity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int emptyQuantity = channelStocks.Sum(cs => cs.ReturnQuantity);
 | 
				
			||||||
 | 
					            string speakTxt = $"正在打开{DrawerNo}号抽屉,请将{strNames}的";
 | 
				
			||||||
 | 
					            if (drugQuantity > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                speakTxt += $"共计{drugQuantity}个药放入抽屉!";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (emptyQuantity > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                speakTxt += $"共计{emptyQuantity}个空瓶放入抽屉!";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync(speakTxt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 发送取药数量
 | 
				
			||||||
 | 
					            //singleChannels.ForEach(it =>
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    try
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //        _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //    catch (Exception ex)
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            Message = $"打开抽屉异常{ex.Message}",
 | 
				
			||||||
 | 
					            //            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					            //        };
 | 
				
			||||||
 | 
					            //        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            _portUtil.WindowName = "SurgeryTakeWindow";
 | 
				
			||||||
 | 
					            _portUtil.BoardType = channelStocks.Count > 0 ? channelStocks[0].BoardType : 1;
 | 
				
			||||||
 | 
					            _portUtil.ColNos = channelStocks.Select(it => it.ColNo).ToArray();
 | 
				
			||||||
 | 
					            _portUtil.DrawerNo = DrawerNo;
 | 
				
			||||||
 | 
					            _portUtil.Start();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _isFinishClick = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsFinishClick { get => _isFinishClick; set => SetProperty(ref _isFinishClick, value); }
 | 
				
			||||||
 | 
					        //完成
 | 
				
			||||||
 | 
					        private void TakeFinish()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            IsFinishClick = true;
 | 
				
			||||||
 | 
					            bool bRet = false;
 | 
				
			||||||
 | 
					            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                for (int i = 0; i < ReturnStockLst.Count; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ChannelStock it = ReturnStockLst[i];
 | 
				
			||||||
 | 
					                    int quantity = 0;
 | 
				
			||||||
 | 
					                    if (it.AddQuantity > 0)  //还药
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        quantity = it.AddQuantity;
 | 
				
			||||||
 | 
					                        bRet = ReturnDrug(it);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        quantity = it.ReturnQuantity;
 | 
				
			||||||
 | 
					                        bRet = ReturnEmpty(it);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (!bRet)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    // 更新屏显库存
 | 
				
			||||||
 | 
					                    if (it.BoardType == 5)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + quantity);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue("操作完成,库存已更新!");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return bRet;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            if (!f.IsSuccess || !f.Data)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                SnackbarMessageQueue.Enqueue("库存更新失败!");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            Status = 0;
 | 
				
			||||||
 | 
					            IsFinishClick = false;
 | 
				
			||||||
 | 
					            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 还药
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private bool ReturnDrug(ChannelStock stock)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    string InvoiceId = "RETURN_" + CurrentTimeMillis(); 
 | 
				
			||||||
 | 
					                    MachineRecord recordInfo = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(rd => rd.Id == stock.MachineRecordId).First();
 | 
				
			||||||
 | 
					                    // 更新数据 库存信息
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Quantity = stock.Quantity + stock.AddQuantity,
 | 
				
			||||||
 | 
					                        Id = stock.Id,
 | 
				
			||||||
 | 
					                    }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    // 获取更新完库存后的药品库存
 | 
				
			||||||
 | 
					                    List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                        .Where(cs => cs.MachineId.Equals(stock.MachineId))
 | 
				
			||||||
 | 
					                        .Where(cs => cs.DrugId.Equals(stock.DrugId))
 | 
				
			||||||
 | 
					                        .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
 | 
					                        .ToList();
 | 
				
			||||||
 | 
					                    // 更新数据 取药记录 设置还药数量、状态 
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ReturnQuantity1 = recordInfo.ReturnQuantity1 + stock.AddQuantity,
 | 
				
			||||||
 | 
					                        Id = recordInfo.Id,
 | 
				
			||||||
 | 
					                        Status = (recordInfo.CanReturnQuantity - stock.AddQuantity) == 0 ? 2 : 1,
 | 
				
			||||||
 | 
					                    }).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // 保存数据 还药记录
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = stock.MachineId,
 | 
				
			||||||
 | 
					                        DrawerNo = stock.DrawerNo,
 | 
				
			||||||
 | 
					                        ColNo = stock.ColNo,
 | 
				
			||||||
 | 
					                        DrugId = stock.DrugId,
 | 
				
			||||||
 | 
					                        ManuNo = stock.ManuNo,
 | 
				
			||||||
 | 
					                        EffDate = !String.IsNullOrEmpty(stock.EffDate) ? DateTime.ParseExact(stock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Quantity = stock.AddQuantity,
 | 
				
			||||||
 | 
					                        Type = 31,
 | 
				
			||||||
 | 
					                        InvoiceId = InvoiceId,
 | 
				
			||||||
 | 
					                        GetId = stock.MachineRecordId
 | 
				
			||||||
 | 
					                        //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //保存账册
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        DrugId = Convert.ToInt32(stock.DrugId),
 | 
				
			||||||
 | 
					                        Type = 1,
 | 
				
			||||||
 | 
					                        Department = ConfigurationManager.AppSettings["department"].ToString(),
 | 
				
			||||||
 | 
					                        InvoiceNo = InvoiceId,
 | 
				
			||||||
 | 
					                        ManuNo = stock.ManuNo,
 | 
				
			||||||
 | 
					                        EffDate = stock.EffDate,
 | 
				
			||||||
 | 
					                        AddQuantity = stock.AddQuantity,
 | 
				
			||||||
 | 
					                        UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                        MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                        CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                        CreateTime = DateTime.Now
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    //修改凌晨生成的日结存数据
 | 
				
			||||||
 | 
					                    AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                    .Where(ab => ab.MachineId.Equals(stock.MachineId))
 | 
				
			||||||
 | 
					                    .Where(ab => ab.Type == 3)
 | 
				
			||||||
 | 
					                    .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId))
 | 
				
			||||||
 | 
					                    .Where(ab => ab.ManuNo == stock.ManuNo)
 | 
				
			||||||
 | 
					                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                    if (accountBookG2Day != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + stock.AddQuantity;
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
				
			||||||
 | 
					                        int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            DrugId = Convert.ToInt32(stock.DrugId),
 | 
				
			||||||
 | 
					                            Type = 3,
 | 
				
			||||||
 | 
					                            ManuNo = stock.ManuNo,
 | 
				
			||||||
 | 
					                            EffDate = stock.EffDate,
 | 
				
			||||||
 | 
					                            YQuantity = 0,
 | 
				
			||||||
 | 
					                            ManuStock = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                            TotalStock = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                            InvoiceNo = "日结存"
 | 
				
			||||||
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        if (iDayResult <= 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            logger.Info($"未写入日结存数据{stock.DrugId}-{stock.ManuNo}-{stock.EffDate}-{stock.AddQuantity}");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    //修改凌晨生成的总结存数据
 | 
				
			||||||
 | 
					                    AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                    .Where(ab => ab.MachineId.Equals(stock.MachineId))
 | 
				
			||||||
 | 
					                    .Where(ab => ab.Type == 4)
 | 
				
			||||||
 | 
					                    .Where(ab => ab.DrugId == Convert.ToInt32(stock.DrugId))
 | 
				
			||||||
 | 
					                    .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                    if (accountBookG2Total != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + stock.AddQuantity;
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
				
			||||||
 | 
					                        int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            DrugId = Convert.ToInt32(stock.DrugId),
 | 
				
			||||||
 | 
					                            Type = 4,
 | 
				
			||||||
 | 
					                            YQuantity = 0,
 | 
				
			||||||
 | 
					                            ManuStock = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                            TotalStock = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                            InvoiceNo = "总结存"
 | 
				
			||||||
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        if (iTotalResult <= 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            logger.Info($"未写入总结存数据{stock.DrugId}-{stock.AddQuantity}");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                if (f.IsSuccess)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                throw;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 还空瓶
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private bool ReturnEmpty(ChannelStock stock)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string InvoiceId = "RETURN_" + CurrentTimeMillis();
 | 
				
			||||||
 | 
					            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 更新数据 库存信息
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Quantity = stock.Quantity + stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                    Id = stock.Id,
 | 
				
			||||||
 | 
					                }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 获取更新完库存后的药品库存
 | 
				
			||||||
 | 
					                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                    .Where(cs => cs.MachineId.Equals(stock.MachineId))
 | 
				
			||||||
 | 
					                    .Where(cs => cs.DrugId.Equals(stock.DrugId))
 | 
				
			||||||
 | 
					                    .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
 | 
					                    .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                MachineRecord recordInfo = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(rd => rd.Id == stock.MachineRecordId).First();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 更新数据 取药记录 设置还药数量、状态
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ReturnQuantity2 = stock.ReturnQuantity,
 | 
				
			||||||
 | 
					                    Id = recordInfo.Id,
 | 
				
			||||||
 | 
					                    Status = 2,
 | 
				
			||||||
 | 
					                }).UpdateColumns(it => new { it.ReturnQuantity2, it.Status }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 保存数据 还药空瓶记录
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    MachineId = stock.MachineId,
 | 
				
			||||||
 | 
					                    DrawerNo = stock.DrawerNo,
 | 
				
			||||||
 | 
					                    ColNo = stock.ColNo,
 | 
				
			||||||
 | 
					                    DrugId = stock.DrugId,
 | 
				
			||||||
 | 
					                    ManuNo = stock.ManuNo,
 | 
				
			||||||
 | 
					                    EffDate = !String.IsNullOrEmpty(stock.EffDate) ? DateTime.ParseExact(stock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
				
			||||||
 | 
					                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                    OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                    Quantity = stock.ReturnQuantity, //ReturnQuantity,
 | 
				
			||||||
 | 
					                    Type = 32,
 | 
				
			||||||
 | 
					                    InvoiceId = InvoiceId,
 | 
				
			||||||
 | 
					                    GetId = stock.MachineRecordId
 | 
				
			||||||
 | 
					                    //,StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!f.IsSuccess || !f.Data)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public long CurrentTimeMillis()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 取消
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand CancleTake
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _portUtil.ResetData();
 | 
				
			||||||
 | 
					                Status = 0;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // 完成按钮
 | 
				
			||||||
 | 
					        public DelegateCommand TakeFinishCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(TakeFinish);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,230 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.select;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using Prism.Services.Dialogs;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class SurgeryTakeWindowViewModel : 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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DelegateCommand _rowSelected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public SurgeryTakeWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = DialogService;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            new OrderTakeSelect
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Code = "OrderNo",
 | 
				
			||||||
 | 
					                Name = "手术号"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }; 
 | 
				
			||||||
 | 
					        private SurgicalSchedule? _selectedSurgicalSchedule;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public SurgicalSchedule? SelectedSurgicalSchedule
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _selectedSurgicalSchedule; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _selectedSurgicalSchedule, value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //OpenOrderDialog();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _scheduleTime = DateTime.Now.ToString("yyyy-MM-dd");
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件  手术计划开始时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string ScheduleTime
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _scheduleTime; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!String.IsNullOrEmpty(value))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SetProperty(ref _scheduleTime, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SetProperty(ref _scheduleTime, value);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string? _searchValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件 查询字段值
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? SearchValue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _searchValue; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _searchValue, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<SurgicalSchedule> _surgicalSchedule = new();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<SurgicalSchedule> _SurgicalSchedule { get { return _surgicalSchedule; } set { SetProperty(ref _surgicalSchedule, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public async void OpenOrderDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (SelectedSurgicalSchedule != null && SelectedSurgicalSchedule.DmStatus == 0 && SelectedSurgicalSchedule.HisState == 1)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 此处延时1毫秒,等待页面渲染
 | 
				
			||||||
 | 
					                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
				
			||||||
 | 
					                DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                dialogParameters.Add("SurgeryInfo", SelectedSurgicalSchedule);
 | 
				
			||||||
 | 
					                DialogServiceExtensions.ShowDialogHost(_dialogService, "SurgeryTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void DoDialogResult(IDialogResult dialogResult)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 委托   被动执行     被子窗口执行
 | 
				
			||||||
 | 
					            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
				
			||||||
 | 
					            //if(dialogResult.Result == ButtonResult.OK)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            SelectedSurgicalSchedule = null;
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
				
			||||||
 | 
					        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            continuationCallback(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 录入手术
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand AddSurgeryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() => {
 | 
				
			||||||
 | 
					                DialogServiceExtensions.ShowDialogHost(_dialogService, "AddSurgeryDialog", null, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand QueryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _SurgicalSchedule.Clear();
 | 
				
			||||||
 | 
					            int totalCount = 0;
 | 
				
			||||||
 | 
					            List<SurgicalSchedule> queryData = SqlSugarHelper.Db.Queryable<SurgicalSchedule>()
 | 
				
			||||||
 | 
					                .WhereIF(ScheduleTime != null, ss => ss.ScheduleTime.ToString("yyyy-MM-dd") == ScheduleTime)
 | 
				
			||||||
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue), ss => ss.OperationId == SearchValue) 
 | 
				
			||||||
 | 
					                .Where(ss => ss.DmStatus == 0)
 | 
				
			||||||
 | 
					                .Where(ss => ss.HisState == 1) 
 | 
				
			||||||
 | 
					                .GroupBy(ss => ss.OperationId)
 | 
				
			||||||
 | 
					                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
				
			||||||
 | 
					            _SurgicalSchedule = queryData;
 | 
				
			||||||
 | 
					            TotalCount = totalCount;
 | 
				
			||||||
 | 
					            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
				
			||||||
 | 
					        } 
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (msg.EventType == EventType.CODESCAN)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SearchValue = msg.Code;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -175,7 +175,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            int totalcount = 0;
 | 
					            int totalcount = 0;
 | 
				
			||||||
            UserList = SqlSugarHelper.Db.Queryable<UserList>()
 | 
					            UserList = SqlSugarHelper.Db.Queryable<UserList>()
 | 
				
			||||||
                .Includes<RoleDm>(ul => ul.Role)
 | 
					                .Includes<RoleDm>(ul => ul.Role)
 | 
				
			||||||
                .Where(ul => ul.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					                .Where(ul => ul.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) , (di) => di.Nickname.Contains(SearchValue))
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) , (di) => di.Nickname.Contains(SearchValue))
 | 
				
			||||||
                .ToPageList(PageNum, PageSize, ref totalcount)
 | 
					                .ToPageList(PageNum, PageSize, ref totalcount)
 | 
				
			||||||
                //.ToList()
 | 
					                //.ToList()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -190,9 +190,9 @@
 | 
				
			||||||
                    </Style>
 | 
					                    </Style>
 | 
				
			||||||
                </DataGrid.Resources>
 | 
					                </DataGrid.Resources>
 | 
				
			||||||
                <!--GroupStyle to group data-->
 | 
					                <!--GroupStyle to group data-->
 | 
				
			||||||
                <DataGrid.GroupStyle>
 | 
					                <!--<DataGrid.GroupStyle>
 | 
				
			||||||
                    <GroupStyle>
 | 
					                    <GroupStyle>
 | 
				
			||||||
                        <!--Group DataItems into DataGroup-->
 | 
					                        --><!--Group DataItems into DataGroup--><!--
 | 
				
			||||||
                        <GroupStyle.ContainerStyle>
 | 
					                        <GroupStyle.ContainerStyle>
 | 
				
			||||||
                            <Style TargetType="{x:Type GroupItem}">
 | 
					                            <Style TargetType="{x:Type GroupItem}">
 | 
				
			||||||
                                <Setter Property="Template">
 | 
					                                <Setter Property="Template">
 | 
				
			||||||
| 
						 | 
					@ -207,7 +207,7 @@
 | 
				
			||||||
                                                        <TextBlock FontWeight="Bold" Text="{Binding Path=Name.DrugInfo.Manufactory,StringFormat=厂家:{0},}" />
 | 
					                                                        <TextBlock FontWeight="Bold" Text="{Binding Path=Name.DrugInfo.Manufactory,StringFormat=厂家:{0},}" />
 | 
				
			||||||
                                                        <TextBlock FontWeight="Bold" Text="{Binding Path=Items,Converter={StaticResource GroupSumConverter}}" />
 | 
					                                                        <TextBlock FontWeight="Bold" Text="{Binding Path=Items,Converter={StaticResource GroupSumConverter}}" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                                        <!--<TextBlock FontWeight="Bold" Text="{Binding Path=Items,Converter={StaticResource GroupSumConverter}}" />-->
 | 
					                                                        --><!--<TextBlock FontWeight="Bold" Text="{Binding Path=Items,Converter={StaticResource GroupSumConverter}}" />--><!--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                                    </StackPanel>
 | 
					                                                    </StackPanel>
 | 
				
			||||||
                                                </Expander.Header>
 | 
					                                                </Expander.Header>
 | 
				
			||||||
| 
						 | 
					@ -220,19 +220,31 @@
 | 
				
			||||||
                        </GroupStyle.ContainerStyle>
 | 
					                        </GroupStyle.ContainerStyle>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    </GroupStyle>
 | 
					                    </GroupStyle>
 | 
				
			||||||
                </DataGrid.GroupStyle>
 | 
					                </DataGrid.GroupStyle>-->
 | 
				
			||||||
                <DataGrid.Columns>
 | 
					                <DataGrid.Columns>
 | 
				
			||||||
                    <DataGridTextColumn Width="100"
 | 
					                    <DataGridTextColumn Width="100" Header="药品" 
 | 
				
			||||||
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
 | 
					                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}" Binding="{Binding DrugInfo.DrugName}">                        
 | 
				
			||||||
 | 
					                    </DataGridTextColumn>
 | 
				
			||||||
 | 
					                    <DataGridTextColumn Width="100" Header="规格" 
 | 
				
			||||||
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
 | 
					                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}" Binding="{Binding DrugInfo.DrugSpec}">                        
 | 
				
			||||||
 | 
					                    </DataGridTextColumn>
 | 
				
			||||||
 | 
					                    <DataGridTextColumn Width="180" Header="厂家" 
 | 
				
			||||||
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
 | 
					                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}" Binding="{Binding DrugInfo.Manufactory}">                        
 | 
				
			||||||
 | 
					                    </DataGridTextColumn>
 | 
				
			||||||
 | 
					                    <DataGridTextColumn Width="60"
 | 
				
			||||||
                        Binding="{Binding Location}"
 | 
					                        Binding="{Binding Location}"
 | 
				
			||||||
                        Header="库位"
 | 
					                        Header="库位"
 | 
				
			||||||
                        IsReadOnly="True"
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
					                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
				
			||||||
                    <DataGridTextColumn  Width="147"
 | 
					                    <DataGridTextColumn  Width="80"
 | 
				
			||||||
                        Binding="{Binding ManuNo}"
 | 
					                        Binding="{Binding ManuNo}"
 | 
				
			||||||
                        Header="批次"
 | 
					                        Header="批次"
 | 
				
			||||||
                        IsReadOnly="True"
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
					                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
				
			||||||
                    <DataGridTextColumn  Width="147"
 | 
					                    <DataGridTextColumn  Width="100"
 | 
				
			||||||
                        Binding="{Binding EffDate}"
 | 
					                        Binding="{Binding EffDate}"
 | 
				
			||||||
                        Header="效期"
 | 
					                        Header="效期"
 | 
				
			||||||
                        IsReadOnly="True"
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
| 
						 | 
					@ -242,7 +254,7 @@
 | 
				
			||||||
                        Header="库存"
 | 
					                        Header="库存"
 | 
				
			||||||
                        IsReadOnly="True"
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
					                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
				
			||||||
                    <DataGridTemplateColumn Width="100"
 | 
					                    <DataGridTemplateColumn Width="80"
 | 
				
			||||||
                        Header="添加数量">
 | 
					                        Header="添加数量">
 | 
				
			||||||
                        <DataGridTemplateColumn.CellTemplate>
 | 
					                        <DataGridTemplateColumn.CellTemplate>
 | 
				
			||||||
                            <DataTemplate>
 | 
					                            <DataTemplate>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -145,11 +145,11 @@
 | 
				
			||||||
                </GroupStyle>
 | 
					                </GroupStyle>
 | 
				
			||||||
            </DataGrid.GroupStyle>
 | 
					            </DataGrid.GroupStyle>
 | 
				
			||||||
            <DataGrid.Columns>
 | 
					            <DataGrid.Columns>
 | 
				
			||||||
                <DataGridTextColumn Width="180"
 | 
					                <!--<DataGridTextColumn Width="180"
 | 
				
			||||||
                        Binding="{Binding OrderNo}"
 | 
					                        Binding="{Binding OrderNo}"
 | 
				
			||||||
                        Header="处方号"
 | 
					                        Header="处方号"
 | 
				
			||||||
                        IsReadOnly="True"
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
					                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
 | 
				
			||||||
                <DataGridTextColumn Width="180"
 | 
					                <DataGridTextColumn Width="180"
 | 
				
			||||||
                        Binding="{Binding drugInfo.DrugName}"
 | 
					                        Binding="{Binding drugInfo.DrugName}"
 | 
				
			||||||
                        Header="药品名称"
 | 
					                        Header="药品名称"
 | 
				
			||||||
| 
						 | 
					@ -165,11 +165,12 @@
 | 
				
			||||||
                        Header="厂家"
 | 
					                        Header="厂家"
 | 
				
			||||||
                        IsReadOnly="True"
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
					                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
				
			||||||
                <DataGridTextColumn Width="80"
 | 
					                <DataGridTextColumn Width="80"  Header="请领数"
 | 
				
			||||||
                                    Binding="{Binding Quantity}"
 | 
					                                    Binding="{Binding Quantity}" 
 | 
				
			||||||
                                    Header="数量"
 | 
					 | 
				
			||||||
                                    IsReadOnly="True"
 | 
					                                    IsReadOnly="True"
 | 
				
			||||||
                                    ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
 | 
					                                    ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}">
 | 
				
			||||||
 | 
					                </DataGridTextColumn>
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
                <!--<DataGridTextColumn Width="100"
 | 
					                <!--<DataGridTextColumn Width="100"
 | 
				
			||||||
                        Binding="{Binding CurrentMachineId}"
 | 
					                        Binding="{Binding CurrentMachineId}"
 | 
				
			||||||
                        Header="当前所在"
 | 
					                        Header="当前所在"
 | 
				
			||||||
| 
						 | 
					@ -181,6 +182,31 @@
 | 
				
			||||||
                        IsReadOnly="True"
 | 
					                        IsReadOnly="True"
 | 
				
			||||||
                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
 | 
					                        ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <DataGridTemplateColumn Header="批次" IsReadOnly="True">
 | 
				
			||||||
 | 
					                    <DataGridTemplateColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        <DataTemplate>
 | 
				
			||||||
 | 
					                            <ListBox ItemsSource="{Binding ManuNoList}" DisplayMemberPath="ManuNo" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
 | 
				
			||||||
 | 
					                        </DataTemplate>
 | 
				
			||||||
 | 
					                    </DataGridTemplateColumn.CellTemplate>
 | 
				
			||||||
 | 
					                </DataGridTemplateColumn>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <DataGridTemplateColumn Header="效期" IsReadOnly="True">
 | 
				
			||||||
 | 
					                    <DataGridTemplateColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        <DataTemplate>
 | 
				
			||||||
 | 
					                            <ListBox ItemsSource="{Binding ManuNoList}" DisplayMemberPath="EffDate" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
 | 
				
			||||||
 | 
					                        </DataTemplate>
 | 
				
			||||||
 | 
					                    </DataGridTemplateColumn.CellTemplate>
 | 
				
			||||||
 | 
					                </DataGridTemplateColumn>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <DataGridTemplateColumn Header="入库数" IsReadOnly="True">
 | 
				
			||||||
 | 
					                    <DataGridTemplateColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        <DataTemplate>
 | 
				
			||||||
 | 
					                            <ListBox ItemsSource="{Binding ManuNoList}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
 | 
				
			||||||
 | 
					                        </DataTemplate>
 | 
				
			||||||
 | 
					                    </DataGridTemplateColumn.CellTemplate>
 | 
				
			||||||
 | 
					                </DataGridTemplateColumn>
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            </DataGrid.Columns>
 | 
					            </DataGrid.Columns>
 | 
				
			||||||
        </DataGrid>
 | 
					        </DataGrid>
 | 
				
			||||||
        <!--<Grid.RowDefinitions>
 | 
					        <!--<Grid.RowDefinitions>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -117,9 +117,9 @@
 | 
				
			||||||
                    <GridViewColumn  Width="200"
 | 
					                    <GridViewColumn  Width="200"
 | 
				
			||||||
                        DisplayMemberBinding="{Binding OrderNo}"
 | 
					                        DisplayMemberBinding="{Binding OrderNo}"
 | 
				
			||||||
                        Header="处方号"/>
 | 
					                        Header="处方号"/>
 | 
				
			||||||
                    <GridViewColumn Width="240"
 | 
					                    <!--<GridViewColumn Width="240"
 | 
				
			||||||
                        DisplayMemberBinding="{Binding DeptName}"
 | 
					                        DisplayMemberBinding="{Binding DeptName}"
 | 
				
			||||||
                        Header="科室"/>
 | 
					                        Header="科室"/>-->
 | 
				
			||||||
                    <GridViewColumn Width="240"
 | 
					                    <GridViewColumn Width="240"
 | 
				
			||||||
                        DisplayMemberBinding="{Binding DrugName}"
 | 
					                        DisplayMemberBinding="{Binding DrugName}"
 | 
				
			||||||
                        Header="药品名称"/>
 | 
					                        Header="药品名称"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,329 @@
 | 
				
			||||||
 | 
					<UserControl x:Class="DM_Weight.Views.Dialog.AddSurgeryDialog"
 | 
				
			||||||
 | 
					             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
				
			||||||
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
 | 
					             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
				
			||||||
 | 
					             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
				
			||||||
 | 
					             xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
 | 
				
			||||||
 | 
					              xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
				
			||||||
 | 
					             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
				
			||||||
 | 
					              xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
				
			||||||
 | 
					              xmlns:prism="http://prismlibrary.com/"
 | 
				
			||||||
 | 
					             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
				
			||||||
 | 
					             mc:Ignorable="d"  
 | 
				
			||||||
 | 
					             MinWidth="880"
 | 
				
			||||||
 | 
					             MinHeight="479"
 | 
				
			||||||
 | 
					             Width="900"
 | 
				
			||||||
 | 
					             Height="650">
 | 
				
			||||||
 | 
					    <UserControl.Resources>
 | 
				
			||||||
 | 
					        <convert:StatusConverter x:Key="StatusConverter" />
 | 
				
			||||||
 | 
					        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
				
			||||||
 | 
					            <Style.Setters>
 | 
				
			||||||
 | 
					                <Setter Property="Height">
 | 
				
			||||||
 | 
					                    <Setter.Value>55</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Background">
 | 
				
			||||||
 | 
					                    <Setter.Value>#31ccec</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Foreground">
 | 
				
			||||||
 | 
					                    <Setter.Value>white</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					            </Style.Setters>
 | 
				
			||||||
 | 
					        </Style>
 | 
				
			||||||
 | 
					    </UserControl.Resources>
 | 
				
			||||||
 | 
					    <Grid>
 | 
				
			||||||
 | 
					        <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					        </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					        <Grid Background="#03a9f4" Grid.Row="0">
 | 
				
			||||||
 | 
					            <TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="录入手术" />
 | 
				
			||||||
 | 
					            <Button
 | 
				
			||||||
 | 
					                        Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
				
			||||||
 | 
					                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
				
			||||||
 | 
					                        HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                        Command="{Binding BtnCloseCommand}"
 | 
				
			||||||
 | 
					                        ToolTip="关闭"
 | 
				
			||||||
 | 
					                    >
 | 
				
			||||||
 | 
					                <materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
 | 
				
			||||||
 | 
					            </Button>
 | 
				
			||||||
 | 
					        </Grid>
 | 
				
			||||||
 | 
					        <materialDesign:Card Grid.Row="1">
 | 
				
			||||||
 | 
					            <Grid Margin="0 6 0 6" VerticalAlignment="Center" HorizontalAlignment="Left">
 | 
				
			||||||
 | 
					                <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					                    <RowDefinition Height="Auto"/>
 | 
				
			||||||
 | 
					                    <RowDefinition Height="Auto"/>
 | 
				
			||||||
 | 
					                </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					                <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                    <ColumnDefinition  Width="150"/>
 | 
				
			||||||
 | 
					                    <ColumnDefinition  Width="130"/>
 | 
				
			||||||
 | 
					                    <ColumnDefinition  Width="130"/>
 | 
				
			||||||
 | 
					                    <ColumnDefinition  Width="130"/>
 | 
				
			||||||
 | 
					                    <ColumnDefinition  Width="350"/>
 | 
				
			||||||
 | 
					                </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                <TextBox
 | 
				
			||||||
 | 
					                    Grid.Row="0"
 | 
				
			||||||
 | 
					                    Grid.Column="0"  
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="姓名"
 | 
				
			||||||
 | 
					                    Text="{Binding _SurgicalSchedule.PName}"
 | 
				
			||||||
 | 
					                    Margin="6"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					                <ComboBox
 | 
				
			||||||
 | 
					                Grid.Column="1"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
				
			||||||
 | 
					                SelectedItem="{Binding SelectedSex}"
 | 
				
			||||||
 | 
					                DisplayMemberPath="Value"
 | 
				
			||||||
 | 
					                ItemsSource="{Binding SexKeyValue}"
 | 
				
			||||||
 | 
					                />
 | 
				
			||||||
 | 
					                <TextBox
 | 
				
			||||||
 | 
					                    Grid.Row="0"
 | 
				
			||||||
 | 
					                    Grid.Column="2"
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="年龄"
 | 
				
			||||||
 | 
					                    Text="{Binding _SurgicalSchedule.Age}"
 | 
				
			||||||
 | 
					                    Margin="6"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					                <TextBox
 | 
				
			||||||
 | 
					                    Grid.Row="0"
 | 
				
			||||||
 | 
					                    Grid.Column="3"
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="身份证号"
 | 
				
			||||||
 | 
					                    Text="{Binding _SurgicalSchedule.IdNumber}"
 | 
				
			||||||
 | 
					                    Margin="6"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					                <TextBox
 | 
				
			||||||
 | 
					                    Grid.Row="0"
 | 
				
			||||||
 | 
					                    Grid.Column="4"
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="入院诊断"
 | 
				
			||||||
 | 
					                    Text="{Binding _SurgicalSchedule.Indiagnosis}"
 | 
				
			||||||
 | 
					                    Margin="6"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					                <TextBox
 | 
				
			||||||
 | 
					                    Grid.Row="1"
 | 
				
			||||||
 | 
					                    Grid.Column="0"
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="手术号"
 | 
				
			||||||
 | 
					                    Text="{Binding _SurgicalSchedule.OperationId}"
 | 
				
			||||||
 | 
					                    Margin="6"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					                <TextBox
 | 
				
			||||||
 | 
					                    Grid.Row="1"
 | 
				
			||||||
 | 
					                    Grid.Column="1"
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="手术间代码"
 | 
				
			||||||
 | 
					                    Text="{Binding _SurgicalSchedule.OpRoomCode}"
 | 
				
			||||||
 | 
					                    Margin="6"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					                <TextBox
 | 
				
			||||||
 | 
					                    Grid.Row="1"
 | 
				
			||||||
 | 
					                    Grid.Column="2" 
 | 
				
			||||||
 | 
					                    Text="{Binding _SurgicalSchedule.OpRoomName}"
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="手术间名称"
 | 
				
			||||||
 | 
					                    Margin="6"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					                <DatePicker
 | 
				
			||||||
 | 
					                    Grid.Row="1"
 | 
				
			||||||
 | 
					                    Grid.Column="3" 
 | 
				
			||||||
 | 
					                    SelectedDate="{Binding _SurgicalSchedule.ScheduleTime, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
 | 
				
			||||||
 | 
					                    SelectedDateFormat="Short"
 | 
				
			||||||
 | 
					                    Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="手术日期"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
 | 
				
			||||||
 | 
					                <DatePicker Width="200" HorizontalAlignment="Left"
 | 
				
			||||||
 | 
					                    Grid.Row="1"
 | 
				
			||||||
 | 
					                    Grid.Column="4" 
 | 
				
			||||||
 | 
					                    SelectedDate="{Binding _SurgicalSchedule.Indate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
 | 
				
			||||||
 | 
					                    SelectedDateFormat="Short"
 | 
				
			||||||
 | 
					                    Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="入院日期"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
 | 
				
			||||||
 | 
					            </Grid>
 | 
				
			||||||
 | 
					        </materialDesign:Card>
 | 
				
			||||||
 | 
					        <Grid  Grid.Row="2">
 | 
				
			||||||
 | 
					            <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					                <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					                <RowDefinition />
 | 
				
			||||||
 | 
					                <RowDefinition Height="Auto"/>
 | 
				
			||||||
 | 
					            </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
				
			||||||
 | 
					                <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="110" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="180" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition />
 | 
				
			||||||
 | 
					                </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                <ComboBox
 | 
				
			||||||
 | 
					                Grid.Column="0"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
				
			||||||
 | 
					                SelectedItem="{Binding SelectedItem}"
 | 
				
			||||||
 | 
					                DisplayMemberPath="Name"
 | 
				
			||||||
 | 
					                ItemsSource="{Binding Selects}"
 | 
				
			||||||
 | 
					                />
 | 
				
			||||||
 | 
					                <TextBox
 | 
				
			||||||
 | 
					                Grid.Column="1"
 | 
				
			||||||
 | 
					                Text="{Binding SearchValue}"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.Hint="{Binding SelectedItem.Name}"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                       Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=ConfirmVsRefresh}"
 | 
				
			||||||
 | 
					                        HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                        Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                        VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                        Command="{Binding AddSurgeryCommand}"
 | 
				
			||||||
 | 
					                        Content="保存并核销" />
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                        Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
 | 
				
			||||||
 | 
					                        materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                        materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                        HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                        Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                        VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                        Command="{Binding ReturnCommand}"
 | 
				
			||||||
 | 
					                        Content="全部归还" />
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                            Margin="2"
 | 
				
			||||||
 | 
					                            Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
 | 
				
			||||||
 | 
					                            Style="{StaticResource MaterialDesignRaisedAccentButton}"
 | 
				
			||||||
 | 
					                            Content="完成"
 | 
				
			||||||
 | 
					                            Command="{Binding TakeFinishCommand}"/>
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                            Margin="2"
 | 
				
			||||||
 | 
					                            Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
 | 
				
			||||||
 | 
					                            Style="{StaticResource MaterialDesignRaisedButton}"
 | 
				
			||||||
 | 
					                            Background="Orange"
 | 
				
			||||||
 | 
					                            BorderBrush="Orange"
 | 
				
			||||||
 | 
					                            Content="取消"
 | 
				
			||||||
 | 
					                            Command="{Binding CancleTake}" Cursor="Hand" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                        Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=ConfirmVsRefresh}"
 | 
				
			||||||
 | 
					                        HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                        Margin="0 0 6 0"
 | 
				
			||||||
 | 
					                        VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                        Command="{Binding QueryCommand}"
 | 
				
			||||||
 | 
					                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                        ToolTip="刷新" Cursor="Hand">
 | 
				
			||||||
 | 
					                        <materialDesign:PackIcon Kind="Refresh" />
 | 
				
			||||||
 | 
					                    </Button>
 | 
				
			||||||
 | 
					                </StackPanel>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            </Grid>
 | 
				
			||||||
 | 
					            <ListView
 | 
				
			||||||
 | 
					            Grid.Row="1"
 | 
				
			||||||
 | 
					            ItemsSource="{Binding MachineRecordList}"
 | 
				
			||||||
 | 
					            SelectedItem="{Binding SelectedRecord}"
 | 
				
			||||||
 | 
					            materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
				
			||||||
 | 
					            materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
				
			||||||
 | 
					            materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
				
			||||||
 | 
					                <ListView.Resources>
 | 
				
			||||||
 | 
					                    <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
				
			||||||
 | 
					                        <Setter Property="Foreground" Value="White" />
 | 
				
			||||||
 | 
					                    </Style>
 | 
				
			||||||
 | 
					                </ListView.Resources>
 | 
				
			||||||
 | 
					                <i:Interaction.Triggers>
 | 
				
			||||||
 | 
					                    <i:EventTrigger EventName="SelectionChanged">
 | 
				
			||||||
 | 
					                        <i:InvokeCommandAction Command="{Binding RowSelected}" />
 | 
				
			||||||
 | 
					                    </i:EventTrigger>
 | 
				
			||||||
 | 
					                </i:Interaction.Triggers>
 | 
				
			||||||
 | 
					                <ListView.View>
 | 
				
			||||||
 | 
					                    <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
				
			||||||
 | 
					                        <GridViewColumn Header="选择" Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <CheckBox IsChecked="{Binding IsSelected}"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="110"
 | 
				
			||||||
 | 
					                        Header="操作时间"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding OperationTime, StringFormat='yyyy-MM-dd HH:mm:ss'}"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        Header="操作人"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding User.Nickname}" />
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="130"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DrugInfo.DrugName}"
 | 
				
			||||||
 | 
					                        Header="药品名称"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DrugInfo.DrugSpec}"
 | 
				
			||||||
 | 
					                        Header="规格"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding ManuNo}"
 | 
				
			||||||
 | 
					                        Header="批次"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding EffDate, StringFormat=yyyy-MM-dd}"
 | 
				
			||||||
 | 
					                        Header="效期"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.Header>
 | 
				
			||||||
 | 
					                                <TextBlock Text="取药数量" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                            </GridViewColumn.Header>
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBlock Text="{Binding Quantity}" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.Header>
 | 
				
			||||||
 | 
					                                <TextBlock Text="已核销数量" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                            </GridViewColumn.Header>
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBlock Text="{Binding HasCheckNum}" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Header="核销数量" Width="80">
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" Width="50">
 | 
				
			||||||
 | 
					                                        <TextBox.Text>
 | 
				
			||||||
 | 
					                                            <Binding Path="CheckQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
 | 
				
			||||||
 | 
					                                                <Binding.ValidationRules>
 | 
				
			||||||
 | 
					                                                    <ExceptionValidationRule />
 | 
				
			||||||
 | 
					                                                </Binding.ValidationRules>
 | 
				
			||||||
 | 
					                                            </Binding>
 | 
				
			||||||
 | 
					                                        </TextBox.Text>
 | 
				
			||||||
 | 
					                                    </TextBox>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.Header>
 | 
				
			||||||
 | 
					                                <TextBlock Text="还药数量" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                            </GridViewColumn.Header>
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBlock Text="{Binding ReturnQuantity1}"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.Header>
 | 
				
			||||||
 | 
					                                <TextBlock Text="还空瓶数量" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                            </GridViewColumn.Header>
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBlock Text="{Binding ReturnQuantity2}"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                    </GridView>
 | 
				
			||||||
 | 
					                </ListView.View>
 | 
				
			||||||
 | 
					            </ListView>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <pagination:Pagination Grid.Row="2"
 | 
				
			||||||
 | 
					                                   CurrentPage="{Binding PageNum}"
 | 
				
			||||||
 | 
					                                   PageSize="{Binding PageSize}"
 | 
				
			||||||
 | 
					                                   TotalPages="{Binding TotalCount}"
 | 
				
			||||||
 | 
					                                   InfoTextIsEnabel="True"
 | 
				
			||||||
 | 
					                                />
 | 
				
			||||||
 | 
					            <materialDesign:Snackbar
 | 
				
			||||||
 | 
					                Background="{Binding SnackbarBackground}"
 | 
				
			||||||
 | 
					                MessageQueue="{Binding SnackbarMessageQueue}"/>
 | 
				
			||||||
 | 
					        </Grid>
 | 
				
			||||||
 | 
					    </Grid>
 | 
				
			||||||
 | 
					</UserControl>
 | 
				
			||||||
| 
						 | 
					@ -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.Dialog
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// AddSurgeryDialog.xaml 的交互逻辑
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class AddSurgeryDialog : UserControl
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public AddSurgeryDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,242 @@
 | 
				
			||||||
 | 
					<UserControl x:Class="DM_Weight.Views.Dialog.SurgeryTakeDialog"
 | 
				
			||||||
 | 
					             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
				
			||||||
 | 
					             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
				
			||||||
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
 | 
					             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
				
			||||||
 | 
					             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
				
			||||||
 | 
					             xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
 | 
				
			||||||
 | 
					             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
				
			||||||
 | 
					             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
				
			||||||
 | 
					             xmlns:prism="http://prismlibrary.com/"
 | 
				
			||||||
 | 
					             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
				
			||||||
 | 
					             mc:Ignorable="d" 
 | 
				
			||||||
 | 
					             MinWidth="880"
 | 
				
			||||||
 | 
					             MinHeight="479"
 | 
				
			||||||
 | 
					             Width="900"
 | 
				
			||||||
 | 
					             Height="650"
 | 
				
			||||||
 | 
					             >
 | 
				
			||||||
 | 
					    <UserControl.Resources>
 | 
				
			||||||
 | 
					        <convert:StatusConverter x:Key="StatusConverter" />
 | 
				
			||||||
 | 
					        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
				
			||||||
 | 
					            <Style.Setters>
 | 
				
			||||||
 | 
					                <Setter Property="Height">
 | 
				
			||||||
 | 
					                    <Setter.Value>55</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Background">
 | 
				
			||||||
 | 
					                    <Setter.Value>#31ccec</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Foreground">
 | 
				
			||||||
 | 
					                    <Setter.Value>white</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					            </Style.Setters>
 | 
				
			||||||
 | 
					        </Style>
 | 
				
			||||||
 | 
					    </UserControl.Resources>
 | 
				
			||||||
 | 
					    <Grid>
 | 
				
			||||||
 | 
					        <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					        </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					        <Grid Background="#03a9f4" Grid.Row="0">
 | 
				
			||||||
 | 
					            <TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="手术核销" />
 | 
				
			||||||
 | 
					            <Button
 | 
				
			||||||
 | 
					                        Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
				
			||||||
 | 
					                        Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
 | 
				
			||||||
 | 
					                        HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                        Command="{Binding BtnCloseCommand}"
 | 
				
			||||||
 | 
					                        ToolTip="关闭"
 | 
				
			||||||
 | 
					                    >
 | 
				
			||||||
 | 
					                <materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
 | 
				
			||||||
 | 
					            </Button>
 | 
				
			||||||
 | 
					        </Grid>
 | 
				
			||||||
 | 
					        <Grid  Grid.Row="1">
 | 
				
			||||||
 | 
					            <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					                <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					                <RowDefinition />
 | 
				
			||||||
 | 
					                <RowDefinition Height="Auto"/>
 | 
				
			||||||
 | 
					            </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
				
			||||||
 | 
					                <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="110" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition Width="180" />
 | 
				
			||||||
 | 
					                    <ColumnDefinition />
 | 
				
			||||||
 | 
					                </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                <ComboBox
 | 
				
			||||||
 | 
					                Grid.Column="0"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedComboBox}"
 | 
				
			||||||
 | 
					                SelectedItem="{Binding SelectedItem}"
 | 
				
			||||||
 | 
					                DisplayMemberPath="Name"
 | 
				
			||||||
 | 
					                ItemsSource="{Binding Selects}"
 | 
				
			||||||
 | 
					                />
 | 
				
			||||||
 | 
					                <TextBox
 | 
				
			||||||
 | 
					                Grid.Column="1"
 | 
				
			||||||
 | 
					                Text="{Binding SearchValue}"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.Hint="{Binding SelectedItem.Name}"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                       Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=ConfirmVsRefresh}"
 | 
				
			||||||
 | 
					                        HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                        Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                        VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                        Command="{Binding AddSurgeryCommand}"
 | 
				
			||||||
 | 
					                        Content="确认核销" />
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                        Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
 | 
				
			||||||
 | 
					                        materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                        materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
 | 
				
			||||||
 | 
					                        HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                        Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                        VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                        Command="{Binding ReturnCommand}"
 | 
				
			||||||
 | 
					                        Content="全部归还" />
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                            Margin="2"
 | 
				
			||||||
 | 
					                            Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
 | 
				
			||||||
 | 
					                            Style="{StaticResource MaterialDesignRaisedAccentButton}"
 | 
				
			||||||
 | 
					                            Content="完成"
 | 
				
			||||||
 | 
					                            Command="{Binding TakeFinishCommand}"/>
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                            Margin="2"
 | 
				
			||||||
 | 
					                            Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
 | 
				
			||||||
 | 
					                            Style="{StaticResource MaterialDesignRaisedButton}"
 | 
				
			||||||
 | 
					                            Background="Orange"
 | 
				
			||||||
 | 
					                            BorderBrush="Orange"
 | 
				
			||||||
 | 
					                            Content="取消"
 | 
				
			||||||
 | 
					                            Command="{Binding CancleTake}" Cursor="Hand" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <Button
 | 
				
			||||||
 | 
					                        Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=ConfirmVsRefresh}"
 | 
				
			||||||
 | 
					                        HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                        Margin="0 0 6 0"
 | 
				
			||||||
 | 
					                        VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                        Command="{Binding QueryCommand}"
 | 
				
			||||||
 | 
					                        Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                        ToolTip="刷新" Cursor="Hand">
 | 
				
			||||||
 | 
					                        <materialDesign:PackIcon Kind="Refresh" />
 | 
				
			||||||
 | 
					                    </Button>
 | 
				
			||||||
 | 
					                </StackPanel>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            </Grid>
 | 
				
			||||||
 | 
					            <ListView
 | 
				
			||||||
 | 
					            Grid.Row="1"
 | 
				
			||||||
 | 
					            ItemsSource="{Binding MachineRecordList}"
 | 
				
			||||||
 | 
					            SelectedItem="{Binding SelectedRecord}"
 | 
				
			||||||
 | 
					            materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
				
			||||||
 | 
					            materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
				
			||||||
 | 
					            materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
				
			||||||
 | 
					                <ListView.Resources>
 | 
				
			||||||
 | 
					                    <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
				
			||||||
 | 
					                        <Setter Property="Foreground" Value="White" />
 | 
				
			||||||
 | 
					                    </Style>
 | 
				
			||||||
 | 
					                </ListView.Resources>
 | 
				
			||||||
 | 
					                <i:Interaction.Triggers>
 | 
				
			||||||
 | 
					                    <i:EventTrigger EventName="SelectionChanged">
 | 
				
			||||||
 | 
					                        <i:InvokeCommandAction Command="{Binding RowSelected}" />
 | 
				
			||||||
 | 
					                    </i:EventTrigger>
 | 
				
			||||||
 | 
					                </i:Interaction.Triggers>
 | 
				
			||||||
 | 
					                <ListView.View>
 | 
				
			||||||
 | 
					                    <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
				
			||||||
 | 
					                        <GridViewColumn Header="选择" Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <CheckBox IsChecked="{Binding IsSelected}"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="110"
 | 
				
			||||||
 | 
					                        Header="操作时间"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding OperationTime, StringFormat='yyyy-MM-dd HH:mm:ss'}"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        Header="操作人"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding User.Nickname}" />
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="130"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DrugInfo.DrugName}"
 | 
				
			||||||
 | 
					                        Header="药品名称"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DrugInfo.DrugSpec}"
 | 
				
			||||||
 | 
					                        Header="规格"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding ManuNo}"
 | 
				
			||||||
 | 
					                        Header="批次"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding EffDate, StringFormat=yyyy-MM-dd}"
 | 
				
			||||||
 | 
					                        Header="效期"/>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.Header>
 | 
				
			||||||
 | 
					                                <TextBlock Text="取药数量" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                            </GridViewColumn.Header>
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBlock Text="{Binding Quantity}" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.Header>
 | 
				
			||||||
 | 
					                                <TextBlock Text="已核销数量" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                            </GridViewColumn.Header>
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBlock Text="{Binding HasCheckNum}" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Header="核销数量" Width="80">
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" Width="50">
 | 
				
			||||||
 | 
					                                        <TextBox.Text>
 | 
				
			||||||
 | 
					                                            <Binding Path="CheckQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
 | 
				
			||||||
 | 
					                                                <Binding.ValidationRules>
 | 
				
			||||||
 | 
					                                                    <ExceptionValidationRule />
 | 
				
			||||||
 | 
					                                                </Binding.ValidationRules>
 | 
				
			||||||
 | 
					                                            </Binding>
 | 
				
			||||||
 | 
					                                        </TextBox.Text>
 | 
				
			||||||
 | 
					                                    </TextBox>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.Header>
 | 
				
			||||||
 | 
					                                <TextBlock Text="还药数量" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                            </GridViewColumn.Header>
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBlock Text="{Binding ReturnQuantity1}"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                        <GridViewColumn Width="40">
 | 
				
			||||||
 | 
					                            <GridViewColumn.Header>
 | 
				
			||||||
 | 
					                                <TextBlock Text="还空瓶数量" TextWrapping="Wrap"/>
 | 
				
			||||||
 | 
					                            </GridViewColumn.Header>
 | 
				
			||||||
 | 
					                            <GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                                <DataTemplate>
 | 
				
			||||||
 | 
					                                    <TextBlock Text="{Binding ReturnQuantity2}"/>
 | 
				
			||||||
 | 
					                                </DataTemplate>
 | 
				
			||||||
 | 
					                            </GridViewColumn.CellTemplate>
 | 
				
			||||||
 | 
					                        </GridViewColumn>
 | 
				
			||||||
 | 
					                    </GridView>
 | 
				
			||||||
 | 
					                </ListView.View>
 | 
				
			||||||
 | 
					            </ListView>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <pagination:Pagination Grid.Row="2"
 | 
				
			||||||
 | 
					                                   CurrentPage="{Binding PageNum}"
 | 
				
			||||||
 | 
					                                   PageSize="{Binding PageSize}"
 | 
				
			||||||
 | 
					                                   TotalPages="{Binding TotalCount}"
 | 
				
			||||||
 | 
					                                   InfoTextIsEnabel="True"
 | 
				
			||||||
 | 
					                                />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <materialDesign:Snackbar
 | 
				
			||||||
 | 
					                Background="{Binding SnackbarBackground}"
 | 
				
			||||||
 | 
					                MessageQueue="{Binding SnackbarMessageQueue}"/>
 | 
				
			||||||
 | 
					        </Grid>
 | 
				
			||||||
 | 
					    </Grid>
 | 
				
			||||||
 | 
					</UserControl>
 | 
				
			||||||
| 
						 | 
					@ -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.Dialog
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// SurgeryTakeDialog.xaml 的交互逻辑
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class SurgeryTakeDialog : UserControl
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public SurgeryTakeDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -52,7 +52,13 @@
 | 
				
			||||||
                materialDesign:HintAssist.Hint="结束时间"
 | 
					                materialDesign:HintAssist.Hint="结束时间"
 | 
				
			||||||
                Style="{StaticResource MaterialDesignOutlinedDatePicker}"
 | 
					                Style="{StaticResource MaterialDesignOutlinedDatePicker}"
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
 | 
					            <!--<ComboBox
 | 
				
			||||||
 | 
					                    Margin="12 0 0 0"
 | 
				
			||||||
 | 
					                    Grid.Column="2"
 | 
				
			||||||
 | 
					                    ItemsSource="{Binding DrugTypeList}"
 | 
				
			||||||
 | 
					                    SelectedItem="{Binding _DrugType}"
 | 
				
			||||||
 | 
					                    materialDesign:HintAssist.Hint="药品类型"
 | 
				
			||||||
 | 
					                    IsEditable="True" DisplayMemberPath="TypeName"  Visibility="Collapsed"/>-->
 | 
				
			||||||
            <StackPanel Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
					            <StackPanel Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
 | 
				
			||||||
                <!--<Button
 | 
					                <!--<Button
 | 
				
			||||||
                    Margin="0 0 3 0"
 | 
					                    Margin="0 0 3 0"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,9 @@ using Unity;
 | 
				
			||||||
using Unity.Lifetime;
 | 
					using Unity.Lifetime;
 | 
				
			||||||
using DM_Weight.msg;
 | 
					using DM_Weight.msg;
 | 
				
			||||||
using DM_Weight.util;
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.Views
 | 
					namespace DM_Weight.Views
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -28,6 +31,7 @@ namespace DM_Weight.Views
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        //IRegionManager _regionManager;
 | 
					        //IRegionManager _regionManager;
 | 
				
			||||||
        //IUnityContainer _container;
 | 
					        //IUnityContainer _container;
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(PortUtil));
 | 
				
			||||||
        public MainWindow()
 | 
					        public MainWindow()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            InitializeComponent();
 | 
					            InitializeComponent();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,110 @@
 | 
				
			||||||
 | 
					<UserControl x:Class="DM_Weight.Views.ReturnEmptyDestoryWindow"
 | 
				
			||||||
 | 
					              xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
				
			||||||
 | 
					             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
				
			||||||
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
 | 
					             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 | 
				
			||||||
 | 
					             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
				
			||||||
 | 
					             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
				
			||||||
 | 
					             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
				
			||||||
 | 
					             xmlns:prism="http://prismlibrary.com/" >
 | 
				
			||||||
 | 
					    <UserControl.Resources>
 | 
				
			||||||
 | 
					        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
				
			||||||
 | 
					            <Style.Setters>
 | 
				
			||||||
 | 
					                <Setter Property="Height">
 | 
				
			||||||
 | 
					                    <Setter.Value>55</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Background">
 | 
				
			||||||
 | 
					                    <Setter.Value>#31ccec</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Foreground">
 | 
				
			||||||
 | 
					                    <Setter.Value>white</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					            </Style.Setters>
 | 
				
			||||||
 | 
					        </Style>
 | 
				
			||||||
 | 
					    </UserControl.Resources>
 | 
				
			||||||
 | 
					    <Grid>
 | 
				
			||||||
 | 
					        <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            <RowDefinition />
 | 
				
			||||||
 | 
					        </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
				
			||||||
 | 
					            <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="1.5*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="1.5*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="5*"/>
 | 
				
			||||||
 | 
					            </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					            <DatePicker
 | 
				
			||||||
 | 
					                Grid.Column="0"
 | 
				
			||||||
 | 
					                SelectedDate="{Binding StartDate, TargetNullValue=''}"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.Hint="开始时间"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedDatePicker}"
 | 
				
			||||||
 | 
					            />
 | 
				
			||||||
 | 
					            <DatePicker
 | 
				
			||||||
 | 
					                Grid.Column="1"
 | 
				
			||||||
 | 
					                SelectedDate="{Binding EndDate}"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.Hint="结束时间"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedDatePicker}"
 | 
				
			||||||
 | 
					            />
 | 
				
			||||||
 | 
					            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"  Grid.Column="3">
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding DestoryEmptyCommand}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    Content="销毁" />
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding DownloadRecordCommand}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    Content="导出回收销毁记录" />
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    Margin="0 0 6 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding Query}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    ToolTip="刷新"
 | 
				
			||||||
 | 
					                >
 | 
				
			||||||
 | 
					                    <materialDesign:PackIcon
 | 
				
			||||||
 | 
					                    Kind="Refresh" />
 | 
				
			||||||
 | 
					                </Button>
 | 
				
			||||||
 | 
					            </StackPanel>
 | 
				
			||||||
 | 
					        </Grid>
 | 
				
			||||||
 | 
					        <ListView
 | 
				
			||||||
 | 
					            Grid.Row="1"
 | 
				
			||||||
 | 
					            ItemsSource="{Binding Channels}"
 | 
				
			||||||
 | 
					            SelectedItem="{Binding Channel}"
 | 
				
			||||||
 | 
					            materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
 | 
				
			||||||
 | 
					            materialDesign:DataGridAssist.ColumnHeaderPadding="10"
 | 
				
			||||||
 | 
					            materialDesign:ListViewAssist.ListViewItemPadding="13">
 | 
				
			||||||
 | 
					            <ListView.Resources>
 | 
				
			||||||
 | 
					                <Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
 | 
				
			||||||
 | 
					                    <Setter Property="Foreground" Value="White" />
 | 
				
			||||||
 | 
					                </Style>
 | 
				
			||||||
 | 
					            </ListView.Resources>
 | 
				
			||||||
 | 
					            <ListView.View>
 | 
				
			||||||
 | 
					                <GridView ColumnHeaderContainerStyle="{StaticResource st}">
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="140"
 | 
				
			||||||
 | 
					                        Header="库位"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding Location}"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn  Width="200"
 | 
				
			||||||
 | 
					                        Header="药品名称"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DrugInfo.DrugName}" />
 | 
				
			||||||
 | 
					                    <GridViewColumn  Width="200"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DrugInfo.DrugSpec}"
 | 
				
			||||||
 | 
					                        Header="规格"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn  Width="200"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DrugInfo.Manufactory}"
 | 
				
			||||||
 | 
					                        Header="厂家"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn  Width="150"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding Quantity}"
 | 
				
			||||||
 | 
					                        Header="库存"/>
 | 
				
			||||||
 | 
					                </GridView>
 | 
				
			||||||
 | 
					            </ListView.View>
 | 
				
			||||||
 | 
					        </ListView>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    </Grid>
 | 
				
			||||||
 | 
					</UserControl>
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// ReturnEmptyDestoryWindow.xaml 的交互逻辑
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class ReturnEmptyDestoryWindow : UserControl
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public ReturnEmptyDestoryWindow()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,134 @@
 | 
				
			||||||
 | 
					<UserControl x:Class="DM_Weight.Views.SurgeryTakeWindow"
 | 
				
			||||||
 | 
					             xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
 | 
				
			||||||
 | 
					             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 
 | 
				
			||||||
 | 
					             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
				
			||||||
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
 | 
					             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
 | 
				
			||||||
 | 
					              xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
 | 
				
			||||||
 | 
					             xmlns:prism="http://prismlibrary.com/"
 | 
				
			||||||
 | 
					             xmlns:convert="clr-namespace:DM_Weight.Converter"
 | 
				
			||||||
 | 
					             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 | 
				
			||||||
 | 
					             xmlns:local="clr-namespace:DM_Weight.Views"
 | 
				
			||||||
 | 
					             mc:Ignorable="d" >
 | 
				
			||||||
 | 
					    <UserControl.Resources>
 | 
				
			||||||
 | 
					        <convert:OrderStatusConverter x:Key="OrderStatusConverter" />
 | 
				
			||||||
 | 
					        <Style x:Key="st" TargetType="GridViewColumnHeader">
 | 
				
			||||||
 | 
					            <Style.Setters>
 | 
				
			||||||
 | 
					                <Setter Property="Height">
 | 
				
			||||||
 | 
					                    <Setter.Value>55</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Background">
 | 
				
			||||||
 | 
					                    <Setter.Value>#31ccec</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					                <Setter Property="Foreground">
 | 
				
			||||||
 | 
					                    <Setter.Value>white</Setter.Value>
 | 
				
			||||||
 | 
					                </Setter>
 | 
				
			||||||
 | 
					            </Style.Setters>
 | 
				
			||||||
 | 
					        </Style>
 | 
				
			||||||
 | 
					    </UserControl.Resources>
 | 
				
			||||||
 | 
					    <Grid>
 | 
				
			||||||
 | 
					        <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					            <RowDefinition />
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
 | 
					        </Grid.RowDefinitions>
 | 
				
			||||||
 | 
					        <Grid Margin="0 6 0 6" Grid.Row="0">
 | 
				
			||||||
 | 
					            <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                <!--<ColumnDefinition Width="1.5*" />-->
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="2*" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="6*"/>
 | 
				
			||||||
 | 
					            </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <TextBox
 | 
				
			||||||
 | 
					                Grid.Column="0"
 | 
				
			||||||
 | 
					                Text="{Binding SearchValue, UpdateSourceTrigger=PropertyChanged}"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.Hint="手术号"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.IsFloating="True"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
 | 
				
			||||||
 | 
					            <DatePicker
 | 
				
			||||||
 | 
					                Grid.Column="1"
 | 
				
			||||||
 | 
					                SelectedDate="{Binding ScheduleTime, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
 | 
				
			||||||
 | 
					                SelectedDateFormat="Short"
 | 
				
			||||||
 | 
					                Margin="6 0 0 0"
 | 
				
			||||||
 | 
					                materialDesign:HintAssist.Hint="手术日期"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
 | 
				
			||||||
 | 
					            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="2">
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                    Margin="0 0 3 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    Command="{Binding AddSurgeryCommand}"
 | 
				
			||||||
 | 
					                    Content="录入手术" />
 | 
				
			||||||
 | 
					                <Button
 | 
				
			||||||
 | 
					                    HorizontalAlignment="Right"
 | 
				
			||||||
 | 
					                    Margin="0 0 6 0"
 | 
				
			||||||
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
 | 
					                    Command="{Binding QueryCommand}"
 | 
				
			||||||
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
 | 
					                    ToolTip="刷新" Cursor="Hand">
 | 
				
			||||||
 | 
					                    <materialDesign:PackIcon
 | 
				
			||||||
 | 
					                    Kind="Refresh" />
 | 
				
			||||||
 | 
					                </Button>
 | 
				
			||||||
 | 
					            </StackPanel>
 | 
				
			||||||
 | 
					        </Grid>
 | 
				
			||||||
 | 
					        <ListView
 | 
				
			||||||
 | 
					            Grid.Row="1"  Grid.ColumnSpan="3"
 | 
				
			||||||
 | 
					            ItemsSource="{Binding _SurgicalSchedule}"
 | 
				
			||||||
 | 
					            SelectedItem="{Binding SelectedSurgicalSchedule}"
 | 
				
			||||||
 | 
					            materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"> 
 | 
				
			||||||
 | 
					            <i:Interaction.Triggers>
 | 
				
			||||||
 | 
					                <i:EventTrigger EventName="SelectionChanged">
 | 
				
			||||||
 | 
					                    <i:InvokeCommandAction Command="{Binding RowSelected}" />
 | 
				
			||||||
 | 
					                </i:EventTrigger>
 | 
				
			||||||
 | 
					            </i:Interaction.Triggers>
 | 
				
			||||||
 | 
					            <ListView.ItemContainerStyle>
 | 
				
			||||||
 | 
					                <Style TargetType="ListViewItem" BasedOn="{StaticResource MaterialDesignGridViewItem}">
 | 
				
			||||||
 | 
					                    <Setter Property="ListView.Height" Value="50"/>
 | 
				
			||||||
 | 
					                </Style>
 | 
				
			||||||
 | 
					            </ListView.ItemContainerStyle>
 | 
				
			||||||
 | 
					            <ListView.View>
 | 
				
			||||||
 | 
					                <GridView ColumnHeaderContainerStyle="{StaticResource st}" >
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        Header="患者ID"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding PatientId}"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="100"
 | 
				
			||||||
 | 
					                        Header="姓名"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding PName}" />
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding Sex}"
 | 
				
			||||||
 | 
					                        Header="性别"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn  Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding Age}"
 | 
				
			||||||
 | 
					                        Header="年龄"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="153"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding IdNumber}"
 | 
				
			||||||
 | 
					                        Header="身份证"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding OperationId}"
 | 
				
			||||||
 | 
					                        Header="手术号"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="153"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding OpRoomCode}"
 | 
				
			||||||
 | 
					                        Header="手术间代码"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="153"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding OpRoomName}"
 | 
				
			||||||
 | 
					                        Header="手术间名称"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn Width="153"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding ScheduleTime, StringFormat='yyyy-MM-dd HH:mm:ss'}"
 | 
				
			||||||
 | 
					                        Header="手术时间"/>
 | 
				
			||||||
 | 
					                    <GridViewColumn  Width="80"
 | 
				
			||||||
 | 
					                        DisplayMemberBinding="{Binding DmStatus, Converter={StaticResource OrderStatusConverter}}"
 | 
				
			||||||
 | 
					                        Header="状态"/>
 | 
				
			||||||
 | 
					                </GridView>
 | 
				
			||||||
 | 
					            </ListView.View>
 | 
				
			||||||
 | 
					        </ListView>
 | 
				
			||||||
 | 
					        <pagination:Pagination Grid.Row="2" Grid.ColumnSpan="3"
 | 
				
			||||||
 | 
					                                   CurrentPage="{Binding PageNum}"
 | 
				
			||||||
 | 
					                                   PageSize="{Binding PageSize}"
 | 
				
			||||||
 | 
					                                   TotalPages="{Binding TotalCount}"
 | 
				
			||||||
 | 
					                                   InfoTextIsEnabel="True"
 | 
				
			||||||
 | 
					                                />
 | 
				
			||||||
 | 
					    </Grid>
 | 
				
			||||||
 | 
					</UserControl>
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// SurgeryTakeWindow.xaml 的交互逻辑
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class SurgeryTakeWindow : UserControl
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public SurgeryTakeWindow()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue