999 lines
		
	
	
		
			33 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			999 lines
		
	
	
		
			33 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.ServiceReferenceInRequest; 
 | |
| //using DeiNiu.wms.win.ServiceReferenceInRequestLocal;
 | |
| using DeiNiu.wms.win.OrderService;
 | |
| using DeiNiu.wms.win.utils;
 | |
| using DeiNiu.wms.win.FlowService;
 | |
| 
 | |
| namespace DeiNiu.wms.win
 | |
| {
 | |
|     public partial class TaskCenter : BasicRibbonForm
 | |
|     {
 | |
|          
 | |
| 
 | |
|       //  lWmsStock ls = new lWmsStock();
 | |
|       //  lWmsInRequest lgt = new lWmsInRequest();
 | |
|         private string fieldName = WmsLocation.fields.locationId.ToString();
 | |
|         private string fieldGoodType = WmsLocation.fields.whGoodsType.ToString();
 | |
|         private string lastQuery = "";
 | |
|         private DataTable dt;
 | |
|         private DataTable DtGv;
 | |
|       //  DataTable dtIndetail;
 | |
|         private int selectedRowIndex = -1;
 | |
|         //to show in detail
 | |
|         int selectedAttIndex = -1;
 | |
|         string detailGoodsName;
 | |
|         decimal avCount = 0;
 | |
|         int selectedAttId;
 | |
|         int selectedAttDetailId = -1;
 | |
|         WcfWmsFlow wcfRequest; 
 | |
|         private bool isShowingInRequest = true;
 | |
|         public TaskCenter()
 | |
|         {
 | |
|          
 | |
|             InitializeComponent();
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                 initialControls();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg(er);
 | |
|             }
 | |
| 
 | |
|             //    loadData();
 | |
| 
 | |
|         }
 | |
|         #region initialControls
 | |
|         private void initialControls()
 | |
|         {
 | |
|             setDatePiker(dateEditFrom, dateEditTo); 
 | |
|             initialComboBoxes();
 | |
|             initialPagerControls();
 | |
|             initialDataGrid();
 | |
|             initialQueryInput(); 
 | |
|             setValidationRule();
 | |
|            
 | |
| 
 | |
| 
 | |
|         }
 | |
|         private void initialComboBoxes()
 | |
|         { 
 | |
|             initialComboBoxs(comTypeQ, taskType,true);
 | |
|             
 | |
|             initialComboBoxs(comStatusQ, taskStatus, true);
 | |
|             
 | |
|         }
 | |
|       
 | |
|         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)
 | |
|         {
 | |
|             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);
 | |
|             setupGridView(gridView, false);
 | |
|             
 | |
|             GridColumn myCol1 = new GridColumn() { Caption = "容器号", Visible = true, FieldName = "flowNo" };
 | |
|             GridColumn myCol2 = new GridColumn() { Caption = "商品ID", Visible = true, FieldName = "goodsId" };
 | |
|             GridColumn myCol3 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = "goodsName",MaxWidth=120 };
 | |
|             GridColumn myCol4 = new GridColumn() { Caption = "生产日期", Visible = true, FieldName = "productDate" };
 | |
|             GridColumn myCol5 = new GridColumn() { Caption = "失效日期", Visible = true, FieldName = "validDate" };
 | |
|             GridColumn myCol6 = new GridColumn() { Caption = "任务数量", Visible = true, FieldName = "count" };
 | |
|             GridColumn myCol61 = new GridColumn() { Caption = "任务件数", Visible = true, FieldName = "box" };
 | |
|             GridColumn myCol7 = new GridColumn() { Caption = "完成数量", Visible = true, FieldName = "finishedCount" };
 | |
|             GridColumn myCol8 = new GridColumn() { Caption = "sku", Visible = true, FieldName = "skuId" };
 | |
|           //  GridColumn myCol9 = new GridColumn() { Caption = "分区", Visible = true, FieldName = "partName" };
 | |
|             GridColumn myCol10 = new GridColumn() { Caption = "货位", Visible = true, FieldName = "locationId" };
 | |
|             GridColumn myCol12 = new GridColumn() { Caption = "单位", Visible = true, FieldName = "unit" };
 | |
