1265 lines
		
	
	
		
			45 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			1265 lines
		
	
	
		
			45 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; | |||
|  | using DeiNiu.wms.win.utils.print;  | |||
|  | using DeiNiu.wms.win.ServiceReferenceStockOutPickRequest; | |||
|  | using Deiniu.win.elelab; | |||
|  | using DeiNiu.wms.win.ServiceReferenceStockOutRequest; | |||
|  |   | |||
|  | 
 | |||
|  | namespace DeiNiu.wms.win | |||
|  | { | |||
|  |     public partial class GoodsBatchOutForm : BasicRibbonForm | |||
|  |     { | |||
|  | 
 | |||
|  |               | |||
|  | 
 | |||
|  |         printIn reqportPrint = new printIn() ; | |||
|  | 
 | |||
|  |       //  lWmsStock ls = new lWmsStock(); | |||
|  |     //    lWmsOutPickRequest lgt = new lWmsOutPickRequest(); | |||
|  |         private string fieldName = WmsLocation.fields.locationId.ToString(); | |||
|  |         private string fieldGoodType = WmsLocation.fields.whGoodsType.ToString(); | |||
|  |         private string lastQuery = ""; | |||
|  |         private DataTable dtPickOrders; | |||
|  |         private DataTable dtRepOrders; | |||
|  |         private int selectedRowIndex = -1; | |||
|  |         private WmsOutPickRequest selectedRequest; | |||
|  |         bool autoOrder; | |||
|  |         int lightId = 0; | |||
|  |         int comId = 1; | |||
|  | 
 | |||
|  |         public GoodsBatchOutForm() | |||
|  |         { | |||
|  |             InitializeComponent(); | |||
|  |             initialControls(); | |||
|  |             //    loadData(); | |||
|  |               | |||
|  |         } | |||
|  |   | |||
|  |         #region initialControls | |||
|  |         private void initialControls() | |||
|  |         { | |||
|  |            | |||
|  |             initialComboBoxes(); | |||
|  |              | |||
|  |             initialDataGrid(); | |||
|  |             initialQueryInput();  | |||
|  |             setValidationRule(); | |||
|  |             initialTimer(); | |||
|  |             initialChannelLight(); | |||
|  |            // searchLight(); | |||
|  |           //  swAutoOrder.IsOn = WmsConstants.AUTO_PICK_BATCH_PICK_ORDER; | |||
|  | 
 | |||
|  |         } | |||
|  |         private void initialComboBoxes() | |||
|  |         { | |||
|  |             Node[] nds = { }; | |||
|  |             DataTable dt = Park.getDictionary(false); | |||
|  |             if (dt.Rows.Count == 0) | |||
|  |             { | |||
|  |                 return; | |||
|  |             } | |||
|  |             DataRow[] drs = dt.Select("flag >0"); | |||
|  |             foreach (DataRow dr in drs) | |||
|  |             { | |||
|  |                 int flag = Convert.ToInt32(dr["flag"].ToString()); | |||
|  |                 int parentId = Convert.ToInt32(dr["id"].ToString()); | |||
|  |                 DataRow[] drss = Park.getDictionary(false).Select("parentId =" + parentId); | |||
|  |                 switch (flag) | |||
|  |                 { | |||
|  |                      | |||
|  | 
 | |||
|  |                     case 3001: | |||
|  |                      //   initialComboBoxs(this.comboLines, drss, true); | |||
|  |                         break; | |||
|  |                 } | |||
|  |             }  | |||
|  |              | |||
|  |             DataTable dtSales = null; | |||
|  |             using (WmsOutRequestClient oclient = new WmsOutRequestClient()) | |||
|  |             { | |||
|  |                 dtSales = oclient.getSalesMen(); | |||
|  |             } | |||
|  |             string[] sales = new string[dtSales.Rows.Count]; | |||
|  | 
 | |||
|  |             int i = 0; | |||
|  |             foreach (DataRow dr in dtSales.Rows) | |||
|  |             { | |||
|  |                 sales[i] = dr[0].ToString(); | |||
|  |                 i++; | |||
|  |             } | |||
|  | 
 | |||
|  |        //     this.initialComboBoxs(comboSales, sales, "全部"); | |||
|  | 
 | |||
|  |       //      initialComboBoxs(comboOwner, getOwners()); | |||
|  |         } | |||
|  |        | |||
|  |         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(GridView gridView) | |||
|  |         { | |||
|  |             setupGridView(gridView, false); | |||
|  |             //setupGridView(gridView2, false,false); | |||
|  |             //setupGridView(gridView3, false,false); | |||
|  |             //   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 = WmsOutPickRequest.fields.pickOrderNo.ToString() }; | |||
|  |             GridColumn myCol2 = new GridColumn() { Caption = "客户", Visible = true, FieldName = WmsOutPickRequest.fields.customerName.ToString() }; | |||
|  |             GridColumn myCol3 = new GridColumn() { Caption = "状态", Visible = true, FieldName = WmsOutPickRequest.fields.batchPickState.ToString() };  | |||
|  | 
 | |||
|  | 
 | |||
|  |             gridView.Columns.Add(myCol1);  | |||
|  |             gridView.Columns.Add(myCol3);  | |||
|  |             gridView.Columns.Add(myCol2);   | |||
|  |   | |||
|  |             //to show bottom scroll bar | |||
|  |             gridView.OptionsView.ColumnAutoWidth = false; | |||
|  |             gridView.BestFitColumns(); | |||
|  |             gridView.Focus(); | |||
|  | 
 | |||
|  |             //if (gridView1 == gridView) | |||
|  |             //{ | |||
|  |             //    this.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 myCol13 = new GridColumn() { Caption = "小整数量", Visible = true, FieldName = WmsOutPickDetail.fields.batch1Count.ToString() }; | |||
|  |             GridColumn myCol131 = new GridColumn() { Caption = "大整数量", Visible = true, FieldName = WmsOutPickDetail.fields.batch2Count.ToString() }; | |||
|  | 
 | |||
|  |             GridColumn myCol14 = new GridColumn() { Caption = "批号", Visible = true, FieldName = WmsInRequestDetail.fields.batch.ToString() }; | |||
|  |             GridColumn myCol15 = new GridColumn() { Caption = "生产日期", Visible = true, FieldName = WmsInRequestDetail.fields.productDate.ToString() }; | |||
|  |             GridColumn myCol16 = new GridColumn() { Caption = "有效期", Visible = true, FieldName = WmsInRequestDetail.fields.validDate.ToString() }; | |||
|  | 
 | |||
|  |             GridColumn myCol17 = new GridColumn() { Caption = "状态", Visible = true, FieldName = gridview == gridView3 ? "state" : WmsOutPickDetail .fields.batchPickState.ToString() }; | |||
|  |             GridColumn myCol18 = new GridColumn() { Caption = "说明", Visible = true, FieldName = WmsInRequestDetail.fields.description.ToString() }; | |||
|  |             | |||
|  |             GridColumn myCol19 = new GridColumn() { Caption = "货位", Visible = true, FieldName = WmsOutPickLable.fields.locationId.ToString() }; | |||
|  |             GridColumn myCol20 = new GridColumn() { Caption = "出库数量", Visible = true, FieldName = WmsOutPickLable.fields.count.ToString() }; | |||
|  |             GridColumn myCol21 = new GridColumn() { Caption = "集货货位", Visible = true, FieldName = WmsOutPickPort.fields.tranLocationId.ToString() }; | |||
|  |             | |||
|  |             GridColumn myCol130 = new GridColumn() { Caption = "skuId", Visible = true, FieldName = "skuId" }; | |||
|  |             GridColumn myCol133 = new GridColumn() { Caption = "sku", Visible = true, FieldName = "skuCode" }; | |||
|  |             GridColumn myCol132 = new GridColumn() { Caption = "货主", Visible = true, FieldName = "ownerName" }; | |||
|  |             GridColumn myCol191 = new GridColumn() { Caption = "货位分区", Visible = true, FieldName = "partName" }; | |||
|  |              | |||
|  |             if (gridview == gridView3) | |||
|  |             {  | |||
|  |                 gridview.Columns.Add(myCol191); | |||
|  |             } | |||
|  |             gridview.Columns.Add(myCol2); | |||
|  |     | |||
|  |             gridview.Columns.Add(myCol132); | |||
|  |             gridview.Columns.Add(myCol130); | |||
|  |             gridview.Columns.Add(myCol14);  | |||
|  |             if (gridview == gridView3) | |||
|  |             { | |||
|  |               | |||
|  |                 gridview.Columns.Add(myCol19); | |||
|  |                 gridview.Columns.Add(myCol20); | |||
|  |                 gridview.Columns.Add(myCol21); | |||
|  |             } | |||
|  | 
 | |||
|  |             //if  (gridView4.IsFocusedView) | |||
|  |             //{ | |||
|  |             //    gridview.Columns.Add(myCol13); | |||
|  |             //    gridview.Columns.Add(myCol14); | |||
|  |             //    gridview.Columns.Add(myCol15); | |||
|  |             //    gridview.Columns.Add(myCol16); | |||
|  |             //    gridview.Columns.Add(myCol3); | |||
|  |             //} | |||
|  |             else | |||
|  |             { | |||
|  |                 gridview.Columns.Add(myCol13); | |||
|  |                 gridview.Columns.Add(myCol131); | |||
|  |             } | |||
|  |            | |||
|  |              | |||
|  |             | |||
|  |                 gridview.Columns.Add(myCol5);    | |||
|  |                 gridview.Columns.Add(myCol6); | |||
|  |                 gridview.Columns.Add(myCol17); | |||
|  |                 gridview.Columns.Add(myCol3);  | |||
|  |                 gridview.Columns.Add(myCol15); | |||
|  |                 gridview.Columns.Add(myCol16); | |||
|  |                 gridview.Columns.Add(myCol3); | |||
|  |            gridview.Columns.Add(myCol133); | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  |             gridview.Columns.Add(myCol8); | |||
|  |             gridview.Columns.Add(myCol9); | |||
|  |             gridview.Columns.Add(myCol10); | |||
|  |             gridview.Columns.Add(myCol11); | |||
|  | 
 | |||
|  |             gridview.Columns.Add(myCol2); | |||
|  |          | |||
|  | 
 | |||
|  |             | |||
|  |             gridview.Columns.Add(myCol4); | |||
|  |             gridview.Columns.Add(myCol7); | |||
|  | 
 | |||
|  |             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>   | |||
|  |         /// loading data | |||
|  |         /// </summary>   | |||
|  |         private int loadData() | |||
|  |         { | |||
|  |             //initialRequestOrders(); | |||
|  |             //this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView; | |||
|  |             showWaitForm(); | |||
|  |            // getRepOrders(); | |||
|  |             lbCust.Text = ""; | |||
|  |             lbOrderNo.Text = ""; | |||
|  |             try | |||
|  |             { | |||
|  |                // pickClient.newBatchOnlyPDATasks(); //TODO: make it in a service job | |||
|  |               //  closeClient();; | |||
|  |                 DataSet ds = pickClient.getBatchOutPickOrders4Pick();// lgt.Query(query, start, end); | |||
|  |                 closeClient();; | |||
|  |                 dtPickOrders = ds.Tables[0]; | |||
|  |                 dtRepOrders = ds.Tables[1]; | |||
|  | 
 | |||
|  |                 DataView dv1 = dtRepOrders.DefaultView; | |||
|  | 
 | |||
|  |                 dv1.RowFilter = string.Format( "batchPickState in ({1},{2})"  ,  (int)enumOutStoreType.拣货出库, (int)enumOutStockPickStatus.待处理,(int)enumOutStockPickStatus.正在分拣 ); | |||
|  |             | |||
|  |                   | |||
|  |                 DataView dv = dtPickOrders.DefaultView; | |||
|  |                 dv.RowFilter = string.Format(/*"orderType in ({0},{1}) and "*/"batchPickState in ({2},{3})",  | |||
|  |                                         (int)enumOutStoreType.拣货出库, (int)enumOutStoreType.播种拣货出库,  | |||
|  |                                         (int)enumOutStockPickStatus.已定位, (int)enumOutStockPickStatus.正在分拣); | |||
|  |                 int cnt = dv.Count; | |||
|  |              | |||
|  |                 closeChannelLight(); | |||
|  |                 if (dv1.Count + cnt > 0) | |||
|  |                 { | |||
|  |                     updateLightColor(dv1.Count > 0); | |||
|  |                     openChannelLight(); | |||
|  |                 } | |||
|  | 
 | |||
|  |                 //if (cnt > 0) | |||
|  |                 //{ //light the out light | |||
|  |                 //    closeChannelLight(); | |||
|  |                 //    updateLightColor(false); | |||
|  |                     | |||
|  |                 //    openChannelLight(); | |||
|  |                 //} | |||
|  |                 //else | |||
|  |                 //{ | |||
|  |                 //     closeChannelLight(); | |||
|  |                 //} | |||
|  |                 //if (dv1.Count > 0) | |||
|  |                 //{ //light the rep light | |||
|  |                 //    updateLightColor(true); | |||
|  |                 //    openChannelLight(); | |||
|  |                     | |||
|  |                 //} | |||
|  | 
 | |||
|  |                 this.gridControl4.DataSource = dv1; | |||
|  |                 initialDataGridColumns(gridView4); | |||
|  | 
 | |||
|  |                | |||
|  |                 //dt = lgt.Query(query, start, end); //string.IsNullOrEmpty(query) ? lgt.GetGoodType.getAllData(start, end) : lgt.g; | |||
|  | 
 | |||
|  |                 dtPickOrders.PrimaryKey = new DataColumn[] { dtPickOrders.Columns["ID"] }; | |||
|  |   | |||
|  | 
 | |||
|  |                  | |||
|  |                 this.gridControl1.DataSource = dv; | |||
|  |                 initialDataGridColumns(gridView1); | |||
|  |                 //update selected row index to the last updated one. | |||
|  |                 | |||
|  |                 if (selectedRequest !=null) | |||
|  |                 { | |||
|  |                     selectedRowIndex = -1; | |||
|  |                     DataRow dr = dtPickOrders.Rows.Find(selectedRequest.ID); | |||
|  |                     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(); | |||
|  |                 } | |||
|  |                 setCurrentRequestDetail(); | |||
|  |                 closeWaitForm(); | |||
|  |                 return cnt; | |||
|  |             } | |||
|  |             catch (Exception e) | |||
|  |             { | |||
|  |                 showErrorMsg(e,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; | |||
|  |         } | |||
|  |           | |||
|  |         | |||
|  | 
 | |||
|  |         | |||
|  |         | |||
|  |         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); | |||
|  | 
 | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         int selectedRepIndex; | |||
|  |         string selectedRepOrderNo = ""; | |||
|  |         private void gridView4_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) | |||
|  |         { | |||
|  |             if (gridView4.FocusedRowHandle < 0 || gridView4.FocusedRowHandle == selectedRepIndex) | |||
|  |             { | |||
|  |                 if (gridView4.IsGroupRow(e.RowHandle)) //set first row of group selected | |||
|  |                 { | |||
|  |                     selectedRepIndex = gridView4.GetChildRowHandle(e.RowHandle, 0); | |||
|  |                     setCurrentRepRequestDetail(); | |||
|  |                 } | |||
|  | 
 | |||
|  |                 return; | |||
|  | 
 | |||
|  |             } | |||
|  |             selectedRepIndex = gridView4.FocusedRowHandle; | |||
|  |             // showErrorMsg("selection:"+ selectedRowIndex); | |||
|  |             setCurrentRepRequestDetail(); | |||
|  |               | |||
|  |         } | |||
|  | 
 | |||
|  |          | |||
|  | 
 | |||
|  |         private void gridView4_DataSourceChanged(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (selectedRepIndex >= 0 && dtRepOrders.Rows.Count > selectedRepIndex) | |||
|  |             { | |||
|  |                 gridView4.FocusedRowHandle = selectedRepIndex; | |||
|  |                 gridView4.MakeRowVisible(selectedRepIndex); | |||
|  | 
 | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         private bool getCurrentRepObject() | |||
|  |         { | |||
|  |             if (selectedRepIndex < 0 || selectedRepIndex >= dtRepOrders.Rows.Count) | |||
|  |             { | |||
|  |                 return false; | |||
|  |             } | |||
|  | 
 | |||
|  |             //  DataRow currentRow = dt.Rows[selectedRowIndex]; | |||
|  |             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView4)[selectedRepIndex]); | |||
|  |             selectedRepOrderNo = dr["orderNo"].ToString(); | |||
|  |             return true; | |||
|  | 
 | |||
|  |         } | |||
|  |         private void setCurrentRepRequestDetail() | |||
|  |         { | |||
|  | 
 | |||
|  |             if (!getCurrentRepObject() || selectedRepOrderNo == null) | |||
|  |             { | |||
|  |                 return; | |||
|  |             } | |||
|  |             /// gridView1.FocusedRowHandle = selectedRowIndex;// | |||
|  |             //  gridView1.SelectRow(selectedRowIndex); | |||
|  |             showWaitForm(); | |||
|  | 
 | |||
|  |             try | |||
|  |             { | |||
|  | 
 | |||
|  |                 DataTable dt1 = pickClient.getBatchOutPickOrderDetails(selectedRepOrderNo); | |||
|  |                 closeClient();; | |||
|  |                 this.gridControl2.DataSource = dt1; | |||
|  |                 initialGridView2Columns(gridView2); | |||
|  | 
 | |||
|  |                 DataTable dt2 =  pickClient.getBatchOutPickOrderPickDetails(selectedRepOrderNo); | |||
|  |                 closeClient();; | |||
|  |                 this.gridControl3.DataSource = dt2; | |||
|  |                 initialGridView2Columns(gridView3); | |||
|  |                 gridView4.Focus();   | |||
|  |                 btnOut.Enabled = false;             | |||
|  |             } | |||
|  |             catch (Exception e) | |||
|  |             { | |||
|  |                 showErrorMsg(e.Message); | |||
|  |             } | |||
|  |             closeWaitForm(); | |||
|  |         } | |||
|  | 
 | |||
|  |         private void btnDelete_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |              | |||
|  | 
 | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         protected void query() | |||
|  |         { | |||
|  |             loadData(); | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         private void queryGoods() | |||
|  |         { | |||
|  | 
 | |||
|  |             showWaitForm(); | |||
|  |             try | |||
|  |             { | |||
|  |                 query();// loadData();   | |||
|  |             } | |||
|  |             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; | |||
|  |             queryGoods(); | |||
|  |         } | |||
|  | 
 | |||
|  |         | |||
|  | 
 | |||
|  |         private void updateObjects(List<WmsGoods> goods) | |||
|  |         {  | |||
|  |             showWaitForm(); | |||
|  |             //WaitFormService.Show(this);  | |||
|  |             try | |||
|  |             { | |||
|  |              //   lgt.update(goods); | |||
|  | 
 | |||
|  |                 //get updated data  | |||
|  |                 query(); | |||
|  | 
 | |||
|  |             } | |||
|  |             catch (Exception e) | |||
|  |             { | |||
|  |                 showErrorMsg(e,e.Message); | |||
|  |             } | |||
|  |             finally | |||
|  |             { | |||
|  |                 // WaitFormService.Close(); | |||
|  |                 closeWaitForm(); | |||
|  |               | |||
|  |             } | |||
|  |               | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         private bool getCurrentObject() | |||
|  |         { | |||
|  |             if (selectedRowIndex <0 || selectedRowIndex >= dtPickOrders.Rows.Count) | |||
|  |             { | |||
|  |                 return false; | |||
|  |             } | |||
|  |             | |||
|  |           //  DataRow currentRow = dt.Rows[selectedRowIndex]; | |||
|  |             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]); | |||
|  |             selectedRequest = new WmsOutPickRequest(dr.Row); | |||
|  |             lbCust.Text = ""; | |||
|  |             lbOrderNo.Text =""; | |||
|  |             return true; | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         | |||
|  | 
 | |||
|  | 
 | |||
|  |         private void btnQuery_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             queryGoods(); | |||
|  |         } | |||
|  | 
 | |||
|  |         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 = true;//按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.gridView2.IndicatorWidth = 40; | |||
|  |             this.gridView2.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator); | |||
|  |             //this.gridView3.IndicatorWidth = 40; | |||
|  |             //this.gridView3.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator); | |||
|  |             this.gridView3.IndicatorWidth = 40; | |||
|  |             this.gridView3.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator); | |||
|  |           | |||
|  |              | |||
|  |             gridView1.CustomColumnDisplayText += gridView2_CustomColumnDisplayText; | |||
|  |             gridView2.CustomColumnDisplayText += gridView2_CustomColumnDisplayText; | |||
|  |             gridView3.CustomColumnDisplayText += gridView2_CustomColumnDisplayText; | |||
|  |             gridView4.CustomColumnDisplayText += gridView2_CustomColumnDisplayText; | |||
|  |              | |||
|  |             gridView2.RowCellStyle += gridView_RowCellStyle; | |||
|  |             gridView1.RowCellStyle += gridView_RowCellStyle; | |||
|  |             gridView3.RowCellStyle += gridView_RowCellStyle; | |||
|  | 
 | |||
|  |             gridView4.OptionsSelection.MultiSelect = false;//按shift / control 多选 | |||
|  |             this.gridView4.OptionsBehavior.AutoPopulateColumns = false; | |||
|  |            // this.gridView4.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus; | |||
|  |             this.gridView4.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus; | |||
|  |             this.gridView4.OptionsBehavior.Editable = false; | |||
|  |             //    this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false; | |||
|  | 
 | |||
|  |             //this.gridView4.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView4_FocusedRowObjectChanged); | |||
|  |             //this.gridView4.DataSourceChanged += new System.EventHandler(this.gridView4_DataSourceChanged); | |||
|  | 
 | |||
|  |             //show line number | |||
|  |             this.gridView4.IndicatorWidth = 40; | |||
|  |             this.gridView4.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator); | |||
|  | 
 | |||
