1256 lines
		
	
	
		
			48 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			1256 lines
		
	
	
		
			48 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | ||
| using System.Collections.Generic;
 | ||
| using System.ComponentModel;
 | ||
| using System.Data;
 | ||
| using System.Drawing;
 | ||
| using System.Text;
 | ||
| using System.Linq;
 | ||
| using System.Windows.Forms;
 | ||
| using DevExpress.XtraBars;
 | ||
| using DevExpress.XtraGrid.Views.Base;
 | ||
| using DeiNiu.wms.Logical;
 | ||
| using DeiNiu.wms.Data;
 | ||
| using DevExpress.XtraGrid.Columns;
 | ||
|  
 | ||
| using System.Threading;
 | ||
| using DevExpress.XtraGrid.Views.Grid;
 | ||
| using DevExpress.XtraEditors.DXErrorProvider;
 | ||
| using DeiNiu.wms.Data.Model;
 | ||
| using DevExpress.XtraEditors;
 | ||
| using DevExpress.XtraEditors.Controls;
 | ||
| using DeiNiu.Utils;
 | ||
| 
 | ||
| 
 | ||
| namespace DeiNiu.wms.win
 | ||
| {
 | ||
|     public partial class GoodsOutValidationQueryForm : BasicRibbonForm
 | ||
|     {
 | ||
|       //  lWmsStock ls = new lWmsStock();
 | ||
|         lWmsOutPickRequest lgt = new lWmsOutPickRequest();
 | ||
|         lWmsOutRequest lgOutReq = new lWmsOutRequest();
 | ||
|        // lWmsOutPickRequest outPickRequest = new lWmsOutPickRequest();
 | ||
|         private string lastQuery = "";
 | ||
|         DataSet dsPickOrders;
 | ||
|         private DataTable dtPickOrders;
 | ||
|         private DataTable dtPickOrdersDetail;
 | ||
|         private DataTable dtPickOrders4Validation;
 | ||
|         private DataTable dtPickOrdersValidated;
 | ||
|         private DataTable dtPickDetails;
 | ||
|         private int selectedRowIndex = -1;
 | ||
|         private WmsOutPickDetail_tmp currentDetail;
 | ||
|         string lastScanBarcode = "";
 | ||
|         private int desk =1;
 | ||
|         Thread threadPreProcess;
 | ||
|         bool autoOrder;
 | ||
|         string currentPickOrder = "";
 | ||
|         public GoodsOutValidationQueryForm()
 | ||
|         {
 | ||
|             InitializeComponent();
 | ||
|             initialControls();
 | ||
|             initialBackGroundTasks();
 | ||
|            
 | ||
|         }
 | ||
|         #region initialControls
 | ||
|         private void initialControls()
 | ||
|         {
 | ||
|             initialComboBoxes();
 | ||
|            // initialPagerControls();
 | ||
|             initialDataGrid();
 | ||
|             initialQueryInput(); 
 | ||
|             setValidationRule();
 | ||
|             textEditBarcode.GotFocus += new EventHandler(textEditBarcode_GotFocus);
 | ||
|             textEditBarcode.MouseUp += new MouseEventHandler(textEditBarcode_MouseUp);   
 | ||
| 
 | ||
|         }
 | ||
|         private void initialBackGroundTasks()
 | ||
|         {
 | ||
| 
 | ||
| 
 | ||
|             swAutoOrder.IsOn = WmsConstants.AUTO_SYNC_SALE_ORDER;
 | ||
|             autoOrder = swAutoOrder.IsOn;
 | ||
|            // lgOutReq.UpdateUIDelegate += updateValidationList;
 | ||
|             
 | ||
|             if (autoOrder)
 | ||
|             {
 | ||
|                 this.getValidationOrders();
 | ||
|             }
 | ||
| 
 | ||
|            
 | ||
|             
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
|         private void initialComboBoxes()
 | ||
|         {
 | ||
|            
 | ||
|         }
 | ||
|       
 | ||
|         private void setValidationRule()
 | ||
|         {
 | ||
|           //  dxValidationProvider.SetValidationRule(comWarehouse, ValidationRules.notEmptyValidationRule);
 | ||
|             //txtGoodType.Properties.MaxLength = 40;
 | ||
|             //txtGoodDesc.Properties.MaxLength = 250;
 | ||
|             //textEdit1.Properties.MaxLength = txtGoodType.Properties.MaxLength;
 | ||
|         }
 | ||
| 
 | ||
|         private void initialQueryInput()
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
|       
 | ||
|         private void initialDataGridColumns()
 | ||
|         {
 | ||
|             setupGridView(gridView1,false);
 | ||
|             //setupGridView(gridView2, false,false);
 | ||
|             //setupGridView(gridView3, false,false);
 | ||
|             //   gridviewGoodsType.PopulateColumns();
 | ||
|             gridView1.Columns.Clear();
 | ||
|             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]); 
 | ||
|             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
 | ||
|             myCol0.Visible = false;
 | ||
|             this.gridView1.Columns.Add(myCol0);
 | ||
|             GridColumn myCol1 = new GridColumn() { Caption = "单号", Visible = true, FieldName = WmsOutPickRequest.fields.pickOrderNo.ToString() };
 | ||
|          //   GridColumn myCol2 = new GridColumn() { Caption = "类别", Visible = true, FieldName = WmsOutPickRequest.fields.orderTypeName.ToString() };
 | ||
|             GridColumn myCol3 = new GridColumn() { Caption = "状态", Visible = true, FieldName = "orderState" };
 | ||
| 
 | ||
|             GridColumn myCol4 = new GridColumn() { Caption = "客户", Visible = true, FieldName = WmsOutPickRequest.fields.customerName. ToString() };
 | ||
|             GridColumn myCol5 = new GridColumn() { Caption = "备注", Visible = true, FieldName = WmsOutPickRequest.fields.description.ToString() };
 | ||
|             //GridColumn myCol6 = new GridColumn() { Caption = "日期", Visible = true, FieldName = WmsOutPickRequest.fields.orderDate.ToString() };
 | ||
|             
 | ||
| 
 | ||
| 
 | ||
|             this.gridView1.Columns.Add(myCol1);
 | ||
|           //  this.gridView1.Columns.Add(myCol6);
 | ||
|           //  this.gridView1.Columns.Add(myCol3); 
 | ||
| 
 | ||
|             this.gridView1.Columns.Add(myCol4);
 | ||
|             this.gridView1.Columns.Add(myCol5);  
 | ||
|  
 | ||
|             //to show bottom scroll bar
 | ||
|             gridView1.OptionsView.ColumnAutoWidth = false;
 | ||
|             gridView1.BestFitColumns();
 | ||
|            // gridView1.Focus();
 | ||
| 
 | ||
| 
 | ||
|         //    initialGridView2Columns();
 | ||
|             //gridControl2.DataSource = null;
 | ||
|         }
 | ||
|         private void initialGridView2Columns(GridView gridview)
 | ||
|         {
 | ||
|             setupGridView(gridview, false, true, false);
 | ||
|             gridview.FocusRectStyle = DrawFocusRectStyle.None;
 | ||
|             //   gridviewGoodsType.PopulateColumns();
 | ||
|             gridview.Columns.Clear();
 | ||
|             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]); 
 | ||
