997 lines
		
	
	
		
			32 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			997 lines
		
	
	
		
			32 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Data;
 | |
| using System.Drawing;
 | |
| using System.Text;
 | |
| using System.Linq;
 | |
| using System.Windows.Forms;
 | |
| using DevExpress.XtraBars;
 | |
| using DevExpress.XtraGrid.Views.Base;
 | |
| //using DeiNiu.wms.Logical;
 | |
| using DeiNiu.wms.Data;
 | |
| using DevExpress.XtraGrid.Columns;
 | |
|  
 | |
| using System.Threading;
 | |
| using DevExpress.XtraGrid.Views.Grid;
 | |
| using DevExpress.XtraEditors.DXErrorProvider;
 | |
| using DeiNiu.wms.Data.Model;
 | |
| using DevExpress.XtraEditors;
 | |
| using DevExpress.XtraEditors.Controls;
 | |
| using DeiNiu.Utils;
 | |
| using DeiNiu.wms.win.utils.print; 
 | |
| using DeiNiu.wms.win.ServiceReferenceStockOutPickRequest;
 | |
| using Deiniu.win.elelab;
 | |
| using DeiNiu.wms.win.ServiceReferenceStockOutRequest;
 | |
| using DeiNiu.wms.win.waveRuleService;
 | |
|  
 | |
| 
 | |
| namespace DeiNiu.wms.win
 | |
| {
 | |
|     public partial class GoodsSaleOutDetails : BasicRibbonForm
 | |
|     {
 | |
| 
 | |
|        
 | |
|         printIn reqportPrint = new printIn() ;
 | |
| 
 | |
|       //  lWmsStock ls = new lWmsStock();
 | |
|     //    lWmsOutPickRequest lgt = new lWmsOutPickRequest();
 | |
|         private string fieldName = WmsLocation.fields.locationId.ToString();
 | |
|         private string fieldGoodType = WmsLocation.fields.whGoodsType.ToString();
 | |
|         private string lastQuery = "";
 | |
|         string waveNo = "", lastWaveNo = "";
 | |
|         private DataTable dtRepOrders;
 | |
|         private int selectedRowIndex = -1;
 | |
|       
 | |
|         bool autoOrder;
 | |
|         int lightId = 0;
 | |
|         int comId = 1;
 | |
| 
 | |
|         public GoodsSaleOutDetails()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             try
 | |
|             {
 | |
|                 initialControls();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er);
 | |
|             }
 | |
|             //    loadData();
 | |
| 
 | |
|         }
 | |
|  
 | |
|         #region initialControls
 | |
|         private void initialControls()
 | |
|         {
 | |
|             setDatePiker(dateEditFrom, dateEditTo); 
 | |
|             initialComboBoxes();
 | |
|             initialPagerControls();
 | |
|             initialDataGrid();
 | |
|             initialQueryInput(); 
 | |
|             setValidationRule();
 | |
|            
 | |
|             initialChannelLight();
 | |
|            // searchLight();
 | |
|           //  swAutoOrder.IsOn = WmsConstants.AUTO_PICK_BATCH_PICK_ORDER;
 | |
| 
 | |
|         }
 | |
|         /// <summary>  
 | |
|         /// 分页控件产生的事件  
 | |
|         /// </summary>  
 | |
|         private int pager_EventPaging(DeiNiu.Controls.pager.EventPagingArg e)
 | |
|         {
 | |
|             selectedRowIndex = 0; //reset currentRowIndex
 | |
|             return loadData();
 | |
|         }
 | |
| 
 | |
|        
 | |
| 
 | |
|         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 = Utils.WmsConstants.PAGER_SIZE;//每页行数  
 | |
|             
 | |
|             #endregion
 | |
| 
 | |
|             
 | |
|             this.pager1.Bind();//绑定  
 | |
|         }
 | |
| 
 | |
|         private void initialDataGrid()
 | |
|         {
 | |
|             this.gridView3.IndicatorWidth = 80;
 | |
|             this.gridView3.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | |
|              gridView3.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
 | |
|               
 | |
|         }
 | |
|    
 | |
| 
 | |
|         private void initialComboBoxes()
 | |
|         {
 | |
|            
 | |
|   
 | |
|         }
 | |
|       
 | |
|         private void setValidationRule()
 | |
|         {
 | |
|           //  dxValidationProvider.SetValidationRule(comWarehouse, ValidationRules.notEmptyValidationRule);
 | |
|             //txtGoodType.Properties.MaxLength = 40;
 | |
|             //txtGoodDesc.Properties.MaxLength = 250;
 | |
|             //textEdit1.Properties.MaxLength = txtGoodType.Properties.MaxLength;
 | |
|         }
 | |