|             GridColumn myCol13 = new GridColumn() { Caption = "规格", Visible = true, FieldName = "spec" };
 | |
|             //   GridColumn myCol11 = new GridColumn() { Caption = "客户", Visible = true, FieldName = "custName" };
 | |
|             GridColumn myCol92 = new GridColumn() { Caption = "时间", Visible = true, FieldName = "createtime", MinWidth = 140 };
 | |
| 
 | |
|             if (gridView == gridView1)
 | |
|             {
 | |
|                 GridColumn myCol21 = new GridColumn() { Caption = "任务", Visible = true, FieldName = "task", MinWidth = 80 };
 | |
|                 GridColumn myCol31 = new GridColumn() { Caption = "单号", Visible = true, FieldName = "orderNo" ,MinWidth=80};
 | |
|                 GridColumn myCol41 = new GridColumn() { Caption = "出区域", Visible = true, FieldName = "fromPartName" };
 | |
|                 GridColumn myCol411 = new GridColumn() { Caption = "货区", Visible = true, FieldName = "taskPartName" };
 | |
|                 GridColumn myCol51 = new GridColumn() { Caption = "类型", Visible = true, FieldName = "typeName", MinWidth = 110 };
 | |
|                 GridColumn myCol611 = new GridColumn() { Caption = "状态", Visible = true, FieldName = "state", MinWidth = 80 };
 | |
|                 GridColumn myCol71 = new GridColumn() { Caption = "入区域", Visible = true, FieldName = "toPartName" };
 | |
| 
 | |
|                 GridColumn myCol81 = new GridColumn() { Caption = "任务数", Visible = true, FieldName = "taskCnt"  };
 | |
|                 GridColumn myCol91 = new GridColumn() { Caption = "进度%", Visible = true, FieldName = "progress"   };
 | |
|                 
 | |
|                 GridColumn myCol93 = new GridColumn() { Caption = "负责人", Visible = true, FieldName = "ownerName" };
 | |
| 
 | |
| 
 | |
|                 gridView.Columns.Add(myCol21);
 | |
|                         
 | |
|                 gridView.Columns.Add(myCol51);
 | |
|                 
 | |
|                 gridView1.Columns.Add(myCol611);
 | |
|                 gridView1.Columns.Add(myCol81);
 | |
|                 gridView1.Columns.Add(myCol91);
 | |
|                 gridView.Columns.Add(myCol411);
 | |
|                 //gridView.Columns.Add(myCol41);
 | |
|                 gridView.Columns.Add(myCol93);gridView.Columns.Add(myCol31);
 | |
|                 gridView1.Columns.Add(myCol92);  
 | |
|               //  gridView1.Columns.Add(myCol71);
 | |
| 
 | |
|             
 | |
|             }else
 | |
|             if (gridView == gridView2)
 | |
|             {
 | |
|                 // GridColumn colChk = new GridColumn() { Caption = CheckBoxField, Visible = true, FieldName = CheckBoxField };
 | |
|                 //  gridView.Columns.Add(colChk);
 | |
|                 // GridCheckEdit(gridView, CheckBoxField, 50);
 | |
| 
 | |
|                 GridColumn myCol93 = new GridColumn() { Caption = "完成人", Visible = true, FieldName = "taskBy" };
 | |
| 
 | |
| 
 | |
|                 gridView.Columns.Add(myCol2);
 | |
|                 gridView.Columns.Add(myCol3);
 | |
|                 gridView.Columns.Add(myCol93);
 | |
| 
 | |
|                 gridView.Columns.Add(myCol10); 
 | |
|               
 | |
|                 gridView.Columns.Add(myCol4);
 | |
|                 
 | |
|                 gridView.Columns.Add(myCol61);
 | |
|                 gridView.Columns.Add(myCol6);
 | |
|           
 | |
|                 gridView.Columns.Add(myCol7);
 | |
|                 gridView.Columns.Add(myCol12); 
 | |
|               
 | |
|               
 | |
|                 gridView.Columns.Add(myCol13);
 | |
|                 gridView.Columns.Add(myCol1); 
 | |
|                 gridView.Columns.Add(myCol8);   
 | |
|                 gridView.Columns.Add(myCol5);
 | |
| 
 | |
|                 //  gridView.Columns.Add(myCol9);
 | |
| 
 | |
|                 //gridView.Columns.Add(myCol11);
 | |
|                 // GridColumn myCol111 = new GridColumn() { Caption = "test", Visible = true, FieldName = "createtime" };
 | |
|                 gridView.Columns.Add(myCol92); 
 | |
|                 
 | |
|                 
 | |
|             }
 | |