|             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
 | ||
|             myCol0.Visible = false;
 | ||
|             gridview.Columns.Add(myCol0); 
 | ||
|             GridColumn myCol1 = new GridColumn() { Caption = "商品编码", Visible = true, FieldName = WmsGoods.fields.goodsId.ToString() };
 | ||
|             GridColumn myCol2 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = WmsGoods.exfields.goodsName.ToString() };
 | ||
|             GridColumn myCol3 = new GridColumn() { Caption = "厂家", Visible = true, FieldName = WmsGoods.exfields.manufacturer.ToString() };
 | ||
|             GridColumn myCol4 = new GridColumn() { Caption = "规格", Visible = true, FieldName = WmsGoods.exfields.spec.ToString() };
 | ||
|             GridColumn myCol5 = new GridColumn() { Caption = "单位", Visible = true, FieldName = WmsGoods.exfields.unit.ToString() };
 | ||
|             GridColumn myCol6 = new GridColumn() { Caption = "大包装数量", Visible = true, FieldName = WmsGoods.exfields.bigCount.ToString() };
 | ||
|             GridColumn myCol7 = new GridColumn() { Caption = "剂型", Visible = true, FieldName = WmsGoods.exfields.type.ToString() };
 | ||
|             GridColumn myCol8 = new GridColumn() { Caption = "商品类型", Visible = true, FieldName = WmsGoods.exfields.goodsTypeName.ToString() };
 | ||
|           //  GridColumn myCol9 = new GridColumn() { Caption = "大零", Visible = true, FieldName = WmsGoods.fields.bulkMax.ToString() };
 | ||
|         //    GridColumn myCol10 = new GridColumn() { Caption = "小整", Visible = true, FieldName = WmsGoods.fields.batchMax1.ToString() };
 | ||
|         //    GridColumn myCol11 = new GridColumn() { Caption = "大整", Visible = true, FieldName = WmsGoods.fields.batchMax2.ToString() };
 | ||
|             GridColumn myCol12 = new GridColumn() { Caption = "药监码", Visible = true, FieldName = WmsGoods.exfields.regeditCode.ToString() };
 | ||
| 
 | ||
|             GridColumn myCol100 = new GridColumn() { Caption = "数量", Visible = true, FieldName = WmsOutDetail.fields.count.ToString() };
 | ||
|             GridColumn myCol101 = new GridColumn() { Caption = "零货", Visible = true, FieldName = WmsOutDetail.fields.bulkCount.ToString() };
 | ||
|          //   GridColumn myCol102 = new GridColumn() { Caption = "小整", Visible = true, FieldName = WmsOutDetail.fields.batch1Count.ToString() };
 | ||
|         //    GridColumn myCol103 = new GridColumn() { Caption = "大整", Visible = true, FieldName = WmsOutDetail.fields.batch2Count.ToString() };
 | ||
|          //   GridColumn myCol104 = new GridColumn() { Caption = "箱", Visible = true, FieldName = WmsOutDetail.fields.boxcnt.ToString() };
 | ||
|             GridColumn myCol14 = new GridColumn() { Caption = "批号", Visible = true, FieldName = WmsOutDetail.fields.batch.ToString() };
 | ||
|             GridColumn myCol15 = new GridColumn() { Caption = "生产日期", Visible = true, FieldName = WmsOutDetail.fields.productDate.ToString() };
 | ||
|             GridColumn myCol16 = new GridColumn() { Caption = "有效期", Visible = true, FieldName = WmsOutDetail.fields.validDate.ToString() };
 | ||
| 
 | ||
|          //   GridColumn myCol17 = new GridColumn() { Caption = "状态", Visible = true, FieldName = WmsOutDetail.fields.state.ToString() };
 | ||
|             GridColumn myCol18 = new GridColumn() { Caption = "说明", Visible = true, FieldName = WmsOutDetail.fields.description.ToString() };
 | ||
|               
 | ||
|             GridColumn myCol25 = new GridColumn() { Caption = "订单", Visible = true, FieldName = WmsOutPickDetail_error.fields.orderNo.ToString() };
 | ||
|             GridColumn myCol26 = new GridColumn() { Caption = "条码", Visible = true, FieldName = "barCode" };
 | ||
|             if (gridview == gridViewSaleOrders)
 | ||
|             {
 | ||
|                 gridview.Columns.Add(myCol25);
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 gridview.Columns.Add(myCol26);
 | ||
|             }
 | ||
|             gridview.Columns.Add(myCol2);
 | ||
|             gridview.Columns.Add(myCol14);
 | ||
|             gridview.Columns.Add(myCol100);    
 | ||
|             gridview.Columns.Add(myCol101);
 | ||
|         //    gridview.Columns.Add(myCol102);
 | ||
|            // gridview.Columns.Add(myCol103);
 | ||
|          //   gridview.Columns.Add(myCol104);
 | ||
|             gridview.Columns.Add(myCol6);
 | ||
|             gridview.Columns.Add(myCol5);
 | ||
|         
 | ||
|             gridview.Columns.Add(myCol15);
 | ||
|             gridview.Columns.Add(myCol16);
 | ||
|             gridview.Columns.Add(myCol3);
 | ||
| 
 | ||
|            
 | ||
| 
 | ||
|             gridview.Columns.Add(myCol3);
 | ||
| 
 | ||
|             gridview.Columns.Add(myCol8);
 | ||
|             //gridview.Columns.Add(myCol9);
 | ||
|       
 | ||
| 
 | ||
|             gridview.Columns.Add(myCol2);
 | ||
|          //   gridview.Columns.Add(myCol6);
 | ||
| 
 | ||
|            
 | ||
|             gridview.Columns.Add(myCol4);
 | ||
|             gridview.Columns.Add(myCol7);
 | ||
| 
 | ||
|             gridview.Columns.Add(myCol12);
 | ||
|             gridview.Columns.Add(myCol1);
 | ||
|         //    gridview.Columns.Add(myCol17);
 | ||
|             gridview.Columns.Add(myCol18);
 | ||
|           
 | ||
|             
 | ||
|             //to show bottom scroll bar
 | ||
|             gridview.OptionsView.ColumnAutoWidth = false;
 | ||
|             gridview.BestFitColumns();
 | ||
|           //  gridView2.Focus();
 | ||
|         }
 | ||
| 
 | ||
|         private void initialGridView3Columns(GridView gridview)
 | ||
|         {
 | ||
|             setupGridView(gridview, false, true, false);
 | ||
|             gridview.FocusRectStyle = DrawFocusRectStyle.None;
 | ||
|             //   gridviewGoodsType.PopulateColumns();
 | ||
|             gridview.Columns.Clear();
 | ||
|             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]); 
 | ||
|             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
 | ||
|             myCol0.Visible = false;
 | ||
|             gridview.Columns.Add(myCol0);
 | ||
|             GridColumn myCol1 = new GridColumn() { Caption = "商品编码", Visible = true, FieldName = WmsGoods.fields.goodsId.ToString() };
 | ||
|             GridColumn myCol2 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = WmsGoods.exfields.goodsName.ToString() };
 | ||
|             GridColumn myCol3 = new GridColumn() { Caption = "厂家", Visible = true, FieldName = WmsGoods.exfields.manufacturer.ToString() };
 | ||