| 
 | |
|         private void initialQueryInput()
 | |
|         {
 | |
| 
 | |
|         }
 | |
|       
 | |
|         private void initialDataGridColumns(GridView gridView)
 | |
|         {
 | |
|             setupGridView(gridView, false);
 | |
|             //setupGridView(gridView2, false,false);
 | |
|             //setupGridView(gridView3, false,false);
 | |
|             //   gridviewGoodsType.PopulateColumns();
 | |
|             gridView.Columns.Clear();
 | |
|             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]); 
 | |
|             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
 | |
|             myCol0.Visible = false;
 | |
|             gridView.Columns.Add(myCol0);
 | |
|             GridColumn myCol1 = new GridColumn() { Caption = "波次号", Visible = true, FieldName = WmsWave.fields.waveNo.ToString() };
 | |
|             GridColumn myCol2 = new GridColumn() { Caption = "类型", Visible = true, FieldName = WmsWave.fields.type.ToString(),MinWidth=80 };
 | |
|             GridColumn myCol3 = new GridColumn() { Caption = "状态", Visible = true, FieldName = WmsWave.fields.state.ToString(), MinWidth = 60 };
 | |
|             GridColumn myCol4 = new GridColumn() { Caption = "时间", Visible = true, FieldName = "createtime", MinWidth = 120 }; 
 | |
| 
 | |
| 
 | |
|             gridView.Columns.Add(myCol1);
 | |
|             gridView.Columns.Add(myCol2); 
 | |
|             gridView.Columns.Add(myCol3); 
 | |
|             gridView.Columns.Add(myCol4);  
 | |
|  
 | |
|             //to show bottom scroll bar
 | |
|             gridView.OptionsView.ColumnAutoWidth = false;
 | |
|             gridView.BestFitColumns();
 | |
|             gridView.Focus();
 | |
| 
 | |
|             //if (gridView1 == gridView)
 | |
|             //{
 | |
|             //    this.gridView1.Focus(); ;
 | |
|             //}
 | |
| 
 | |
| 
 | |
|         //    initialGridView2Columns();
 | |
|         //    gridControl2.DataSource = null;
 | |
|         }
 | |
|         private void initialGridView2Columns(GridView gridview)
 | |
|         {
 | |
|             setupGridView(gridview, false, true, false);
 | |
|             gridview.FocusRectStyle = DrawFocusRectStyle.None;
 | |
|             //   gridviewGoodsType.PopulateColumns();
 | |
|             gridview.Columns.Clear();
 | |
|             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]); 
 | |
|             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
 | |
|             myCol0.Visible = false;
 | |
|             gridview.Columns.Add(myCol0);
 | |
|      
 | |
|             GridColumn myCol1 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = WmsGoods.exfields.goodsName.ToString() };
 | |
| 
 | |
|             GridColumn myCol2 = new GridColumn() { Caption = "商品编号", Visible = true, FieldName ="goods_id" }; 
 | |
| 
 | |
|             GridColumn myCol3 = new GridColumn() { Caption = "拣货数量", Visible = true, FieldName = "pickCount" };
 | |
|             GridColumn myCol4 = new GridColumn() { Caption = "单位", Visible = true, FieldName = WmsGoods.exfields.unit.ToString() };
 | |
|       
 | |
|             GridColumn myCol5 = new GridColumn() { Caption = "分拣单", Visible = true, FieldName = "pickOrder" };
 | |
|             
 | |
|             GridColumn myCol6 = new GridColumn() { Caption = "件数", Visible = true, FieldName = "boxcnt" };
 | |
|             GridColumn myCol7 = new GridColumn() { Caption = "客户", Visible = true, FieldName = "custor_name" };
 | |
|             
 | |
|             GridColumn myCol8 = new GridColumn() { Caption = "规格", Visible = true, FieldName = "spec" };  
 | |
|            
 | |
|             GridColumn myCol9 = new GridColumn() { Caption = "创建时间", Visible = true, FieldName = "createtime"  };
 | |
| 
 | |
|             GridColumn myCol10 = new GridColumn() { Caption = "订单号码", Visible = true, FieldName = "sale_order" };
 | |
|             GridColumn myCol11 = new GridColumn() { Caption = "售卖单位", Visible = true, FieldName = "minOperateUnit" };
 | |
| 
 | |
|             if (!chkSum.Checked)
 | |
|             {    
 | |
|                 gridview.Columns.Add(myCol7);
 | |
|                 gridview.Columns.Add(myCol10);
 | |
|               
 | |
|             
 | |
|             }
 | |
| 
 | |
|             gridview.Columns.Add(myCol1); 
 | |