| 
 | |
|             //to show bottom scroll bar
 | |
|             gridView.OptionsView.ColumnAutoWidth = false;
 | |
|             gridView.BestFitColumns();
 | |
|         }
 | |
|         
 | |
|         
 | |
|         #endregion
 | |
| 
 | |
| 
 | |
|         private void initialRequestOrders()
 | |
|         {
 | |
|             showWaitForm();
 | |
|             try{
 | |
|                 //lotClient.getInRequests();
 | |
|                // getInValidOrders();
 | |
|             }
 | |
|             //catch (DeiNiuTimeOutException te)
 | |
|             //{
 | |
|             //     
 | |
|             //}
 | |
|             catch(Exception e){
 | |
|                 showErrorMsg(e.Message);
 | |
|                 }
 | |
|             finally{
 | |
|                 closeWaitForm();
 | |
|             }
 | |
|           
 | |
|         }
 | |
|       
 | |
|         /// <summary>  
 | |
|         /// loading data
 | |
|         /// </summary>  
 | |
|         private int loadData()
 | |
|         {
 | |
|             this.gridControl1.DataSource = null;
 | |
|             gridControl2.DataSource = null;
 | |
|             lbTaskNo.Text = "";
 | |
|             btnApprove.Enabled = btnReject.Enabled = false;
 | |
|             //this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView;
 | |
|             showWaitForm();
 | |
|  
 | |
|             try
 | |
|             {
 | |
| 
 | |
|                 string orderNo = this.txtOrderNo.Text.Trim();
 | |
|                 string query = (string.IsNullOrEmpty(orderNo) ? ""
 | |
|                     : string.Format("{0} =#'{1}';", WmsFlow.fields.task, filtRiskChar(txtOrderNo.Text.Trim())));
 | |
| 
 | |
|                 query += this.txtOccupiedBy.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", WmsFlow.fields.owner, filtRiskChar(txtOccupiedBy.Text.Trim()));
 | |
| 
 | |
|                 // this.splashScreenManager1.ShowWaitForm();
 | |
|                 if (string.IsNullOrEmpty(orderNo))
 | |
|                 {
 | |
|                     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));
 | |
| 
 | |
|                     query += (this.comStatusQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", WmsFlow.fields.state.ToString(), ((Colitem)this.comStatusQ.SelectedItem).key))
 | |
|                             + (this.comTypeQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", WmsFlow.fields.type.ToString(), ((Colitem)this.comTypeQ.SelectedItem).key))
 | |
| ;
 | |
|                 }
 | |
| 
 | |
|                 bool isQueryNotChanged = lastQuery.Equals(query);
 | |
|                 this.pager1.PageCurrent = isQueryNotChanged ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值
 | |
|                 int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1);
 | |
|                 int end = (pager1.PageSize * pager1.PageCurrent);
 | |
|                 lastQuery = query;
 | |
|                 DataSet ds = taskClient.query(query, start, end);// lgt.Query(query, start, end);
 | |
|                // taskClient.Close();
 | |
|                 closeClient();;
 | |
|                 dt = ds.Tables[0];
 | |
|                 int cnt = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString());
 | |
|                 //dt = lgt.Query(query, start, end); //string.IsNullOrEmpty(query) ? lgt.GetGoodType.getAllData(start, end) : lgt.g;
 | |
| 
 | |
|                 dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] };
 | |
|                 bool firstLoad = !isQueryNotChanged || this.gridControl1.DataSource == null;
 | |
|                 this.gridControl1.DataSource = dt.DefaultView;
 | |
|                 initialDataGridColumns(gridView1);
 | |
|                 //update selected row index to the last updated one.
 | |
|                
 | |
|                 if (wcfRequest !=null)
 | |