|             GridColumn myCol4 = new GridColumn() { Caption = "规格", Visible = true, FieldName = WmsGoods.exfields.spec.ToString() };
 | ||
|             GridColumn myCol5 = new GridColumn() { Caption = "单位", Visible = true, FieldName = WmsGoods.exfields.unit.ToString() };
 | ||
|            // GridColumn myCol6 = new GridColumn() { Caption = "大包装数量", Visible = true, FieldName = WmsGoods.exfields.bigCount.ToString() };
 | ||
|             GridColumn myCol7 = new GridColumn() { Caption = "剂型", Visible = true, FieldName = WmsGoods.exfields.type.ToString() };
 | ||
|             GridColumn myCol8 = new GridColumn() { Caption = "商品类型", Visible = true, FieldName = WmsGoods.exfields.goodsTypeName.ToString() };
 | ||
|             //  GridColumn myCol9 = new GridColumn() { Caption = "大零", Visible = true, FieldName = WmsGoods.fields.bulkMax.ToString() };
 | ||
|             //    GridColumn myCol10 = new GridColumn() { Caption = "小整", Visible = true, FieldName = WmsGoods.fields.batchMax1.ToString() };
 | ||
|             //    GridColumn myCol11 = new GridColumn() { Caption = "大整", Visible = true, FieldName = WmsGoods.fields.batchMax2.ToString() };
 | ||
|             GridColumn myCol12 = new GridColumn() { Caption = "药监码", Visible = true, FieldName = WmsGoods.exfields.regeditCode.ToString() };
 | ||
| 
 | ||
|              GridColumn myCol100 = new GridColumn() { Caption = "数量", Visible = true, FieldName = WmsOutDetail.fields.count.ToString() };
 | ||
|          //   GridColumn myCol101 = new GridColumn() { Caption = "零货", Visible = true, FieldName = WmsOutDetail.fields.count.ToString() };
 | ||
|            // GridColumn myCol102 = new GridColumn() { Caption = "整货", Visible = true, FieldName = WmsOutDetail.fields.batch1Count.ToString() };
 | ||
|            // GridColumn myCol103 = new GridColumn() { Caption = "大整", Visible = true, FieldName = WmsOutDetail.fields.batch2Count.ToString() };
 | ||
|           //  GridColumn myCol104 = new GridColumn() { Caption = "箱", Visible = true, FieldName = WmsOutDetail.fields.boxcnt.ToString() };
 | ||
|             GridColumn myCol14 = new GridColumn() { Caption = "批号", Visible = true, FieldName = WmsOutDetail.fields.batch.ToString() };
 | ||
|             GridColumn myCol15 = new GridColumn() { Caption = "生产日期", Visible = true, FieldName = WmsOutDetail.fields.productDate.ToString() };
 | ||
|             GridColumn myCol16 = new GridColumn() { Caption = "有效期", Visible = true, FieldName = WmsOutDetail.fields.validDate.ToString() };
 | ||
| 
 | ||
|             GridColumn myCol17 = new GridColumn() { Caption = "状态", Visible = true, FieldName = WmsOutDetail.fields.state.ToString() };
 | ||
|             GridColumn myCol18 = new GridColumn() { Caption = "说明", Visible = true, FieldName = WmsOutDetail.fields.description.ToString() };
 | ||
| 
 | ||
| 
 | ||
|             GridColumn myCol20 = new GridColumn() { Caption = "波次", Visible = true, FieldName = WmsOutPickLable.fields.waveOrder.ToString() };
 | ||
|             GridColumn myCol21 = new GridColumn() { Caption = "颜色", Visible = true, FieldName = WmsOutPickLable.fields.color.ToString() };
 | ||
|             GridColumn myCol22 = new GridColumn() { Caption = "货位", Visible = true, FieldName = WmsOutPickLable.fields.locationId.ToString() };
 | ||
|             GridColumn myCol23 = new GridColumn() { Caption = "标签", Visible = true, FieldName = WmsOutPickLable.fields.elabId.ToString() };
 | ||
|             GridColumn myCol24 = new GridColumn() { Caption = "客户", Visible = true, FieldName = WmsOutPickRequest.fields.customerName.ToString() };
 | ||
|           //  GridColumn myCol25 = new GridColumn() { Caption = "订单", Visible = true, FieldName = WmsOutPickDetail.fields.orderNo.ToString() };
 | ||
|            
 | ||
|          //   gridview.Columns.Add(myCol25);
 | ||
|             gridview.Columns.Add(myCol2); 
 | ||
|             gridview.Columns.Add(myCol14);
 | ||
|          //   gridview.Columns.Add(myCol21);
 | ||
|             gridview.Columns.Add(myCol100);
 | ||
|             gridview.Columns.Add(myCol22); 
 | ||
|             gridview.Columns.Add(myCol23);
 | ||
|            /*
 | ||
|             gridview.Columns.Add(myCol5);
 | ||
|             gridview.Columns.Add(myCol17);
 | ||
|             gridview.Columns.Add(myCol24);
 | ||
| 
 | ||
|             gridview.Columns.Add(myCol7);
 | ||
| 
 | ||
|            
 | ||
|             gridview.Columns.Add(myCol3);
 | ||
| 
 | ||
|             gridview.Columns.Add(myCol15);
 | ||
|             gridview.Columns.Add(myCol16);
 | ||
|             gridview.Columns.Add(myCol3); 
 | ||
|             gridview.Columns.Add(myCol8);
 | ||
|             //gridview.Columns.Add(myCol9); 
 | ||
|             gridview.Columns.Add(myCol2);
 | ||
|             //   gridview.Columns.Add(myCol6); 
 | ||
|             gridview.Columns.Add(myCol4); 
 | ||
|             gridview.Columns.Add(myCol12);
 | ||
|             gridview.Columns.Add(myCol1); 
 | ||
|             gridview.Columns.Add(myCol18);
 | ||
| 
 | ||
|             */
 | ||
| 
 | ||
|             //to show bottom scroll bar
 | ||
|             gridview.OptionsView.ColumnAutoWidth = false;
 | ||
|             gridview.BestFitColumns();
 | ||
|             //  gridView2.Focus();
 | ||
|         }
 | ||
| 
 | ||
|         #endregion
 | ||
| 
 | ||
| 
 | ||
|         
 | ||
|         /// <summary>
 | ||
|         /// 预处理,按客户分拆订单,生成分拣单,并出库
 | ||
|         /// </summary>
 | ||
|         private void getValidationOrders()
 | ||
|         {
 | ||
| 
 | ||
|             threadPreProcess = new Thread(this.getPickOrders4Validation);
 | ||
|             threadPreProcess.IsBackground = true; 
 | ||
|             threadPreProcess.Start();
 | ||
|         }
 | ||
| 
 | ||
|         private void getPickOrders4Validation()
 | ||
|         {
 | ||
|             dsPickOrders = lgt.getPickRequest4BulkValidate(desk);
 | ||
|             dtPickOrders = dsPickOrders.Tables[1];
 | ||
|             dtPickOrdersDetail = dsPickOrders.Tables[0];
 | ||
|             dtPickOrdersDetail.PrimaryKey = new DataColumn[] { dtPickOrdersDetail.Columns["id"] };
 | ||
|            updateValidationList();
 | ||
| 
 | ||
|         }
 | ||