|  |             //gridView1.LostFocus += new EventHandler(gridview_LostFocus); | |||
|  |             //gridView4.LostFocus += new EventHandler(gridview_LostFocus); | |||
|  |             //gridView1.GotFocus += new EventHandler(gridview_GotFocus); | |||
|  |             //gridView4.GotFocus += new EventHandler(gridview_GotFocus); | |||
|  |           | |||
|  |           | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  |         } | |||
|  |     | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  |        private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) | |||
|  |         { | |||
|  | 
 | |||
|  | 
 | |||
|  |             | |||
|  | 
 | |||
|  |                 if (e.Column.FieldName == WmsOutPickDetail.fields.batchPickState.ToString()) | |||
|  |                 { | |||
|  |                     if (!pickStatus.ContainsValue(e.DisplayText)) | |||
|  |                     { | |||
|  | 
 | |||
|  |                         int display = -100; | |||
|  |                         string disTxt = e.DisplayText; | |||
|  | 
 | |||
|  |                         try | |||
|  |                         { | |||
|  |                             display = Convert.ToInt16(e.DisplayText); | |||
|  | 
 | |||
|  |                             e.DisplayText = pickStatus[display]; | |||
|  | 
 | |||
|  |                         } | |||
|  |                         catch | |||
|  |                         { | |||
|  |                             return; | |||
|  |                         } | |||
|  |                     } | |||
|  |                    // e.DisplayText = pickStatus.ContainsKey(display) ? pickStatus[display] : display+""; | |||
|  | 
 | |||
|  |                 }else if(e.Column.FieldName == WmsOutPickDetail.fields.state.ToString()){ | |||
|  |                     if (!pickOrNot.ContainsValue(e.DisplayText)) | |||
|  |                     { | |||
|  | 
 | |||
|  |                         int display = -100; | |||
|  |                         string disTxt = e.DisplayText; | |||
|  | 
 | |||
|  |                         try | |||
|  |                         { | |||
|  |                             display = Convert.ToInt16(e.DisplayText); | |||
|  | 
 | |||
|  |                             e.DisplayText = pickOrNot[display]; | |||
|  | 
 | |||
|  |                         } | |||
|  |                         catch | |||
|  |                         { | |||
|  |                             return; | |||
|  |                         } | |||
|  |                     } | |||
|  |                    // e.DisplayText = pickOrNot.ContainsKey(display) ? pickOrNot[display] : display+"";   | |||
|  |                 } | |||
|  |              | |||
|  |                 //else | |||
|  |                 //if (e.Column.FieldName == WmsOutPickDetail.fields.state.ToString()) | |||
|  |                 //{  | |||
|  |                 //    e.DisplayText = pickRequestStatus.ContainsKey(display) ? pickRequestStatus[display] : display;  | |||
|  |                 //} | |||
|  | 
 | |||
|  |                /* if (e.Column.FieldName == "batchPickState") | |||
|  |                 { | |||
|  |                    | |||
|  |                     switch (e.DisplayText) | |||
|  |                     { | |||
|  |                         case "1": | |||
|  |                             e.DisplayText = "已分配货位"; | |||
|  |                             break; | |||
|  |                         case "0": | |||
|  |                             e.DisplayText = "未分配货位"; | |||
|  | 
 | |||
|  |                             break; | |||
|  |                         case "2": | |||
|  |                             e.DisplayText = "出现错误"; | |||
|  |                             break; | |||
|  |                         case "": | |||
|  |                             e.DisplayText = "未分配货位"; | |||
|  |                             break; | |||
|  |                         //default:  | |||
|  |                         //    e.DisplayText = "未分配货位"; | |||
|  |                     } | |||
|  |                 }*/ | |||
|  |               | |||
|  |         } | |||
|  |        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 = ""; | |||
|  |            bool isGray = false; | |||
|  |            bool isAlert = false; | |||
|  |            | |||
|  |            if (currentView == gridView3) | |||
|  |             { | |||
|  |                state = currentView.GetDataRow(e.RowHandle)["state"].ToString().Trim(); | |||
|  | 
 | |||
|  | 
 | |||
|  |                isGray = Convert.ToInt16(state) == (int)enumPickState.已拣; | |||
|  | 
 | |||
|  |               // isAlert = Convert.ToInt16(state) == (int)enumLabelPickState.notPicked; | |||
|  |              } | |||
|  |            else | |||
|  |             { | |||
|  |                 state = currentView.GetDataRow(e.RowHandle)["batchPickState"].ToString().Trim(); | |||
|  |                isGray = Convert.ToInt16(state) == (int)enumOutStockPickStatus.正在分拣; | |||
|  |                 isAlert = Convert.ToInt16(state) == (int)enumOutStockPickStatus.复核异常; | |||
|  |             } | |||
|  |            /* | |||
|  |            state = currentView.GetDataRow(e.RowHandle)["batchPickState"].ToString().Trim(); | |||
|  |            isGray = Convert.ToInt16(state) == (int)enumOutStockPickStatus.正在分拣; | |||
|  |            isAlert = Convert.ToInt16(state) == (int)enumOutStockPickStatus.复核异常; | |||
|  |            */ | |||
|  |            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 (isGray) | |||
|  |            { | |||
|  |                rowStyle = isFocused ? passedFocus : passed; | |||
|  |            } | |||
|  |            else if (isAlert) | |||
|  |            { | |||
|  |                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() || selectedRequest == null) | |||
|  |             { | |||
|  |                 return; | |||
|  |             } | |||
|  |             /// gridView1.FocusedRowHandle = selectedRowIndex;// | |||
|  |             //  gridView1.SelectRow(selectedRowIndex); | |||
|  |             showWaitForm(); | |||
|  | 
 | |||