|                 {
 | |
|                     selectedRowIndex = -1;
 | |
|                     DataRow dr = dt.Rows.Find(wcfRequest.id);
 | |
|                     if (dr != null)
 | |
|                     {
 | |
|                         selectedRowIndex = dt.Rows.IndexOf(dr);
 | |
|                     }
 | |
| 
 | |
|                     if (selectedRowIndex >= 0 && dt.Rows.Count > selectedRowIndex)
 | |
|                     {
 | |
|                         // gridView1.SelectRow(selectedRowIndex);
 | |
|                         gridView1.FocusedRowHandle = selectedRowIndex;
 | |
|                         //  gridView1.MakeRowVisible(selectedRowIndex);
 | |
| 
 | |
|                     }
 | |
| 
 | |
|                     //gridView1.FocusedRowHandle = selectedRowIndex;
 | |
|                 }else
 | |
|                // if (firstLoad)
 | |
|                 {
 | |
|                     selectedRowIndex = 0;
 | |
|                     gridView1.FocusedRowHandle = 0;
 | |
|                     gridView1.SelectRow(0);
 | |
|                     
 | |
|                 }
 | |
|                 setCurrentRequestDetail();
 | |
|                 closeWaitForm();
 | |
|                 return cnt;
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e,e.Message);
 | |
|             }
 | |
| 
 | |
|             closeWaitForm();
 | |
|             return 0;// lgt.getRowCount(query);
 | |
|             // return lgt.GetGoodType.QueryCount(); 
 | |
| 
 | |
|         }
 | |
| 
 | |
|       
 | |
|          
 | |
|         private void bindDetail()
 | |
|         {
 | |
| 
 | |
|         }
 | |
|         private void setDataBack()
 | |
|         {
 | |
| 
 | |
| 
 | |
|         }
 | |
|         private bool validData()
 | |
|         {
 | |
|             bool isvalid = dxValidationProvider1.Validate();
 | |
| 
 | |
|             // MessageBox.Show("goodtype is " + txtGoodType.Text +", is valid ? " + isvalid);
 | |
| 
 | |
|             return isvalid;
 | |
|             //String gdtype = txtGoodType.Text.Trim();
 | |
|             //if (gdtype.Length == 0)
 | |
|             //{
 | |
| 
 | |
|             //    dxValidationProvider.Validate();
 | |
|             //    return false;
 | |
|             //} 
 | |
| 
 | |
|             //return true;
 | |
|         }
 | |
|          
 | |
|        
 | |
| 
 | |
|         /// <summary>  
 | |
|         /// 分页控件产生的事件  
 | |
|         /// </summary>  
 | |
|         private int pager_EventPaging(DeiNiu.Controls.pager.EventPagingArg e)
 | |
|         {
 | |
|             selectedRowIndex = -1; //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;//每页行数  
 | |
|             this.pager1.Bind();//绑定  
 | |
|             #endregion
 | |
| 
 | |
|         }
 | |
| 
 | |
|         bool isCheckedIn = false;
 | |
|         private void gridView1_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | |
|         {
 | |
|             if (gridView1.FocusedRowHandle < 0 || gridView1.FocusedRowHandle == selectedRowIndex || gridView1.FocusedRowHandle==0 && isCheckedIn)
 | |
|             {
 | |
|                 isCheckedIn = gridView1.FocusedRowHandle > 0;
 | |
|                 if (gridView1.IsGroupRow(e.RowHandle)) //set first row of group selected
 | |
|                 {
 | |
|                     selectedRowIndex = gridView1.GetChildRowHandle(e.RowHandle, 0);
 | |
|                     setCurrentRequestDetail();
 | |
|                 }
 | |
|                 if (isCheckedIn)
 | |
|                 {
 | |
|                     isCheckedIn = false;
 | |
|                 }
 | |
|                     return;
 | |
|                 
 | |
|             }
 | |
|             selectedRowIndex = gridView1.FocusedRowHandle;
 | |
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | |
|             setCurrentRequestDetail();
 | |
|             
 | |
|         }
 | |
| 
 | |
|         private void clearInputs()
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         
 | |
|         private void gridView1_DataSourceChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (selectedRowIndex >= 0 && dt.Rows.Count > selectedRowIndex)
 | |
