2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
										 
									
								 
							
							
								 using  gregn6Lib ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  Newtonsoft.Json ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  System ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  System.Collections.Generic ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  System.IO ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  System.Linq ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  System.Text ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  System.Threading.Tasks ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  DM_Weight.Models ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  System.Configuration ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  DM_Weight.util ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  System.Data ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  MySqlConnector ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								using  System.Windows.Markup ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								namespace  DM_Weight.Report 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    public  class  GridReportUtil 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  string  gridConnectionString  =  ConfigurationManager . AppSettings [ "gridConnectionString" ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         *  打 印 预 览 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         *  tempname :  模 板 文 件 名 称 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         *  data :  模 板 数 据 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReport ( string  tempname ,  object  data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  tempname ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  s  =  JsonConvert . SerializeObject ( data ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载数据 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadDataFromXML ( JsonConvert . SerializeObject ( data ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportStock ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . Initialize  + =  new  _IGridppReportEvents_InitializeEventHandler ( ( )  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "machine_id" ) . Value  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  SQL  =  $ @ "SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          di . ` drug_name `  AS  drugName , di . ` drug_spec `  AS  drugSpec , di . ` pack_unit `  AS  packUnit , di . small_unit  as  smallUnit , di . ` manufactory `  AS  manuFactory , di . ` max_stock `  AS  baseQuantity , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 16:58:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          cl . ` drug_id `  AS  drugId  FROM  channel_stock  cl  INNER  JOIN  drug_info  di  ON  di . ` drug_id `  =  cl . ` drug_id `  WHERE  cl . ` machine_id `  =   ' { machine_id } '  AND  cl . ` drawer_type `  =  1  ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            if ( App . SingleModel ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                SQL  + =  " and cl.row_no<=8" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                SQL  + =  " and cl.row_no>8" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  + =  " ORDER BY cl.`drug_id`" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "stock_template.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . ConnectionString  =  gridConnectionString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . QuerySQL  =  SQL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// 导出盘点后库存信息 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// </summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="startDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="endDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportStockNew ( DateTime ?  startDate ,  DateTime ?  endDate ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_startDate  =  startDate  ? ?  Convert . ToDateTime ( "2010-1-1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_endDate  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() => 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //    Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //}); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  SQL  =  $ @ "SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-24 11:35:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          ` drug_name `  AS  drugName , ` drug_spec `  AS  drugSpec , ` pack_unit `  AS   packUnit , pack_unit   AS  smallUnit , ` manufactory `  AS  manuFactory , ` max_stock `  AS  baseQuantity , 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          cl . ` drug_id `  AS  drugId , cl . manuquantity ,  cl . ` optdate `  FROM  check_stock  cl  WHERE  cl . ` machine_id `  =   ' { machine_id } '  AND  cl . ` optdate `  >  ' { p_startDate } '  AND  cl . ` optdate `  <  ' { p_endDate } '  ORDER  BY  cl . ` optdate `  desc ,  cl . ` drug_id ` ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "machine_log_check_new2.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . ConnectionString  =  gridConnectionString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . QuerySQL  =  SQL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportAccountBook ( DateTime ?  startDate ,  DateTime ?  endDate ,  int  type ,  string  drug_id ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_startDate  =  startDate  ? ?  Convert . ToDateTime ( "2010-1-1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_endDate  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  p_machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "account_book_temp.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  SQL  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . ConnectionString  =  gridConnectionString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . Initialize  + =  new  _IGridppReportEvents_InitializeEventHandler ( ( )  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "machine_id" ) . Value  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "startDate" ) . Value  =  startDate  ? ?  Convert . ToDateTime ( "2010-1-1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "endDate" ) . Value  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //Report.DetailGrid.Recordset.QuerySQL = SQL; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  =  $ @ "SELECT TYPE, stockQuantity,inQuantity,outQuantity,operationTime,invoiceId,drugName,drugId,drugSpec,packUnit,smallUnit,dosage,manufactory,manuNo,effDate,
 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        operatorName , reviewerName , supplierDept , receiveDept , bigUnit  FROM  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        ( SELECT  mr . type ,  mr . ` stock_quantity `  AS  ` stockQuantity ` ,  IF ( mr . ` type `  IN  ( 1 ,  31 ) ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  >  0 ,  mr . ` quantity ` ,  0 ) )  
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        AS  ` inQuantity ` ,  IF ( mr . ` type `  =  2 ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  <  0 ,  ( 0  -  mr . ` quantity ` ) ,  0 ) )  AS  ` outQuantity ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                         mr . ` operation_time `  AS  ` operationTime ` , IF ( mr . ` type ` = 1 , mr . ` invoice_id ` , NULL )  AS  ` invoiceId ` ,  di . ` drug_name `  AS  ` drugName ` ,  di . ` drug_id `  AS  ` drugId ` , 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                         di . ` drug_spec `  AS  ` drugSpec ` ,  di . ` pack_unit `  AS  ` packUnit ` , di . big_unit  as  bigUnit , di . small_unit  as  smallUnit ,  di . ` dosage `  AS  ` dosage ` ,  di . ` manufactory `  AS  ` manufactory ` ,  
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        mr . ` manu_no `  AS  ` manuNo ` ,  mr . ` eff_date `  AS  ` effDate ` ,  u1 . ` user_name `  AS  ` operatorName ` ,  u2 . ` user_name `  AS  ` reviewerName ` , mr . supplierDept , mr . receiveDept  FROM  
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        dm_machine_record  mr   LEFT  JOIN  drug_info  di  ON  mr . ` drug_id `  =  di . ` drug_id `   LEFT  JOIN  user_list  u1  ON  mr . ` operator `  =  u1 . ` id `   
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        LEFT  JOIN  user_list  u2  ON  mr . ` reviewer `  =  u2 . ` id `  WHERE  mr . ` machine_id `  =  ' { p_machine_id } '  AND  mr . ` operation_time `  >  ' { p_startDate } ' 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        AND  mr . ` operation_time `  <  ' { p_endDate } '   and  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  =  0 ,  99999 ,  mr . ` quantity ` )  < > 99999  ";
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            if  ( ! string . IsNullOrEmpty ( drug_id ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                SQL  + =  " AND mr.drug_id='"  +  drug_id  +  "' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  + =  " ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`) AS T" ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            if  ( type  >  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                if  ( type  = =  1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    SQL  + =  " WHERE inQuantity>0 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                if  ( type  = =  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    SQL  + =  " WHERE outQuantity>0 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                if  ( type  = =  5 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    SQL  + =  " WHERE type=5 " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . QuerySQL  =  SQL ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportMechineRecord ( int  type ,  DateTime ?  startDate ,  DateTime ?  endDate ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_startDate  =  startDate  ? ?  Convert . ToDateTime ( "2010-1-1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_endDate  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  p_machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  SQL  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . Initialize  + =  new  _IGridppReportEvents_InitializeEventHandler ( ( )  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "machine_id" ) . Value  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "startDate" ) . Value  =  startDate  ? ?  DateTime . Now . AddYears ( - 10 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "endDate" ) . Value  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            if  ( type  = =  1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "machine_log_add.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                SQL  =  $ @ "SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,dmr.`quantity` AS quantity,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      dmr . ` manu_no `  AS  manuNo , dmr . ` eff_date `  AS  effDate , dmr . ` operation_time `  AS  operationTime , 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      di . ` drug_name `  AS  drugName , di . ` drug_spec `  AS  drugSpec , di . ` pack_unit `  AS  packUnit , di . small_unit  as  smallUnit , 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      di . ` manufactory `  AS  manuFactory , di . ` max_stock `  AS  baseQuantity , dmr . ` drug_id `  AS  drugId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      ul . ` user_name `  AS  nickname  FROM  dm_machine_record  dmr  LEFT  JOIN  drug_info  di  ON  di . ` drug_id `  =  dmr . ` drug_id ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    LEFT  JOIN  user_list  ul  ON  ul . ` id `  =  dmr . ` Operator `  WHERE  dmr . ` type `  =  1  AND  dmr . ` machine_id `  =  ' { p_machine_id } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                     AND  dmr . ` operation_time `  >  ' { p_startDate } '  AND  dmr . ` operation_time `  <  ' { p_endDate } ' ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            else  if  ( type  = =  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "machine_log_take.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                SQL  =  $ @ " SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,dmr.`quantity` AS quantity,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      dmr . ` manu_no `  AS  manuNo , dmr . ` eff_date `  AS  effDate , dmr . ` operation_time `  AS  operationTime , 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      di . ` drug_name `  AS  drugName , di . ` drug_spec `  AS  drugSpec , di . ` pack_unit `  AS  packUnit , di . small_unit  as  smallUnit , 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      di . ` manufactory `  AS  manuFactory , di . ` max_stock `  AS  baseQuantity , dmr . ` drug_id `  AS  drugId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      ul . ` user_name `  AS  nickname  FROM  dm_machine_record  dmr  LEFT  JOIN  drug_info  di  ON  di . ` drug_id `  =  dmr . ` drug_id ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    LEFT  JOIN  user_list  ul  ON  ul . ` id `  =  dmr . ` Operator `  WHERE  dmr . ` type `  =  2  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                     AND  dmr . ` machine_id `  = ' { p_machine_id } '   AND  dmr . ` operation_time `  >  ' { p_startDate } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                     AND  dmr . ` operation_time `  <  ' { p_endDate } ' ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            else  if  ( type  = =  3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "machine_log_return.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                SQL  =  $ @ " SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      CONCAT ( dmr . ` quantity ` , IF ( dmr . ` type ` = 32 , "" ( 空 瓶 ) "" , "" "" ) )  AS  quantity , dmr . ` manu_no `  AS  manuNo , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      dmr . ` eff_date `  AS  effDate , dmr . ` operation_time `  AS  operationTime , di . ` drug_name `  AS  drugName , 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      di . ` drug_spec `  AS  drugSpec , di . ` pack_unit `  AS  packUnit , di . small_unit  as  smallUnit , 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      di . ` manufactory `  AS  manuFactory , di . ` max_stock `  AS  baseQuantity , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                      dmr . ` drug_id `  AS  drugId , ul . ` user_name `  AS  nickname  FROM  dm_machine_record  dmr 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    LEFT  JOIN  drug_info  di  ON  di . ` drug_id `  =  dmr . ` drug_id `  LEFT  JOIN  user_list  ul  ON  ul . ` id `  =  dmr . ` Operator ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    WHERE  dmr . ` type `  in  ( 31 ,  32 )  AND  dmr . ` machine_id `  =  ' { p_machine_id } '  AND  dmr . ` operation_time `  >  ' { p_startDate } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                     AND  dmr . ` operation_time `  <  ' { p_endDate } ' ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "machine_log_check.grf" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-27 15:35:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                SQL  =  $ @ " SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,dmr.`check_quantity` AS quantity,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          dmr . ` manu_no `  AS  manuNo , dmr . ` eff_date `  AS  effDate , dmr . ` operation_time `  AS  operationTime , 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          di . ` drug_name `  AS  drugName , di . ` drug_spec `  AS  drugSpec , di . ` pack_unit `  AS  packUnit , di . small_unit  as  smallUnit , 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          di . ` manufactory `  AS  manuFactory , di . ` max_stock `  AS  baseQuantity , dmr . ` drug_id `  AS  drugId , 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-27 15:35:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          ul . ` user_name `  AS  nickname , u2 . ` user_name `  as  reviewer  FROM  dm_machine_record  dmr  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          LEFT  JOIN  drug_info  di  ON  di . ` drug_id `  =  dmr . ` drug_id ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          LEFT  JOIN  user_list  ul  ON  ul . ` id `  =  dmr . ` Operator `  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          LEFT  JOIN  user_list  u2  ON  dmr . ` reviewer `  =  u2 . ` id `  WHERE  dmr . ` type `  =  4  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          AND  dmr . ` machine_id `  =  ' { p_machine_id } '  AND  dmr . ` operation_time `  >  ' { p_startDate } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                          AND  dmr . ` operation_time `  <  ' { p_endDate } ' ";
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . ConnectionString  =  gridConnectionString ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . QuerySQL  =  SQL ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         *  打 印 预 览 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         *  tempname :  模 板 文 件 名 称 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         *  data :  模 板 数 据 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								         * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintMachineRecordReport ( List < MachineRecord >  data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//machine_log.grf" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载数据 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . ParameterByName ( "type" ) . AsInteger  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        //交接班记录报表 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintChangeShiftsReport ( DateTime ?  startDate ,  DateTime ?  endDate ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_startDate  =  startDate  ? ?  Convert . ToDateTime ( "2010-1-1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_endDate  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  p_machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 17:33:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "changeShifts_temp.grf"); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "changeShifts_temp_new.grf" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  SQL  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . ConnectionString  =  gridConnectionString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . Initialize  + =  new  _IGridppReportEvents_InitializeEventHandler ( ( )  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "machine_id" ) . Value  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "startDate" ) . Value  =  startDate  ? ?  Convert . ToDateTime ( "2010-1-1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "endDate" ) . Value  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  =  $ @ "SELECT opt_date,drug_name,drug_spec,beforenum,getnum,usenum,manu_no,surplus,CONCAT(fromoperator,' ',fromreviewer) as fromoperator,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-07 17:33:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    CONCAT ( tooperator , ' ' , toreviewer )  as  tooperator , pack_unit , stockQuantity , emptyQuantity 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    from  ` hkc_shiftsreport `  WHERE  ` machineid `  =  ' { p_machine_id } '  AND  ` opt_date `  >  ' { p_startDate } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        AND  opt_date  <  ' { p_endDate } '   ORDER  BY  opt_date ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . QuerySQL  =  SQL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// 盘点页面导出记录,按选中行进行导出 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// </summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="type"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="startDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="endDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportMechineRecordForSelect ( List < MachineRecord >  data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//machine_log_check.grf" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Dictionary < string ,  List < MachineRecord > >  records  =  new  Dictionary < string ,  List < MachineRecord > > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            records . Add ( "table" ,  data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  str  =  JsonConvert . SerializeObject ( records ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadDataFromXML ( str ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载数据 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// 导出处方登记专册 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// </summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="orderNo"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="startDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="endDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportOrderAccount ( string  orderNo ,  DateTime ?  startDate ,  DateTime ?  endDate ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_startDate  =  startDate  ? ?  Convert . ToDateTime ( "2010-1-1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_endDate  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  p_machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  SQL  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . Initialize  + =  new  _IGridppReportEvents_InitializeEventHandler ( ( )  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "machine_id" ) . Value  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "startDate" ) . Value  =  startDate  ? ?  DateTime . Now . AddYears ( - 10 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "endDate" ) . Value  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//account_book_order.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-18 17:20:40 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  =  $ @ "SELECT DISTINCT oi.recv_date,oi.p_name,oi.sex,oi.age,oi.id_number,oi.patient_no,oi.patient_id,oi.disease,dm.manu_no,dm.Quantity,oi.doctor_name,oi.order_no,dm.reviewer,dm.operator,ul.user_name operatorName,ul2.user_name reviewerName
 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-15 09:06:29 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
									                , di . Drug_name , di . Drug_spec , di . big_unit , di . small_unit  as  smallUnit , di . drug_id , di . manuFactory , dm . receivePerson , dm . ordinalNum  as  ordinalNum , CONCAT ( DATE_FORMAT ( operation_time , ' % Y % m % d ' ) , ordinalnum )  as  OrderOrdinal 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
									                 from  order_info  oi  inner  join  order_detail  od  on  oi . order_no = od . Order_No   
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 14:42:32 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
									                 LEFT  JOIN  dm_machine_record  dm  on  oi . order_no = dm . invoice_id  AND  od . ` drug_id ` = dm . ` drug_id ` 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-14 14:04:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
									                 inner  JOIN  drug_info  di  on  od . drug_id = di . drug_id  left  join  user_list  ul  on  dm . operator = ul . id  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                     left  join  user_list  ul2  on  dm . reviewer = ul2 . id  
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 14:42:32 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                     WHERE  dm . machine_id  =  ' { p_machine_id } '  and  oi . recv_date > ' { p_startDate } '  and  oi . recv_date < ' { p_endDate } '   and  dm . type = 2  ";
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            if  ( ! string . IsNullOrEmpty ( orderNo ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                SQL  + =  $" and oi.order_no='{orderNo}'" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-14 15:02:54 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  + =  " order by di.drug_id,oi.recv_date,dm.ordinalNum" ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . ConnectionString  =  gridConnectionString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . QuerySQL  =  SQL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// 导出回收登记记录 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// </summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="orderNo"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="startDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="endDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportReturnEmpty ( DateTime ?  startDate ,  DateTime ?  endDate ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_startDate  =  startDate  ? ?  Convert . ToDateTime ( "2010-1-1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            DateTime ?  p_endDate  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  p_machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  SQL  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . Initialize  + =  new  _IGridppReportEvents_InitializeEventHandler ( ( )  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "machine_id" ) . Value  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "startDate" ) . Value  =  startDate  ? ?  DateTime . Now . AddYears ( - 10 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                Report . ParameterByName ( "endDate" ) . Value  =  endDate  ? ?  DateTime . Now . AddDays ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//return_empty.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  =  $ @ "SELECT di.drug_id, YEAR(dm.operation_time) as dmYear,oi.P_name,oi.dept_name,dm.operation_time,dm.Quantity,dm.manu_no,dm.returnPerson,dm.receivePerson,di.drug_name,di.Drug_spec,di.big_unit,di.small_unit as smallUnit,di.manufactory from order_info oi 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
																	 inner  join  dm_machine_record  dm  on  oi . order_no = dm . invoice_id  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																	 inner  join  drug_info  di  on  dm . drug_id = di . drug_id 	
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                     where  dm . type = 32  and  dm . machine_id  =  ' { p_machine_id } '  and  dm . operation_time > ' { p_startDate } '  and  dm . operation_time < ' { p_endDate } ' ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-05 11:21:25 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  + =  " order by di.drug_id,dm.operation_time" ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . ConnectionString  =  gridConnectionString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . QuerySQL  =  SQL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// 逐日消耗专用账册 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// </summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="startDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="endDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="drug_id"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportSpecialAccount ( DateTime  endDate ,  string  drug_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1"); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  strDate  =  endDate . ToString ( "yyyy-MM" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  p_machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  SQL  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-03 10:52:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //  SQL = $@"SELECT mr.drug_id as drugId,'test' InTotal,YEAR(mr.`operation_time`) as DMYear,MONTH(mr.`operation_time`) as DMMonth, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //  DAY(mr.`operation_time`) as DMDay,manu_no as manuNo,operation_time as operationTime,return_quantity1 as inQuantity,return_quantity2 as outQuantity, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //                        manunoQuantity as stockQuantity,u1.user_name as operatorName,u2.user_name as  reviewerName,di.`drug_name` AS `drugName`, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //                       di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`,di.big_unit as bigUnit, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //FROM dm_machine_record mr INNER JOIN DRUG_INFO di ON mr.drug_id=di.drug_id  LEFT JOIN  user_list u1 ON mr.`operator` = u1.`id`LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id`  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //WHERE mr.`machine_id` = '{machine_id}' and type=5 and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}' ORDER BY mr.drug_id,operation_time"; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //            SQL = $@" SELECT drugId,DMYear,DMMonth,DMDay,manuNo,operationTime,sum(inQuantity) as inQuantity,SUM(outQuantity) as outQuantity,stockQuantity,operatorName,reviewerName,drugName,drugSpec,packUnit,bigUnit,dosage,manufactory 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //FROM ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //SELECT mr.drug_id as drugId,'test' InTotal,YEAR(mr.`operation_time`) as DMYear,MONTH(mr.`operation_time`) as DMMonth, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //            DAY(mr.`operation_time`) as DMDay,manu_no as manuNo,operation_time as operationTime,-- return_quantity1 as inQuantity,return_quantity2 as outQuantity, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //            IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //                        AS `inQuantity`, IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0)) AS `outQuantity`, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //                                  manunoQuantity as stockQuantity,u1.user_name as operatorName,u2.user_name as  reviewerName,di.`drug_name` AS `drugName`, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //                                 di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`,di.big_unit as bigUnit, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //								  FROM dm_machine_record mr INNER JOIN DRUG_INFO di ON mr.drug_id=di.drug_id  LEFT JOIN  user_list u1 ON mr.`operator` = u1.`id`LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id`  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //								  WHERE mr.`machine_id` = '{machine_id}' and type in(1,2,31,4,5) and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}'and IF(mr.`type` = 4 AND mr.`quantity` = 0, 99999, mr.`quantity`) <>99999 ORDER BY mr.drug_id,operation_time 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //) t GROUP BY drugId,DMYear,DMMonth,DMDay,manuNo"; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  =  $ @ "SELECT t.drugId,t.DMYear,t.DMMonth,t.DMDay,t.manuNo,t.operationTime,t.inQuantity as inQuantity,t.outQuantity AS outQuantity,dmr.manunoQuantity AS stockQuantity,t.operatorName,t.reviewerName,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                t . drugName , t . drugSpec , t . packUnit , t . bigUnit , t . smallUnit , t . dosage , t . manufactory   from  dm_machine_record  dmr  inner  join  
							 
						 
					
						
							
								
									
										
										
										
											2024-12-03 10:52:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                ( SELECT  max ( mr . id )  id ,  mr . drug_id  as  drugId , ' test '  InTotal , YEAR ( mr . ` operation_time ` )  as  DMYear , MONTH ( mr . ` operation_time ` )  as  DMMonth , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                DAY ( mr . ` operation_time ` )  as  DMDay , manu_no  as  manuNo , operation_time  as  operationTime , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								               SUM ( IF ( mr . ` type `  IN  ( 1 ,  31 ) ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  >  0 ,  mr . ` quantity ` ,  0 ) )  )  AS  ` inQuantity ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								               SUM ( IF ( mr . ` type `  =  2 ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  <  0 ,  ( 0  -  mr . ` quantity ` ) ,  0 ) ) )  AS  ` outQuantity ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								               manunoQuantity  as  stockQuantity , u1 . user_name  as  operatorName , u2 . user_name  as   reviewerName , di . ` drug_name `  AS  ` drugName ` , 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								               di . ` drug_spec `  AS  ` drugSpec ` ,  di . ` pack_unit `  AS  ` packUnit ` , di . big_unit  as  bigUnit , di . small_unit  as  smallUnit ,  di . ` dosage `  AS  ` dosage ` ,  di . ` manufactory `  AS  ` manufactory ` 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-03 10:52:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								               FROM  dm_machine_record  mr  INNER  JOIN  DRUG_INFO  di  ON  mr . drug_id = di . drug_id   LEFT  JOIN   user_list  u1  ON  mr . ` operator `  =  u1 . ` id ` LEFT  JOIN  user_list  u2  ON  mr . ` reviewer `  =  u2 . ` id ` 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 13:48:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								              WHERE  mr . ` machine_id `  =  ' { machine_id } '  and  type  in ( 1 , 2 , 31 , 4 , 5 )  and  mr . manu_no  is  not  NULL  and  DATE_FORMAT ( operation_time , ' % Y - % m ' ) = ' { strDate } ' and  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  =  0 ,  99999 ,  mr . ` quantity ` )  < > 99999 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-03 10:52:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								              GROUP  BY  drugId , DMYear , DMMonth , DMDay , manuNo   ORDER  BY  mr . drug_id , operation_time )  t  on  dmr . id = t . id ";
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            List < Dictionary < string ,  object > >  tableList  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( SQL ) . ToDictionaryList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            for  ( int  i  =  0 ;  i  <  tableList . Count ;  i + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                LastMonthModel  InTotalModel  =  new  LastMonthModel ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                LastMonthModel  OutTotalModel  =  new  LastMonthModel ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                LastMonthModel  StackTotalModel  =  new  LastMonthModel ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                foreach  ( KeyValuePair < string ,  object >  kvp  in  tableList [ i ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    if  ( kvp . Key  = =  "drugId" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        //查询药品id对应的上月结存数量及批号 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        string  strValue  =  kvp . Value . ToString ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        string  inQuantitySQL  =  $ @ "SELECT GROUP_CONCAT(SumInQuantity) as StrTotalQuantity,GROUP_CONCAT(manu_no) as StrTotalManuNo from
 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-03 10:52:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                        ( SELECT   sum ( IF ( mr . ` type `  IN  ( 1 ,  31 ) ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  >  0 ,  mr . ` quantity ` ,  0 ) ) )   as   SumInQuantity , manu_no 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 13:48:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
																		from  dm_machine_record  mr  where  drug_id = ' { strValue } '  and  machine_id = ' { machine_id } '  and  type  in ( 1 , 2 , 31 , 4 , 5 )  and  mr . manu_no  is  not  NULL  
							 
						 
					
						
							
								
									
										
										
										
											2024-12-03 10:52:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                        and  DATE_FORMAT ( operation_time , ' % Y - % m ' ) = ' { strDate } ' and  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  =  0 ,  99999 ,  mr . ` quantity ` )  < > 99999  GROUP  BY  drug_id , manu_no   ORDER  BY  drug_id , operation_time )  as  t ";
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        InTotalModel  =  SqlSugarHelper . Db . SqlQueryable < LastMonthModel > ( inQuantitySQL ) . First ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        string  outQuantitySQL  =  $ @ "SELECT GROUP_CONCAT(SumInQuantity) as StrTotalQuantity,GROUP_CONCAT(manu_no) as StrTotalManuNo from
 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-03 10:52:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                              ( SELECT  sum ( IF ( mr . ` type `  =  2 ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  <  0 ,  ( 0  -  mr . ` quantity ` ) ,  0 ) ) )  as  SumInQuantity  , manu_no 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 13:48:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
																			  from  dm_machine_record  mr  where  drug_id = ' { strValue } '  and  machine_id = ' { machine_id } '  and  type  in ( 1 , 2 , 31 , 4 , 5 )  and  mr . manu_no  is  not  NULL  
							 
						 
					
						
							
								
									
										
										
										
											2024-12-03 10:52:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                        and  DATE_FORMAT ( operation_time , ' % Y - % m ' ) = ' { strDate } '  and  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  =  0 ,  99999 ,  mr . ` quantity ` )  < > 99999  GROUP  BY  drug_id , manu_no   ORDER  BY  drug_id , operation_time )  as  t ";
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        OutTotalModel  =  SqlSugarHelper . Db . SqlQueryable < LastMonthModel > ( outQuantitySQL ) . First ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        string  stockQuantitySQL  =  $ @ "SELECT GROUP_CONCAT(a.Manu_No) as StrTotalManuNo,GROUP_CONCAT(a.manunoQuantity) as StrTotalQuantity  from dm_machine_record a inner join
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                    ( select  drug_id , manu_no , max ( operation_time )  as  latest_date , stock_quantity  from  dm_machine_record   
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 13:48:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                    WHERE   DATE_FORMAT ( operation_time , ' % Y - % m ' ) = ' { strDate } '  and  machine_id = ' { machine_id } ' and  manu_no  is  not  NULL   GROUP  BY  drug_id , manu_no   )  b  on  a . drug_id = b . drug_id  and  a . manu_no = b . manu_no 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                    and  a . operation_time = b . latest_date  and  machine_id = ' { machine_id } '  WHERE  a . drug_id = ' { strValue } '  and   DATE_FORMAT ( operation_time , ' % Y - % m ' ) = ' { strDate } ' ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        StackTotalModel  =  SqlSugarHelper . Db . SqlQueryable < LastMonthModel > ( stockQuantitySQL ) . First ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                tableList [ i ] . Add ( "inTotal" ,  InTotalModel . StrTotalQuantity ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                tableList [ i ] . Add ( "inTotalManuNo" ,  InTotalModel . StrTotalManuNo ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                tableList [ i ] . Add ( "outTotal" ,  OutTotalModel . StrTotalQuantity ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                tableList [ i ] . Add ( "outTotalManuNo" ,  OutTotalModel . StrTotalManuNo ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                tableList [ i ] . Add ( "stockTotal" ,  StackTotalModel . StrTotalQuantity ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                tableList [ i ] . Add ( "stockTotalManuNO" ,  StackTotalModel . StrTotalManuNo ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Dictionary < string ,  List < Dictionary < string ,  object > > >  records  =  new  Dictionary < string ,  List < Dictionary < string ,  object > > > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            records . Add ( "table" ,  tableList ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  str  =  JsonConvert . SerializeObject ( records ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "account_book_temp-01.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadDataFromXML ( str ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        static  GridppReport  rptMain  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        static  GridppReport  rptCustomerList  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// 逐日消耗专用账册2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// </summary> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="startDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="endDate"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        /// <param name="drug_id"></param> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportSpecialAccount2 ( DateTime  endDate ,  string  drug_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //InsertSubReport("ReportTemp//account_book_temp-022.grf", "2d"); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //用推模式给子报表提供数据:为子报表定义一个外部的报表对象,以便处理其报表事件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //用推模式给子报表提供数据: 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //rptMain.ControlByName("2d").AsSubReport.Report = rptCustomerList; //子报表部件框的报表对象关联一个外部报表对象,以便响应报表事件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            ////rptCustomerList.DetailGrid.Recordset.ConnectionString = gridConnectionString;      //让子报表 rptProductList 用推模式填入报表数据,将程序中取得的数据填入到报表中 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //rptCustomerList.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(CustomerListFetchRecord); //连接报表事件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //rptMain.PrintPreview(true); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  strDate  =  endDate . ToString ( "yyyy-MM" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  masterSql  =  $ @ "		SELECT DISTINCT di.`drug_id` AS `drugId`, YEAR(mr.`operation_time`) as DMYear,MONTH(mr.`operation_time`) as DMMonth, di.`drug_name` AS `drugName`, di.`drug_spec` AS `drugSpec`,
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                di . big_unit  as  bigUnit , di . small_unit  as  smallUnit ,  di . ` dosage `  AS  ` dosage ` ,  di . ` manufactory `  AS  ` manufactory ` ,  ' '  lastMonthStock , ' '  lastMonthMauno , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        mr . ` manu_no `  AS  ` manuNo ` from  dm_machine_record  mr  inner  join  drug_info  di  on  mr . drug_id = di . drug_id  where  machine_id = ' { machine_id } '  and  type  in ( 1 , 2 , 31 , 4 )  and  DATE_FORMAT ( mr . operation_time , ' % Y - % m ' ) = ' { strDate } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                         ORDER  BY  mr . drug_id ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            List < Dictionary < string ,  object > >  masterList  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( masterSql ) . ToDictionaryList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  detail1Sql  =  $ @ "	SELECT      di.drug_id as drugId,DAY(mr.operation_time) AS DMDAY,mr.TYPE,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				IF ( mr . ` type `  IN  ( 1 ,  31 ) ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  >  0 ,  mr . ` quantity ` ,  0 ) )  AS  ` inQuantity ` ,  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				mr . manu_no  as  manuNo , ul . user_name  as  operatorname , u2 . user_name  as  reviewername  from  dm_machine_record  mr  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                inner  join  drug_info  di  on  mr . drug_id = di . drug_id  left  join  user_list  ul  on  mr . operator = ul . id  left  join  user_list  u2  on  mr . reviewer = u2 . id  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                where  mr . machine_id = ' { machine_id } '  and  type  in  ( 1 , 31 , 4 )  and  DATE_FORMAT ( mr . operation_time , ' % Y - % m ' ) = ' { strDate } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				and  if ( mr . Type = 4  and  mr . Quantity = 0 , 99999 ,  mr . ` quantity ` )  < > 99999  ORDER  BY  mr . drug_id ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            List < Dictionary < string ,  object > >  detail1List  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( detail1Sql ) . ToDictionaryList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  detail2Sql  =  $ @ "SELECT 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				di . ` drug_id `  AS  ` drugId ` , DAY ( mr . ` operation_time ` )  as  DMDay , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				mr . type ,  mr . ` stock_quantity `  AS  ` stockQuantity ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				- -  IF ( mr . ` type `  IN  ( 1 ,  31 ) ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  >  0 ,  mr . ` quantity ` ,  0 ) )  AS  ` inQuantity ` ,  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				IF ( mr . ` type `  =  2 ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  <  0 ,  ( 0  -  mr . ` quantity ` ) ,  0 ) )  AS  ` outQuantity ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                         mr . ` operation_time `  AS  ` operationTime ` , - -  IF ( mr . ` type ` = 1 , mr . ` invoice_id ` , NULL )  AS  ` invoiceId ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																			 mr . ` manu_no `  AS  ` manuNo ` , - -  mr . ` eff_date `  AS  ` effDate ` ,  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				u1 . ` user_name `  AS  ` operatorName ` ,  u2 . ` user_name `  AS  ` reviewerName `  - -  , mr . supplierDept , mr . receiveDept 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				- -  sum ( InQuantity )  as   TotalInQuantity 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				FROM  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        dm_machine_record  mr   INNER  JOIN  drug_info  di  ON  mr . ` drug_id `  =  di . ` drug_id `   LEFT  JOIN  user_list  u1  ON  mr . ` operator `  =  u1 . ` id `   
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        LEFT  JOIN  user_list  u2  ON  mr . ` reviewer `  =  u2 . ` id `  WHERE  mr . ` machine_id `  =  ' { machine_id } '  AND  type  in ( 2 , 4 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        AND  DATE_FORMAT ( mr . operation_time , ' % Y - % m ' ) =   ' { strDate } '  and  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  =  0 ,  99999 ,  mr . ` quantity ` )  < > 99999 	 ORDER  BY  mr . drug_id  ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            List < Dictionary < string ,  object > >  detail2List  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( detail2Sql ) . ToDictionaryList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Dictionary < string ,  List < Dictionary < string ,  object > > >  records  =  new  Dictionary < string ,  List < Dictionary < string ,  object > > > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            records . Add ( "Master" ,  masterList ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            records . Add ( "Detail1" ,  detail1List ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            records . Add ( "Detail2" ,  detail2List ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  str  =  JsonConvert . SerializeObject ( records ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "account_book_temp-022.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadDataFromXML ( str ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载数据 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  PrintReportSpecialAccount2New ( DateTime  MonthDate ,  string  drug_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  strDate  =  MonthDate . ToString ( "yyyy-MM" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            int  DMYear  =  MonthDate . Year ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            int  DMMonth  =  MonthDate . Month ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  masterSql  =  $ @ "SELECT distinct di.drug_id as drugId,di.drug_name as drugName,di.drug_spec as drugSpec,di.big_unit as bigUnit,di.small_unit as smallUnit,di.manufactory as manufactory,{DMYear} DMYear,{DMMonth} DMMonth from channel_stock cs 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                inner  join  drug_info  di  on  cs . drug_id = di . drug_id  where  machine_id = ' { machine_id } '  ORDER  BY  di . drug_id  ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            List < Dictionary < string ,  object > >  masterList  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( masterSql ) . ToDictionaryList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            for  ( int  i  =  0 ;  i  <  masterList . Count ;  i + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                LastMonthModel  lastMonth  =  new  LastMonthModel ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                foreach  ( KeyValuePair < string ,  object >  kvp  in  masterList [ i ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    if  ( kvp . Key  = =  "drugId" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        //查询药品id对应的上月结存数量及批号 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        string  strValue  =  kvp . Value . ToString ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        string  lastMonthSql  =  $ @ "SELECT  GROUP_CONCAT(manu_no) as StrTotalManuNo,GROUP_CONCAT(manunoQuantity) as StrTotalQuantity 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																			  from  dm_machine_record  where  drug_id = ' { strValue } '  and  machine_id = ' { machine_id } '  and  DATE_FORMAT ( operation_time , ' % Y - % m - % d ' ) = LAST_DAY ( DATE_SUB ( ' { MonthDate } ' ,  INTERVAL  1  MONTH ) )  and  type = 5 ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        lastMonth  =  SqlSugarHelper . Db . SqlQueryable < LastMonthModel > ( lastMonthSql ) . First ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                masterList [ i ] . Add ( "lastMonthStock" ,  lastMonth . StrTotalManuNo ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                masterList [ i ] . Add ( "lastMonthMauno" ,  lastMonth . StrTotalQuantity ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  detailSql  =  $ @ "SELECT drug_id as drugId,DAY(mr.`operation_time`) as DMDay,manu_no as manuNo,operation_time as operationTime,return_quantity1 as inQuantity,return_quantity2 as outQuantity,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                  manunoQuantity  as  stockQuantity , u1 . user_name  as  operatorName , u2 . user_name  as   reviewerName 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																  FROM  dm_machine_record  mr  LEFT  JOIN   user_list  u1  ON  mr . ` operator `  =  u1 . ` id ` LEFT  JOIN  user_list  u2  ON  mr . ` reviewer `  =  u2 . ` id `  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																  WHERE  mr . ` machine_id `  =  ' { machine_id } '  and  type = 5  and  DATE_FORMAT ( operation_time , ' % Y - % m ' ) = ' { strDate } '  ORDER  BY  drug_id , operation_time ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            List < Dictionary < string ,  object > >  detailMaster0List  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( detailSql ) . ToDictionaryList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            List < Dictionary < string ,  object > >  detailMaster1List  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( detailSql ) . ToDictionaryList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //List<Dictionary<string, object>> detail1List = detailList.Where(it => Convert.ToInt32(it.GetValueOrDefault("inQuantity")) > 0 && Convert.ToInt32(it.GetValueOrDefault("outQuantity")) <= 0) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            List < Dictionary < string ,  object > >  detail1List  =  detailMaster0List . Where ( it  = >  Convert . ToInt32 ( it . GetValueOrDefault ( "inQuantity" ) )  >  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                          . Select ( it  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                          { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                              it . Remove ( "outQuantity" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                              it . Remove ( "stockQuantity" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                              return  it ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                          } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                          . ToList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //List<Dictionary<string, object>> detail2List = detailList.Where(it => Convert.ToInt32(it.GetValueOrDefault("outQuantity")) >0||!(Convert.ToInt32(it.GetValueOrDefault("inQuantity")) >0 && Convert.ToInt32(it.GetValueOrDefault("outQuantity")) == 0)) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            List < Dictionary < string ,  object > >  detail2List  =  detailMaster1List 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                          . Select ( it  = > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                          { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                              it . Remove ( "inQuantity" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                              return  it ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                          } ) . ToList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Dictionary < string ,  List < Dictionary < string ,  object > > >  records  =  new  Dictionary < string ,  List < Dictionary < string ,  object > > > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            records . Add ( "Master" ,  masterList ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            records . Add ( "Detail1" ,  detail1List ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            records . Add ( "Detail2" ,  detail2List ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  str  =  JsonConvert . SerializeObject ( records ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "account_book_temp-022.grf" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadDataFromXML ( str ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载数据 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-04 13:35:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  static  void  test ( DateTime  endDate ,  string  drug_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1"); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  strDate  =  endDate . ToString ( "yyyy-MM" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  p_machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 定义Grid++Report报表主对象 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            GridppReport  Report  =  new  GridppReport ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            // 加载模板文件 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . LoadFromFile ( new  FileInfo ( AppDomain . CurrentDomain . BaseDirectory )  +  "ReportTemp//"  +  "account_book_temp-02.grf" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  SQL  =  string . Empty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  machine_id  =  ( ConfigurationManager . AppSettings [ "machineId" ]  ? ?  "DM1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  strINSql  =  $ @ "SELECT GROUP_CONCAT(Manu_No) AS StrTotalManuNo,GROUP_CONCAT(totalInQuantity) AS StrTotalQuantity FROM
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				SELECT  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				 DISTINCT  Manu_No  , sum ( IF ( mr . ` type `  IN  ( 1 ,  31 ) ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  >  0 ,  mr . ` quantity ` ,  0 ) ) )  as  totalInQuantity 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				from  dm_machine_record  mr 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				 INNER  JOIN  drug_info  di  ON  mr . ` drug_id `  =  di . ` drug_id `  where  mr . machine_id = ' { machine_id } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				 and   IF ( mr . ` type `  IN  ( 1 ,  31 ) ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  >  0 ,  mr . ` quantity ` ,  0 ) )  > 0  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				 and  DATE_FORMAT ( operation_time , ' % Y - % m ' ) =  ' { strDate } '  and  type  in ( ' 1 , 31 , 4 ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				GROUP  BY  mr . drug_id , mr . manu_no 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				)  as  t ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            AccountTotalQuantity  InQuantityList  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( strINSql ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                              . Select ( it  = >  new  AccountTotalQuantity ( ) ) . First ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  strOutSql  =  $ @ "SELECT GROUP_CONCAT(Manu_No) AS StrTotalManuNo,GROUP_CONCAT(TotalOutQuantity) AS StrTotalQuantity FROM
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				SELECT  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				 DISTINCT  Manu_No  , SUM ( IF ( mr . ` type `  =  2 ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  <  0 ,  ( 0  -  mr . ` quantity ` ) ,  0 ) ) )  AS  TotalOutQuantity 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				from  dm_machine_record  mr 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				 INNER  JOIN  drug_info  di  ON  mr . ` drug_id `  =  di . ` drug_id `  where  mr . machine_id = ' { machine_id } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				 and   IF ( mr . ` type `  =  2 ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  <  0 ,  ( 0  -  mr . ` quantity ` ) ,  0 ) )  > 0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				 and  DATE_FORMAT ( operation_time , ' % Y - % m ' ) =  ' { strDate } '    and  type  in ( ' 2 , 4 ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				GROUP  BY  mr . drug_id , mr . manu_no 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				)  as  t ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            AccountTotalQuantity  OutQuantityList  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( strOutSql ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                              . Select ( it  = >  new  AccountTotalQuantity ( ) ) . First ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  strStockSql  =  $ @ "SELECT GROUP_CONCAT(Manu_No) AS StrTotalManuNo,GROUP_CONCAT(stock_quantity) AS StrTotalQuantity FROM
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                    ( SELECT  a . Manu_No , a . stock_quantity  from  dm_machine_record  a  inner  join 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                    ( select  drug_id , manu_no , max ( operation_time )  as  latest_date , stock_quantity  from  dm_machine_record   
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                    WHERE   DATE_FORMAT ( operation_time , ' % Y - % m ' ) = ' { strDate } '  and  machine_id = ' { machine_id } '  GROUP  BY  drug_id , manu_no   )  b  on  a . drug_id = b . drug_id  and  a . manu_no = b . manu_no 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                    and  a . operation_time = b . latest_date  and  machine_id = ' { machine_id } '  WHERE   DATE_FORMAT ( operation_time , ' % Y - % m ' ) = ' { strDate } ' )  as  t  ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            AccountTotalQuantity  StockQuantityList  =  SqlSugarHelper . Db . SqlQueryable < dynamic > ( strStockSql ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                              . Select ( it  = >  new  AccountTotalQuantity ( ) ) . First ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  str1  =  "本月领药数量"  +  ":"  +  InQuantityList . StrTotalQuantity  +  "     批号:"  +  InQuantityList . StrTotalManuNo ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  str2  =  "本月发药数量"  +  ":"  +  OutQuantityList . StrTotalQuantity  +  "     批号:"  +  OutQuantityList . StrTotalManuNo ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            string  str3  =  "本月结存数量"  +  ":"  +  StockQuantityList . StrTotalQuantity  +  "     批号:"  +  StockQuantityList . StrTotalManuNo ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //Report.ControlByName("StaticBox24").AsStaticBox.Text = str1;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //Report.ControlByName("StaticBox26").AsStaticBox.Text = str2;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //Report.ControlByName("StaticBox28").AsStaticBox.Text = str3; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . ConnectionString  =  gridConnectionString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() => 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //    Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //    Report.ParameterByName("startDate").Value = startDate ?? Convert.ToDateTime("2010-1-1"); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //    Report.ParameterByName("endDate").Value = endDate ?? DateTime.Now.AddDays(1); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //}); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            //Report.DetailGrid.Recordset.QuerySQL = SQL; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  =  $ @ "SELECT 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				YEAR ( mr . ` operation_time ` )  as  DMYear , MONTH ( mr . ` operation_time ` )  as  DMMonth , DAY ( mr . ` operation_time ` )  as  DMDay , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				mr . type ,  mr . ` stock_quantity `  AS  ` stockQuantity ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				- -  IF ( mr . ` type `  IN  ( 1 ,  31 ) ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  >  0 ,  mr . ` quantity ` ,  0 ) )  AS  ` inQuantity ` ,  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				IF ( mr . ` type `  =  2 ,  mr . ` quantity ` ,  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  <  0 ,  ( 0  -  mr . ` quantity ` ) ,  0 ) )  AS  ` outQuantity ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                         mr . ` operation_time `  AS  ` operationTime ` , - -  IF ( mr . ` type ` = 1 , mr . ` invoice_id ` , NULL )  AS  ` invoiceId ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				 di . ` drug_name `  AS  ` drugName ` ,  di . ` drug_id `  AS  ` drugId ` , 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-10 18:08:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                         di . ` drug_spec `  AS  ` drugSpec ` ,  di . ` pack_unit `  AS  ` packUnit ` , di . big_unit  as  bigUnit , di . small_unit  as  smallUnit ,  di . ` dosage `  AS  ` dosage ` ,  di . ` manufactory `  AS  ` manufactory ` ,  
							 
						 
					
						
							
								
									
										
										
										
											2024-09-12 18:01:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        mr . ` manu_no `  AS  ` manuNo ` , - -  mr . ` eff_date `  AS  ` effDate ` ,  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				u1 . ` user_name `  AS  ` operatorName ` ,  u2 . ` user_name `  AS  ` reviewerName `  - -  , mr . supplierDept , mr . receiveDept 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				- -  sum ( InQuantity )  as   TotalInQuantity 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
																				FROM  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        dm_machine_record  mr   INNER  JOIN  drug_info  di  ON  mr . ` drug_id `  =  di . ` drug_id `   LEFT  JOIN  user_list  u1  ON  mr . ` operator `  =  u1 . ` id `   
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        LEFT  JOIN  user_list  u2  ON  mr . ` reviewer `  =  u2 . ` id `  WHERE  mr . ` machine_id `  =  ' { machine_id } '  AND  type  in ( 2 , 4 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                        AND  DATE_FORMAT ( mr . operation_time , ' % Y - % m ' ) =   ' { strDate } '  and  IF ( mr . ` type `  =  4  AND  mr . ` quantity `  =  0 ,  99999 ,  mr . ` quantity ` )  < > 99999 	 ";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            if  ( ! string . IsNullOrEmpty ( drug_id ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                SQL  + =  " AND mr.drug_id='"  +  drug_id  +  "' " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            SQL  + =  "ORDER BY YEAR(mr.`operation_time`),MONTH(mr.`operation_time`),DAY(mr.`operation_time`),mr.`drug_id`,mr.manu_no" ;  //"  GROUP BY mr.drug_id,mr.manu_no,mr.operation_time " + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . DetailGrid . Recordset . QuerySQL  =  SQL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								            Report . PrintPreview ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    public  class  LastMonthModel 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  string  StrTotalManuNo  {  get ;  set ;  }  =  "0" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								        public  string  StrTotalQuantity  {  get ;  set ;  }  =  "0" ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-13 13:25:46 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								}