|  |             lbCust.Text = selectedRequest.customerName; | |||
|  |             lbOrderNo.Text = selectedRequest.pickOrderNo; | |||
|  |             try | |||
|  |             { | |||
|  | 
 | |||
|  |                 DataTable dt1 = pickClient.getBatchOutPickOrderDetails(selectedRequest.pickOrderNo); | |||
|  |                 closeClient();; | |||
|  |                 this.gridControl2.DataSource = dt1; | |||
|  |                 initialGridView2Columns(gridView2); | |||
|  | 
 | |||
|  |                 DataTable dt2 = pickClient.getBatchOutPickOrderPickDetails(selectedRequest.pickOrderNo); | |||
|  |                 closeClient();; | |||
|  |                 this.gridControl3.DataSource = dt2; | |||
|  |                 initialGridView2Columns(gridView3); | |||
|  |                // gridView1.Focus(); | |||
|  |                // this.selectedInvalidIndex = -1; | |||
|  |                 gridView4.FocusedRowHandle = -1; | |||
|  | 
 | |||
|  |                 btnOut.Enabled = true;  | |||
|  |             } | |||
|  |             catch (Exception e) | |||
|  |             { | |||
|  |                 showErrorMsg(e.Message); | |||
|  |             } | |||
|  |             closeWaitForm(); | |||
|  |         } | |||
|  | 
 | |||
