2926 lines
		
	
	
		
			108 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			2926 lines
		
	
	
		
			108 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.ServiceReferenceStockOutPickRequest;
 | ||
| using System.ServiceModel;
 | ||
| using DeiNiu.wms.win.utils.print;
 | ||
| using Deiniu.win.elelab;
 | ||
| using DevExpress.XtraLayout;
 | ||
| using DeiNiu.wms.win.ServiceReferenceLot;
 | ||
| 
 | ||
| namespace DeiNiu.wms.win
 | ||
| {
 | ||
|     public partial class GoodsOutSeedsForm : BasicRibbonForm
 | ||
|     {
 | ||
| 
 | ||
|  
 | ||
|       //  lWmsStock ls = new lWmsStock();
 | ||
|         //lWmsOutPickRequest lgt = new lWmsOutPickRequest();
 | ||
|         //lWmsOutRequest lgOutReq = new lWmsOutRequest();
 | ||
|        // lWmsOutPickRequest outPickRequest = new lWmsOutPickRequest();
 | ||
|         //private string lastQuery = "";
 | ||
|         DataSet dsPickOrders;
 | ||
|         private DataTable dtSeedsOrders; //
 | ||
|         private DataTable dtSeedsGoods; //seedsOrders' goods list 
 | ||
|         //private DataTable dtPickOrders4Validation; //商品分播对象分拣单 
 | ||
|         private DataTable dtPickOrders4Validation; //待播商品对应的分拣单
 | ||
|         private DataTable dtSeedsLight; //播种亮灯数据
 | ||
|       //  private DataTable dtPickOrdersValidated;
 | ||
|         private DataTable dtPickDetails;
 | ||
|       //  private DataTable dtExceptionSolutions;
 | ||
|         private int selectedSeedsOrderRowIndex = -1;
 | ||
|         private WmsOutPickDetail_tmp currentGoodsDetail;
 | ||
|         string lastScanBarcode = "";
 | ||
|        
 | ||
|       //  Thread threadPreProcess;
 | ||
|         bool autoOrder;
 | ||
|         string currentSeedsOrder = "";
 | ||
|         string currentWave = "";
 | ||
|         string currentGoodsId = "";
 | ||
|         string currentGoodsBatch = "";
 | ||
|         byte deskPort = 0;
 | ||
| 
 | ||
|         bool showId = true;
 | ||
|         private bool isDoubleChk;
 | ||
|         private int currentSkuId;
 | ||
| 
 | ||
|         public GoodsOutSeedsForm()
 | ||
|         {   
 | ||
|            
 | ||
|             InitializeComponent();
 | ||
|             initialControls(); 
 | ||
|             initComs();
 | ||
|             initialBackGroundTasks();
 | ||
|             initialTimer();
 | ||
|         
 | ||
|         }
 | ||
|         #region initialControls
 | ||
|         private void initialControls()
 | ||
|         {
 | ||
|             initialComboBoxes();
 | ||
|            // initialPagerControls();
 | ||
|             initialDataGrid();
 | ||
|             initialQueryInput(); 
 | ||
|             setValidationRule();
 | ||
|             textEditBarcode.GotFocus += new EventHandler(textEditBarcode_GotFocus);
 | ||
|             textEditBarcode.MouseUp += new MouseEventHandler(textEditBarcode_MouseUp);
 | ||
| 
 | ||
|             txtBoxId.GotFocus += new EventHandler(textBoxId_GotFocus);
 | ||
|             txtBoxId.MouseUp += new MouseEventHandler(textBoxId_MouseUp);
 | ||
|             light.printLabPack += printLabPack;
 | ||
|             light.seedsGoodItemValided = seedsGoodItemValided;
 | ||
|             lllightbutton.Visibility =  DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
 | ||
|         }
 | ||
|         int tryCnt = 0;
 | ||
|         private void printLabPack(int labId)
 | ||
|         {
 | ||
|             currentLabId = labId;
 | ||
|             if (labId == 0)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             if (dsPickOrders == null)
 | ||
|             {
 | ||
|                 // dsPickOrders = pickClient.getPickRequest4BulkValidate(desk);
 | ||
|                
 | ||
|                 /*
 | ||
|                 enumOutStockRequestStatus status = getQueryStatus();
 | ||
|                 string seedsNo = getQuerySeedsNo();
 | ||
|                 dsPickOrders = pickClient.getPickRequest4SeedsOperation(desk,(int)status, seedsNo); 
 | ||
|                 closeClient();
 | ||
|                 */
 | ||
| 
 | ||
|                 getSeedsOrders4Validation();
 | ||
|             }
 | ||
|             try
 | ||
|             {
 | ||
|                 showWaitForm("正在打印");
 | ||
|                 DataView dv = dsPickOrders.Tables[2].DefaultView; // distinct pickOrderNo
 | ||
|                 dv.RowFilter = "dpsOrder='" + currentWave + "' and seedsLabelId=" + labId;
 | ||
|                
 | ||
|                 
 | ||
|                 DataTable dt = dv.ToTable(true, "pickOrderNo", "seedsLabelId", "customerName", "desk");//, "customerName", "seedsLabelId");
 | ||
|                 dt.TableName = "tableSeedsPickOrders";
 | ||
| 
 | ||
|                 if (WmsConstants.VALIDATION_SEEDS_PACK_DESK_SPLIT)
 | ||
|                 {
 | ||
|                     reqportPrint.printSeedsPickOrderCode(dt);
 | ||
|                 }
 | ||
| 
 | ||
|                 if (InvokeRequired)
 | ||
|                 {
 | ||
|                     try
 | ||
|                     {
 | ||
|                         this.Invoke(new loadNewPickOrders(delegate()
 | ||
|                         {
 | ||
|                             bindSeedsGoodsPickOrderTables();  
 | ||
| 
 | ||
|                         }));
 | ||
|                     }
 | ||
|                     catch (Exception er)
 | ||
|                     {
 | ||
|                         LogHelper.WriteLog(this.GetType(), er);
 | ||
|                     }
 | ||
| 
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     bindSeedsGoodsPickOrderTables();
 | ||
|                 }
 | ||
|              
 | ||
| 
 | ||
|                 closeWaitForm();
 | ||
|                 if (!WmsConstants.VALIDATION_SEEDS_PACK_DESK_SPLIT)  //直接打包装条码
 | ||
|                 {
 | ||
|                     if (dv.Count >= 1)
 | ||
|                     {
 | ||
|                         tmpOrder = dv[0]["pickOrderNo"].ToString();
 | ||
| 
 | ||
|                         Thread completeThread = new Thread(completeValidation);
 | ||
|                         completeThread.IsBackground = true;
 | ||
|                         completeThread.Start();
 | ||
|                     }
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
|             catch (Exception er)
 | ||
|             {
 | ||
|                 tryCnt++;
 | ||
|                 if (tryCnt < 2)
 | ||
|                 {
 | ||
|                     printLabPack(labId);
 | ||
|                 }
 | ||
|                 showErrorMsg(er);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private enumOutStockRequestStatus getQueryStatus()
 | ||
|         {
 | ||
|            return enumOutStockRequestStatus.复核完成;
 | ||
|         }
 | ||
| 
 | ||
|         private string getQuerySeedsNo()
 | ||
|         {
 | ||
|             return "";
 | ||
|         }
 | ||
| 
 | ||
|         private void seedsGoodItemValided()
 | ||
|         {
 | ||
|             string condition = string.Format("seedsPickNo='{0}' and skuId='{1}'",
 | ||
|                 currentSeedsOrder, currentGoodsDetail.skuId);
 | ||
|           DataRow[] drs=  dtSeedsGoods.Select(condition);
 | ||
|           if (drs.Length > 0)
 | ||
|           {
 | ||
|               drs[0]["bulkPickState"] = (int)enumOutStockPickStatus.复核完成;
 | ||
|           }
 | ||
|             dtSeedsGoods.DefaultView.RowFilter = "";
 | ||
|              
 | ||
|             
 | ||
|             
 | ||
|             
 | ||
|             if (InvokeRequired)
 | ||
|             {
 | ||
|                  this.Invoke(new loadNewPickOrders(delegate ()
 | ||
|                 { 
 | ||
|                     int i = gridViewSeedsGoods.FocusedRowHandle;
 | ||
|                     this.gridSeedsGoods.DataSource = dtSeedsGoods.DefaultView;
 | ||
|                     gridViewSeedsGoods.FocusedRowHandle = i;
 | ||
|                 }));
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 int i = gridViewSeedsGoods.FocusedRowHandle;              
 | ||
|                 this.gridSeedsGoods.DataSource = dtSeedsGoods.DefaultView;
 | ||
|                 gridViewSeedsGoods.FocusedRowHandle = i;
 | ||
|                 
 | ||
|             } 
 | ||
| 
 | ||
|            
 | ||
|          //this.bindSeedsGoodsPickOrderTables(); 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private void initialBackGroundTasks()
 | ||
|         { 
 | ||
|             swAutoOrder.IsOn = WmsConstants.AUTO_PICK_BULK_VALIDATION_ORDER;
 | ||
|             autoOrder = swAutoOrder.IsOn;
 | ||
|            // lgOutReq.UpdateUIDelegate += updateValidationList;
 | ||
|             
 | ||
|             if (autoOrder)
 | ||
|             {
 | ||
|                 this.getValidationOrders();
 | ||
|             } 
 | ||
| 
 | ||
|         }
 | ||
|         /*
 | ||
|         string oldDesk = "";
 | ||
|         private int desk
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (combColors.SelectedIndex == -1)
 | ||
|                 {
 | ||
|                     showErrorMsg(null, "请选择控制台");
 | ||
| 
 | ||
|                     combColors.Focus();
 | ||
|                     return -1;
 | ||
|                 }
 | ||
|                 // return Convert.ToInt16( ((Node)combColors.SelectedItem).name);
 | ||
|                 if (oldDesk != combColors.Text)
 | ||
|                 {
 | ||
|                     oldDesk = combColors.Text;
 | ||
|                     writeConfig("Desk", combColors.Text);
 | ||
|                 }
 | ||
|                 return Convert.ToInt16(combColors.Text);
 | ||
|             }
 | ||
|         }*/
 | ||
| 
 | ||
|         string oldDesk = "";
 | ||
|         private int desk
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (combColors.SelectedIndex == -1)
 | ||
|                 {
 | ||
|                     showErrorMsg(null, "请选择控制台");
 | ||
| 
 | ||
|                     combColors.Focus();
 | ||
|                     return -1;
 | ||
|                 }
 | ||
|                 // return Convert.ToInt16( ((Node)combColors.SelectedItem).name);
 | ||
|                 if (oldDesk != combColors.Text)
 | ||
|                 {
 | ||
|                     oldDesk = combColors.Text;
 | ||
|                     writeConfig("Desk", combColors.Text);
 | ||
|                 }
 | ||
|                 int i = 0;
 | ||
|                 foreach (string v in enumColors.Values)
 | ||
|                 {
 | ||
|                     i++;
 | ||
|                     if (v == combColors.Text)
 | ||
|                     {
 | ||
|                         return i;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 return 1;
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void combColors_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             string printerName = WmsConstants.PRINTER_NAME_CODE;
 | ||
|             if (String.IsNullOrEmpty(printerName))
 | ||
|             {
 | ||
|                 string msg = String.Format("没有定义条码打印机,请先设置本地条码打印机");
 | ||
|                 showErrorMsg(msg); 
 | ||
|             }
 | ||
| 
 | ||
|             if (oldDesk == "-1")
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             showWaitForm();
 | ||
|             this.refreshInterval = 0;
 | ||
|             clearDetails();
 | ||
|             getValidationOrders();
 | ||
|             if (coms.com_manage[currentPort] != null)
 | ||
|             {
 | ||
|                 coms.com_manage[currentPort].write_reset_device();
 | ||
|             }
 | ||
|             getDeskStatus();
 | ||
|             closeWaitForm();
 | ||
|             
 | ||
|         }
 | ||
| 
 | ||
|         private void initialComboBoxes()
 | ||
|         {
 | ||
|             DataTable dtDesk = pickClient.getDeskList((int)enumDeskType.播种); 
 | ||
|            
 | ||
|             List<string> desks = new List<string>();
 | ||
|             foreach (DataRow dr in dtDesk.Rows)
 | ||
|             {
 | ||
|                 desks.Add(dr["deskName"].ToString());
 | ||
|             }
 | ||
|             oldDesk = "-1";
 | ||
|             initialComboBoxs(this.combColors, desks.ToArray()  );
 | ||
|             oldDesk = System.Configuration.ConfigurationManager.AppSettings["Desk"]; 
 | ||
|            
 | ||
|             try
 | ||
|             {
 | ||
|                 int i = 0;
 | ||
|                 foreach (string desk in desks)
 | ||
|                 {
 | ||
| 
 | ||
|                     if (!string.IsNullOrEmpty(oldDesk) && oldDesk == desk)
 | ||
|                     {
 | ||
|                         combColors.SelectedIndex = i;
 | ||
|                     }
 | ||
|                     i++;
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
|             catch
 | ||
|             {
 | ||
|             }
 | ||
| 
 | ||
|             getDeskStatus();
 | ||
| 
 | ||
|             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 2006:
 | ||
|                         initialComboBoxs(this.comValidException, drss, false); //
 | ||
|                         break;
 | ||
|                     /*
 | ||
|                     case 4002:
 | ||
|                         initialComboBoxs(this.combColors, drss,false); //复合台
 | ||
|                         if (combColors.Properties.Items.Count > 0)
 | ||
|                         {
 | ||
|                             combColors.SelectedIndex = 0;
 | ||
|                         }
 | ||
|                         break;
 | ||
|                         */
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|             
 | ||
| 
 | ||
|         }
 | ||
|       
 | ||
|         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(gridViewPickOrders4valid,false);
 | ||
|             //setupGridView(gridView2, false,false);
 | ||
|             //setupGridView(gridView3, false,false);
 | ||
|             //   gridviewGoodsType.PopulateColumns();
 | ||
|             gridViewPickOrders4valid.Columns.Clear();
 | ||
|             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]); 
 | ||
|             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
 | ||
|             myCol0.Visible = false;
 | ||
|             this.gridViewPickOrders4valid.Columns.Add(myCol0);
 | ||
|             GridColumn myCol1 = new GridColumn() { Caption = "分拣单号", Visible = true, FieldName = WmsOutPickRequest.fields.pickOrderNo.ToString(),MinWidth=100 };
 | ||
|          //   GridColumn myCol2 = new GridColumn() { Caption = "类别", Visible = true, FieldName = WmsOutPickRequest.fields.orderTypeName.ToString() };
 | ||
|             GridColumn myCol3 = new GridColumn() { Caption = "复核状态", Visible = true, FieldName = "bulkPickState",MaxWidth=90 };
 | ||
| 
 | ||
|             GridColumn myCol4 = new GridColumn() { Caption = "客户", Visible = true, FieldName = WmsOutPickRequest.fields.customerName. ToString() , MinWidth = 240 };
 | ||
|             GridColumn myCol5 = new GridColumn() { Caption = "备注", Visible = true, FieldName = WmsOutPickRequest.fields.description.ToString() };
 | ||
|             //GridColumn myCol6 = new GridColumn() { Caption = "日期", Visible = true, FieldName = WmsOutPickRequest.fields.orderDate.ToString() };
 | ||
|             GridColumn myCol6 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = WmsGoods.exfields.goodsName.ToString() };
 | ||
|             GridColumn myCol7 = new GridColumn() { Caption = "批号", Visible = true, FieldName = WmsOutDetail.fields.batch.ToString() };
 | ||
|             GridColumn myCol8 = new GridColumn() { Caption = "订单数量", Visible = true, FieldName = WmsOutDetail.fields.bulkCount.ToString(), MaxWidth = 80 };
 | ||
|             GridColumn myCol9 = new GridColumn() { Caption = "标签ID", Visible = true, FieldName = WmsOutPickRequest.fields.seedsLabelId.ToString(),MaxWidth=80 };
 | ||
|             GridColumn myCol10= new GridColumn() { Caption = "播种数量", Visible = true, FieldName =  WmsOutPickDetail_tmp.fields.confirmedCount.ToString() };
 | ||
|  
 | ||
| 
 | ||
| 
 | ||
|             this.gridViewPickOrders4valid.Columns.Add(myCol4);
 | ||
|      
 | ||
|            
 | ||
|           //  this.gridView1.Columns.Add(myCol6);
 | ||
|           //  this.gridView1.Columns.Add(myCol3); 
 | ||
|             this.gridViewPickOrders4valid.Columns.Add(myCol8);    
 | ||
|        
 | ||
|           //  this.gridViewPickOrders4valid.Columns.Add(myCol10);
 | ||
|             this.gridViewPickOrders4valid.Columns.Add(myCol3);
 | ||
|               this.gridViewPickOrders4valid.Columns.Add(myCol9);
 | ||
|           this.gridViewPickOrders4valid.Columns.Add(myCol1);
 | ||
|            
 | ||
|              
 | ||
|          
 | ||
|           //  this.gridViewPickOrders4valid.Columns.Add(myCol6);
 | ||
|           //  this.gridViewPickOrders4valid.Columns.Add(myCol7);  
 | ||
|                this.gridViewPickOrders4valid.Columns.Add(myCol5) ;
 | ||
|             //to show bottom scroll bar
 | ||
|          //   gridViewPickOrders4valid.OptionsView.ColumnAutoWidth = false;
 | ||
|          //   gridViewPickOrders4valid.BestFitColumns();
 | ||
|          //  // gridView1.Focus();
 | ||
|             gridViewPickOrders4valid.OptionsView.ColumnAutoWidth = true;
 | ||
|             gridViewPickOrders4valid.BestFitColumns();
 | ||
| 
 | ||
|              myCol1 = new GridColumn() { Caption = "播种单", Visible = true, FieldName = "seedsPickNo", MinWidth =120 };
 | ||
|              GridColumn myCol2 = new GridColumn() { Caption = "波次", Visible = true, FieldName = "dpsOrder", MinWidth =120 };
 | ||
|             // myCol3 = new GridColumn() { Caption = "状态", Visible = true, FieldName = "orderState" ,MinWidth=80 };
 | ||
|             gridViewSeedsPick.Columns.Clear();
 | ||
|             setupGridView(this.gridViewSeedsPick, false,false);
 | ||
|          //this.gridViewSeedsPick.Columns.Add(myCol2);
 | ||
|             this.gridViewSeedsPick.Columns.Add(myCol2);
 | ||
|             this.gridViewSeedsPick.Columns.Add(myCol1);
 | ||
|             GridColumn myCol200 = new GridColumn() { Caption = "状态", Visible = true, FieldName = "seedsStatus" };
 | ||
|           //  gridViewSeedsPick.Columns.Add(myCol200);
 | ||
| 
 | ||
|             gridViewSeedsPick.OptionsView.ColumnAutoWidth = true;
 | ||
|             gridViewSeedsPick.BestFitColumns();
 | ||
|         //    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 myCol161 = new GridColumn() { Caption = "复核状态", Visible = true, FieldName = WmsOutPickDetail.fields.bulkPickState.ToString(), MinWidth = 90 };
 | ||
|             GridColumn myCol17 = new GridColumn() { Caption = "状态", Visible = true, FieldName = WmsOutDetail.fields.state.ToString(), MinWidth = 90 };
 | ||
|             GridColumn myCol18 = new GridColumn() { Caption = "说明", Visible = true, FieldName = WmsOutDetail.fields.description.ToString() };
 | ||
|               
 | ||
|             GridColumn myCol25 = new GridColumn() { Caption = "订单", Visible = true, FieldName = WmsOutRequest.fields.orderNo.ToString(), MinWidth = 90 };
 | ||
|             GridColumn myCol26 = new GridColumn() { Caption = "条码", Visible = true, FieldName = "barCode" };
 | ||
| 
 | ||
|             GridColumn myCol29 = new GridColumn() { Caption = "复核结果", Visible = true, FieldName = "validResult" };
 | ||
|             GridColumn myCol27 = new GridColumn() { Caption = "异常回馈", Visible = true, FieldName = "solution" };
 | ||
|             GridColumn myCol28 = new GridColumn() { Caption = "回馈说明", Visible = true, FieldName = WmsOutPickDetail.fields.solutionRemark.ToString() };
 | ||
|             GridColumn myCol30 = new GridColumn() { Caption = "复核数量", Visible = true, FieldName = WmsOutPickDetail.fields.confirmedCount.ToString() };
 | ||
| 
 | ||
|             if (gridview == gridViewPickOrders)
 | ||
|             { 
 | ||
|                 GridColumn myCol11 = new GridColumn() { Caption = "单号", Visible = true, FieldName = WmsOutPickRequest.fields.pickOrderNo.ToString() };
 | ||
|                 //   GridColumn myCol2 = new GridColumn() { Caption = "类别", Visible = true, FieldName = WmsOutPickRequest.fields.orderTypeName.ToString() };
 | ||
|                 GridColumn myCol31 = new GridColumn() { Caption = "复核状态", Visible = true, FieldName = "orderState", MinWidth = 90 };
 | ||
| 
 | ||
|                 GridColumn myCol41 = new GridColumn() { Caption = "客户", Visible = true, FieldName = WmsOutPickRequest.fields.customerName.ToString(), MinWidth = 120 };
 | ||
|                 
 | ||
|                 gridview.Columns.Add(myCol41);
 | ||
|                 gridview.Columns.Add(myCol11);
 | ||
|               
 | ||
|               //  gridview.Columns.Add(myCol31);
 | ||
|                
 | ||
|                 return;
 | ||
|             } 
 | ||
|             else
 | ||
|             {
 | ||
|                 gridview.Columns.Add(myCol26);
 | ||
|                 gridview.Columns.Add(myCol101);
 | ||
|             }
 | ||
|             gridview.Columns.Add(myCol1);
 | ||
|             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(myCol17);
 | ||
|             gridview.Columns.Add(myCol18);
 | ||
|           
 | ||
|             
 | ||
|             //to show bottom scroll bar
 | ||
|             gridview.OptionsView.ColumnAutoWidth = false;
 | ||
|             gridview.BestFitColumns();
 | ||
|           //  gridView2.Focus();
 | ||
|             if (dtPickOrders4Validation.Rows.Count > 0)
 | ||
|             {
 | ||
|                 switchGridViewRowSelection(gridViewSeedsGoods, true);
 | ||
|               
 | ||
| 
 | ||
|                 if (gridViewSeedsGoods.IsFocusedView)
 | ||
|                 {
 | ||
|                     return;
 | ||
|                 }
 | ||
|                 gridViewSeedsGoods.Focus();
 | ||
|             }
 | ||
|             
 | ||
|         }
 | ||
| 
 | ||
|         private void initialGridView3Columns(GridView gridview)
 | ||
|         {
 | ||
|             setupGridView(gridview, false,false, 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(), MinWidth = 180 };
 | ||
|             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.bulkCount.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(), MinWidth = 120 };
 | ||
|             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 myCol1001 = new GridColumn() { Caption = "拣货数量", Visible = true, FieldName = "pdaOuting" };
 | ||
|             
 | ||
|             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 myCol19 = new GridColumn() { Caption = "状态", Visible = true, FieldName = "bulkPickState",MinWidth=90 };
 | ||
|             GridColumn myCol191 = new GridColumn() { Caption = "状态", Visible = true, FieldName = "pickState", MinWidth = 90 };
 | ||
| 
 | ||
|             GridColumn myCol20 = new GridColumn() { Caption = "波次", Visible = true, FieldName = WmsOutPickLable.fields.dpsOrder.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.pickOrderNo.ToString() };
 | ||
| 
 | ||
|            GridColumn myCol26 = new GridColumn() { Caption = "异常回馈", Visible = true, FieldName = "solution" };
 | ||
|            GridColumn myCol27 = new GridColumn() { Caption = "回馈说明", Visible = true, FieldName = WmsOutPickDetail.fields.solutionRemark.ToString() };
 | ||
|            GridColumn myCol28 = new GridColumn() { Caption = "条码", Visible = true, FieldName = "barCode" };
 | ||
|        
 | ||
| 
 | ||
| 
 | ||
|            if (gridview == gridViewException)
 | ||
|            {
 | ||
|                gridview.Columns.Add(myCol25);
 | ||
|                gridview.Columns.Add(myCol26);
 | ||
|                gridview.Columns.Add(myCol27);
 | ||
|                gridViewException.OptionsSelection.EnableAppearanceFocusedRow = true;
 | ||
|                gridViewException.FocusRectStyle = DrawFocusRectStyle.RowFocus;
 | ||
|            }
 | ||
|            if (gridview == gridViewPickDetail)
 | ||
|            {
 | ||
|                gridview.Columns.Add(myCol2);
 | ||
|                gridview.Columns.Add(myCol14);
 | ||
|                gridview.Columns.Add(myCol22);
 | ||
|                gridview.Columns.Add(myCol1001);
 | ||
|                gridview.Columns.Add(myCol5);
 | ||
|                gridview.Columns.Add(myCol4);
 | ||
|            
 | ||
|                gridview.Columns.Add(myCol191);
 | ||
|               
 | ||
|         
 | ||
|            }
 | ||
|            else
 | ||
|            {
 | ||
|                 gridview.Columns.Add(myCol2);              
 | ||
|                 gridview.Columns.Add(myCol14);
 | ||
|                 
 | ||
|                 gridview.Columns.Add(myCol100);
 | ||
|                 GridColumn myCol200 = new GridColumn() { Caption = "完成数量", Visible = true, FieldName = "confirmedCount" };
 | ||
|                    gridview.Columns.Add(myCol28);
 | ||
|                 //
 | ||
| 
 | ||
|             }
 | ||
|            
 | ||
| 
 | ||
|             //to show bottom scroll bar
 | ||
|             gridview.OptionsView.ColumnAutoWidth = false;
 | ||
|             gridview.BestFitColumns();
 | ||
|             //  gridView2.Focus();
 | ||
|         }
 | ||
| 
 | ||
|         #endregion
 | ||
| 
 | ||
| 
 | ||
|         
 | ||
|         /// <summary>
 | ||
|         /// 预处理,按客户分拆订单,生成分拣单,并出库
 | ||
|         /// </summary>
 | ||
|         private void getValidationOrders()
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 getSeedsOrders4Validation();
 | ||
|             }
 | ||
|             catch (Exception ee)
 | ||
|             {
 | ||
|                 LogHelper.WriteLog(typeof(GoodsOutValidationForm), ee);
 | ||
|               
 | ||
|             }
 | ||
|            
 | ||
|             //threadPreProcess = new Thread(this.getPickOrders4Validation);
 | ||
|             //threadPreProcess.IsBackground = true; 
 | ||
|             //threadPreProcess.Start();
 | ||
|         }
 | ||
| 
 | ||
|         private void getSeedsOrders4Validation()
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 closeWaitForm();
 | ||
|                 showWaitForm();
 | ||
| 
 | ||
|                 enumOutStockRequestStatus status = getQueryStatus();
 | ||
|                 string seedsNo = getQuerySeedsNo();
 | ||
|                 dsPickOrders = pickClient.getPickRequest4SeedsOperation(desk, (int)status, seedsNo);
 | ||
|                 closeClient();
 | ||
|                 //   dtExceptionSolutions = pickClient.getBulkValidationExceptionSolutions(desk);
 | ||
|                 //  closeClient();
 | ||
|                 closeWaitForm();
 | ||
|             }
 | ||
|            
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 showErrorMsg(e,e.Message);
 | ||
|                 LogHelper.WriteLog(this.GetType(), e);
 | ||
|                 return;
 | ||
|             }
 | ||
|             dtSeedsOrders = dsPickOrders.Tables[3];
 | ||
|            // dtPickOrders4Validation = dsPickOrders.Tables[2];
 | ||
|            
 | ||
|             dtSeedsOrders.PrimaryKey = new DataColumn[] { dtSeedsOrders.Columns["seedsPickNo"] }; 
 | ||
|             
 | ||
|             dtSeedsGoods = dsPickOrders.Tables[1];
 | ||
|            // dtPickOrders4Validation.PrimaryKey = new DataColumn[] { dtPickOrders4Validation.Columns["pickOrderNo"] };
 | ||
|             // dtSeedsGoods.PrimaryKey = new DataColumn[] { dtSeedsGoods.Columns["id"] };
 | ||
|          //   updateValidationList(null,null);
 | ||
| 
 | ||
|             //如果当前没有当天的复核任务,则请求新波次
 | ||
|             if (dtSeedsOrders.Rows.Count == 0)
 | ||
|             {
 | ||
|                 pickClient.setDeskFree(desk);
 | ||
|             }
 | ||
| 
 | ||
|             if (InvokeRequired)
 | ||
|             {
 | ||
|                 this.Invoke(new loadNewPickOrders(delegate()
 | ||
|                 {
 | ||
|                     swAutoOrder.Enabled = true;
 | ||
|                     btnPickOrders.Enabled = !autoOrder;
 | ||
|                     this.loadSeedsOrders();
 | ||
|                 }));
 | ||
| 
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 swAutoOrder.Enabled = true;
 | ||
|                 btnPickOrders.Enabled = !autoOrder;
 | ||
|                 this.loadSeedsOrders();
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|           //  getValidationOrders();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         DateTime lastRefreshTime;
 | ||
|         int refreshInterval = 5;
 | ||
|         //完成任务时需要调用
 | ||
|         delegate void loadNewPickOrders();
 | ||
|         private void updateValidationList(object source, System.Timers.ElapsedEventArgs e)
 | ||
|         {
 | ||
|             //还可以进行其他的一些完任务完成之后的逻辑处理
 | ||
| 
 | ||
|             closeWaitForm();
 | ||
|  
 | ||
|             /*
 | ||
|             if (autoOrder)
 | ||
|             {
 | ||
|                 TimeSpan ts = DateTime.Now - lastRefreshTime;
 | ||
| 
 | ||
|                 if (  ts.TotalSeconds < refreshInterval)
 | ||
|                 {
 | ||
|                     return;
 | ||
|                 }
 | ||
|                 lastRefreshTime = DateTime.Now; 
 | ||
| 
 | ||
|                 refreshInterval = Convert.ToInt32(  spinOrder.Value * 60);
 | ||
|              
 | ||
|                 getValidationOrders();
 | ||
|             }
 | ||
|              
 | ||
|              * */
 | ||
|             try
 | ||
|             {
 | ||
|                 if (InvokeRequired)
 | ||
|                 {
 | ||
|                     this.Invoke(new loadNewCurrentWave(delegate()
 | ||
|                     {
 | ||
|                         updateLableStatus();
 | ||
|             
 | ||
|                     }));
 | ||
| 
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     //lbLightsInfo.Text = (lights.Count > 0 ? "" : "未检测到通道灯");
 | ||
|                     updateLableStatus();
 | ||
|             
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (Exception er)
 | ||
|             {
 | ||
|                 pickClient.Close();
 | ||
|                 LogHelper.WriteLog(typeof(GoodsOutForm), er);
 | ||
|             }
 | ||
|             
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void clearDetails()
 | ||
|         {
 | ||
|             resetValidationDetails();
 | ||
|             //this.gridControlPickOrders.DataSource = null;
 | ||
|             this.gridSeedsGoods.DataSource = null;
 | ||
|             gridSeedsPick.DataSource = null;
 | ||
|             lbPickOrderNo.Text = ""; 
 | ||
|             isDoubleChk = false;
 | ||
|             txtAccount.Text = txtPasswd.Text = "";
 | ||
|             gridControlPkDetail.DataSource = null;
 | ||
|             //gridControlPickOrders.DataSource = null;
 | ||
|             currentSeedsOrder = "";
 | ||
|             resetValidationDetails();
 | ||
|            
 | ||
|             lbPickOrderNo.Text = "";
 | ||
|             WmsConstants.CURRENT_SEEDS_NO = "";
 | ||
|             WmsConstants.CURRENT_SEEDS_GOODSID = "";
 | ||
|             WmsConstants.CURRENT_SEEDS_GOOD_BATCH = "";
 | ||
|             WmsConstants.CURRENT_SEEDS_GOOD_SKUID = 0;
 | ||
|             this.currentSkuId = 0;
 | ||
|             tryCnt = 0;
 | ||
|             //resetLights();
 | ||
|         }
 | ||
| 
 | ||
|         System.Timers.Timer timer = new System.Timers.Timer();//实例化Timer类
 | ||
|          
 | ||
|         private void initialTimer()
 | ||
|         {
 | ||
|             int intTime = 1000;
 | ||
|             timer.Interval = intTime;//设置间隔时间,为毫秒;
 | ||
|             timer.Elapsed += new System.Timers.ElapsedEventHandler(updateValidationList);//到达时间的时候执行事件;
 | ||
|             timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
 | ||
|             timer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
 | ||
|             timer.Start();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 更新拣选明细
 | ||
|         /// </summary>
 | ||
|         /// <summary>
 | ||
|         /// 更新拣选明细
 | ||
|         /// </summary>
 | ||
|         private void updatePickDetails()
 | ||
|         {
 | ||
|            this.gridControlPkDetail.DataSource = null;
 | ||
|             try
 | ||
|             {
 | ||
|                 Thread threadPickdetail = new Thread(this.getPickOrdersPickDetail);
 | ||
|                 threadPickdetail.IsBackground = true;
 | ||
|                 threadPickdetail.Start();
 | ||
|             }
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 LogHelper.WriteLog(this.GetType(), e);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         private void getPickOrdersPickDetail()
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 dtPickDetails = pickClient.getPickDetailBySeedsPickOrderNo(this.currentSeedsOrder,currentSkuId);
 | ||
|                // closeClient();
 | ||
|             }
 | ||
|             catch(Exception e)
 | ||
|             {
 | ||
|                 showErrorMsg(e.Message);
 | ||
|             }
 | ||
| 
 | ||
|             if (InvokeRequired)
 | ||
|             {
 | ||
|                 try
 | ||
|                 {
 | ||
|                     this.Invoke(new loadNewPickOrders(delegate()
 | ||
|                 {
 | ||
|                     bindPickDetails();
 | ||
|                      
 | ||
|                 }));
 | ||
|                 }
 | ||
|                 catch (Exception er)
 | ||
|                 {
 | ||
|                     LogHelper.WriteLog(this.GetType(), er);
 | ||
|                 }  
 | ||
| 
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 bindPickDetails();
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|      
 | ||
|          
 | ||
|          
 | ||
|         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 gridViewSeedsOrders_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | ||
|         {
 | ||
|             if (this.gridViewSeedsPick.FocusedRowHandle < 0 || gridViewSeedsPick.FocusedRowHandle == selectedSeedsOrderRowIndex
 | ||
|                                                             || isDataSourceChanged && selectedSeedsOrderRowIndex > 0)
 | ||
|             {
 | ||
|                 if (gridViewSeedsPick.IsGroupRow(e.RowHandle)) //set first row of group selected
 | ||
|                 {
 | ||
|                     selectedSeedsOrderRowIndex = gridViewSeedsPick.GetChildRowHandle(e.RowHandle, 0);
 | ||
|                      setCurrentSeedsRequestGoodsList();
 | ||
|                 } 
 | ||
|                 isDataSourceChanged = false;  
 | ||
|                 return;
 | ||
|             }
 | ||
|             isDataSourceChanged = false;
 | ||
|             selectedSeedsOrderRowIndex = gridViewSeedsPick.FocusedRowHandle;
 | ||
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | ||
|             setCurrentSeedsRequestGoodsList();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         int gridViewPickOrders4validIndex = 0;
 | ||
|         private void gridViewPickOrders4valid_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | ||
|         {
 | ||
|             currentLabId = 0;
 | ||
|             if (this.gridViewPickOrders4valid.FocusedRowHandle < 0 || gridViewPickOrders4valid.FocusedRowHandle == gridViewPickOrders4validIndex)
 | ||
|             {
 | ||
|                 if (gridViewPickOrders4valid.IsGroupRow(e.RowHandle)) //set first row of group selected
 | ||
|                 {
 | ||
|                     gridViewPickOrders4validIndex = gridViewPickOrders4valid.GetChildRowHandle(e.RowHandle, 0);
 | ||
| 
 | ||
|                     setCurrentLabId();
 | ||
|                 }
 | ||
|                 
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|             gridViewPickOrders4validIndex = gridViewPickOrders4valid.FocusedRowHandle;
 | ||
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | ||
|             setCurrentLabId();
 | ||
| 
 | ||
|         }
 | ||
|         int currentLabId = 0;
 | ||
|         void setCurrentLabId()
 | ||
|         {
 | ||
|             DataRowView currentRow = (DataRowView)(GetGridViewFilteredAndSortedData(gridViewPickOrders4valid)[gridViewPickOrders4validIndex]); 
 | ||
| 
 | ||
|             //  selectedRequest = new WmsOutPickRequest(currentRow); 
 | ||
|             currentSeedsOrder = currentRow[WmsOutPickRequest.fields.seedsLabelId.ToString()].ToString();
 | ||
|             
 | ||
|         }
 | ||
|         bool isDataSourceChanged = false;
 | ||
|         private void gridViewSeedsPick_DataSourceChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             isDataSourceChanged = true;
 | ||
|             if (selectedSeedsOrderRowIndex >= 0 && dtPickOrders4Validation!=null 
 | ||
|                 && dtPickOrders4Validation.Rows.Count > selectedSeedsOrderRowIndex)
 | ||
|             {
 | ||
|                 gridViewPickOrders4valid.FocusedRowHandle = selectedSeedsOrderRowIndex;
 | ||
|                 gridViewPickOrders4valid.MakeRowVisible(selectedSeedsOrderRowIndex);
 | ||
| 
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void btnDelete_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|              
 | ||
|         }
 | ||
|         void bindBoxes()
 | ||
|         {
 | ||
|             if (string.IsNullOrEmpty(currentWave))
 | ||
|             {
 | ||
|                 this.gridcontrolBox.DataSource = null;
 | ||
|                 return;
 | ||
|             }
 | ||
|             try
 | ||
|             {
 | ||
|                 DataTable dt = pickClient.getBoxsByWave(currentWave, desk);
 | ||
|                 initialBoxColumns(gvBox);
 | ||
|                 this.gridcontrolBox.DataSource = dt;
 | ||
|               //  closeClient();
 | ||
|             }
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 closeClient();
 | ||
|                 showErrorMsg(e, "");
 | ||
|             }
 | ||
|         }
 | ||
|         private void initialBoxColumns(GridView gridView1)
 | ||
|         {
 | ||
|             setupGridView(gridView1, false,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;
 | ||
|             gridView1.Columns.Add(myCol0);
 | ||
|             GridColumn myCol1 = new GridColumn() { Caption = "颜色", Visible = true, FieldName = "color" };
 | ||
|             GridColumn myCol2 = new GridColumn() { Caption = "箱子编号", Visible = true, FieldName = "plateId" };
 | ||
|             GridColumn myCol3 = new GridColumn() { Caption = "容积", Visible = true, FieldName = "volume" };
 | ||
|             GridColumn myCol4 = new GridColumn() { Caption = "", Visible = true, FieldName = " " };
 | ||
|              
 | ||
|             gridView1.Columns.Add(myCol2);
 | ||
|        
 | ||
|             gridView1.Columns.Add(myCol3);
 | ||
|             //to show bottom scroll bar
 | ||
|             gridView1.OptionsView.ColumnAutoWidth = true;
 | ||
|             //   gridView1.BestFitColumns();
 | ||
|             gridView1.Focus();
 | ||
| 
 | ||
| 
 | ||
|             //    initialGridView2Columns();
 | ||
|             //gridControl2.DataSource = null;
 | ||
|         }
 | ||
|         protected void query()
 | ||
|         {
 | ||
|            // pager1.Bind();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         private void loadSeedsOrders()
 | ||
|         {
 | ||
| 
 | ||
|           //  showWaitForm();
 | ||
|             try
 | ||
|             {
 | ||
|                 clearDetails();
 | ||
|                 bool firstLoad = this.gridSeedsPick.DataSource == null;
 | ||
| 
 | ||
|                 isKeyIn = false;
 | ||
|              
 | ||
|                 DataView dvp = dtSeedsOrders.DefaultView;
 | ||
|                 dvp.RowFilter = getFilter();
 | ||
|                 if (!string.IsNullOrEmpty(boxId) && !string.IsNullOrEmpty(boxWave) && desk == boxDesk)
 | ||
|                 {
 | ||
|                     dvp.RowFilter += string.Format(" and dpsOrder='{0}' and desk={1}", boxWave, boxDesk);
 | ||
|                     this.gridSeedsPick.DataSource = dvp;
 | ||
|                     selectedSeedsOrderRowIndex = 0;
 | ||
|                     getCurrentSeedsOrderObject();
 | ||
|                 }
 | ||
|                 dvp.Sort = "dpsOrder";
 | ||
|                 this.gridSeedsPick .DataSource = dvp; 
 | ||
| 
 | ||
|                 if (!firstLoad && !string.IsNullOrEmpty(currentSeedsOrder) )
 | ||
|                 {
 | ||
|                     selectedSeedsOrderRowIndex = -1;
 | ||
|                     DataRow dr = this.dtSeedsOrders.Rows.Find(currentSeedsOrder);
 | ||
| 
 | ||
|                     DataView dv = dtSeedsOrders.DefaultView;
 | ||
| 
 | ||
|                     dv.RowFilter += " and seedsPickNo='" + currentSeedsOrder +"'";
 | ||
| 
 | ||
| 
 | ||
|                     if (dv.Count>0)// != null)
 | ||
|                     {
 | ||
|                        // selectedSeedsOrderRowIndex = dtSeedsOrders.Rows.IndexOf(dr);
 | ||
| 
 | ||
|                         selectedSeedsOrderRowIndex = 0;
 | ||
|                         foreach (DataRowView drv in GetGridViewFilteredAndSortedData(gridViewSeedsPick))
 | ||
|                         {
 | ||
|                             if (drv["seedsPickNo"].ToString().Equals(currentSeedsOrder))
 | ||
|                             {
 | ||
|                                 break;
 | ||
|                             }
 | ||
|                             selectedSeedsOrderRowIndex++;
 | ||
|                         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|                     }else{
 | ||
|                         selectedSeedsOrderRowIndex = 0;
 | ||
|                     }
 | ||
|                    // dv.RowFilter = "";
 | ||
|                     if (selectedSeedsOrderRowIndex >= 0 && dtSeedsOrders.Rows.Count > selectedSeedsOrderRowIndex)
 | ||
|                     {
 | ||
|                         // gridView1.SelectRow(selectedRowIndex);
 | ||
|                       this.gridViewSeedsPick.FocusedRowHandle = selectedSeedsOrderRowIndex;
 | ||
|                         //  gridView1.MakeRowVisible(selectedRowIndex);
 | ||
| 
 | ||
|                     }
 | ||
| 
 | ||
|                     //gridView1.FocusedRowHandle = selectedRowIndex;
 | ||
|                 }
 | ||
|                 else
 | ||
|                 // if (firstLoad)
 | ||
|                 {
 | ||
|                     gridViewSeedsPick.FocusedRowHandle = 0;
 | ||
| 
 | ||
|                     gridViewSeedsPick.SelectRow(0);
 | ||
|                    // setCurrentRequestDetail();
 | ||
|                 }
 | ||
|                 if (firstLoad && dtSeedsOrders.Rows.Count > 0)
 | ||
|                 {
 | ||
|                     selectedSeedsOrderRowIndex =0;
 | ||
|                     
 | ||
|                     selectedGoodsItem = 0;
 | ||
|                     
 | ||
|                 }
 | ||
| 
 | ||
|                 setCurrentSeedsRequestGoodsList();
 | ||
| 
 | ||
|             
 | ||
|                 //to load exception solutions
 | ||
| 
 | ||
|               //  DataView dv = dtExceptionSolutions.DefaultView;
 | ||
| #if DEBUG
 | ||
| #else
 | ||
|             //    dv.RowFilter = "desk =" + desk;
 | ||
| #endif
 | ||
| 
 | ||
|              //   gridControlException.DataSource = dv;
 | ||
|                 try
 | ||
|                 {
 | ||
|                   //  initialGridView3Columns(gridViewException);
 | ||
|                     initialDataGridColumns();
 | ||
|                     initialGridView3Columns(this.gridViewSeedsGoods);
 | ||
|                 }
 | ||
|                 catch { }
 | ||
|                 if (firstLoad)
 | ||
|                 {
 | ||
|                     
 | ||
|                   //  setCurrentValidationDetail(); 
 | ||
| 
 | ||
|                 }
 | ||
|                 
 | ||
|                 textEditBarcode.Focus();
 | ||
|                 textEditBarcode.SelectAll();
 | ||
|                 
 | ||
|             }
 | ||
|             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;
 | ||
|             loadSeedsOrders();
 | ||
|         }
 | ||
| 
 | ||
|        
 | ||
| 
 | ||
|         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 getCurrentSeedsOrderObject()
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 if (selectedSeedsOrderRowIndex < 0 || selectedSeedsOrderRowIndex >= this.dtSeedsOrders.Rows.Count)
 | ||
|                 {
 | ||
|                     return false;
 | ||
|                 }
 | ||
| 
 | ||
|                 //clearDetails();
 | ||
|                 int cnt = GetGridViewFilteredAndSortedData(this.gridViewSeedsPick).Count;
 | ||
|                 if (selectedSeedsOrderRowIndex + 1 > cnt)
 | ||
|                 {
 | ||
|                     selectedSeedsOrderRowIndex = 0;
 | ||
|                     //   return false;
 | ||
|                 }
 | ||
|                 // DataRow currentRow = dtPickOrders4Validation.Rows[selectedRowIndex];
 | ||
|                 DataRowView currentRow = (DataRowView)(GetGridViewFilteredAndSortedData(gridViewSeedsPick)[selectedSeedsOrderRowIndex]);
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|                 //  selectedRequest = new WmsOutPickRequest(currentRow); 
 | ||
|                 currentSeedsOrder = currentRow["seedsPickNo"].ToString();
 | ||
|                 currentWave = currentRow["dpsOrder"].ToString();
 | ||
|                 // lbPickOrderNo.Text = currentSeedsOrder;
 | ||
|                 //lbCustmer.Text = currentRow["customerName"].ToString();
 | ||
|                 // bindBoxes();
 | ||
|             }
 | ||
|             catch (Exception er)
 | ||
|             {
 | ||
|                 showErrorMsg(er);
 | ||
|             }
 | ||
|             return true;
 | ||
| 
 | ||
|         }
 | ||
|        
 | ||
|        
 | ||
| 
 | ||
| 
 | ||
|         private void btnQuery_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             clearDetails(); 
 | ||
|             loadSeedsOrders();
 | ||
|         }
 | ||
| 
 | ||
|         private void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
 | ||
|         {
 | ||
|             if (gridViewPickOrders4valid.FocusedRowHandle <0 || gridViewPickOrders4valid.FocusedRowHandle == selectedSeedsOrderRowIndex)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             selectedSeedsOrderRowIndex = gridViewPickOrders4valid.FocusedRowHandle;
 | ||
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | ||
|             setCurrentSeedsRequestGoodsList();
 | ||
| 
 | ||
|             bindBoxes();
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void initialDataGrid()
 | ||
|         {
 | ||
|             //播种单列表
 | ||
|             this.gridViewSeedsPick.OptionsSelection.MultiSelect = false;//按shift / control 多选
 | ||
|             this.gridViewSeedsPick.OptionsBehavior.AutoPopulateColumns = false;
 | ||
|             this.gridViewSeedsPick.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | ||
|             this.gridViewSeedsPick.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus;
 | ||
|             this.gridViewSeedsPick.OptionsBehavior.Editable = false;
 | ||
|             this.gridViewSeedsPick.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
| 
 | ||
|             this.gridViewSeedsPick.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridViewSeedsOrders_FocusedRowObjectChanged);
 | ||
|             this.gridViewSeedsPick.DataSourceChanged += new System.EventHandler(this.gridViewSeedsPick_DataSourceChanged);
 | ||
| 
 | ||
|             //show line number
 | ||
|             this.gridViewSeedsPick.IndicatorWidth = 40;
 | ||
|             this.gridViewSeedsPick.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
| 
 | ||
|             //待分播商品
 | ||
|             this.gridViewSeedsGoods.IndicatorWidth = 40;
 | ||
|             this.gridViewSeedsGoods.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|             this.gridViewSeedsGoods.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridViewSeedsGoodsDetail_FocusedRowObjectChanged);
 | ||
|             gridViewSeedsGoods.OptionsSelection.MultiSelect = false;
 | ||
|             gridViewSeedsGoods.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | ||
|             gridViewSeedsGoods.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
|             this.gridViewSeedsGoods.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|             this.gridViewSeedsGoods.OptionsSelection.MultiSelect = false;
 | ||
|             gridViewSeedsGoods.RowCellStyle += gridView_RowCellStyle;
 | ||
|             gridViewSeedsGoods.CustomColumnDisplayText += gridView_CustomColumnDisplayText;
 | ||
|             //商品播种对象分拣单列表
 | ||
|             gridViewPickOrders4valid.OptionsSelection.MultiSelect = false;//按shift / control 多选
 | ||
|             this.gridViewPickOrders4valid.OptionsBehavior.AutoPopulateColumns = false;
 | ||
|             this.gridViewPickOrders4valid.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | ||
|             this.gridViewPickOrders4valid.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus;
 | ||
|             this.gridViewPickOrders4valid.OptionsBehavior.Editable = false;
 | ||
|             this.gridViewPickOrders4valid.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
|             gridViewPickOrders4valid.CustomDrawCell += gridView_CustomDrawCell;
 | ||
|             gridViewPickOrders4valid.RowCellStyle += gridView_RowCellStyle;
 | ||
|             gridViewPickOrders4valid.CustomColumnDisplayText += gridView_CustomColumnDisplayText;
 | ||
|             gridViewSeedsPick.CustomColumnDisplayText += gridView_CustomColumnDisplayText;
 | ||
|             gridViewSeedsPick.RowCellStyle += gridView_RowCellStyle;
 | ||
| 
 | ||
|              this.gridViewPickOrders4valid.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridViewSeedsOrders_FocusedRowObjectChanged);
 | ||
|              //this.gridViewPickOrders4valid.DataSourceChanged += new System.EventHandler(this.gridView1_DataSourceChanged);
 | ||
| 
 | ||
|             //show line number
 | ||
|             this.gridViewPickOrders4valid.IndicatorWidth = 30;
 | ||
|             this.gridViewPickOrders4valid.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|             this.gridViewPickDetail.IndicatorWidth = 30;
 | ||
|             this.gridViewPickDetail.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|             gridViewPickDetail.CustomColumnDisplayText += gridView_CustomColumnDisplayText;      
 | ||
| 
 | ||
|             //seedPickNo 对应的分拣单
 | ||
|             this.gridViewPickOrders .IndicatorWidth = 40;
 | ||
|             this.gridViewPickOrders.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|             gridViewPickOrders.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
|             gridViewPickOrders.CustomColumnDisplayText += gridView_CustomColumnDisplayText;
 | ||
|             //分拣单商品详情
 | ||
|            // this.gridViewPickDetails.IndicatorWidth = 40;
 | ||
|            // this.gridViewPickDetails.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|            
 | ||
|           //  gridViewPickDetails.OptionsSelection.MultiSelect = false;
 | ||
|           //  gridViewPickDetails.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
| 
 | ||
| 
 | ||
|           
 | ||
|             this.gridViewException.IndicatorWidth = 20;
 | ||
|             this.gridViewException.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | ||
|             this.gridViewException.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridViewException_FocusedRowObjectChanged);
 | ||
|             gridViewException.OptionsSelection.MultiSelect = false;
 | ||
|             gridViewException.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | ||
|             gridViewException.OptionsSelection.EnableAppearanceFocusedCell = false;
 | ||
| 
 | ||
|             //gridViewSeedsDetail.GotFocus += new EventHandler(gridview_GotFocus);
 | ||
|                  switchGridViewRowSelection(gridViewException,false);
 | ||
|           //  switchGridViewRowSelection(gridViewPickDetails, false);
 | ||
|             switchGridViewRowSelection(gridViewPickOrders, false);
 | ||
| 
 | ||
|             gridViewException.LostFocus += new EventHandler(gridview_LostFocus);
 | ||
|             gridViewPickOrders.LostFocus += new EventHandler(gridview_LostFocus);
 | ||
|          //   gridViewPickDetails.LostFocus += new EventHandler(gridview_LostFocus);
 | ||
| 
 | ||
|             gridViewException.GotFocus += new EventHandler(gridview_GotFocus);
 | ||
|             gridViewPickOrders.GotFocus += new EventHandler(gridview_GotFocus);
 | ||
|          //   gridViewPickDetails.GotFocus += new EventHandler(gridview_GotFocus);
 | ||
| 
 | ||
|            //  gridViewPickDetails.CustomColumnDisplayText += gridView_CustomColumnDisplayText;
 | ||
|             this.gridViewException.CustomColumnDisplayText += gridView_CustomColumnDisplayText;
 | ||
|         }
 | ||
|    
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|        private void gridView_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
 | ||
|         { 
 | ||
|             //if (sender == gridViewValidated)
 | ||
|             {
 | ||
| 
 | ||
| 
 | ||
|                 if (e.Column.FieldName == "orderState" )
 | ||
|                 {
 | ||
| 
 | ||
|                     if (!pickDetailStatus.ContainsValue(e.DisplayText))
 | ||
|                     {
 | ||
| 
 | ||
|                         int display = -100;
 | ||
|                         string disTxt = e.DisplayText;
 | ||
| 
 | ||
|                         try
 | ||
|                         {
 | ||
|                             display = Convert.ToInt16(e.DisplayText);
 | ||
| 
 | ||
|                              e.DisplayText = pickStatus[display];
 | ||
| 
 | ||
|                         }
 | ||
|                         catch
 | ||
|                         {
 | ||
|                             return;
 | ||
|                         }
 | ||
|                     }
 | ||
|                   
 | ||
| 
 | ||
|                 }else 
 | ||
|                       if ( e.Column.FieldName == "bulkPickState" || e.Column.FieldName == "pickState")
 | ||
|                 {
 | ||
| 
 | ||
|                     if (!pickStatus.ContainsValue(e.DisplayText))
 | ||
|                     {
 | ||
| 
 | ||
|                         int display = -100;
 | ||
|                         string disTxt = e.DisplayText;
 | ||
| 
 | ||
|                         try
 | ||
|                         {
 | ||
|                             display = Convert.ToInt16(e.DisplayText);
 | ||
| 
 | ||
|                             e.DisplayText = pickStatus[display];
 | ||
| 
 | ||
|                         }
 | ||
|                         catch
 | ||
|                         {
 | ||
|                             return;
 | ||
|                         }
 | ||
|                     }
 | ||
|                   
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|                
 | ||
|             }
 | ||
|         }
 | ||
|        
 | ||
|        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 == "bulkPickState" && e.CellValue != null)
 | ||
|            {
 | ||
|                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=String.Empty ;
 | ||
|            if ( currentView == gridViewSeedsPick)
 | ||
|            {
 | ||
| 
 | ||
|              //  state = currentView.GetDataRow(e.RowHandle)["orderState"].ToString().Trim();
 | ||
|            }
 | ||
|            else
 | ||
|             if (currentView == gridViewSeedsGoods)
 | ||
|             {
 | ||
|                 state = currentView.GetDataRow(e.RowHandle)["bulkPickState"].ToString().Trim();
 | ||
|                 string confiredCnt = currentView.GetDataRow(e.RowHandle)["confirmedCount"].ToString().Trim();
 | ||
|                 string totalCnt = currentView.GetDataRow(e.RowHandle)["bulkCount"].ToString().Trim();
 | ||
|                 state = confiredCnt.Equals(totalCnt) ? (int)enumOutStockPickStatus.复核完成 + "" : state;
 | ||
|                 //  state = currentView.GetDataRow(e.RowHandle)["orderState"].ToString().Trim();
 | ||
|                
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                state = currentView.GetDataRow(e.RowHandle)["bulkPickState"].ToString().Trim();
 | ||
|               
 | ||
|            }
 | ||
|           
 | ||
|            
 | ||
|            if (string.IsNullOrEmpty(state))
 | ||
|            {
 | ||
|                return;
 | ||
|            }
 | ||
| 
 | ||
|            enumOutStockPickStatus status = (enumOutStockPickStatus)Convert.ToInt16(state);
 | ||
| 
 | ||
| 
 | ||
|            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 alertFocus = new DevExpress.Utils.AppearanceDefault(Color.White,Color.Red);
 | ||
|            DevExpress.Utils.AppearanceDefault alert  = new DevExpress.Utils.AppearanceDefault(Color.Red, Color.White );
 | ||
| 
 | ||
|            DevExpress.Utils.AppearanceDefault passedFocus = new DevExpress.Utils.AppearanceDefault(Color.Gray, Color.WhiteSmoke);
 | ||
|            DevExpress.Utils.AppearanceDefault passed  = new DevExpress.Utils.AppearanceDefault(Color.Gray,Color.White);
 | ||
| 
 | ||
|            DevExpress.Utils.AppearanceDefault solutionFocus = new DevExpress.Utils.AppearanceDefault(Color.Green, Color.Yellow);
 | ||
|            DevExpress.Utils.AppearanceDefault solution = new DevExpress.Utils.AppearanceDefault(Color.Green, Color.White);
 | ||
| 
 | ||
| 
 | ||
|            if (status == enumOutStockPickStatus.复核完成)
 | ||
|            {
 | ||
|                rowStyle = isFocused ? passedFocus : passed;
 | ||
|            }
 | ||
|            else if (status == enumOutStockPickStatus.复核异常)
 | ||
|            {
 | ||
|                rowStyle = isFocused ? alertFocus : alert;
 | ||
|            }
 | ||
|            else if (status == enumOutStockPickStatus.复核异常处理)
 | ||
|            {
 | ||
|                rowStyle = isFocused ? solutionFocus : solution;
 | ||
|            }
 | ||
| 
 | ||
| 
 | ||
|            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);
 | ||
|                } 
 | ||
|            }
 | ||
|            */
 | ||
|        }
 | ||
|        bool isGoodsSourceChanged = false;
 | ||
|       
 | ||
|         private void setCurrentSeedsRequestGoodsList()
 | ||
|        {
 | ||
|            
 | ||
|             if (!getCurrentSeedsOrderObject() || string.IsNullOrEmpty( currentSeedsOrder)) 
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|             
 | ||
|         //   showWaitForm();
 | ||
| 
 | ||
|             try
 | ||
|             {
 | ||
|                 DataView dvGoodsList = dsPickOrders.Tables[1].DefaultView;
 | ||
| 
 | ||
|                 dvGoodsList = pickClient.getSeedsGoods(currentSeedsOrder).DefaultView;
 | ||
|                 //  dv.Sort = "orderNo ASC";
 | ||
|                //  dvGoodsList.RowFilter = string.Format("seedsPickNo ='{0}'", currentSeedsOrder);
 | ||
|                  dvGoodsList.Sort = "confirmedCount";
 | ||
|  
 | ||
|                 dtSeedsGoods = dvGoodsList.ToTable();
 | ||
| 
 | ||
|               //  dtSeedsGoods.PrimaryKey = new DataColumn[] { dtSeedsGoods.Columns["orderState"], dtSeedsGoods.Columns["goodsId"], dtSeedsGoods.Columns["batch"] };
 | ||
|                 isGoodsSourceChanged = true;
 | ||
|                 this.gridSeedsGoods.DataSource = dvGoodsList;
 | ||
|              
 | ||
|                 
 | ||
|                 selectedGoodsItem = -1;
 | ||
|                 this.gridViewSeedsGoods.FocusedRowHandle = 0;
 | ||
|                // isFirstLoad = true;
 | ||
|                 gridViewSeedsGoods.SelectRow(0);
 | ||
|                 /*
 | ||
|                 selectedGoodsItem = 0;
 | ||
|                 foreach (DataRowView drv in GetGridViewFilteredAndSortedData(gridViewSeedsPick))
 | ||
|                 {
 | ||
|                     if (drv["seedsPickNo"].ToString().Equals(currentGoodsId)
 | ||
|                         && drv["batch"].ToString().Equals(currentGoodsBatch))
 | ||
|                     {
 | ||
|                         break;
 | ||
|                     }
 | ||
|                     selectedGoodsItem++;
 | ||
|                 }
 | ||
|                 this.gridViewSeedsDetail.FocusedRowHandle = selectedGoodsItem;
 | ||
|  */
 | ||
|                 bindSeedsGoodsPickOrderTables();
 | ||
| 
 | ||
|                // if (lgOutPickDetail.Expanded)
 | ||
|                 {
 | ||
|                     showOrderPickDetail();
 | ||
|                 }
 | ||
| 
 | ||
|               //  bindBoxes();
 | ||
|             }
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 showErrorMsg(e.Message);
 | ||
|             }
 | ||
|          //   closeWaitForm();
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         void showOrderPickDetail()
 | ||
|         {
 | ||
|             if (string.IsNullOrEmpty(currentSeedsOrder))
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             try
 | ||
|             {
 | ||
|                 DataView dv =dsPickOrders.Tables[0].DefaultView;  
 | ||
|                 dv.RowFilter = string.Format("seedsPickNo = '{0}'",currentSeedsOrder);
 | ||
|                 DataTable dt = dv.ToTable(true, "pickOrderNo","orderState", "customerName", "custAddress");  
 | ||
|                 this.gridPickOrders.DataSource = dt.DefaultView;// pickClient.getOutRequestDetail(currentSeedsOrder).DefaultView;
 | ||
|             
 | ||
|                 
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 showErrorMsg(ex,ex.Message);
 | ||
|                 return;
 | ||
| 
 | ||
|             }
 | ||
|            
 | ||
|             initialGridView2Columns(gridViewPickOrders);
 | ||
|             //set pick details
 | ||
|          //   updatePickDetails();
 | ||
|         }
 | ||
|         private void bindSeedsGoodsPickOrderTables()
 | ||
|         {   
 | ||
|             //set seeds goods details for current seeds order
 | ||
| 
 | ||
|           /*
 | ||
|             //set sales order details
 | ||
|             DataView dv = dsPickOrders.Tables[0].DefaultView;  //v_stockOutPickDetailValidation
 | ||
|           //  dv.Sort = "orderNo ASC";
 | ||
|            // this.currentGoodsId = currentGoodsDetail.goodsId;
 | ||
|            // this.currentGoodsBatch = currentGoodsDetail.batch;
 | ||
|          //   dv.RowFilter = string.Format("seedsPickNo = '{2}' and goodsId ='{0}' and batch ='{1}' and bulkcount > confirmedcount ", currentGoodsId, currentGoodsBatch,currentSeedsOrder);
 | ||
|             dv.RowFilter = string.Format("seedsPickNo = '{2}' and goodsId ='{0}' and batch ='{1}' ", currentGoodsId, currentGoodsBatch, currentSeedsOrder); 
 | ||
| 
 | ||
|              dtPickOrders4Validation = dv.ToTable();
 | ||
|           
 | ||
|           //  DataView dv1 = dtPickOrders4Validation.DefaultView;
 | ||
|          //   dv1.RowFilter = string.Format("bulkCount>0 and bulkPickState <{0}", (int)enumOutStockPickStatus.分拣完成);  
 | ||
|           //  dtPickOrders4Validation = dv1.ToTable();
 | ||
|             dtPickOrders4Validation.PrimaryKey = new DataColumn[] { dtPickOrders4Validation.Columns["id"] };
 | ||
|             this.gridControlPickOrders.DataSource = dv;
 | ||
|            // initialGridView2Columns(this.gridViewPickOrders4valid);
 | ||
|           //  btnPrint.Enabled = dtPickOrders4Validation.Rows.Count == 0 ;//&& dtPickOrdersValidated.Select("bulkpickstate < " + (int)enumOutStockPickStatus.复核完成).Length ==0;
 | ||
|             */
 | ||
|             WmsConstants.CURRENT_SEEDS_NO = currentSeedsOrder;
 | ||
|             WmsConstants.CURRENT_SEEDS_GOODSID = currentGoodsId;
 | ||
|             WmsConstants.CURRENT_SEEDS_GOOD_BATCH = currentGoodsBatch;
 | ||
|              
 | ||
|             //lbPickOrderNo.Text = currentWave;// currentSeedsOrder;
 | ||
|             
 | ||
|             showWaitForm();
 | ||
|             DataSet ds = pickClient.getSeedsLightData(currentSeedsOrder, currentGoodsId, currentGoodsBatch);
 | ||
|            
 | ||
|             //closeClient();
 | ||
|             closeWaitForm();
 | ||
|             dtSeedsLight = ds.Tables[0];
 | ||
|             dtPickOrders4Validation = ds.Tables[1];
 | ||
|             dtPickOrders4Validation.PrimaryKey = new DataColumn[] { dtPickOrders4Validation.Columns["id"] };
 | ||
|             this.gridControlPickOrders.DataSource = dtPickOrders4Validation.DefaultView;
 | ||
|             updatePickDetails();
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         
 | ||
|           
 | ||
|         private void btnPickOrders_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             clearDetails();
 | ||
|             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 = "";
 | ||
|             selectedGoodsItem = -1;
 | ||
|             currentGoodsDetail = null;
 | ||
|             lbGoodsName.Text ="";
 | ||
|              
 | ||
|             this.lbManufacturer.Text = "";
 | ||
|             this.lbPickCount.Text = "";
 | ||
|             this.lbSaleCount.Text = "";
 | ||
|             this.textEditValidCount.Text = "";
 | ||
|             this.textEditValidtionRemark.Text = "";
 | ||
|             this.comValidException.SelectedIndex = -1;
 | ||
|              
 | ||
|             this.lbType.Text = "";
 | ||
|             this.lbUnit.Text = "";
 | ||
|             this.checkEditPass.Checked = false;
 | ||
|             textEditBarcode.Text = "";
 | ||
|             this.btnValidateItem.Enabled = false;
 | ||
|             textEditBarcode.BackColor = textEditValidCount.BackColor; ;
 | ||
|             gridControlPickOrders.DataSource = null;
 | ||
|             if (dtPickOrders4Validation != null)
 | ||
|             {
 | ||
|                 dtPickOrders4Validation.Rows.Clear();
 | ||
|             }
 | ||
| 
 | ||
|             foreach (LotAtt la in SKUs.Keys)
 | ||
|             {
 | ||
|                 SKUs[la].Text = "";
 | ||
| 
 | ||
|             }
 | ||
|         }
 | ||
|        
 | ||
|         //exception 
 | ||
|         int selectedExceptionItem = -1;
 | ||
|         private void gridViewException_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | ||
|         {
 | ||
|             if (this.gridViewException.FocusedRowHandle < 0 || gridViewException.FocusedRowHandle == selectedExceptionItem)
 | ||
|             {
 | ||
|                 if (gridViewException.IsGroupRow(e.RowHandle)) //set first row of group selected
 | ||
|                 {
 | ||
|                     selectedExceptionItem = gridViewException.GetChildRowHandle(e.RowHandle, 0);
 | ||
|                   //  setCurrentExceptionDetail(); 
 | ||
|                 } 
 | ||
|                  return;
 | ||
|                  
 | ||
|             }
 | ||
|             selectedExceptionItem = gridViewException.FocusedRowHandle;
 | ||
|            // setCurrentExceptionDetail(); 
 | ||
|  
 | ||
|         }
 | ||
|         /*
 | ||
|         private void setCurrentExceptionDetail()
 | ||
|         {
 | ||
| 
 | ||
|             if (selectedExceptionItem < 0 || selectedExceptionItem >= dtExceptionSolutions.Rows.Count)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|             //DataRow dr = this.dtExceptionSolutions.Rows[selectedExceptionItem];
 | ||
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridViewException)[selectedExceptionItem]);
 | ||
|             if (dr != null)
 | ||
|             {
 | ||
|                 this.currentSeedsOrder = dr["pickOrderNo"].ToString();
 | ||
|                 isDataSourceChanged = true;
 | ||
|                 loadSeedsOrders();
 | ||
|                 this.setCurrentSeedsRequestGoodsList();
 | ||
|                 this.switchGridViewRowSelection(gridViewException, true);
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 showErrorMsg("no record found");
 | ||
|             } 
 | ||
|         }
 | ||
|         */
 | ||
| 
 | ||
|         // gridViewSeedsDetail  待播商品列表
 | ||
| 
 | ||
|         int selectedGoodsItem = -1;
 | ||
|         private void gridViewSeedsGoodsDetail_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | ||
|         {
 | ||
|             if(isKeyIn)
 | ||
|             if (isGoodsSourceChanged)
 | ||
|             {
 | ||
|                 isGoodsSourceChanged = false;
 | ||
|                 return;
 | ||
|             }
 | ||
|             if (this.gridViewSeedsGoods.FocusedRowHandle < 0 || gridViewSeedsGoods.FocusedRowHandle == selectedGoodsItem)
 | ||
|             {
 | ||
|                 if (gridViewSeedsGoods.IsGroupRow(e.RowHandle)) //set first row of group selected
 | ||
|                 {
 | ||
|                     selectedGoodsItem = gridViewSeedsGoods.GetChildRowHandle(e.RowHandle, 0);
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     return;
 | ||
|                 }
 | ||
|             }
 | ||
|             selectedGoodsItem = gridViewSeedsGoods.FocusedRowHandle >= 0 ? gridViewSeedsGoods.FocusedRowHandle : selectedGoodsItem;  
 | ||
|             setCurrentValidationDetail();
 | ||
|          
 | ||
|         }
 | ||
|         private void setCurrentValidationDetail()
 | ||
|         {
 | ||
|             if (!gridSeedsGoods.IsFocused)
 | ||
|             {
 | ||
|               //  return;
 | ||
|             }
 | ||
|             if (isKeyIn)
 | ||
|             {
 | ||
|                 isKeyIn = false;
 | ||
|                // return;
 | ||
|             }
 | ||
|             if (selectedGoodsItem < 0 || selectedGoodsItem >= dtSeedsGoods.Rows.Count)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|       
 | ||
|            
 | ||
| 
 | ||
|          //   DataRow dr = dtPickOrders4Validation.Rows[selectedValidationItem];
 | ||
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridViewSeedsGoods)[selectedGoodsItem]);
 | ||
|            
 | ||
|             //待播商品明细
 | ||
|               setValidataDetail(dr.Row);
 | ||
|             //待播商品对应的分拣单列表
 | ||
| 
 | ||
|              bindSeedsGoodsPickOrderTables();
 | ||
| 
 | ||
|             
 | ||
|              
 | ||
|         }
 | ||