|             {
 | |
|                 gridView1.FocusedRowHandle = selectedRowIndex;
 | |
|                 gridView1.MakeRowVisible(selectedRowIndex);
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|        
 | |
| 
 | |
|         
 | |
|         private void gridView2_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | |
|         {
 | |
|             if (!isShowingInRequest)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             if (gridView2.FocusedRowHandle < 0 || gridView2.FocusedRowHandle == selectedAttIndex)
 | |
|             {
 | |
|                 if (gridView2.IsGroupRow(e.RowHandle)) //set first row of group selected
 | |
|                 {
 | |
|                     selectedAttIndex = gridView2.GetChildRowHandle(e.RowHandle, 0);
 | |
|                      
 | |
|                 }
 | |
| 
 | |
|                 return;
 | |
| 
 | |
|             }
 | |
|             selectedAttIndex = gridView2.FocusedRowHandle;
 | |
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | |
|              
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
| 
 | |
|         private void gridView2_DataSourceChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!isShowingInRequest)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             if (selectedAttIndex >= 0)// && dtIndetail.Rows.Count > selectedInIndex)
 | |
|             {
 | |
|                 gridView2.FocusedRowHandle = selectedAttIndex;
 | |
|                 gridView2.MakeRowVisible(selectedAttIndex);
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         
 | |
|          
 | |
|         private void btnDelete_Click(object sender, EventArgs e)
 | |
|         { 
 | |
| 
 | |
|         }
 | |
| 
 | |
|         protected void query()
 | |
|         {
 | |
|             pager1.Bind();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         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.Message);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 // WaitFormService.Close();
 | |
|                 closeWaitForm();
 | |
|              
 | |
|             }
 | |
|              
 | |
| 
 | |
|         }
 | |
|         string lastSelectedOrderNo = "";
 | |
|         private bool getCurrentObject()
 | |
|         {
 | |
|             if (selectedRowIndex <0 || selectedRowIndex >= dt.Rows.Count)
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
|            
 | |
|           //  DataRow currentRow = dt.Rows[selectedRowIndex];
 | |
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]);
 | |
| 
 | |
|             lastSelectedOrderNo = wcfRequest == null ? "" : wcfRequest.task;
 | |
| 
 | |
|             wcfRequest = getWcfObject( new WmsFlow(dr.Row));  
 | |
| 
 | |
|             this.gridControl2.DataSource = null;
 | |
| 
 | |
|          
 | |
|            
 | |
|     
 | |
|             return true;
 | |
| 
 | |
|         }
 | |
| 
 | |
|         public WcfWmsFlow getWcfObject(WmsFlow dbObj)
 | |
|         {
 | |
| 
 | |
|             WcfWmsFlow wcfObj = new WcfWmsFlow();
 | |
|             wcfObj.id = dbObj.ID;
 | |
|             wcfObj.task = dbObj.task;
 | |
|             wcfObj.flowNo = dbObj.flowNo;
 | |
|             wcfObj.orderNo = dbObj.orderNo;
 | |
|             wcfObj.type = dbObj.type;
 | |
|             wcfObj.typeName = dbObj.typeName;
 | |
|             wcfObj.state = dbObj.state;
 | |
|             wcfObj.fromPartion = dbObj.fromPartion;
 | |
|             wcfObj.toPartion = dbObj.toPartion;
 | |
|             wcfObj.fromLocationId = dbObj.fromLocationId;
 | |
|             wcfObj.toLocationId = dbObj.toLocationId;
 | |
|             wcfObj.owner = dbObj.owner;
 | |
|             wcfObj.taskCnt = dbObj.taskCnt;
 | |
|             wcfObj.finishedCnt = dbObj.finishedCnt;
 | |
|             wcfObj.progress = dbObj.progress;
 | |
|             wcfObj.operater = dbObj.operater;
 | |
| 
 | |
|             return wcfObj;
 | |
| 
 | |
|         }
 | |
|      
 | |
| 
 | |
|         
 | |
| 
 | |
|        
 | |
| 
 | |
| 
 | |
|         private void btnQuery_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             queryGoods();
 | |
|         }
 | |
| 
 | |
|         private void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
 | |
|         {
 | |
|             if (gridView1.FocusedRowHandle <0 || gridView1.FocusedRowHandle == selectedRowIndex)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             selectedRowIndex = gridView1.FocusedRowHandle;
 | |
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | |
|             setCurrentRequestDetail();
 | |
|         }
 | |