|         
 | ||
|         //完成任务时需要调用
 | ||
|         delegate void loadNewPickOrders();
 | ||
|         private void updateValidationList()
 | ||
|         {
 | ||
|             //还可以进行其他的一些完任务完成之后的逻辑处理
 | ||
|  
 | ||
|          
 | ||
|            
 | ||
|             if (InvokeRequired)
 | ||
|             {
 | ||
|                 this.Invoke(new loadNewPickOrders(delegate()
 | ||
|                 {
 | ||
|                     swAutoOrder.Enabled = true;
 | ||
|                     btnPickOrders.Enabled = !autoOrder;
 | ||
|                     this.loadPickOrders();
 | ||
|                 }));
 | ||
|                
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 swAutoOrder.Enabled = true;
 | ||
|                 btnPickOrders.Enabled = !autoOrder;
 | ||
|                 this.loadPickOrders();
 | ||
|             }
 | ||
| 
 | ||
|             if (autoOrder)
 | ||
|             {
 | ||
|                 Int32 milseconds = Convert.ToInt32( 1000*spinOrder.Value * 60);
 | ||
| 
 | ||
|                 Thread.CurrentThread.Join(milseconds);
 | ||
|                 //继续后台处理
 | ||
|                 getValidationOrders();
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 更新拣选明细
 | ||
|         /// </summary>
 | ||
|         private void   updatePickDetails() {
 | ||
|             gridPickDetails.DataSource = null;
 | ||
|             Thread threadPickdetail = new Thread(this.getPickOrdersPickDetail);
 | ||
|             threadPickdetail.IsBackground = true;
 | ||
|             threadPickdetail.Start();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private void getPickOrdersPickDetail()
 | ||
|         {
 | ||
|            
 | ||
|             dtPickDetails = lgt.getWmsOutPickRequest. getPickDetailByPickOrderNo(this.currentPickOrder).Tables[0];
 | ||
|            
 | ||
| 
 | ||
|             if (InvokeRequired)
 | ||
|             {
 | ||
|                 this.Invoke(new loadNewPickOrders(delegate()
 | ||
|                 {
 | ||
|                     bindPickDetails();
 | ||
|                      
 | ||
|                 }));
 | ||
| 
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 bindPickDetails();
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void bindPickDetails()
 | ||
|         {
 | ||
|             gridPickDetails.DataSource = dtPickDetails;
 | ||
|             initialGridView3Columns(gridViewPickDetails);
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|           
 | ||
|         /// <summary>  
 | ||
|         /// loading waiting pick orders
 | ||
|         /// </summary>  
 | ||
|         private int pagerQuery()
 | ||
|         {
 | ||
|           //  initialRequestOrders();
 | ||
|             //this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView;
 | ||
|             showWaitForm();
 | ||
| 
 | ||
|             try
 | ||
|             {
 | ||
|                 // this.splashScreenManager1.ShowWaitForm();
 | ||
|                 string query =   string.Format("{0} =#'{1}';", WmsOutRequest.fields.orderType.ToString(), (int)enumOutOrderType.拣货单);
 | ||
|                 query += string.Format("{0} =#'{1}';", WmsOutRequest.fields.state.ToString(), (int) enumOutStockRequestStatus.波次处理 );
 | ||
|                 bool isQueryNotChanged = lastQuery.Equals(query);
 | ||
|                 this.pager1.PageCurrent = isQueryNotChanged ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值
 | ||
|                 int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1);
 | ||
|                 int end = (pager1.PageSize * pager1.PageCurrent);
 | ||
|                 lastQuery = query;
 | ||
|                 DataSet ds = lgt.Query(query, start, end);
 | ||
|                 dtPickOrders = ds.Tables[0];
 | ||
|                 int cnt = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString());
 | ||
|                 //dt = lgt.Query(query, start, end); //string.IsNullOrEmpty(query) ? lgt.GetGoodType.getAllData(start, end) : lgt.g;
 | ||
| 
 | ||
|                 dtPickOrders.PrimaryKey = new DataColumn[] { dtPickOrders.Columns["pickOrderNo"] };
 | ||
|                 bool firstLoad = !isQueryNotChanged || this.gridControl1.DataSource == null;
 | ||
|                 this.gridControl1.DataSource = dtPickOrders.DefaultView;
 | ||
|                 initialDataGridColumns();
 | ||
|                 //update selected row index to the last updated one.
 | ||
| 
 | ||
|                 if (false && !string.IsNullOrEmpty( currentPickOrder))
 | ||
|                 {
 | ||
|                     selectedRowIndex = -1;
 | ||
|                     DataRow dr = dtPickOrders.Rows.Find(currentPickOrder);
 | ||
|                     if (dr != null)
 | ||
|                     {
 | ||
|                         selectedRowIndex = dtPickOrders.Rows.IndexOf(dr);
 | ||
|                     }
 | ||
| 
 | ||
|                     if (selectedRowIndex >= 0 && dtPickOrders.Rows.Count > selectedRowIndex)
 | ||
|                     {
 | ||
|                         // gridView1.SelectRow(selectedRowIndex);
 | ||
|                         gridView1.FocusedRowHandle = selectedRowIndex;
 | ||
|                         //  gridView1.MakeRowVisible(selectedRowIndex);
 | ||
| 
 | ||
|                     }
 | ||
| 
 | ||
|                     //gridView1.FocusedRowHandle = selectedRowIndex;
 | ||
|                 }else
 | ||
|                // if (firstLoad)
 | ||
|                 {
 | ||
|                     gridView1.FocusedRowHandle = 0;
 | ||
|                     gridView1.SelectRow(0);
 | ||
|                     setCurrentRequestDetail();
 | ||
|                 }
 | ||
|                 closeWaitForm();
 | ||
|                 return cnt;
 | ||
|             }
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 showErrorMsg(e.Message);
 | ||
|             }
 | ||
| 
 | ||
|             closeWaitForm();
 | ||
|             return 0;// lgt.getRowCount(query);
 | ||
|             // return lgt.GetGoodType.QueryCount(); 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|    
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         private void bindDetail()
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
|         private void setDataBack()
 | ||
|         {
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
|         private bool validData()
 | ||
|         {
 | ||
|             bool isvalid = dxValidationProvider1.Validate();
 | ||
| 
 | ||
|             // MessageBox.Show("goodtype is " + txtGoodType.Text +", is valid ? " + isvalid);
 | ||
| 
 | ||
|             return isvalid;
 | ||
|             //String gdtype = txtGoodType.Text.Trim();
 | ||
|             //if (gdtype.Length == 0)
 | ||
|             //{
 | ||
| 
 | ||
|             //    dxValidationProvider.Validate();
 | ||
|             //    return false;
 | ||
|             //} 
 | ||
| 
 | ||
|             //return true;
 | ||
|         }
 | ||
|          
 | ||
|        
 | ||
| 
 | ||
|         /// <summary>  
 | ||
|         /// 分页控件产生的事件  
 | ||
|         /// </summary>  
 | ||
|         private int pager_EventPaging(DeiNiu.Controls.pager.EventPagingArg e)
 | ||
|         {
 | ||
|             selectedRowIndex = 0; //reset currentRowIndex
 | ||
|             return pagerQuery();
 | ||
|         }
 | ||
| 
 | ||
|         private void initialPagerControls()
 | ||
|         {
 | ||
| 
 | ||
|             pager1.MaximumSize = new Size(0, 20);
 | ||
|             pager1.EventPaging += new DeiNiu.Controls.pager.EventPagingHandler(pager_EventPaging);
 | ||
|             #region DataGridView与Pager控件绑定
 | ||
|             this.pager1.PageCurrent = 1;//当前页为第一页  
 | ||
|             pager1.PageSize = 200;//每页行数  
 | ||
|             this.pager1.Bind();//绑定  
 | ||
|             #endregion
 | ||
| 
 | ||
|         }
 | ||
|        
 | ||
|         private void gridView1_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | ||
|         {
 | ||
|             if (gridView1.FocusedRowHandle < 0 || gridView1.FocusedRowHandle == selectedRowIndex || isDataSourceChanged && selectedRowIndex >0)
 | ||
|             {
 | ||
|                 if (gridView1.IsGroupRow(e.RowHandle)) //set first row of group selected
 | ||
|                 {
 | ||
|                     selectedRowIndex = gridView1.GetChildRowHandle(e.RowHandle, 0);
 | ||
|                     setCurrentRequestDetail();
 | ||
|                 }
 | ||
|                    
 | ||
|                isDataSourceChanged = false;
 | ||
|                return; ;
 | ||
|             }
 | ||
|             isDataSourceChanged = false;
 | ||
|             selectedRowIndex = gridView1.FocusedRowHandle;
 | ||
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | ||
|             setCurrentRequestDetail();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|      
 | ||
| 
 | ||
|         private void clearInputs()
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         bool isDataSourceChanged = false;
 | ||
|         private void gridView1_DataSourceChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             isDataSourceChanged = true;
 | ||
|             if (selectedRowIndex >= 0 && dtPickOrders.Rows.Count > selectedRowIndex)
 | ||
|             {
 | ||
|                 gridView1.FocusedRowHandle = selectedRowIndex;
 | ||
|                 gridView1.MakeRowVisible(selectedRowIndex);
 | ||
| 
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void btnDelete_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         protected void query()
 | ||
|         {
 | ||
|            // pager1.Bind();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private void loadPickOrders()
 | ||
|         {
 | ||
| 
 | ||
|           //  showWaitForm();
 | ||
|             try
 | ||
|             {
 | ||
| 
 | ||
|                 gridControl1.DataSource = dtPickOrders;
 | ||
|              
 | ||
|                 //dt = lgt.Query(query, start, end); //string.IsNullOrEmpty(query) ? lgt.GetGoodType.getAllData(start, end) : lgt.g;
 | ||
| 
 | ||
|                 dtPickOrders.PrimaryKey = new DataColumn[] { dtPickOrders.Columns["pickOrderNo"] };
 | ||
|                 bool firstLoad =   this.gridControl1.DataSource == null;
 | ||
|                 this.gridControl1.DataSource = dtPickOrders.DefaultView;
 | ||
|                 initialDataGridColumns();
 | ||
|                 //update selected row index to the last updated one.
 | ||
| 
 | ||
|                 if (!string.IsNullOrEmpty(currentPickOrder) )
 | ||
|                 {
 | ||
|                     selectedRowIndex = -1;
 | ||
|                     DataRow dr = dtPickOrders.Rows.Find(currentPickOrder);
 | ||
|                     if (dr != null)
 | ||
|                     {
 | ||
|                         selectedRowIndex = dtPickOrders.Rows.IndexOf(dr);
 | ||
|                     }
 | ||
| 
 | ||
|                     if (selectedRowIndex >= 0 && dtPickOrders.Rows.Count > selectedRowIndex)
 | ||
|                     {
 | ||
|                         // gridView1.SelectRow(selectedRowIndex);
 | ||
|                         gridView1.FocusedRowHandle = selectedRowIndex;
 | ||
|                         //  gridView1.MakeRowVisible(selectedRowIndex);
 | ||
| 
 | ||
|                     }
 | ||
| 
 | ||
|                     //gridView1.FocusedRowHandle = selectedRowIndex;
 | ||
|                 }
 | ||
|                 else
 | ||
|                 // if (firstLoad)
 | ||
|                 {
 | ||
|                     gridView1.FocusedRowHandle = 0;
 | ||
|                     gridView1.SelectRow(0);
 | ||
|                     setCurrentRequestDetail();
 | ||
|                 }
 | ||
|                 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|             }
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 showErrorMsg(e.Message);
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|                 // WaitFormService.Close();
 | ||
|                // closeWaitForm();
 | ||
|                 bbQuery.Enabled = true;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
|          
 | ||
|         private void bbQuery_ItemClick_1(object sender, ItemClickEventArgs e)
 | ||
|         {
 | ||
|             this.bbQuery.Enabled = false;
 | ||
|             loadPickOrders();
 | ||
|         }
 | ||
| 
 | ||
|        
 | ||
| 
 | ||
|         private void updateObjects(List<WmsGoods> goods)
 | ||
|         { 
 | ||
|             showWaitForm();
 | ||
|             //WaitFormService.Show(this); 
 | ||
|             try
 | ||
|             {
 | ||
|              //   lgt.update(goods);
 | ||
| 
 | ||
|                 //get updated data 
 | ||
|                 query();
 | ||
| 
 | ||
|             }
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 showErrorMsg(e.Message);
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|                 // WaitFormService.Close();
 | ||
|                 closeWaitForm();
 | ||
|              
 | ||
|             }
 | ||
|              
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private bool getCurrentObject()
 | ||
|         {
 | ||
|             if (selectedRowIndex <0 || selectedRowIndex >= dtPickOrders.Rows.Count)
 | ||
|             {
 | ||
|                 return false;
 | ||
|             }
 | ||
|            
 | ||
|            // DataRow currentRow = dtPickOrders.Rows[selectedRowIndex];
 | ||
|             DataRowView currentRow = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]);
 | ||
|           //  selectedRequest = new WmsOutPickRequest(currentRow); 
 | ||
|             currentPickOrder = currentRow["pickOrderNo"].ToString();
 | ||
|             lbPickOrderNo.Text = currentPickOrder;
 | ||
|             lbCustmer.Text = currentRow["customerName"].ToString();
 | ||
| 
 | ||
|             return true;
 | ||
| 
 | ||
|         }
 | ||
|        
 | ||
|        
 | ||
| 
 | ||
| 
 | ||
|         private void btnQuery_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             loadPickOrders();
 | ||
|         }
 | ||
| 
 | ||
|         private void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
 | ||
|         {
 | ||
|             if (gridView1.FocusedRowHandle <0 || gridView1.FocusedRowHandle == selectedRowIndex)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             selectedRowIndex = gridView1.FocusedRowHandle;
 | ||
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | ||
|             setCurrentRequestDetail();
 | ||
|         }
 | ||
| 
 | ||
|         private void initialDataGrid()
 | ||
|         {
 | ||
|             gridView1.OptionsSelection.MultiSelect = false;//按shift / control 多选
 | ||
|             this.gridView1.OptionsBehavior.AutoPopulateColumns = false;
 | ||
|             this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | ||
|             this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus;
 | ||
|             this.gridView1.OptionsBehavior.Editable = false;
 | ||
|             this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
| 
 | ||
|             this.gridView1.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView1_FocusedRowObjectChanged);
 | ||
|             this.gridView1.DataSourceChanged += new System.EventHandler(this.gridView1_DataSourceChanged);
 | ||
| 
 | ||
|             //show line number
 | ||
|             this.gridView1.IndicatorWidth = 40;
 | ||
|             this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|            
 | ||
|             this.gridViewValidated.IndicatorWidth = 40;
 | ||
|             this.gridViewValidated.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
| 
 | ||
|             this.gridViewSaleOrders .IndicatorWidth = 40;
 | ||
|             this.gridViewSaleOrders.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|             gridViewSaleOrders.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
| 
 | ||
| 
 | ||
|             this.gridViewPickDetails.IndicatorWidth = 40;
 | ||
|             this.gridViewPickDetails.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|            
 | ||
|             gridViewPickDetails.OptionsSelection.MultiSelect = false;
 | ||
|             gridViewPickDetails.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
| 
 | ||
|             this.gridView4Valid.IndicatorWidth = 40;
 | ||
|             this.gridView4Valid.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|             this.gridView4Valid.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView4Validation_FocusedRowObjectChanged);
 | ||
|             gridView4Valid.OptionsSelection.MultiSelect = false;
 | ||
|             gridView4Valid.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | ||
|             gridView4Valid.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
|             
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|             this.gridViewValidated.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | ||
|             gridViewValidated.OptionsSelection.EnableAppearanceFocusedCell = false; 
 | ||
|             gridViewValidated.OptionsSelection.MultiSelect = false;
 | ||
|             gridViewValidated.RowCellStyle += gridView_RowCellStyle;
 | ||
|             gridView1.RowCellStyle += gridView_RowCellStyle;
 | ||
|         }
 | ||
|    
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|        private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
 | ||
|         {
 | ||
|            
 | ||
|             if (sender == gridViewValidated)
 | ||
|             {
 | ||
|                
 | ||
|                 if (e.Column.FieldName == "state")
 | ||
|                 {
 | ||
|                     if (!pickDetailStatus.ContainsValue(e.DisplayText))
 | ||
|                     {
 | ||
| 
 | ||
|                         int display = -100;
 | ||
|                         string disTxt = e.DisplayText;
 | ||
| 
 | ||
|                         try
 | ||
|                         {
 | ||
|                             display = Convert.ToInt16(e.DisplayText);
 | ||
| 
 | ||
|                             e.DisplayText = pickDetailStatus[display];
 | ||
| 
 | ||
|                         }
 | ||
|                         catch
 | ||
|                         {
 | ||
|                             return;
 | ||
|                         }
 | ||
|                     }
 | ||
| 
 | ||
| 
 | ||
|                   //  e.DisplayText = pickDetailStatus.ContainsKey(display) ? pickDetailStatus[display] : display+"";
 | ||
| 
 | ||
|                 }
 | ||
|                  
 | ||
|             }
 | ||
|         }
 | ||
|        void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
 | ||
|        {
 | ||
|            //var currentView = sender as GridView;
 | ||
|            //if (currentView != null && e.RowHandle == currentView.FocusedRowHandle) return;
 | ||
|            Rectangle r = e.Bounds;
 | ||
|            if (e.Column.FieldName == "state")
 | ||
|            {
 | ||
|                string a = e.CellValue.ToString();
 | ||
|                string b = e.DisplayText;
 | ||
|                if (b.Equals("未分配货位"))
 | ||
|                {
 | ||
|                    e.Appearance.ForeColor = Color.Red;
 | ||
|                    e.Appearance.DrawString(e.Cache, e.DisplayText, r);
 | ||
|                    e.Handled = true;
 | ||
|                }
 | ||
| 
 | ||
|            }
 | ||
|        }
 | ||
| 
 | ||
|        void gridView_RowCellStyle(object sender,DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
 | ||
|        {
 | ||
| 
 | ||
|             var currentView = sender as GridView;
 | ||
|            if( currentView != null){return;}
 | ||
|            string state = currentView.GetDataRow(e.RowHandle)["state"].ToString().Trim();
 | ||
|            
 | ||
|            if (state == "0")
 | ||
|            {
 | ||
|                return;
 | ||
|            }
 | ||
| 
 | ||
|            bool isFocused = e.RowHandle == currentView.FocusedRowHandle;
 | ||
|            DevExpress.Utils.AppearanceDefault rowStyle = null;
 | ||
|             DevExpress.Utils.AppearanceDefault appBlueRed = 
 | ||
|                new DevExpress.Utils.AppearanceDefault (Color.White, Color.Red, Color.Empty, Color.Blue, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
 | ||
|            DevExpress.Utils.AppearanceDefault appYB =
 | ||
|             new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green);
 | ||
| 
 | ||
|            DevExpress.Utils.AppearanceDefault alertFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green,  Color.Yellow);
 | ||
|            DevExpress.Utils.AppearanceDefault alert  = new DevExpress.Utils.AppearanceDefault(Color.Red, Color.White );
 | ||
| 
 | ||
|            DevExpress.Utils.AppearanceDefault passedFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Gray);
 | ||
|            DevExpress.Utils.AppearanceDefault passed  = new DevExpress.Utils.AppearanceDefault(Color.Gray,Color.White);
 | ||
| 
 | ||
|            if (state == "1")
 | ||
|            {
 | ||
|                rowStyle = isFocused ? passedFocus : passed;
 | ||
|            }
 | ||
|            else if (state == "2")
 | ||
|            {
 | ||
|                rowStyle = isFocused ? alertFocus : alert;
 | ||
|            }
 | ||
| 
 | ||
| 
 | ||
|            DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, rowStyle);
 | ||
|            /*
 | ||
|            if (sender == this.gridView2)
 | ||
|            {
 | ||
|                if (this.gridView2.GetDataRow(e.RowHandle)["state"].ToString().Trim() == "2")
 | ||
|                {
 | ||
|                    DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
 | ||
|                }
 | ||
|            }else if(sender == this.gridView1){
 | ||
|                 
 | ||
|                if ( state == "2")
 | ||
|                {
 | ||
|                    if (currentView != null && e.RowHandle == currentView.FocusedRowHandle)
 | ||
|                    {
 | ||
|                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alertFocus);
 | ||
|                    }
 | ||
|                    else
 | ||
|                    {
 | ||
|                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
 | ||
|                    }
 | ||
|                }
 | ||
|                else if (state == "1")
 | ||
|                {
 | ||
|                    DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, passed);
 | ||
|                } 
 | ||
|            }
 | ||
|            */
 | ||
|        }
 | ||
| 
 | ||
|         private void setCurrentRequestDetail()
 | ||
|         {
 | ||
|             if (!getCurrentObject() || string.IsNullOrEmpty( currentPickOrder)) 
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|            
 | ||
|          
 | ||
|         //   showWaitForm();
 | ||
| 
 | ||
|             try
 | ||
|             {
 | ||
|                
 | ||
|                 DataView dv = dtPickOrdersDetail.DefaultView;
 | ||
|                 dv.Sort = "orderNo ASC";
 | ||
|                 dv.RowFilter = string.Format("pickOrderNo ='{0}'", currentPickOrder);
 | ||
|                 this.gridSaleOrders.DataSource = dv;
 | ||
|                 initialGridView2Columns(gridViewSaleOrders);
 | ||
| 
 | ||
| 
 | ||
|                 bindValidationTables();
 | ||
|                 
 | ||
|                 
 | ||
|                 //set pick details
 | ||
|                 updatePickDetails();
 | ||
| 
 | ||
|                  
 | ||
|    
 | ||
|             }
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 showErrorMsg(e.Message);
 | ||
|             }
 | ||
|          //   closeWaitForm();
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private void bindValidationTables()
 | ||
|         {  
 | ||
| 
 | ||
|             resetValidationDetails(); 
 | ||
|             //set sales order details
 | ||
|             DataView dv = dtPickOrdersDetail.DefaultView;
 | ||
|             dv.Sort = "orderNo ASC";
 | ||
|             dv.RowFilter = string.Format("pickOrderNo ='{0}'", currentPickOrder); 
 | ||
| 
 | ||
|             dtPickOrders4Validation = dv.ToTable();
 | ||
|          
 | ||
|             //  dtPickOrders4Validation.PrimaryKey = new DataColumn[] { dtPickOrders4Validation.Columns["barCode"] };
 | ||
|             DataView dv1 = dtPickOrders4Validation.DefaultView;
 | ||
|             dv1.RowFilter = string.Format("bulkCount>0 and state <{0}", (int)enumOutStockDetailStatus.复核完成);
 | ||
|             this.grid4Valid.DataSource = dv1;
 | ||
|             initialGridView2Columns(gridView4Valid);
 | ||
|             dtPickOrders4Validation = dv1.ToTable();
 | ||
|             dtPickOrders4Validation.PrimaryKey = new DataColumn[] { dtPickOrders4Validation.Columns["id"] };
 | ||
| 
 | ||
|             btnPrint .Enabled = dtPickOrders4Validation.Rows.Count == 0;
 | ||
|             dtPickOrdersValidated = dv.ToTable();
 | ||
|             DataView dv2 = dtPickOrdersValidated.DefaultView;
 | ||
|             dv2.RowFilter = string.Format("bulkCount>0 and state >={0}", (int)enumOutStockDetailStatus.复核完成);
 | ||
|             this.gridValidated.DataSource = dv2;
 | ||
| 
 | ||
|             gridViewValidated.FocusedRowHandle = -1;
 | ||
|             gridViewValidated.SelectRow(-1);
 | ||
| 
 | ||
|             dtPickOrdersValidated = dv2.ToTable();
 | ||
|             dtPickOrdersValidated.PrimaryKey = new DataColumn[] { dtPickOrdersValidated.Columns["id"] };
 | ||
| 
 | ||
|             initialGridView2Columns(gridViewValidated);
 | ||
| 
 | ||
|              
 | ||
|         }
 | ||
| 
 | ||
|      
 | ||
|           
 | ||
|         private void btnPickOrders_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             getValidationOrders();
 | ||
|         } 
 | ||
| 
 | ||
|         private void swAutoOrder_Toggled(object sender, EventArgs e)
 | ||
|         {
 | ||
|             autoOrder = swAutoOrder.IsOn;
 | ||
|             btnPickOrders.Enabled = !autoOrder;
 | ||
|             if (autoOrder)
 | ||
|             {
 | ||
|                 getValidationOrders();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         
 | ||
|  
 | ||
| 
 | ||
|         private void ribbon_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|         
 | ||
|         }
 | ||
| 
 | ||
|         private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
|         private void resetValidationDetails()
 | ||
|         {
 | ||
|             lastScanBarcode = "";
 | ||
|             selectedValidationItem = -1;
 | ||
|             currentDetail = null;
 | ||
|             lbGoodsName.Text ="";
 | ||
|             this.lbBatch.Text = ""; ;
 | ||
|             this.lbManufacturer.Text = "";
 | ||
|             this.lbPickCount.Text = "";
 | ||
|             this.lbSaleCount.Text = "";
 | ||
|             this.textEditValidCount.Text = "";
 | ||
|             this.textEditValidtionRemark.Text = "";
 | ||
|             //   this.comValidException.SelectedIndex = Convert.ToInt16( dr[WmsOutPickDetail.fields.validReason.ToString()].ToString());
 | ||
| 
 | ||
|             this.lbProductDate.Text = "";
 | ||
|             this.lbValidDate.Text = "";
 | ||
|             this.lbType.Text = "";
 | ||
|             this.lbUnit.Text = "";
 | ||
|             this.checkEditPass.Checked = false;
 | ||
|             textEditBarcode.Text = "";
 | ||
|             this.btnValidateItem.Enabled = false;
 | ||
|           
 | ||
|        
 | ||
|              
 | ||
|         }
 | ||
| 
 | ||
|         // gridview4validate
 | ||
| 
 | ||
|         int selectedValidationItem = -1;
 | ||
|         private void gridView4Validation_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | ||
|         {
 | ||
|             if (this.gridView4Valid.FocusedRowHandle < 0 || gridView4Valid.FocusedRowHandle == selectedValidationItem)
 | ||
|             {
 | ||
|                 if (gridView4Valid.IsGroupRow(e.RowHandle)) //set first row of group selected
 | ||
|                 {
 | ||
|                     selectedValidationItem = gridView4Valid.GetChildRowHandle(e.RowHandle, 0);
 | ||
|                     setCurrentValidationDetail();
 | ||
|                     gridViewValidated.FocusedRowHandle = -1;
 | ||
|                     gridViewValidated.SelectRow(-1);
 | ||
|                 } 
 | ||
|                     return;  
 | ||
|                  
 | ||
|             }
 | ||
|             selectedValidationItem = gridView4Valid.FocusedRowHandle;
 | ||
|             setCurrentValidationDetail();  
 | ||
|            gridViewValidated .FocusedRowHandle = -1;
 | ||
|            gridViewValidated.SelectRow(-1);
 | ||
|         }
 | ||
|         private void setCurrentValidationDetail()
 | ||
|         {
 | ||
|             if (selectedValidationItem < 0 || selectedValidationItem >= dtPickOrders4Validation.Rows.Count)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|           //  DataRow dr = dtPickOrders4Validation.Rows[selectedValidationItem];
 | ||
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView4Valid)[selectedValidationItem]);
 | ||
| 
 | ||
|             currentDetail = new WmsOutPickDetail_tmp(dr.Row);
 | ||
|             lbGoodsName.Text = dr[WmsGoods.exfields.goodsName.ToString()].ToString(); ;
 | ||
|             this.lbBatch .Text = dr["batch"].ToString(); ;
 | ||
|             this.lbManufacturer.Text = dr[WmsGoods.exfields.manufacturer.ToString()].ToString(); 
 | ||
|             this.lbPickCount.Text = dr[WmsOutPickDetail.fields.bulkCount.ToString()].ToString(); 
 | ||
|             this.lbSaleCount.Text = dr[WmsOutPickDetail.fields.bulkCount.ToString()].ToString();
 | ||
|             this.textEditValidCount.Text = dr[WmsOutPickDetail.fields.bulkCount.ToString()].ToString();
 | ||
|             this.textEditValidtionRemark.Text = dr[WmsOutPickDetail.fields.validRemark.ToString()].ToString();
 | ||
|          //   this.comValidException.SelectedIndex = Convert.ToInt16( dr[WmsOutPickDetail.fields.validReason.ToString()].ToString());
 | ||
| 
 | ||
|             this.lbProductDate.Text = dr[WmsOutPickDetail.fields.productDate.ToString()].ToString();  
 | ||
|             this.lbValidDate.Text = dr[WmsOutPickDetail.fields.validDate.ToString()].ToString();
 | ||
|             this.lbType.Text = dr[WmsGoods.exfields.type.ToString()].ToString();
 | ||
|             this.lbUnit.Text = dr[WmsGoods.exfields.unit.ToString()].ToString();
 | ||
|             this.checkEditPass.Checked = true;
 | ||
|             enumOutStockPickStatus state = (enumOutStockPickStatus)Convert.ToInt16(dr["bulkPickState"].ToString());
 | ||
|             if(state == enumOutStockPickStatus.复核异常){
 | ||
|                 this.checkEditPass.Checked = false;
 | ||
|             }
 | ||
|             textEditBarcode.Text = dr[WmsGoods.exfields.barcode.ToString()].ToString();
 | ||
|             //textEditBarcode.SelectedText = textEditBarcode.Text;
 | ||
|             //textEditBarcode.SelectionLength = textEditBarcode.Text.Length;
 | ||
|             textEditBarcode.Focus();
 | ||
|             textEditBarcode.SelectAll();
 | ||
| 
 | ||
|             this.btnValidateItem.Enabled = true;
 | ||
|              
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void textEditBarcode_EditValueChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|            
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void btnValidateItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             validation();
 | ||
|               
 | ||
|         }
 | ||