|             gridview.Columns.Add(myCol2);
 | |
|             gridview.Columns.Add(myCol3);   
 | |
|             gridview.Columns.Add(myCol4);
 | |
|             gridview.Columns.Add(myCol8);
 | |
| 
 | |
|             gridview.Columns.Add(myCol6);
 | |
|             gridview.Columns.Add(myCol11);
 | |
| 
 | |
|             if (!chkSum.Checked)
 | |
|             {
 | |
|                
 | |
|                 gridview.Columns.Add(myCol9);
 | |
| 
 | |
|             }
 | |
| 
 | |
| 
 | |
| 
 | |
|             //to show bottom scroll bar
 | |
|             gridview.OptionsView.ColumnAutoWidth = false;
 | |
|             gridview.BestFitColumns();
 | |
|             //  gridView2.Focus();
 | |
|         }
 | |
|         
 | |
|         #endregion
 | |
| 
 | |
|         int lastState = 0, state = 0;
 | |
|         /// <summary>  
 | |
|         /// loading data
 | |
|         /// </summary>  
 | |
|         private int loadData()
 | |
|         { 
 | |
|             showWaitForm(); 
 | |
|             string  query ="";
 | |
|             try
 | |
|             { 
 | |
|                 query += (this.dateEditFrom.Text.Trim().Length == 0 ? "" : string.Format("{0} >= # '{1}';", "createtime", dateEditFrom.DateTime))
 | |
|                           + (this.dateEditTo.Text.Trim().Length == 0 ? "" : string.Format("{0} <= # '{1}';", "createtime", dateEditTo.DateTime)) 
 | |
|                           + (this.txtGoodsName.Text.Trim().Length == 0 ? "" : string.Format("{0} like # '%{1}%';", "goodsName", filtRiskChar(txtGoodsName.Text.Trim())))
 | |
|                           + (this.txtcustname.Text.Trim().Length == 0 ? "" : string.Format("{0} like # '%{1}%';", "custor_name", filtRiskChar(txtcustname.Text.Trim())))
 | |
|                         
 | |
|                           + (this.txtSaleNo.Text.Trim().Length == 0 ? "" : string.Format("{0} = # '{1}';", "sale_order", filtRiskChar(txtSaleNo.Text.Trim())))
 | |
|                         
 | |
|                            + (this.txtgoodsId.Text.Trim().Length == 0 ? "" : string.Format("{0} = # '{1}';", "goods_id", filtRiskChar(txtgoodsId.Text.Trim())))
 | |
|                            
 | |
|                           ;
 | |
|                         
 | |
|                 bool isQueryNotChanged = lastQuery.Equals(query);
 | |
| 
 | |
| 
 | |
|                 this.pager1.PageCurrent = lastState == state ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值
 | |
|                 this.pager1.PageCurrent = this.pager1.PageCurrent > 0 ? this.pager1.PageCurrent : 1;
 | |
|                 int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1);
 | |
|                 int end = (pager1.PageSize * pager1.PageCurrent);
 | |
| 
 | |
| 
 | |
|                 DataSet ds;
 | |
|                 if (chkSum.Checked)
 | |
|                 {
 | |
|                     ds = outClient.getPickOutDetailSum(query, start, end);
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     ds = outClient.getPickOutDetail(query, start, end);
 | |
|                 }
 | |
|               
 | |
|                 lastState =  state  ;
 | |
|                 closeClient();
 | |
|                 
 | |
| 
 | |
|         
 | |
|                 this.gridControl3.DataSource = ds.Tables[0];
 | |
|                 initialGridView2Columns(gridView3);
 | |
|               
 | |
|                 closeWaitForm();
 | |
|                 return Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString());
 | |
|                 
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e,e.Message);
 | |
|             }
 | |
| 
 | |
|             closeWaitForm();
 | |
|             return 0;// lgt.getRowCount(query);
 | |
|             // return lgt.GetGoodType.QueryCount(); 
 | |
| 
 | |
|         }
 | |
|  
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void bindDetail()
 | |
|         {
 | |
|             pager1.Bind();
 | |
|         }
 | |
|         private void setDataBack()
 | |
|         {
 | |
| 
 | |
| 
 | |
|         }
 | |
|         private bool validData()
 | |
|         {
 | |
|             bool isvalid = dxValidationProvider1.Validate();
 | |
| 
 | |
|             // MessageBox.Show("goodtype is " + txtGoodType.Text +", is valid ? " + isvalid);
 | |
| 
 | |
|             return isvalid;
 | |
|             //String gdtype = txtGoodType.Text.Trim();
 | |
|             //if (gdtype.Length == 0)
 | |
|             //{
 | |
| 
 | |
|             //    dxValidationProvider.Validate();
 | |
|             //    return false;
 | |
|             //} 
 | |
| 
 | |
|             //return true;
 | |
|         }
 | |