|  |         private void btnOut_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |            | |||
|  |             showWaitForm(); | |||
|  |             try | |||
|  |             { | |||
|  | 
 | |||
|  |                 if (selectedRequest!=null )//&& selectedRequest.batchPickState == (int)enumOutStockPickStatus.待处理) | |||
|  |                 { | |||
|  |                     pickClient.startBatchPick(selectedRequest.pickOrderNo); //startPickBatchPickOrder(selectedRequest.pickOrderNo); | |||
|  |                     closeClient();; | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     showErrorMsg(string.Format("出库异常,当前出库单状态是{0}", Enum.GetName(typeof(enumOutStockPickStatus), selectedRequest.batchPickState) )); | |||
|  |                 } | |||
|  | 
 | |||
|  |               | |||
|  |                reqportPrint.printStockOutCode(pickClient.getPickOrderTmsInfo(selectedRequest.pickOrderNo),false); | |||
|  |                   | |||
|  |                 reqportPrint.printStockOutA4(pickClient.getBatchOutPickOrderPickDetails(selectedRequest.pickOrderNo)); | |||
|  |                 closeClient();; | |||
|  | 
 | |||
|  |                 query(); | |||
|  |             } | |||
|  |             catch (Exception er) | |||
|  |             { | |||
|  |                 setCurrentRequestDetail(); | |||
|  |                 showErrorMsg(er,er.Message); | |||
|  |                 closeClient();; | |||
|  |             } | |||
|  | 
 | |||