| 
 | |
|         private void initialDataGrid()
 | |
|         {
 | |
|             gridView1.OptionsSelection.MultiSelect = true;//按shift / control 多选
 | |
|             this.gridView1.OptionsBehavior.AutoPopulateColumns = false;
 | |
|             this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | |
|             this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus;
 | |
|             this.gridView1.OptionsBehavior.Editable = false;
 | |
|             //    this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
 | |
| 
 | |
|             this.gridView1.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView1_FocusedRowObjectChanged);
 | |
|             this.gridView1.DataSourceChanged += new System.EventHandler(this.gridView1_DataSourceChanged);
 | |
| 
 | |
|             //show line number
 | |
|             this.gridView1.IndicatorWidth = 40;
 | |
|             this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | |
|             this.gridView2.IndicatorWidth = 40;
 | |
|             this.gridView2.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | |
|           
 | |
|             gridView2.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
 | |
|             gridView2.CustomDrawCell += gridView_CustomDrawCell;
 | |
|             gridView2.RowCellStyle += gridView_RowCellStyle;
 | |
|             gridView1.RowCellStyle += gridView_RowCellStyle;
 | |
| 
 | |
|             this.gridView2.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView2_FocusedRowObjectChanged);
 | |
|             
 | |
| 
 | |
|             gridView1.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
 | |
|             gridView1.CustomDrawCell += gridView_CustomDrawCell;
 | |
| 
 | |
|           
 | |
| 
 | |
|         }
 | |
|    
 | |
| 
 | |
| 
 | |
| 
 | |
|        private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
 | |
|         {
 | |
| 
 | |
|             if (sender == gridView1)
 | |
|             {
 | |
|                 if (e.Column.FieldName == "state")
 | |
|                 {
 | |
| 
 | |
|                     if (!this.taskStatus .ContainsValue(e.DisplayText))
 | |
|                     {
 | |
| 
 | |
|                         int display = -100;
 | |
|                         string disTxt = e.DisplayText;
 | |
| 
 | |
|                         try
 | |
|                         {
 | |
|                             display = Convert.ToInt32(e.DisplayText);
 | |
| 
 | |
| 
 | |
|                             e.DisplayText = this.taskStatus[display];
 | |
|                               
 | |
|                         }
 | |
|                         catch
 | |
|                         {
 | |
|                             return;
 | |
|                         }
 | |
|                     }
 | |
| 
 | |
|                 } else if (e.Column.FieldName == "type")
 | |
|                 {
 | |
| 
 | |
|                     if (!this.taskType.ContainsValue(e.DisplayText))
 | |
|                     {
 | |
| 
 | |
|                         int display = -100;
 | |
|                         string disTxt = e.DisplayText;
 | |
| 
 | |
|                         try
 | |
|                         {
 | |
|                             display = Convert.ToInt32(e.DisplayText);
 | |
|                           
 | |
|                             {
 | |
|                                 e.DisplayText = this.taskType[display];
 | |
|                             }
 | |
|                         }
 | |
|                         catch
 | |
|                         {
 | |
|                             return;
 | |
|                         }
 | |
|                     }
 | |
| 
 | |
|                 }
 | |
|                 else if (e.Column.FieldName == "createtime")
 | |
|                 {
 | |
|                     e.Column.DisplayFormat.FormatString = "MM-dd HH:mm";
 | |
|                     string f = e.Column.DisplayFormat.GetFormatString();
 | |
|                     string a = f;
 | |
|                 }
 | |
| 
 | |
|             }
 | |
|            else if (sender == gridView2)
 | |
|             {
 | |
|                 if (e.Column.FieldName == "whtype" || e.Column.FieldName == "toWhType")
 | |
|                 {
 | |
| 
 | |
|                     if (!whType.ContainsValue(e.DisplayText))
 | |
|                     {
 | |
| 
 | |
|                         int display = -100;
 | |
|                         string disTxt = e.DisplayText;
 | |
| 
 | |
|                         try
 | |
|                         {
 | |
|                             display = Convert.ToInt32(e.DisplayText);
 | |
| 
 | |
|                             {
 | |
|                                 e.DisplayText = this.whType[display];
 | |
|                             }
 | |
|                         }
 | |
|                         catch
 | |
|                         {
 | |
|                             return;
 | |
|                         }
 | |
|                     }
 | |
| 
 | |
|                 }  
 | |
|                 else if (e.Column.FieldName == "locState" || e.Column.FieldName == "storeState")
 | |
|                 {
 | |
| 
 | |
|                     if (!this. stockState.ContainsValue(e.DisplayText))
 | |
|                     {
 | |
| 
 | |
|                         int display = -100;
 | |
|                         string disTxt = e.DisplayText;
 | |
| 
 | |
|                         try
 | |
|                         {
 | |
|                             display = Convert.ToInt32(e.DisplayText);
 | |
| 
 | |
|                             {
 | |
|                                 e.DisplayText = this.stockState[display];
 | |
|                             }
 | |
|                         }
 | |
|                         catch
 | |
|                         {
 | |
|                             return;
 | |
|                         }
 | |
|                     }
 | |
| 
 | |
|                 }
 | |
|                 else if (e.Column.FieldName == "productDate" || e.Column.FieldName == "validDate")
 | |
|                 { 
 | |
|                     string f = e.Column.DisplayFormat.GetFormatString();
 | |
|                     string a = f;
 | |
|                    // e.Column.DisplayFormat.FormatString = "yyyy-MM-dd";
 | |
|                    
 | |
|                 }
 | |
|                
 | |
| 
 | |
|             }
 | |
|         }
 | |