|          
 | |
|        
 | |
| 
 | |
|        
 | |
|        
 | |
|        
 | |
| 
 | |
|         private void clearInputs()
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         
 | |
|        bool isDataSourceChanged = false;
 | |
|      
 | |
|  
 | |
|         private void btnDelete_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         protected void query()
 | |
|         {
 | |
|             pager1.Bind(); //loadData();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void queryGoods()
 | |
|         {
 | |
| 
 | |
|             showWaitForm();
 | |
|             try
 | |
|             {
 | |
|                 query();// loadData();  
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e.Message);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 // WaitFormService.Close();
 | |
|                 closeWaitForm();
 | |
|                 bbQuery.Enabled = true;
 | |
|             }
 | |
| 
 | |
|         }
 | |
|          
 | |
|         private void bbQuery_ItemClick_1(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
|             this.bbQuery.Enabled = false;
 | |
|             queryGoods();
 | |
|         }
 | |
| 
 | |
|        
 | |
| 
 | |
|         private void updateObjects(List<WmsGoods> goods)
 | |
|         { 
 | |
|             showWaitForm();
 | |
|             //WaitFormService.Show(this); 
 | |
|             try
 | |
|             {
 | |
|              //   lgt.update(goods);
 | |
| 
 | |
|                 //get updated data 
 | |
|                 query();
 | |
| 
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e,e.Message);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 // WaitFormService.Close();
 | |
|                 closeWaitForm();
 | |
|              
 | |
|             }
 | |
|              
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private bool getCurrentObject()
 | |
|         {
 | |
|             if (selectedRowIndex <0 || selectedRowIndex >= DtGv.Rows.Count)
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
|            
 | |
|           //  DataRow currentRow = dt.Rows[selectedRowIndex];
 | |
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView3)[selectedRowIndex]);
 | |
|             waveNo = dr.Row[1].ToString();
 | |
|            
 | |
|             return true;
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
|        
 | |
| 
 | |
| 
 | |
|         private void btnQuery_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             queryGoods();
 | |
|         }
 | |
| 
 | |
|        
 | |
| 
 | |
| 
 | |
| 
 | |
|        private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
 | |
|         {
 | |
| 
 | |
| 
 | |
|            
 | |
| 
 | |
|                 if (e.Column.FieldName == WmsOutPickDetail.fields.batchPickState.ToString())
 | |
|                 {
 | |
|                     if (!pickStatus.ContainsValue(e.DisplayText))
 | |
|                     {
 | |
| 
 | |
|                         int display = -100;
 | |
|                         string disTxt = e.DisplayText;
 | |
| 
 | |
|                         try
 | |
|                         {
 | |
|                             display = Convert.ToInt16(e.DisplayText);
 | |
| 
 | |
|                             e.DisplayText = pickStatus[display];
 | |
| 
 | |
|                         }
 | |
|                         catch
 | |
|                         {
 | |
|                             return;
 | |
|                         }
 | |
|                     }
 | |
|                    // e.DisplayText = pickStatus.ContainsKey(display) ? pickStatus[display] : display+"";
 | |
| 
 | |
|                 }else if(e.Column.FieldName == WmsWave.fields.state.ToString()){
 | |
|                     if (!pickOrNot.ContainsValue(e.DisplayText))
 | |
|                     {
 | |
| 
 | |
|                         int display = -100;
 | |
|                         string disTxt = e.DisplayText;
 | |
| 
 | |
|                         try
 | |
|                         {
 | |
|                             display = Convert.ToInt16(e.DisplayText);
 | |
| 
 | |
|                             e.DisplayText = pickOrNot[display];
 | |
| 
 | |
|                         }
 | |
|                         catch
 | |
|                         {
 | |
|                             return;
 | |
|                         }
 | |
|                     }
 | |
|                    // e.DisplayText = pickOrNot.ContainsKey(display) ? pickOrNot[display] : display+"";  
 | |
|                 }
 | |
|                 else if (e.Column.FieldName == WmsWave.fields.type.ToString())
 | |
|                 {
 | |
|                     if (!enumStockRecordtype.ContainsValue(e.DisplayText))
 | |
|                     {
 | |
| 
 | |
|                         int display = -100;
 | |
|                         string disTxt = e.DisplayText;
 | |
| 
 | |
|                         try
 | |
|                         {
 | |
|                             display = Convert.ToInt16(e.DisplayText);
 | |
| 
 | |
|                             e.DisplayText = enumStockRecordtype[display];
 | |
| 
 | |
|                         }
 | |
|                         catch
 | |
|                         {
 | |
|                             return;
 | |
|                         }
 | |
|                     }
 | |
|                     // e.DisplayText = pickOrNot.ContainsKey(display) ? pickOrNot[display] : display+"";  
 | |
|                 }
 | |
|                 else if (e.Column.FieldName.ToLower().Contains("time"))
 | |
|                 {
 | |
|                     e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
 | |
|                 }
 | |
|                 else if (e.Column.FieldName == "productDate" || e.Column.FieldName == "validDate")
 | |
|                 {
 | |
|                     e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
 | |
|                 }
 | |
|                 else if (e.Column.FieldName == "createtime")
 | |
|                 {
 | |
|                     e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
 | |
|                 }
 | |
|             
 | |
|                 
 | |
|              
 | |
|         }
 | |