|  |               | |||
|  |            | |||
|  | 
 | |||
|  |             closeWaitForm(); | |||
|  |         } | |||
|  | 
 | |||
|  |         private void btnPrint_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             try | |||
|  |             { | |||
|  |                 reqportPrint.printStockOutCode(pickClient.getPickOrderTmsInfo(selectedRequest.pickOrderNo),false); | |||
|  |                 closeClient();; | |||
|  |             } | |||
|  |             catch (Exception er) | |||
|  |             { | |||
|  |                 showErrorMsg(er, er.Message); | |||
|  |                 closeClient();; | |||
|  |             } | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         private void btnPrintReport_Click(object sender, EventArgs e) | |||
|  |         {  | |||
|  |             try | |||
|  |             { | |||
|  |                 reqportPrint.printStockOutA4(pickClient.getBatchOutPickOrderPickDetails(selectedRequest.pickOrderNo)); | |||
|  |                 closeClient();; | |||
|  |             } | |||
|  |             catch (Exception er) | |||
|  |             { | |||
|  |                 showErrorMsg(er, er.Message); | |||
|  |                 closeClient();; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         private void btnOutStockAll_Click(object sender, EventArgs e) | |||
|  |         {  | |||
|  |             showWaitForm(); | |||
|  |             foreach (DataRow dr in dtPickOrders.Rows) | |||
|  |             { | |||
|  |                 WmsInRequest wi = new WmsInRequest(dr); | |||
|  | 
 | |||
|  |                 try | |||
|  |                 { | |||
|  |                      //lgt.requestInStock(wi); | |||
|  |                   //  pickClient.requestInStock(wi.orderNo); | |||
|  | 
 | |||
|  |                 } | |||
|  |                 catch (Exception er) | |||
|  |                 { | |||
|  | 
 | |||
|  |                     showErrorMsg(er.Message); | |||
|  |                 }  | |||
|  |                  | |||
|  |             } | |||
|  | 
 | |||
|  |             query(); | |||
|  | 
 | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         private void GoodsInForm_FormClosing(object sender, FormClosingEventArgs e) | |||
|  |         { | |||
|  |             timer.Enabled = false; | |||
|  |            // closeClient();; | |||
|  |             closeChannelLight(); | |||
|  |             lightControl.exit_wms_sys(); | |||
|  |              | |||
|  |         } | |||
|  | 
 | |||
|  |         protected new void gridview_GotFocus(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (sender == gridView1) | |||
|  |             { | |||
|  |                 //grid4Valid.ForeColor = Color.Blue; | |||
|  |                 // gridView4Valid.OptionsSelection.EnableAppearanceHideSelection = true; | |||
|  | 
 | |||
|  |                 this.setCurrentRequestDetail(); | |||
|  |                 switchGridViewRowSelection(gridView1, true); | |||
|  |                 switchGridViewRowSelection(gridView4, false); | |||
|  |             } | |||
|  |             else if (sender == gridView4) | |||
|  |             { | |||
|  |                 this.setCurrentRepRequestDetail(); | |||
|  |                 switchGridViewRowSelection(gridView4, true); | |||
|  |                 switchGridViewRowSelection(gridView1, false); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 switchGridViewRowSelection((GridView)sender, true); | |||
|  |             } | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         private void btnForceClose_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             try | |||
|  |             { | |||
|  |                 if (pickClient.completeBatchOut(this.selectedRequest.pickOrderNo)) | |||
|  |                 { | |||
|  |                     MessageBox.Show("出库成功"); | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     showErrorMsg("出库失败"); | |||
|  |                 } | |||
|  |                 closeClient();; | |||
|  |             } | |||
|  |             catch (Exception er) | |||
|  |             { | |||
|  |                 showErrorMsg(er.Message); | |||
|  |             } | |||
|  | 
 | |||
|  |              | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  |         System.Timers.Timer timer = new System.Timers.Timer();//实例化Timer类 | |||
|  | 
 | |||
|  |         private void timeCnt() | |||
|  |         { | |||
|  |             int cnt = (int)spinOrder.Value * 1000 + 1000; | |||
|  |             timer.Enabled = true; | |||
|  |             timer.Stop(); | |||
|  |             timer.Interval = cnt; | |||
|  |             timer.Start();  | |||
|  |         } | |||
|  |         private void initialTimer() | |||
|  |         { | |||
|  |             int intTime = (int)spinOrder.Value * 1000 + 1000; | |||
|  |             timer.Interval = intTime;//设置间隔时间,为毫秒; | |||
|  |          //   timer.Elapsed += new System.Timers.ElapsedEventHandler(showWaveSpan);//到达时间的时候执行事件; | |||
|  |             timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true); | |||
|  |             timer.Enabled = false;//是否执行System.Timers.Timer.Elapsed事件; | |||
|  |            // timer.Start(); | |||
|  |         } | |||
|  |         delegate void loadNewCurrentWave(); | |||
|  |         private void showWaveSpan(object source, System.Timers.ElapsedEventArgs e) | |||
|  |         { | |||
|  |             //   debug(string.Format(" timer loop begin .... " )); | |||
|  |            // TimeSpan ts = DateTime.Now - WmsConstants.WAVE_LAST_TIME;// WmsConstants.WAVE_LAST_TIME;  | |||
|  |             try | |||
|  |             { | |||
|  |                 if (InvokeRequired) | |||
|  |                 { | |||
|  |                     this.Invoke(new loadNewCurrentWave(delegate() | |||
|  |                     {   | |||
|  |                        loadData(); | |||
|  |                     })); | |||
|  | 
 | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     loadData(); | |||
|  |                 } | |||
|  |             } | |||
|  |             catch (Exception er) | |||
|  |             { | |||
|  |                 LogHelper.WriteLog(typeof(GoodsOutForm), er); | |||
|  |             } | |||
|  | 
 | |||
|  |             //   debug(string.Format(" timer loop end .... ")); | |||
|  | 
 | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         private void swAutoOrder_Toggled(object sender, EventArgs e) | |||
|  |         { | |||
|  |             autoOrder = swAutoOrder.IsOn; | |||
|  |             btnPickOrders.Enabled = !autoOrder; | |||
|  |             if (autoOrder) | |||
|  |             { | |||
|  |                 loadData(); | |||
|  |                   | |||
|  |                 timeCnt(); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         private void btnPickOrders_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             loadData(); | |||
|  |         } | |||
|  | 
 | |||
|  |         private void spinOrder_EditValueChanged(object sender, EventArgs e) | |||
|  |         { | |||
|  |             timer.Interval = (int)spinOrder.Value * 1000 + 1000;  | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  | 
 | |||
|  |         dnwms lightControl = new dnwms(); | |||
|  |         private void initialChannelLight() | |||
|  |         {   | |||
|  |                 lightControl.check_state = true; | |||
|  |                 lightControl.on_config_channel += new dnwms.config_channel(aa_on_config_channel); | |||
|  |                 lightControl.on_close_channel += new dnwms.close_channel(aa_on_close_channel); | |||
|  |                 lightControl.on_open_channel += new dnwms.open_channel(openChannelLightResult); | |||
|  |                 lightControl.on_dis_event += new dnwms.receive_dis_data(aa_on_receidata_channel); | |||
|  |               //  getLightId(); | |||
|  |         } | |||
|  | 
 | |||
|  |         private void openChannelLight() | |||
|  |         { | |||
|  |             Model.open_channel_led id; | |||
|  |             id.channel_id = lightId; | |||
|  |             //id.config_word = led_rgb; | |||
|  |             id.state = 1; | |||
|  |             lightControl.write_open_channel_led(id);//write_config_channel_led | |||
|  |         } | |||
|  | 
 | |||
|  |         private void closeChannelLight() | |||
|  |         { | |||
|  |              Model.close_channel_led id; | |||
|  |             id.channel_id =lightId; | |||
|  |             //id.config_word = led_rgb; | |||
|  |              | |||
|  |             id.state = 1; | |||
|  |             lightControl.write_close_channel_led(id);//write_config_channel_led | |||
|  |         } | |||
|  | 
 | |||
|  |         private void openChannelLightResult( Model.open_channel_led data) | |||
|  |         { | |||
|  |        //     MessageBox.Show("打开通道灯 成功"); | |||
|  |         } | |||
|  |         void aa_on_close_channel(Model.close_channel_led data) | |||
|  |         { | |||
|  |           //  MessageBox.Show("关闭通道灯 成功"); | |||
|  |             //throw new NotImplementedException(); | |||
|  |         } | |||
|  |         void aa_on_config_channel(Model.config_channel_led data) | |||
|  |         { | |||
|  |           //  MessageBox.Show("配置 id = " + data.channel_id.ToString() + "配置字 = " + data.config_word.ToString() + " 成功 "); | |||
|  |             //throw new NotImplementedException(); | |||
|  |         } | |||
|  |         void aa_on_receidata_channel(Model.uart_dis_data[] dis_data) | |||
|  |         { | |||
|  |             //  MessageBox.Show("配置 id = " + data.channel_id.ToString() + "配置字 = " + data.config_word.ToString() + " 成功 "); | |||
|  |             //throw new NotImplementedException(); | |||
|  |         } | |||
|  | 
 | |||
|  |         List<int> lights = new List<int>(); | |||
|  |         void searchLight() | |||
|  |         { | |||
|  |             Model.modify_id id; | |||
|  |           | |||
|  |             System.Threading.Thread.Sleep(50); | |||
|  |             for (int i = 5000; i <= 5100; i++) | |||
|  |             { | |||
|  |                 id.order = 0; | |||
|  |                 id.new_ele_id = 0; | |||
|  |                 id.old_ele_id = i; | |||
|  |                 id.state = 1; | |||
|  |                bool ret = lightControl.search_light_id(id); | |||
|  |                 if (ret) | |||
|  |                 { | |||
|  |                     //textBox6.Text = textBox6.Text + "搜索到通道灯:" + i.ToString() + "\r\n"; | |||
|  |                     //this.textBox6.Focus();//获取焦点 | |||
|  |                     //this.textBox6.Select(this.textBox6.TextLength, 0);//光标定位到文本最后 | |||
|  |                     //this.textBox6.ScrollToCaret();//滚动到光标处 | |||
|  |                     lights.Add(i); | |||
|  |                     break; | |||
|  |                    // System.Threading.Thread.Sleep(50); | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  |         void getLightId() | |||
|  |         { | |||
|  |             for (int i = 0; i < 10; i++)//init com0-10 | |||
|  |             { | |||
|  |                 comId = Convert.ToByte(i); | |||
|  | 
 | |||
|  |                 if (lightControl.init_wms_sys(comId)) | |||
|  |                 { | |||
|  |                     lights.Clear(); | |||
|  |                     searchLight(); | |||
|  |                     if (lights.Count > 0) | |||
|  |                     { | |||
|  |                         lightId = lights[0]; | |||
|  |                         break; | |||
|  |                     } | |||
|  |                 } | |||
|  |                 System.Threading.Thread.Sleep(10); | |||
|  |             } | |||
|  |             lbLightsInfo.Text = ""; | |||
|  |             if (lightId == 0) | |||
|  |             { | |||
|  |                 lbLightsInfo.Text = "没找到出库指示灯,请确认出库灯正确连接并工作正常"; | |||
|  |                // MessageBox.Show("没找到出库指示灯,请确认出库灯正确连接并工作正常"); | |||
|  | 
 | |||
|  | 
 | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         private void updateLightColor(bool isAlert) | |||
|  |         { | |||
|  |              Model.config_channel_led id; | |||
|  |          //   byte led_rgb = 0; | |||
|  | 
 | |||
|  |             byte blue = 2; | |||
|  |             byte red = 0; | |||
|  |               | |||
|  |             id.channel_id = Convert.ToInt16(5000); | |||
|  |             id.config_word = isAlert ? red : blue;// led_rgb; | |||
|  |             id.state = 1; | |||
|  |             this.lightControl .write_config_channel_led(id);//write_config_channel_led | |||
|  |         } | |||
|  |           | |||
|  |        | |||
|  |     } | |||
|  | } |