| 
 | ||
|         private void validation()
 | ||
|         {
 | ||
|             if (currentDetail == null)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|             currentDetail.bulkPickState = checkEditPass.Checked ? (int)enumOutStockPickStatus.复核完成 : (int)enumOutStockPickStatus.复核异常;
 | ||
|             currentDetail.validRemark = textEditValidtionRemark.Text.Trim();
 | ||
|             currentDetail.validReason = comValidException.SelectedIndex;
 | ||
|             currentDetail.confirmedCount = Convert.ToDecimal(textEditValidCount.Text.Trim());
 | ||
| 
 | ||
|             Thread updateValidation = new Thread(updateValidationItem);
 | ||
|             updateValidation.IsBackground = true;
 | ||
|             updateValidation.Start();
 | ||
| 
 | ||
| 
 | ||
|             DataRow dr = this.dtPickOrdersDetail.Rows.Find(currentDetail.ID);
 | ||
|             if (dr != null)
 | ||
|             {
 | ||
|                 dr["state"] = currentDetail.state;
 | ||
| 
 | ||
| 
 | ||
|             }
 | ||
|             bindValidationTables();
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
|         private void updateValidationItem()
 | ||
|         {
 | ||
|             if (currentDetail == null)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             currentDetail.Update();
 | ||
|         }
 | ||
| 
 | ||
|         private void gridView4Valid_KeyDown(object sender, KeyEventArgs e)
 | ||
|         {
 | ||
|             if(e.KeyCode == Keys.Enter){
 | ||
| 
 | ||
|                 validation();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void textEditBarcode_Properties_Enter(object sender, EventArgs e)
 | ||
|         {
 | ||
|             textEditBarcode.SelectAll();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         void textEditBarcode_MouseUp(object sender, MouseEventArgs e)
 | ||
|         {
 | ||
|             //如果鼠标左键操作并且标记存在,则执行全选             
 | ||
|             if (e.Button == MouseButtons.Left && (bool)textEditBarcode.Tag == true)
 | ||
|             {
 | ||
|                 textEditBarcode.SelectAll();
 | ||
|             }
 | ||
| 
 | ||
|             //取消全选标记              
 | ||
|             textEditBarcode.Tag = false;
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         void textEditBarcode_GotFocus(object sender, EventArgs e)
 | ||
|         {
 | ||
|             textEditBarcode.Tag = true;    //设置标记              
 | ||
|             textEditBarcode.SelectAll();   //注意1         
 | ||
|         }
 | ||
| 
 | ||
|         private void textEditBarcode_KeyDown(object sender, KeyEventArgs e)
 | ||
|         {
 | ||
|             if (e.KeyCode != Keys.Enter)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             string barcode = textEditBarcode.Text;
 | ||
| 
 | ||
|             if (string.IsNullOrEmpty(barcode))
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|            
 | ||
|             if(lastScanBarcode.Equals(barcode)){
 | ||
|               validation();
 | ||
|             } 
 | ||
|             lastScanBarcode = barcode;
 | ||
| 
 | ||
|             DataRow[] drs = dtPickOrders4Validation.Select(string.Format("barcode ='{0}'", barcode)); ;
 | ||
|             if (drs.Length == 0)
 | ||
|             {
 | ||
|                 setCurrentValidationDetail();
 | ||
|                 return;
 | ||
|             }
 | ||
|             textEditBarcode.BackColor = textEditValidCount.BackColor; ;
 | ||
|             if (drs.Length > 1)
 | ||
|             {
 | ||
|                 textEditBarcode.BackColor = Color.OrangeRed;
 | ||
|             }
 | ||
|            
 | ||
|             DataRow dr = drs[0];
 | ||
|             if (drs != null)
 | ||
|             {
 | ||
|                 selectedValidationItem = dtPickOrders4Validation.Rows.IndexOf(dr);
 | ||
|             }
 | ||
| 
 | ||
|             if (selectedValidationItem >= 0 && dtPickOrders4Validation.Rows.Count > selectedValidationItem)
 | ||
|             {
 | ||
|                 this.gridView4Valid.FocusedRowHandle = selectedValidationItem;
 | ||
|             }
 | ||
|             setCurrentValidationDetail();
 | ||
|         }
 | ||
| 
 | ||
|         private void btnPrint_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             
 | ||
|             //save the box/bag info
 | ||
| 
 | ||
|             //handle tran system
 | ||
|             
 | ||
|             //print
 | ||
| 
 | ||
|             //close current order
 | ||
| 
 | ||
|             Thread completeThread = new Thread(completeValidation);
 | ||
|             completeThread.IsBackground = true;
 | ||
|             completeThread.Start();
 | ||
|             //remove the order from pickorder list
 | ||
| 
 | ||
|             if (dtPickOrders.Rows.Count < 2)
 | ||
|             {
 | ||
|                 showWaitForm();
 | ||
|                 try
 | ||
|                 {
 | ||
|                     getPickOrders4Validation();
 | ||
|                 }
 | ||
|                 catch (Exception ee)
 | ||
|                 {
 | ||
|                     LogHelper.WriteLog(typeof(GoodsOutValidationForm), ee);
 | ||
|                     closeWaitForm();
 | ||
|                 }
 | ||
|                  closeWaitForm();
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
| 
 | ||
|               DataRow dr =  dtPickOrders.Rows.Find(currentPickOrder);
 | ||
|               dtPickOrders.Rows.Remove(dr);
 | ||
|               loadPickOrders();
 | ||
|             }
 | ||
| 
 | ||
|              
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         void completeValidation()
 | ||
|         { 
 | ||
|             
 | ||
|              
 | ||
|         }
 | ||
|   }
 | ||
| } |