|        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" && 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;
 | |
|                }
 | |
|                else if(b.Equals("已核准"))
 | |
|                {
 | |
|                    e.Appearance.ForeColor = Color.Gray;
 | |
|                    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;}
 | |
|            if (!currentView.GetDataRow(e.RowHandle).Table.Columns.Contains("wms_state"))
 | |
|            {
 | |
|                return;
 | |
|            }
 | |
| 
 | |
|            string state = currentView.GetDataRow(e.RowHandle)["wms_state"].ToString().Trim();
 | |
|            
 | |
|            if (state == "0")
 | |
|            {
 | |
|                return;
 | |
|            }
 | |
| 
 | |
|            bool isFocused = e.RowHandle == currentView.FocusedRowHandle;
 | |
|            DevExpress.Utils.AppearanceDefault rowStyle = null;
 | |
|             DevExpress.Utils.AppearanceDefault appBlueRed = 
 | |
|                new DevExpress.Utils.AppearanceDefault (Color.White, Color.Red, Color.Empty, Color.Blue, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
 | |
|            DevExpress.Utils.AppearanceDefault appYB =
 | |
|             new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green);
 | |
| 
 | |
|            DevExpress.Utils.AppearanceDefault alertFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green,  Color.Yellow);
 | |
|            DevExpress.Utils.AppearanceDefault alert  = new DevExpress.Utils.AppearanceDefault(Color.Red, Color.White );
 | |
| 
 | |
|            DevExpress.Utils.AppearanceDefault passedFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Gray);
 | |
|            DevExpress.Utils.AppearanceDefault passed = new DevExpress.Utils.AppearanceDefault(Color.Gray, Color.White);
 | |
| 
 | |
|            if (state == "2"  )
 | |
|            {
 | |
|                rowStyle = isFocused ? passedFocus : passed;
 | |
|            }
 | |
|            else  if (state == "1")
 | |
|            {
 | |
|                rowStyle = isFocused ? alertFocus : alert;
 | |
|            }
 | |
| 
 | |
| 
 | |
|            DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, rowStyle);
 | |
|            /*
 | |
|            if (sender == this.gridView2)
 | |
|            {
 | |
|                if (this.gridView2.GetDataRow(e.RowHandle)["state"].ToString().Trim() == "2")
 | |
|                {
 | |
|                    DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
 | |
|                }
 | |
|            }else if(sender == this.gridView1){
 | |
|                 
 | |
|                if ( state == "2")
 | |
|                {
 | |
|                    if (currentView != null && e.RowHandle == currentView.FocusedRowHandle)
 | |
|                    {
 | |
|                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alertFocus);
 | |
|                    }
 | |
|                    else
 | |
|                    {
 | |
|                        DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
 | |
|                    }
 | |
|                }
 | |
|                else if (state == "1")
 | |
|                {
 | |
|                    DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, passed);
 | |
|                } 
 | |
|            }
 | |
|            */
 | |