|        void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
 | |
|        {
 | |
|            //var currentView = sender as GridView;
 | |
|            //if (currentView != null && e.RowHandle == currentView.FocusedRowHandle) return;
 | |
|            Rectangle r = e.Bounds;
 | |
|            if (e.Column.FieldName == "state")
 | |
|            {
 | |
|                string a = e.CellValue.ToString();
 | |
|                string b = e.DisplayText;
 | |
|                if (b.Equals("未分配货位"))
 | |
|                {
 | |
|                    e.Appearance.ForeColor = Color.Red;
 | |
|                    e.Appearance.DrawString(e.Cache, e.DisplayText, r);
 | |
|                    e.Handled = true;
 | |
|                }
 | |
| 
 | |
|            }
 | |
|        }
 | |
| 
 | |
|        void gridView_RowCellStyle(object sender,DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
 | |
|        {
 | |
| 
 | |
|             var currentView = sender as GridView;
 | |
|            if( currentView == null){return;}
 | |
|            string state = "";
 | |
|            bool isGray = false;
 | |
|            bool isAlert = false;
 | |
|           
 | |
|            if (currentView == gridView3)
 | |
|             {
 | |
|                state = currentView.GetDataRow(e.RowHandle)["state"].ToString().Trim();
 | |
| 
 | |
| 
 | |
|                isGray = Convert.ToInt16(state) == (int)enumPickState.已拣;
 | |
| 
 | |
|               // isAlert = Convert.ToInt16(state) == (int)enumLabelPickState.notPicked;
 | |
|              }
 | |
|            else
 | |
|             {
 | |
|                 state = currentView.GetDataRow(e.RowHandle)["batchPickState"].ToString().Trim();
 | |
|                isGray = Convert.ToInt16(state) == (int)enumOutStockPickStatus.正在分拣;
 | |
|                 isAlert = Convert.ToInt16(state) == (int)enumOutStockPickStatus.复核异常;
 | |
|             }
 | |
|            /*
 | |
|            state = currentView.GetDataRow(e.RowHandle)["batchPickState"].ToString().Trim();
 | |
|            isGray = Convert.ToInt16(state) == (int)enumOutStockPickStatus.正在分拣;
 | |
|            isAlert = Convert.ToInt16(state) == (int)enumOutStockPickStatus.复核异常;
 | |
|            */
 | |
|            bool isFocused = e.RowHandle == currentView.FocusedRowHandle;
 | |
|            DevExpress.Utils.AppearanceDefault rowStyle = null;
 | |
|             DevExpress.Utils.AppearanceDefault appBlueRed = 
 | |
|                new DevExpress.Utils.AppearanceDefault (Color.White, Color.Red, Color.Empty, Color.Blue, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
 | |
|            DevExpress.Utils.AppearanceDefault appYB =
 | |
|             new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green);
 | |
| 
 | |
|            DevExpress.Utils.AppearanceDefault alertFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green,  Color.Yellow);
 | |
|            DevExpress.Utils.AppearanceDefault alert  = new DevExpress.Utils.AppearanceDefault(Color.Red, Color.White );
 | |
| 
 | |
|            DevExpress.Utils.AppearanceDefault passedFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Gray);
 | |
|            DevExpress.Utils.AppearanceDefault passed  = new DevExpress.Utils.AppearanceDefault(Color.Gray,Color.White);
 | |
| 
 | |
| 
 | |
| 
 | |
|            if (isGray)
 | |
|            {
 | |
|                rowStyle = isFocused ? passedFocus : passed;
 | |
|            }
 | |
|            else if (isAlert)
 | |
|            {
 | |
|                rowStyle = isFocused ? alertFocus : alert;
 | |
|            }
 | |
| 
 | |
| 
 | |
|            DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, rowStyle);
 | |