| 
 | ||
|         void setValidataDetail(DataRow dr)
 | ||
|         {
 | ||
|             textEditBarcode.BackColor = textEditValidCount.BackColor; ;
 | ||
|             if (isDoubleChk)
 | ||
|             {
 | ||
|                 if (string.IsNullOrEmpty(txtAccount.Text) || string.IsNullOrEmpty(txtPasswd.Text.Trim()))
 | ||
|                 {
 | ||
|                     showErrorMsg("重点商品,需要双人验收!");
 | ||
|                     this.txtAccount.Focus();
 | ||
|                     return;
 | ||
|                 }
 | ||
| 
 | ||
|                 if (!checkPermission(WmsConstants.SPECIAL_AUTHS_DOUBLE_CHECK))
 | ||
|                 {
 | ||
|                     showErrorMsg(LoginInfo.Account + " 权限不足,需要特殊权限:" + WmsConstants.SPECIAL_AUTHS_DOUBLE_CHECK);
 | ||
|                     return;
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|                 WmsConstants.CHECKED_BY_2_ID = checkPermission(txtAccount.Text, txtPasswd.Text, WmsConstants.SPECIAL_AUTHS_DOUBLE_CHECK);
 | ||
|                 if (WmsConstants.CHECKED_BY_2_ID < 0)
 | ||
|                 {
 | ||
|                     showErrorMsg(txtAccount.Text + " 权限不足,需要特殊权限:" + WmsConstants.SPECIAL_AUTHS_DOUBLE_CHECK);
 | ||
|                     return;
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
|           //  if (currentGoodsDetail != null && currentGoodsDetail.ID == Convert.ToInt32(dr["id"].ToString()))
 | ||
|             if (currentGoodsDetail != null && currentGoodsDetail.goodsId ==  dr["goodsId"].ToString()
 | ||
|                                            && currentGoodsDetail.batch == dr["batch"].ToString())
 | ||
|             {
 | ||
|                 textEditBarcode.Text = dr[WmsGoods.exfields.barcode.ToString()].ToString();
 | ||
|                 textEditBarcode.Focus();
 | ||
|                 textEditBarcode.SelectAll();
 | ||
|                 return;
 | ||
|             }
 | ||
|             currentGoodsDetail = new WmsOutPickDetail_tmp(dr);
 | ||
|             this.currentGoodsId = currentGoodsDetail.goodsId;
 | ||
|             this.currentGoodsBatch = currentGoodsDetail.batch;
 | ||
|             this.currentSkuId = currentGoodsDetail.skuId;
 | ||
|             deskPort = Convert.ToByte( currentGoodsDetail.seedsPort);
 | ||
|             WmsConstants.CURRENT_SEEDS_GOOD_SKUID = currentGoodsDetail.skuId;
 | ||
|           //  WmsConstants.CURRENT_SEEDS_LABLE_ID = currentGoodsDetail.seedsLabelId;
 | ||
|             lbGoodsName.Text = dr[WmsGoods.exfields.goodsName.ToString()].ToString(); ;
 | ||
|            
 | ||
|             this.lbManufacturer.Text = dr[WmsGoods.exfields.manufacturer.ToString()].ToString(); 
 | ||
|             this.lbPickCount.Text = dr[WmsOutPickDetail.fields.bulkCount.ToString()].ToString();
 | ||
|             int i= this.lbPickCount.Text.IndexOf(".");
 | ||
|             if (i > 0)
 | ||
|             {
 | ||
|                 this.lbPickCount.Text = this.lbPickCount.Text.Substring(0, i);
 | ||
|             }
 | ||
|             this.lbSaleCount.Text = dr[WmsOutPickDetail.fields.bulkCount.ToString()].ToString();
 | ||
|             this.textEditValidCount.Text = dr[WmsOutPickDetail.fields.confirmedCount.ToString()].ToString();
 | ||
|             this.textEditValidtionRemark.Text = dr[WmsOutPickDetail.fields.validRemark.ToString()].ToString();
 | ||
| 
 | ||
|             isDoubleChk = "Y".Equals(dr["isDouChk"].ToString().Trim());
 | ||
|             //isDoubleChk = true;
 | ||
|             lgDoulbeChk.Visibility = isDoubleChk ? DevExpress.XtraLayout.Utils.LayoutVisibility.Always
 | ||
|             : DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
 | ||
|             WmsConstants.CHECKED_BY_2_ID = 0;
 | ||
|             
 | ||
| 
 | ||
|            // this.textEditBarcode.Text = dr["barCode"].ToString();
 | ||
|             try
 | ||
|             {
 | ||
|                 string tmp = dr[WmsOutPickDetail.fields.validReason.ToString()].ToString();
 | ||
|                 if (string.IsNullOrEmpty(tmp))
 | ||
|                 {
 | ||
|                     this.comValidException.SelectedIndex = 0;
 | ||
| 
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     int validReason = Convert.ToInt16(tmp);
 | ||
|                     validReason = validReason > 0 ? validReason : 0;
 | ||
|                     if (validReason > 0)
 | ||
|                     {
 | ||
| 
 | ||
|                       DataRow ndr =  Park.getDictionary().Rows.Find(validReason);
 | ||
| 
 | ||
|                       Node n = new Node(ndr);
 | ||
| 
 | ||
| 
 | ||
|                         foreach (Node cc in comValidException.Properties.Items)
 | ||
|                         {
 | ||
| 
 | ||
|                             if (cc.ID == n.ID)
 | ||
|                             {
 | ||
|                                 comValidException.SelectedItem = cc;
 | ||
|                                 break;
 | ||
|                             }
 | ||
| 
 | ||
| 
 | ||
|                         }
 | ||
| 
 | ||
|                     }
 | ||
|                     else
 | ||
|                     {
 | ||
|                         this.comValidException.SelectedIndex = 0;
 | ||
|                     }
 | ||
| 
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|                 
 | ||
|             }
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 this.comValidException.SelectedIndex = 0;
 | ||
|             }
 | ||
|             createSKUinputs(currentGoodsDetail.goodsId, currentGoodsDetail.skuId);
 | ||
| 
 | ||
|             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["orderState"].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 updateLableStatus(DataTable dt = null)
 | ||
|         {
 | ||
|             if (!WmsConstants.OUT_LIGHT_ENABLE)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             string key = "";
 | ||
| 
 | ||
|             if (dt != null)
 | ||
|             {
 | ||
|                 foreach (DataRow dr in dt.Rows)
 | ||
|                 {
 | ||
| 
 | ||
|                     if (dr["state"].ToString().Equals("1"))
 | ||
|                     {
 | ||
|                         key = Util.getLightKey(Convert.ToInt16(dr["color"].ToString()), Convert.ToInt16(dr["elabId"].ToString()), Convert.ToInt16(dr["elabAddress"].ToString()));
 | ||
| 
 | ||
|                         WmsConstants.WAVE_CURRENT_PICK_STATUS[key] = true;
 | ||
| 
 | ||
|                     }
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|             if (dtPickOrders4Validation == null || dtPickOrders4Validation.Rows.Count == 0)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|         //    WmsOutPickLable label;
 | ||
| 
 | ||
|           //  DataView dv = dtPickOrders4Validation.DefaultView; 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|             foreach (DataRow dr in dtPickOrders4Validation.Rows)
 | ||
|             {
 | ||
|                
 | ||
|                key = Util.getLightKey(desk, Convert.ToInt16(dr["seedsLabelId"].ToString()), WmsConstants.CURRENT_SEEDS_GOOD_SKUID);
 | ||
|                if (WmsConstants.SEEDS_CURRENT_PICK_STATUS.ContainsKey(key)
 | ||
|                     && WmsConstants.SEEDS_CURRENT_PICK_STATUS[key])
 | ||
|                 {
 | ||
|                     dr["bulkPickState"] = (int)enumOutStockDetailStatus.复核完成; 
 | ||
|                     seedsGoodItemValided();
 | ||
|                   //  setCurrentSeedsRequestGoodsList();
 | ||
|                     break;
 | ||
|                 }
 | ||
|                 
 | ||
|             }
 | ||
|             // dv.RowFilter = ""; // 如果   dv.RowFilter ="isPicked =0"; 则已拣的不再显示
 | ||
|            
 | ||
|             gridControlPickOrders.DataSource = dtPickOrders4Validation.DefaultView;
 | ||
|     
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         private void textEditBarcode_EditValueChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|            
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void btnValidateItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             validation();
 | ||
|               
 | ||
|         }
 | ||
|         
 | ||
|         private void validation()
 | ||
|         {
 | ||
|             if (currentGoodsDetail == null)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|             currentGoodsDetail.bulkPickState = checkEditPass.Checked ? (int)enumOutStockPickStatus.复核完成 : (int)enumOutStockPickStatus.复核异常;
 | ||
|             currentGoodsDetail.validRemark = textEditValidtionRemark.Text.Trim();
 | ||
|             currentGoodsDetail.validReason = ((Node)comValidException.SelectedItem).ID;
 | ||
|             currentGoodsDetail.confirmedCount = Convert.ToDecimal(textEditValidCount.Text.Trim());
 | ||
|             updateValidationItem();
 | ||
|             //Thread updateValidation = new Thread(updateValidationItem);
 | ||
|             //updateValidation.IsBackground = true;
 | ||
|             //updateValidation.Start();
 | ||
| 
 | ||
| 
 | ||
|             DataRow dr = this.dtSeedsGoods.Rows.Find(currentGoodsDetail.ID); //TODO: ystem.ArgumentException: 被编制索引的键需要 2 个值,但收到了 1 个值。
 | ||
|             if (dr != null)
 | ||
|             {
 | ||
|                 dr[WmsOutPickDetail.fields.validReason.ToString()] = currentGoodsDetail.validReason;
 | ||
|                 dr["bulkPickState"] = currentGoodsDetail.bulkPickState;
 | ||
|                 dr["validResult"] = this.comValidException.Text ;
 | ||
|                 dr[WmsOutPickDetail.fields.validRemark.ToString()] = this.textEditValidtionRemark.Text;
 | ||
|                 dr[WmsOutPickDetail.fields.confirmedCount.ToString()] = currentGoodsDetail.confirmedCount;
 | ||
| 
 | ||
|             }
 | ||
|             bindSeedsGoodsPickOrderTables();
 | ||
|              
 | ||
|         }
 | ||
|         private void updateValidationItem()
 | ||
|         {
 | ||
|             if (currentGoodsDetail == null)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             try
 | ||
|             {
 | ||
|                 bool b = this.pickClient.updateValidBulkPickStatus(currentGoodsDetail.ID, currentGoodsDetail.bulkPickState,
 | ||
|                     currentGoodsDetail.validRemark, currentGoodsDetail.validReason, 
 | ||
|                     currentGoodsDetail.confirmedCount,0);
 | ||
|                // closeClient();
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 closeClient();
 | ||
|                 showErrorMsg(ex,ex.Message);
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|             //  currentDetail.Update();
 | ||
|         }
 | ||
| 
 | ||
|         private void gridView4Valid_KeyDown(object sender, KeyEventArgs e)
 | ||
|         {
 | ||
|             if(e.KeyCode == Keys.Enter){
 | ||
| 
 | ||
|               //  validation();
 | ||
|             }
 | ||
|         }
 | ||
|         delegate void loadNewCurrentWave();
 | ||
|         /// <summary>
 | ||
|         /// <summary>
 | ||
|         /// 点亮待拣选标签
 | ||
|         /// </summary>
 | ||
|         private void lightLabelsCurrentGoods()
 | ||
|         {
 | ||
| 
 | ||
|             //  lightLablesInSvc();
 | ||
| 
 | ||
|             //lightLabelsInWinformSvc();
 | ||
|  
 | ||
|             initialLabs();
 | ||
|             clearDisplay(dtSeedsLight);
 | ||
|             showWaitForm( );
 | ||
|             if (currentPort > 0)
 | ||
|             {
 | ||
|                 foreach (DataRow dr in dtSeedsLight.Rows)
 | ||
|                 {
 | ||
|                     dr["port"] = currentPort;   
 | ||
|                 }
 | ||
|             }
 | ||
| 
 | ||
|           //  string result = lightSeeds.lightsUp(dtSeedsLight, enumLabelPickType.seed);
 | ||
|             string result = light.lightsUp(dtSeedsLight, enumLabelPickType.seed);
 | ||
|             WmsConstants.SEEDS_CURRENT_PICK_STATUS.Clear();
 | ||
|             //#if DEBUG 
 | ||
|             closeWaitForm();
 | ||
|             if (!string.IsNullOrEmpty(result))
 | ||
|             { 
 | ||
|                 lbLightsState.Text = result;
 | ||
|             }
 | ||
|             //#endif
 | ||
|         }
 | ||
| 
 | ||
|         void clearDisplay(DataTable dt)
 | ||
|         {
 | ||
|            // pick.clear_dis(deskPort, Convert.ToByte(desk));
 | ||
|            // lightSeeds.initPort(enumLabelPickType.seed);
 | ||
|             light.clear_order(dt);
 | ||
|             lbLightsState.Text = "";
 | ||
|         }
 | ||
| 
 | ||
|         void initialLabs()
 | ||
|         {
 | ||
|             if (InvokeRequired)
 | ||
|             {
 | ||
|                 this.Invoke(new loadNewCurrentWave(delegate()
 | ||
|                 {
 | ||
|                     lbLightsState.Text = "连接正常";
 | ||
|                     light.initPort(enumLabelPickType.seed);
 | ||
|                     if (light.activeComports.Count == 0)
 | ||
|                     {
 | ||
|                         // lbLightsState.Text = "灯光设备连接错误";
 | ||
|                         // showErrorMsg("拣选设备连接错误,请检查设备连接");
 | ||
|                         //  return;
 | ||
|                     }
 | ||
| 
 | ||
|                 }));
 | ||
| 
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 lbLightsState.Text = "连接正常";
 | ||
|                 light.initPort(enumLabelPickType.seed);
 | ||
|                 if (light.activeComports.Count == 0)
 | ||
|                 {
 | ||
|                     // lbLightsState.Text = "灯光设备连接错误";
 | ||
|                     // showErrorMsg("拣选设备连接错误,请检查设备连接");
 | ||
|                     // return;
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
|         }
 | ||
|        protected new void gridview_GotFocus(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (sender == gridViewSeedsGoods)
 | ||
|             {
 | ||
|                 //grid4Valid.ForeColor = Color.Blue;
 | ||
|                // gridView4Valid.OptionsSelection.EnableAppearanceHideSelection = true;
 | ||
|                 if (this.dtPickOrders4Validation.Rows.Count == 0)
 | ||
|                 {
 | ||
|                     
 | ||
|                 }
 | ||
|              //   this.setCurrentValidationDetail();
 | ||
|                 switchGridViewRowSelection(gridViewSeedsGoods,true);
 | ||
|                
 | ||
|             }
 | ||
|             
 | ||
|             else
 | ||
|             {
 | ||
|                 switchGridViewRowSelection((GridView)sender, true);
 | ||
|             }
 | ||
|             
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|        void textBoxId_GotFocus(object sender, EventArgs e)
 | ||
|        {
 | ||
|            this.txtBoxId.Tag = true;    //设置标记              
 | ||
|            txtBoxId.SelectAll();   //注意1         
 | ||
|        }
 | ||
| 
 | ||
|        void textBoxId_MouseUp(object sender, MouseEventArgs e)
 | ||
|        {
 | ||
|            //如果鼠标左键操作并且标记存在,则执行全选             
 | ||
|            if (e.Button == MouseButtons.Left && txtBoxId.Tag != null && (bool)txtBoxId.Tag == true)
 | ||
|            {
 | ||
|                txtBoxId.SelectAll();
 | ||
|            }
 | ||
| 
 | ||
|            //取消全选标记              
 | ||
|            txtBoxId.Tag = false;
 | ||
|        }
 | ||
| 
 | ||
|         void textEditBarcode_MouseUp(object sender, MouseEventArgs e)
 | ||
|         {
 | ||
|             //如果鼠标左键操作并且标记存在,则执行全选             
 | ||
|             if (e.Button == MouseButtons.Left &&textEditBarcode.Tag!=null&& (bool)textEditBarcode.Tag == true)
 | ||
|             {
 | ||
|                 textEditBarcode.SelectAll();
 | ||
|             }
 | ||
| 
 | ||
|             //取消全选标记              
 | ||
|             textEditBarcode.Tag = false;
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         void textEditBarcode_GotFocus(object sender, EventArgs e)
 | ||
|         {
 | ||
|             textEditBarcode.Tag = true;    //设置标记              
 | ||
|             textEditBarcode.SelectAll();   //注意1         
 | ||
|         }
 | ||
|         bool isKeyIn = false;
 | ||
|         private void textEditBarcode_KeyDown(object sender, KeyEventArgs e)
 | ||
|         {
 | ||
|           
 | ||
| 
 | ||
|             if (e.KeyCode != Keys.Enter)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             string barcode = textEditBarcode.Text;
 | ||
| 
 | ||
|             if (string.IsNullOrEmpty(barcode))
 | ||
|             {
 | ||
| 
 | ||
| 
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|             if (barcode.StartsWith("H-"))//周转箱
 | ||
|             {
 | ||
|                 getDspOrderByBoxId(barcode);
 | ||
|                 // resetValidationDetails();
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|             if (string.IsNullOrEmpty(currentSeedsOrder))
 | ||
|             {
 | ||
|                 textEditBarcode.SelectAll();
 | ||
| 
 | ||
|                 return;
 | ||
|             }
 | ||
|             lastScanBarcode = barcode;
 | ||
|             textEditBarcode.BackColor = textEditValidCount.BackColor; ;
 | ||
|             isKeyIn = true;
 | ||
| 
 | ||
|            //  clearDetails();
 | ||
|              resetValidationDetails();
 | ||
|            //  getSeedsOrders4Validation();    
 | ||
|             //this.gridSeedsGoods.DataSource = null;
 | ||
|             //setCurrentSeedsRequestGoodsList();
 | ||
| 
 | ||
|             DataRow[] drs = this.dtSeedsGoods.Select(string.Format("barcode ='{0}'", barcode));
 | ||
|             //  GetGridViewFilteredAndSortedData(gridViewSeedsDetail)
 | ||
| 
 | ||
|             if (drs.Length == 0)
 | ||
|             {
 | ||
| 
 | ||
|                 //check validated 
 | ||
| 
 | ||
| 
 | ||
|                 resetValidationDetails();
 | ||
|                 return;
 | ||
|             }
 | ||
|             /*
 | ||
|             DataView dv = this.dtSeedsGoods.DefaultView;
 | ||
|             dv.RowFilter = string.Format("barcode ='{0}'", barcode);
 | ||
| 
 | ||
|             string state = dv[0]["bulkPickState"].ToString();
 | ||
|             */
 | ||
| 
 | ||
|             textEditBarcode.BackColor = textEditValidCount.BackColor;
 | ||
|             lllightbutton.Visibility = drs.Length > 1 ? DevExpress.XtraLayout.Utils.LayoutVisibility.Always:DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
 | ||
|             
 | ||
| 
 | ||
|             DataRow dr = drs[0];
 | ||
|             if (drs != null)
 | ||
|             {
 | ||
|                 // selectedGoodsItem = dtSeedsGoods.Rows.IndexOf(dr);
 | ||
|                 // DataRowView dr1 = (DataRowView)(GetGridViewFilteredAndSortedData(gridViewSeedsDetail)[selectedGoodsItem]);
 | ||
|                 selectedGoodsItem = 0;
 | ||
|                 foreach (DataRowView drv in GetGridViewFilteredAndSortedData(gridViewSeedsGoods))
 | ||
|                 {
 | ||
|                     if (drv["barcode"].ToString().Equals(barcode))
 | ||
|                     {
 | ||
|                         //if ( drs.Length==1 || Convert.ToInt16(drv["bulkPickState"].ToString()) < (int)enumOutStockPickStatus.复核完成)
 | ||
|                         break;
 | ||
| 
 | ||
|                     }
 | ||
|                     selectedGoodsItem++;
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
|             if (selectedGoodsItem >= 0 && dtSeedsGoods.Rows.Count > selectedGoodsItem)
 | ||
|             {
 | ||
|                 this.gridViewSeedsGoods.FocusedRowHandle = selectedGoodsItem;
 | ||
| 
 | ||
|                // gridViewSeedsDetail.Focus();
 | ||
|                 setCurrentValidationDetail();
 | ||
|               
 | ||
|                
 | ||
|                 if (drs.Length > 1)
 | ||
|                 {
 | ||
|                     textEditBarcode.BackColor = Color.OrangeRed;
 | ||
|                    
 | ||
|                 }else
 | ||
|                 if (!isDoubleChk || isDoubleChk && WmsConstants.CHECKED_BY_2_ID > 0)
 | ||
|                 {
 | ||
|                     lightLabelsCurrentGoods();
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         string tmpOrder = string.Empty;
 | ||
|         int boxcnt =3;
 | ||
|         int bagcnt =2;
 | ||
|         printIn reqportPrint = new printIn();
 | ||
|         private void btnPrint_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if( currentLabId > 0)
 | ||
|             {
 | ||
|                 printLabPack(currentLabId);
 | ||
|                 return;
 | ||
|             }
 | ||
|            
 | ||
|             try
 | ||
|             {
 | ||
|                 showWaitForm("正在打印");
 | ||
|                 DataView dv = dsPickOrders.Tables[2].DefaultView; // distinct pickOrderNo
 | ||
|                 dv.RowFilter = "dpsOrder='" + currentWave + "'";
 | ||
|                 DataTable dt = dv.ToTable(true, "pickOrderNo" ,"customerName", "seedsLabelId","desk");
 | ||
|                 dt.TableName = "tableSeedsPickOrders";
 | ||
| 
 | ||
|                 reqportPrint.printSeedsPickOrderCode(dt);
 | ||
|                 closeWaitForm();
 | ||
|             }
 | ||
|             catch (Exception er)
 | ||
|             {
 | ||
|                 showErrorMsg(er);
 | ||
|             }
 | ||
|             closeWaitForm();
 | ||
|         }
 | ||
| 
 | ||
|         
 | ||
| 
 | ||
|         void completeValidation()
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 
 | ||
|                 //pickClient.completeBulkValidation(tmpOrder, boxcnt, bagcnt, dtGoods);
 | ||
|                 pickClient.completeSeedsPack(tmpOrder, boxcnt, bagcnt);
 | ||
|               //  pickClient.completeSeedsPack(tmpOrder,0,0);
 | ||
|                 // closeClient();
 | ||
| 
 | ||
|                 //TODO: print bulk boxs\bags label
 | ||
|                 //t_tmsStock
 | ||
|                 printCodes(tmpOrder);
 | ||
| 
 | ||
|                 tryCnt = 0;
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 closeClient();
 | ||
|                 showErrorMsg(ex.Message);
 | ||
|             }
 | ||
|            // lgt.completeBulkValidation(currentPickOrder, dtPickOrdersValidated);
 | ||
|             
 | ||
|            // currentPickOrder = null;
 | ||
|         }
 | ||
|         private void printCodes(string orderNo)
 | ||
|         {
 | ||
|             DataTable dt = tmsClient.getTmsStockBulkDetail(orderNo);
 | ||
|              
 | ||
|             int k= dt.Rows.Count;
 | ||
|             if (k > 1)
 | ||
|             {
 | ||
|                 for (int i = 1; i < k; i++)
 | ||
|                 {
 | ||
|                  //   dt.Rows.RemoveAt(i); ;
 | ||
|                 }
 | ||
|             }
 | ||
|             reqportPrint.printBulkPackingNoStore(dt, boxcnt, bagcnt);
 | ||
|             tmsClient.deletTmsRec(orderNo);
 | ||
|             //closeClient();
 | ||
|             
 | ||
|         }
 | ||
|         private void textEditValidCount_EditValueChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (currentGoodsDetail == null)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             this.checkEditPass.Checked = textEditValidCount.Value == currentGoodsDetail.bulkCount; 
 | ||
|             if (textEditValidCount.Value != currentGoodsDetail.bulkCount)
 | ||
|             {
 | ||
|                
 | ||
|                 this.comValidException.SelectedIndex = -1;
 | ||
| 
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void comValidException_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             this.checkEditPass.Checked = comValidException.SelectedIndex == 0;
 | ||
|         }
 | ||
| 
 | ||
|         private void btnEndWave_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void GoodsOutValidationForm_FormClosing(object sender, FormClosingEventArgs e)
 | ||
|         {
 | ||
|             timer.Stop();
 | ||
|             timer.Close(); 
 | ||
|             closeClient();
 | ||
|         }
 | ||
| 
 | ||
|         
 | ||
| 
 | ||
|         private void lgOutPickDetail_CustomButtonChecked(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
 | ||
|         {
 | ||
|             this.gridPickOrders.DataSource = null;
 | ||
|            // gridPickDetails.DataSource = null;
 | ||
|         }
 | ||
| 
 | ||
|         private void lgOutPickDetail_CustomButtonUnchecked(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
 | ||
|         {
 | ||
|             showOrderPickDetail();
 | ||
|          
 | ||
|             
 | ||
|         }
 | ||
| 
 | ||
|      
 | ||
| 
 | ||
|         private void spinOrder_EditValueChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             refreshInterval = Convert.ToInt32(spinOrder.Value * 60);
 | ||
|         }
 | ||
| 
 | ||
|         string boxWave = "";
 | ||
|         int boxDesk = 0;
 | ||
|         void getDspOrderByBoxId(string box)
 | ||
|         {
 | ||
|             txtBoxId.Text= boxId = box;
 | ||
| 
 | ||
|             if (string.IsNullOrEmpty(boxId))
 | ||
|             {
 | ||
|                 boxWave = string.Empty;
 | ||
|                 boxDesk = 0;
 | ||
|                 getSeedsOrders4Validation();
 | ||
|                 return;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|             try
 | ||
|             {
 | ||
|                 DataTable dt = pickClient.getWaveDeskByBoxId(boxId);
 | ||
|               //  closeClient();
 | ||
| 
 | ||
|                 if (dt.Rows.Count == 0)
 | ||
|                 {
 | ||
|                     showErrorMsg("未找到该箱子的注册信息");
 | ||
|                     return;
 | ||
|                 }
 | ||
| 
 | ||
|                 boxWave = dt.Rows[0]["waveNo"].ToString();
 | ||
| 
 | ||
|                 boxDesk = Convert.ToInt16(dt.Rows[0]["terminal"].ToString());
 | ||
| 
 | ||
|                 if (boxDesk != desk)
 | ||
|                 {
 | ||
|                     showErrorMsg(string.Format("该箱子属于复核台{0}", boxDesk));
 | ||
|                     return;
 | ||
|                 }
 | ||
|                 
 | ||
|                 getSeedsOrders4Validation();
 | ||
|                 //free the box
 | ||
|               //  pickClient.setPlateFree(boxId);//仍保持容器的分播台、波次号等信息,将状态设为可用
 | ||
|               //  closeClient();
 | ||
|             
 | ||
| 
 | ||
| 
 | ||
|                 //loadPickOrders();
 | ||
| 
 | ||
|             }
 | ||
|             catch (Exception er)
 | ||
|             {
 | ||
| 
 | ||
|                 showErrorMsg(er, "");
 | ||
|             }
 | ||
|             closeWaitForm();
 | ||
|         }
 | ||
|         private void txtBoxId_KeyUp(object sender, KeyEventArgs e)
 | ||
|         {
 | ||
|             boxId = txtBoxId.Text.Trim();
 | ||
| 
 | ||
| 
 | ||
|             if (string.IsNullOrEmpty(boxId))
 | ||
|             {
 | ||
|                 boxWave = string.Empty;
 | ||
|                 boxDesk = 0;
 | ||
|             }
 | ||
| 
 | ||
|             if (e.KeyCode != Keys.Enter)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             getDspOrderByBoxId(boxId);
 | ||
|              
 | ||
|         }
 | ||
|         string boxId;
 | ||
|         Dictionary<LotAtt, Label> SKUs = new Dictionary<LotAtt, Label>();
 | ||
|         int lastLotId = 0;
 | ||
|         private void createSKUinputs(string goodsId, int skuId)
 | ||
|         {
 | ||
|             
 | ||
|             DataTable skuValues = null;
 | ||
|             DataTable lotAtts = null;
 | ||
|             using (LotServiceClient client = new LotServiceClient("BasicHttpBinding_ILotService",
 | ||
|            buildSvrAddress("LotService.svc")))
 | ||
|             {
 | ||
|                 try
 | ||
|                 {
 | ||
|                     showWaitForm();
 | ||
|                     lotAtts = client.getLotAtts(goodsId);
 | ||
|                     skuValues = client.querySkuValues(skuId);
 | ||
|                     closeWaitForm();
 | ||
|                 }
 | ||
|                 catch (Exception e)
 | ||
|                 {
 | ||
|                     closeWaitForm();
 | ||
|                     showErrorMsg(e, "出错了");
 | ||
|                     return;
 | ||
|                 }
 | ||
|             }
 | ||
| 
 | ||
|             List<LayoutControlItem> liSKU = new List<LayoutControlItem>();
 | ||
| 
 | ||
| 
 | ||
|             int pjCount = lotAtts.Rows.Count;
 | ||
| 
 | ||
|             if (pjCount == 0)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|             int lotId = Convert.ToInt16(lotAtts.Rows[0]["lotId"].ToString());
 | ||
| 
 | ||
|             if (lastLotId == lotId) //批次定义相同,不需从新创建sku控件
 | ||
|             {
 | ||
|                 foreach (LotAtt la in SKUs.Keys)
 | ||
|                 {
 | ||
|                     SKUs[la].Text = "";
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 lcgSKUGroup.BeginUpdate();
 | ||
|                 lcgSKUGroup.Clear();
 | ||
|                 lcgSKUGroup.Items.Clear();
 | ||
|                 SKUs.Clear();
 | ||
| 
 | ||
|                 LayoutControlItem lastItem = null;
 | ||
|                 int i = 0;
 | ||
|                 foreach (DataRow dr in lotAtts.Rows)
 | ||
|                 {
 | ||
| 
 | ||
|                     Label be;
 | ||
| 
 | ||
|                     LotAtt la = new LotAtt(dr);
 | ||
|                     enumLotAttType enLt = (enumLotAttType)la.attType;
 | ||
| 
 | ||
|                     be = new Label();
 | ||
| 
 | ||
|                     be.Name = "SKU" + la.ID;
 | ||
|                     be.TabIndex = 40 + (i * 8);
 | ||
|                     be.Font = new System.Drawing.Font("微软雅黑", 16F);
 | ||
|                     if (!la.isOptional)
 | ||
|                     {
 | ||
|                         be.ForeColor = Color.Red;
 | ||
|                     }
 | ||
| 
 | ||
| 
 | ||
|                     LayoutControlItem item = lcgSKUGroup.AddItem(la.attName, be) as LayoutControlItem;
 | ||
| 
 | ||
| 
 | ||
|                     item.MaxSize = new System.Drawing.Size(270, 44);
 | ||
|                     item.MinSize = new System.Drawing.Size(270, 44);
 | ||
|                     item.Name = "lci" + la.attName;
 | ||
|                     item.Padding = new DevExpress.XtraLayout.Utils.Padding(20, 2, 2, 2);
 | ||
|                     item.Size = new System.Drawing.Size(839, 44);
 | ||
|                     item.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
 | ||
|                     // this.layoutControlItem2.Text = "批次信息";
 | ||
|                     item.TextSize = new System.Drawing.Size(51, 14);
 | ||
| 
 | ||
|                     if (lastItem != null && i % 4 != 0)
 | ||
|                     {
 | ||
|                         item.Move(lastItem, DevExpress.XtraLayout.Utils.InsertType.Right);
 | ||
|                     }
 | ||
|                     lastItem = item;
 | ||
| 
 | ||
|                     SKUs.Add(la, be);
 | ||
|                     i++;
 | ||
| 
 | ||
|                 }
 | ||
|             }
 | ||
|             lcgSKUGroup.EndUpdate();
 | ||
|             lastLotId = lotId;
 | ||
| 
 | ||
|             foreach (LotAtt la in SKUs.Keys)
 | ||
|             {
 | ||
|                 Label be = SKUs[la];
 | ||
|                 DataRow[] drs = skuValues.Select(string.Format("attID ={0}", la.ID));
 | ||
|                 if (la.isList && la.listId > 0)
 | ||
|                 {
 | ||
|                     foreach (DataRow drr in drs)
 | ||
|                     {
 | ||
|                         DataRow[] drss = Park.getDictionary(false).Select(string.Format("ID ={0}", drr["value"].ToString()));
 | ||
|                         if (drss.Length > 0)
 | ||
|                             be.Text = drss[0]["name"].ToString();
 | ||
|                         break;
 | ||
| 
 | ||
|                     }
 | ||
| 
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
| 
 | ||
|                     if (drs.Length > 0)
 | ||
|                         be.Text = drs[0]["value"].ToString();
 | ||
| 
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|      
 | ||
| 
 | ||
|        //-----------------------------------------------------------------------
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         private void btnInitialCom_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             initialCom();
 | ||
|         }
 | ||
|         void initComs()
 | ||
|         {
 | ||
|             String[] Portname = System.IO.Ports.SerialPort.GetPortNames();
 | ||
| 
 | ||
|             combComs.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
 | ||
|             combComs.Properties.Items.Clear();
 | ||
|             ComboBoxItemCollection col = combComs.Properties.Items;
 | ||
|             col.BeginUpdate();
 | ||
| 
 | ||
|             oCom = System.Configuration.ConfigurationManager.AppSettings["Com"];
 | ||
|             int oldIndex = 0;
 | ||
|             try
 | ||
|             {
 | ||
| 
 | ||
|                 for (int i = 0; i < Portname.Length; i++)
 | ||
|                 {
 | ||
|                     //col.Add(i);
 | ||
|                     col.Add(Portname[i]);
 | ||
|                     if (!string.IsNullOrEmpty(oCom) && oCom == Portname[i])
 | ||
|                     {
 | ||
|                         oldIndex = i;
 | ||
|                     }
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|                 col.EndUpdate();
 | ||
|             }
 | ||
| 
 | ||
|             combComs.SelectedIndex = oldIndex;
 | ||
| 
 | ||
|             if (combComs.Properties.Items.Count > 0)
 | ||
|             {
 | ||
|                 initialCom();
 | ||
|             }
 | ||
|         }
 | ||
|         Dictionary<int, dnwms> activeComs = new Dictionary<int, dnwms>();
 | ||
|         dnwms activePort;
 | ||
|         int currentPort = 0;
 | ||
|         String oCom = "";
 | ||
|         void initialCom()
 | ||
|         {
 | ||
| 
 | ||
|             try
 | ||
|             {
 | ||
|                 int port = Convert.ToInt16(combComs.Text.Substring(3));
 | ||
|                 initialLabs();
 | ||
|                 resetLights();
 | ||
|                 if (activeComs.Keys.Contains(port))
 | ||
|                 {
 | ||
|                     if (String.IsNullOrEmpty(oCom) || !oCom.Equals(combComs.Text))
 | ||
|                     {
 | ||
|                         writeConfig("Com", combComs.Text);
 | ||
|                         oCom = combComs.Text;
 | ||
|                     }
 | ||
| 
 | ||
|                     currentPort = port;
 | ||
|                     this.lbComstatus.Text = string.Format(combComs.Text + " 打开{0}", "成功");
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     this.lbComstatus.Text = string.Format(combComs.Text + " 打开{0}", "失败");
 | ||
|                 }
 | ||
| 
 | ||
|             }
 | ||
|             catch (Exception e)
 | ||
|             {
 | ||
|                 this.lbComstatus.Text = string.Format(e.Message);
 | ||
|             }
 | ||
|             btnShowId.Enabled = currentPort > 0;
 | ||
|         }
 | ||
| 
 | ||
|         private void resetLights()
 | ||
|         {
 | ||
|             if (String.IsNullOrEmpty(combComs.Text))
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             int port = Convert.ToInt16(combComs.Text.Substring(3));
 | ||
|             if (Deiniu.win.elelab.coms.com_manage[port] == null)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             activePort = Deiniu.win.elelab.coms.com_manage[port].init_port;
 | ||
|             //activePort.check_state = true;
 | ||
|             if (light.resetDevice(port))
 | ||
|             {
 | ||
|                 activeComs[port] = activePort;
 | ||
| 
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void btnShowId_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (currentPort == 0)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             if (showId)
 | ||
|             {
 | ||
|                 light.displayLabels(currentPort);
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 light.clearLabels(currentPort);
 | ||
|             }
 | ||
|             showId = !showId;
 | ||
|         }
 | ||
| 
 | ||
|         private void swStatus_Toggled(object sender, EventArgs e)
 | ||
|         {
 | ||
| 
 | ||
|             try
 | ||
|             {
 | ||
|                 showWaitForm();
 | ||
|                 pickClient.setDeskAvailable(desk, !swStatus.IsOn);
 | ||
| 
 | ||
| 
 | ||
|             }
 | ||
|             catch (Exception er)
 | ||
|             {
 | ||
|                 showErrorMsg(er);
 | ||
|             }
 | ||
| 
 | ||
|             pickClient.Close();
 | ||
|             closeWaitForm();
 | ||
|            
 | ||
|         }
 | ||
| 
 | ||
|         void getDeskStatus()
 | ||
|         {
 | ||
| 
 | ||
|             try
 | ||
|             {
 | ||
|                 WmsOutDesk wod = new WmsOutDesk();
 | ||
|                 DataTable dtdesk = pickClient.getDeskByColor(desk);
 | ||
|                 pickClient.Close();
 | ||
|                 if (dtdesk.Rows.Count > 0)
 | ||
|                 {
 | ||
|                     wod = new WmsOutDesk(dtdesk.Rows[0]);
 | ||
|                 }
 | ||
| 
 | ||
|                 swStatus.IsOn = !wod.available;
 | ||
| 
 | ||
|             }
 | ||
|             catch (Exception er)
 | ||
|             {
 | ||
|                 showErrorMsg(er);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void GoodsOutSeedsForm_Load(object sender, EventArgs e)
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void gridViewSeedsDetail_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
 | ||
|         {
 | ||
|             if (gridViewSeedsGoods.FocusedRowHandle < 0 || gridViewSeedsGoods.FocusedRowHandle == selectedGoodsItem)
 | ||
|             {
 | ||
|                 return;
 | ||
|             }
 | ||
|             selectedGoodsItem = gridViewSeedsGoods.FocusedRowHandle;
 | ||
|             //this.gridViewSeedsDetail.FocusedRowHandle = selectedGoodsItem;
 | ||
| 
 | ||
|             // gridViewSeedsDetail.Focus();
 | ||
|             setCurrentValidationDetail();
 | ||
|         }
 | ||
| 
 | ||
|         private void bindPickDetails()
 | ||
|         {
 | ||
|             this.gridControlPkDetail.DataSource = dtPickDetails;
 | ||
|             try
 | ||
|             {
 | ||
|                 initialGridView3Columns(gridViewPickDetail);
 | ||
|             }
 | ||
|             catch { }
 | ||
|           
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void radioButton1_CheckedChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             rd2.Checked = !rd1.Checked;
 | ||
|             setOrderFilter();
 | ||
|         }
 | ||
|   
 | ||
| 
 | ||
|         private void rd2_CheckedChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             rd1.Checked = !rd2.Checked;
 | ||
|             setOrderFilter();
 | ||
|         }
 | ||
|         string filter = "seedsstatus=" + (int)enumOutStockRequestStatus.正在分拣;
 | ||
|         private void setOrderFilter()
 | ||
|         {
 | ||
|             //clearDetails();
 | ||
|             if (rd2.Checked)
 | ||
|             {
 | ||
|                 filter = "seedsstatus>" + (int)enumOutStockRequestStatus.正在分拣;
 | ||
|             }
 | ||
|             else if (rd1.Checked)
 | ||
|             {
 | ||
|                 filter = "seedsstatus=" + (int)enumOutStockRequestStatus.正在分拣;
 | ||
|             }
 | ||
|           //  getSeedsOrders4Validation();
 | ||
| 
 | ||
|         }
 | ||
|         private string getFilter()
 | ||
|         {
 | ||
|             setOrderFilter();
 | ||
|             return filter;
 | ||
|         }
 | ||
| 
 | ||
|         private void sbLight_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             lightLabelsCurrentGoods();
 | ||
|         }
 | ||
|     }
 | ||
| } |