|        }
 | |
| 
 | |
|         private void setCurrentRequestDetail()
 | |
|         {
 | |
|             
 | |
|             if (!getCurrentObject() || wcfRequest == null)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             /// gridView1.FocusedRowHandle = selectedRowIndex;//
 | |
|             //  gridView1.SelectRow(selectedRowIndex);
 | |
|             showWaitForm();
 | |
| 
 | |
|          
 | |
|             lbTaskNo.Text = wcfRequest.task;
 | |
|           
 | |
|           
 | |
|             try
 | |
|             {
 | |
|                 isShowingInRequest = true;
 | |
| 
 | |
|                 DtGv = taskClient.getDetail(wcfRequest.task);
 | |
|                // addCheckField(DtGv);//add checkbox
 | |
|                 closeClient();;
 | |
|                 //selectedInIndex = -1;
 | |
|              
 | |
|                 this.gridControl2.DataSource = DtGv;
 | |
|                 initialDataGridColumns(gridView2);
 | |
|                 selectedAttIndex = gridView2.FocusedRowHandle;
 | |
|  
 | |
|                  
 | |
|               //  this.btnAdd.Enabled = selectedRequest.state != (int)enumInStockOrderStatus.已入库;
 | |
|                  
 | |
|              
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e.Message);
 | |
|             }
 | |
|             closeWaitForm();
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|         }
 | |
|         
 | |
|         private void btnIn_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|            
 | |
| 
 | |
|            
 | |
|         }
 | |
| 
 | |
|         void receiveByItem()
 | |
|         {
 | |
|               
 | |
|         }
 | |
|  
 | |
|          
 | |
| 
 | |
|         private void GoodsInForm_FormClosing(object sender, FormClosingEventArgs e)
 | |
|         {
 | |
|             //closeClient();;
 | |
|         }
 | |
| 
 | |
|         protected new void gridview_GotFocus(object sender, EventArgs e)
 | |
|         {
 | |
|             if (sender == gridView1)
 | |
|             {
 | |
|                 //grid4Valid.ForeColor = Color.Blue;
 | |
|                 // gridView4Valid.OptionsSelection.EnableAppearanceHideSelection = true;
 | |
|                 if (!isShowingInRequest)
 | |
|                 {
 | |
|                     this.setCurrentRequestDetail();
 | |
|                 }
 | |
|                 switchGridViewRowSelection(gridView1, true);
 | |
|                
 | |
|             }
 | |
|            
 | |
|             else
 | |
|             {
 | |
|                 switchGridViewRowSelection((GridView)sender, true);
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|          
 | |
|          
 | |
|         bool validOrder( )
 | |
|         {
 | |
|          
 | |
| 
 | |
|             return true;
 | |
|         }
 | |
|         private void btnUpdateLot_Click(object sender, EventArgs e)
 | |
|         {
 | |
|           
 | |
| 
 | |
|         }
 | |
|   
 | |
| 
 | |
|           private void btnUpdate_Click(object sender, EventArgs e)
 | |
|           {
 | |
|               if (!validOrder())
 | |
|               {
 | |
|                   return;
 | |
|               } 
 | |
| 
 | |
|    
 | |
|             
 | |
|               showWaitForm();
 | |
| 
 | |
|               try
 | |
|               {
 | |
| 
 | |
|                 //  orderClient.update(wcfRequest);
 | |
| 
 | |
|               }
 | |
|               catch (Exception er)
 | |
|               {
 | |
| 
 | |
|                   showErrorMsg(er, "出错了");
 | |
| 
 | |
| 
 | |
|               }
 | |
|               closeClient(); ;
 | |
|               closeWaitForm();
 | |
| 
 | |
|               query();
 | |
| 
 | |
|           }
 | |
| 
 | |
|           private void btnReject_Click(object sender, EventArgs e)
 | |
|           {
 | |
| 
 | |
|           }
 | |
| 
 | |
|           private void btnApprove_Click(object sender, EventArgs e)
 | |
|           {
 | |
| 
 | |
|           }
 | |
| 
 | |
|         private void btnApprove_Click_1(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
|     }
 | |
| } |