|            /*
 | |
|            if (sender == this.gridView2)
 | |
|            {
 | |
|                if (this.gridView2.GetDataRow(e.RowHandle)["state"].ToString().Trim() == "2")
 | |
|                {
 | |
|                    DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
 | |
|                }
 | |
|            }else if(sender == this.gridView1){
 | |
|                 
 | |
|                if ( state == "2")
 | |
|                {
 | |
|                    if (currentView != null && e.RowHandle == currentView.FocusedRowHandle)
 | |
|                    {
 | |
|                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alertFocus);
 | |
|                    }
 | |
|                    else
 | |
|                    {
 | |
|                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
 | |
|                    }
 | |
|                }
 | |
|                else if (state == "1")
 | |
|                {
 | |
|                    DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, passed);
 | |
|                } 
 | |
|            }
 | |
|            */
 | |
|        }
 | |
|      
 | |
|         private int setCurrentRequestDetail()
 | |
|         {
 | |
| 
 | |
|             if (!getCurrentObject() || String.IsNullOrEmpty(waveNo))
 | |
|             {
 | |
|                  this.gridControl3.DataSource = null;
 | |
|                 return 0;
 | |
|             }
 | |
|             /// gridView1.FocusedRowHandle = selectedRowIndex;//
 | |
|             //  gridView1.SelectRow(selectedRowIndex);
 | |
|             showWaitForm();
 | |
|  
 | |
|             try
 | |
|             {
 | |
|                 this.pager1.PageCurrent = lastWaveNo == waveNo ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值
 | |
|                 this.pager1.PageCurrent = this.pager1.PageCurrent > 0 ? this.pager1.PageCurrent : 1;
 | |
|                 int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1);
 | |
|                 int end = (pager1.PageSize * pager1.PageCurrent);
 | |
|                 lastWaveNo = waveNo;
 | |
|                 DataSet ds = pickClient.getTasks(waveNo, start, end);
 | |
|                 closeClient();
 | |
|                 this.gridControl3.DataSource = ds.Tables[0];
 | |
|                 initialGridView2Columns(gridView3);
 | |
|                // gridView1.Focus();
 | |
|                // this.selectedInvalidIndex = -1;
 | |
|                 closeWaitForm();
 | |
|                 return Convert.ToInt16( ds.Tables[1].Rows[0][0].ToString());
 | |
|                 
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {    closeWaitForm();
 | |
|                 showErrorMsg(e.Message);
 | |
|             }
 | |
|         
 | |
|             return 1;
 | |
|         }
 | |
| 
 | |
|         private void btnOut_Click(object sender, EventArgs e)
 | |
|         {
 | |
|           
 | |
|             showWaitForm();
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 if (String.IsNullOrEmpty(waveNo))//&& selectedRequest.batchPickState == (int)enumOutStockPickStatus.待处理)
 | |
|                 {
 | |
|                     pickClient.startBatchPick(waveNo); //startPickBatchPickOrder(selectedRequest.pickOrderNo);
 | |
|                     closeClient();
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                    // showErrorMsg(string.Format("出库异常,当前出库单状态是{0}",
 | |
|                    //     Enum.GetName(typeof(enumOutStockPickStatus), selectedRequest.batchPickState) ));
 | |
|                 }
 | |
| 
 | |
|              
 | |
|             //  reqportPrint.printStockOutCode(pickClient.getPickOrderTmsInfo(selectedRequest.pickOrderNo));
 | |
|                  
 | |
|              //   reqportPrint.printStockOutA4(pickClient.getBatchOutPickOrderPickDetails(selectedRequest.pickOrderNo));
 | |
|                 closeClient();
 | |
| 
 | |
|                 query();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 bindDetail();// setCurrentRequestDetail();
 | |
|                 showErrorMsg(er,er.Message);
 | |
|                 closeClient();
 | |
|             }
 | |
| 
 | |
|              
 | |
|           
 | |
| 
 | |
|             closeWaitForm();
 | |
|         }
 | |
| 
 | |
|         private void btnPrint_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (string.IsNullOrEmpty(waveNo))
 | |
|             {
 | |
|                 showErrorMsg("请选择波次记录");
 | |
|                 return;
 | |
|             }
 | |
|             try
 | |
|             {
 | |
|                 // reqportPrint.printStockOutCode(pickClient.getPickOrderTmsInfo("PICK060000026285"));
 | |
|                 reqportPrint.printStockOutCode(pickClient.getPickVolInfo(waveNo, (int)enumWhLocVol.小整),false); closeClient();
 | |
|                 reqportPrint.printStockOutCode(pickClient.getPickVolInfo(waveNo, (int)enumWhLocVol.中整),false); closeClient();
 | |
|                 reqportPrint.printStockOutCode(pickClient.getPickVolInfo(waveNo, (int)enumWhLocVol.大整),false); closeClient();
 | |
|                
 | |
|                 reqportPrint.printStockOutCode(pickClient.getPickSummary(waveNo, (int)enumWhLocVol.零库),false); closeClient();
 | |
| 
 | |
| 
 | |
| 
 | |
|                 closeClient();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er, er.Message);
 | |
|                 closeClient();
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void btnPrintReport_Click(object sender, EventArgs e)
 | |
|         { 
 | |
|             try
 | |
|             {
 | |
|                // reqportPrint.printStockOutA4(pickClient.getBatchOutPickOrderPickDetails(selectedRequest.pickOrderNo));
 | |
|                //  closeClient();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er, er.Message);
 | |
|                 closeClient();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void btnOutStockAll_Click(object sender, EventArgs e)
 | |
|         { 
 | |
|             showWaitForm();
 | |
|             foreach (DataRow dr in DtGv.Rows)
 | |
|             {
 | |
|                 WmsInRequest wi = new WmsInRequest(dr);
 | |
| 
 | |
|                 try
 | |
|                 {
 | |
|                      //lgt.requestInStock(wi);
 | |
|                   //  pickClient.requestInStock(wi.orderNo);
 | |
| 
 | |
|                 }
 | |
|                 catch (Exception er)
 | |
|                 {
 | |
| 
 | |
|                     showErrorMsg(er.Message);
 | |
|                 } 
 | |
|                 
 | |
|             }
 | |
| 
 | |
|             query();
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void GoodsInForm_FormClosing(object sender, FormClosingEventArgs e)
 | |
|         {
 | |
|            
 | |
|             closeClient();
 | |
|             closeChannelLight();
 | |
|             lightControl.exit_wms_sys();
 | |
|             
 | |
|         }
 | |
| 
 | |
|         
 | |
| 
 | |
|         private void btnForceClose_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             try
 | |
|             {
 | |
|                // if (pickClient.completeBatchOut(this.selectedRequest.pickOrderNo))
 | |
|                 {
 | |
|              //       MessageBox.Show("出库成功");
 | |
|                 }
 | |
|             //    else
 | |
|                 {
 | |
|               //      showErrorMsg("出库失败");
 | |
|                 }
 | |
|             //    closeClient();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er.Message);
 | |
|             }
 | |
| 
 | |
|             
 | |
|         }
 | |
| 
 | |
|          
 | |
| 
 | |
|         private void btnPickOrders_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             loadData();
 | |
|         }
 | |
| 
 | |
|       
 | |
| 
 | |
| 
 | |
|         dnwms lightControl = new dnwms();
 | |
|         private void initialChannelLight()
 | |
|         {  
 | |
|                 lightControl.check_state = true;
 | |
|                 lightControl.on_config_channel += new dnwms.config_channel(aa_on_config_channel);
 | |
|                 lightControl.on_close_channel += new dnwms.close_channel(aa_on_close_channel);
 | |
|                 lightControl.on_open_channel += new dnwms.open_channel(openChannelLightResult);
 | |
|                 lightControl.on_dis_event += new dnwms.receive_dis_data(aa_on_receidata_channel);
 | |
|               //  getLightId();
 | |
|         }
 | |
| 
 | |
|         private void openChannelLight()
 | |
|         {
 | |
|             Model.open_channel_led id;
 | |
|             id.channel_id = lightId;
 | |
|             //id.config_word = led_rgb;
 | |
|             id.state = 1;
 | |
|             lightControl.write_open_channel_led(id);//write_config_channel_led
 | |
|         }
 | |
| 
 | |
|         private void closeChannelLight()
 | |
|         {
 | |
|              Model.close_channel_led id;
 | |
|             id.channel_id =lightId;
 | |
|             //id.config_word = led_rgb;
 | |
|             
 | |
|             id.state = 1;
 | |
|             lightControl.write_close_channel_led(id);//write_config_channel_led
 | |
|         }
 | |
| 
 | |
|         private void openChannelLightResult( Model.open_channel_led data)
 | |
|         {
 | |
|        //     MessageBox.Show("打开通道灯 成功");
 | |
|         }
 | |
|         void aa_on_close_channel(Model.close_channel_led data)
 | |
|         {
 | |
|           //  MessageBox.Show("关闭通道灯 成功");
 | |
|             //throw new NotImplementedException();
 | |
|         }
 | |
|         void aa_on_config_channel(Model.config_channel_led data)
 | |
|         {
 | |
|           //  MessageBox.Show("配置 id = " + data.channel_id.ToString() + "配置字 = " + data.config_word.ToString() + " 成功 ");
 | |
|             //throw new NotImplementedException();
 | |
|         }
 | |
|         void aa_on_receidata_channel(Model.uart_dis_data[] dis_data)
 | |
|         {
 | |
|             //  MessageBox.Show("配置 id = " + data.channel_id.ToString() + "配置字 = " + data.config_word.ToString() + " 成功 ");
 | |
|             //throw new NotImplementedException();
 | |
|         }
 | |
| 
 | |
|         List<int> lights = new List<int>();
 | |
|         void searchLight()
 | |
|         {
 | |
|             Model.modify_id id;
 | |
|          
 | |
|             System.Threading.Thread.Sleep(50);
 | |
|             for (int i = 5000; i <= 5100; i++)
 | |
|             {
 | |
|                 id.order = 0;
 | |
|                 id.new_ele_id = 0;
 | |
|                 id.old_ele_id = i;
 | |
|                 id.state = 1;
 | |
|                bool ret = lightControl.search_light_id(id);
 | |
|                 if (ret)
 | |
|                 {
 | |
|                     //textBox6.Text = textBox6.Text + "搜索到通道灯:" + i.ToString() + "\r\n";
 | |
|                     //this.textBox6.Focus();//获取焦点
 | |
|                     //this.textBox6.Select(this.textBox6.TextLength, 0);//光标定位到文本最后
 | |
|                     //this.textBox6.ScrollToCaret();//滚动到光标处
 | |
|                     lights.Add(i);
 | |
|                     break;
 | |
|                    // System.Threading.Thread.Sleep(50);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         void getLightId()
 | |
|         {
 | |
|             for (int i = 0; i < 10; i++)//init com0-10
 | |
|             {
 | |
|                 comId = Convert.ToByte(i);
 | |
| 
 | |
|                 if (lightControl.init_wms_sys(comId))
 | |
|                 {
 | |
|                     lights.Clear();
 | |
|                     searchLight();
 | |
|                     if (lights.Count > 0)
 | |
|                     {
 | |
|                         lightId = lights[0];
 | |
|                         break;
 | |
|                     }
 | |
|                 }
 | |
|                 System.Threading.Thread.Sleep(10);
 | |
|             }
 | |
|           //  lbLightsInfo.Text = "";
 | |
|             if (lightId == 0)
 | |
|             {
 | |
|             //    lbLightsInfo.Text = "没找到出库指示灯,请确认出库灯正确连接并工作正常";
 | |
|                // MessageBox.Show("没找到出库指示灯,请确认出库灯正确连接并工作正常");
 | |
| 
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void updateLightColor(bool isAlert)
 | |
|         {
 | |
|              Model.config_channel_led id;
 | |
|          //   byte led_rgb = 0;
 | |
| 
 | |
|             byte blue = 2;
 | |
|             byte red = 0;
 | |
|              
 | |
|             id.channel_id = Convert.ToInt16(5000);
 | |
|             id.config_word = isAlert ? red : blue;// led_rgb;
 | |
|             id.state = 1;
 | |
|             this.lightControl .write_config_channel_led(id);//write_config_channel_led
 | |
|         }
 | |
| 
 | |
|     
 | |
|         void setRule()
 | |
|         {
 | |
|             
 | |
|         //    waveRule.lineId = comboLines.SelectedIndex <= 0 ? -1 : ((Node)comboLines.SelectedItem).ID;
 | |
|         //    waveRule.sales = comboSales.SelectedIndex <= 0 ? "" : comboSales.Text;
 | |
| 
 | |
|             try
 | |
|             {
 | |
|           //      pickClient.updateWaveRule(waveRule);
 | |
|         //        closeClient();
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e, "出错了");
 | |
| 
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 closeClient();
 | |
|             }
 | |
| 
 | |
| 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void comboLines_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             setRule();
 | |
|         }
 | |
| 
 | |
|         private void comboSales_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             setRule();
 | |
|         }
 | |
| 
 | |
|         private void simpleButton2_Click(object sender, EventArgs e)
 | |
|         {
 | |
|            // showWaitForm();
 | |
|           //  pickClient.createPDATasks();
 | |
|        //   bool res=  pickClient.createPickWaves();
 | |
|         //  MessageBox.Show(" create wave "+res);  
 | |
|        //   closeClient();
 | |
|         //  closeWaitForm();
 | |
|          // loadData();
 | |
|         }
 | |
| 
 | |
|      
 | |
|         private void btnDel_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
|             this.exportExcel(this.gridView3);
 | |
|         }
 | |
| 
 | |
|         private void btnQ_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             query();
 | |
|         }
 | |
| 
 | |
|         
 | |
|     }
 | |
| } |