807 lines
		
	
	
		
			27 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			807 lines
		
	
	
		
			27 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.TMService;
 | |
| 
 | |
| 
 | |
| namespace DeiNiu.wms.win
 | |
| {
 | |
|     public partial class TranLinesForm : BasicRibbonForm
 | |
|     {
 | |
|          
 | |
|         //  lWmsStock ls = new lWmsStock();
 | |
|       //  lWmsOutPickRequest lgt = new lWmsOutPickRequest();
 | |
|      //   lWmsOutRequest lgOutReq = new lWmsOutRequest();
 | |
|        // lWmsOutPickRequest outPickRequest = new lWmsOutPickRequest();
 | |
|         private string lastQuery = "";
 | |
|         private DataTable dtLines;
 | |
|         private DataTable dtCust;
 | |
|         private int selectedRowIndex = -1;
 | |
|         private int currentLineId = 0;
 | |
|        // string currentOrder = "";
 | |
|         int newOrder = 0;
 | |
|         DataTable dtDetail;
 | |
|         DataView dtDetailViwer;
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|         public TranLinesForm()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|             initialControls();
 | |
| 
 | |
|             //initialBackGroundTasks();
 | |
|             //    loadData();
 | |
|         }
 | |
|         #region initialControls
 | |
|         private void initialControls()
 | |
|         {
 | |
|             initialComboBoxes();
 | |
|             initialPagerControls();
 | |
|             initialDataGrid();
 | |
|             initialQueryInput(); 
 | |
|             setValidationRule();
 | |
|             queryLines();
 | |
|         }
 | |
|         /*
 | |
|         private void initialBackGroundTasks()
 | |
|         {
 | |
|             lgOutReq.UpdateUIDelegate += updatePreOutStatus;
 | |
|             lgOutReq.TaskCallBack += preOutFinished;
 | |
|              
 | |
|             lgt.UpdateUIDelegate += updatePickDetails;
 | |
|             lgt.TaskCallBack += waveFinished;
 | |
|          
 | |
|             newWave();
 | |
|             preErpOrders(); 
 | |
|         }
 | |
| 
 | |
|         */
 | |
| 
 | |
|         private void initialComboBoxes()
 | |
|         {
 | |
|             
 | |
|         }
 | |
|       
 | |
|         private void setValidationRule()
 | |
|         { 
 | |
|         }
 | |
| 
 | |
|         private void initialQueryInput()
 | |
|         {
 | |
| 
 | |
|         }
 | |
|       
 | |
|         private void initialDataGridColumns()
 | |
|         {
 | |
|             setupGridView(gridView1,false);
 | |
|             //setupGridView(gridView2, false,false);
 | |
|             //setupGridView(gridView3, false,false);
 | |
|             //   gridviewGoodsType.PopulateColumns();
 | |
|             gridView1.Columns.Clear();
 | |
|             // gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]); 
 | |
|             GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
 | |
|             myCol0.Visible = false;
 | |
|             this.gridView1.Columns.Add(myCol0);
 | |
|             GridColumn myCol1 = new GridColumn() { Caption = "线路", Visible = true, FieldName = Node.fields.name.ToString() };
 | |
|             GridColumn myCol2 = new GridColumn() { Caption = "分拣优先级", Visible = true, FieldName = Node.fields.flag.ToString() };
 | |
|           //  GridColumn myCol3 = new GridColumn() { Caption = "说明", Visible = true, FieldName = Node.fields.description.ToString() }; 
 | |
|             this.gridView1.Columns.Add(myCol1);
 | |
|             this.gridView1.Columns.Add(myCol2);
 | |
|  
 | |
|             //to show bottom scroll bar
 | |
|             gridView1.OptionsView.ColumnAutoWidth = false;
 | |
|             gridView1.BestFitColumns();
 | |
|             gridView1.Focus();
 | |
| 
 | |
| 
 | |
|         //    initialGridView2Columns();
 | |
|             gridControlDetail.DataSource = null;
 | |
|             this.gridcontrolCusts.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 = Node.fields.name.ToString() };
 | |
|             GridColumn myCol2 = new GridColumn() { Caption = "客户", Visible = true, FieldName = "custName" };
 | |
|             GridColumn myCol3 = new GridColumn() { Caption = "客户编号", Visible = true, FieldName = "custId" }; 
 | |
|             GridColumn myCol5 = new GridColumn() { Caption = "客户地址", Visible = true, FieldName = "Address" };
 | |
|             GridColumn myCol4 = new GridColumn() { Caption = "排序", Visible = true, FieldName = "lineOrder" };
 | |
|             gridview.Columns.Add(myCol1); 
 | |
|             gridview.Columns.Add(myCol4); 
 | |
|         
 | |
|             gridview.Columns.Add(myCol2);
 | |
|             gridview.Columns.Add(myCol5);
 | |
|             
 | |
|             gridview.Columns.Add(myCol3);
 | |
|              
 | |
|             //to show bottom scroll bar
 | |
|             gridview.OptionsView.ColumnAutoWidth = false;
 | |
|             gridview.BestFitColumns();
 | |
|           //  gridView2.Focus();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void initialDataGridLogColumns(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;
 | |
|             this.gridView1.Columns.Add(myCol0);
 | |
|             GridColumn myCol2 = new GridColumn() { Caption = "客户", Visible = true, FieldName = "custName" };
 | |
|             GridColumn myCol3 = new GridColumn() { Caption = "客户编号", Visible = true, FieldName = "custId" };
 | |
|             GridColumn myCol5 = new GridColumn() { Caption = "客户地址", Visible = true, FieldName = "Address" };
 | |
| 
 | |
| 
 | |
| 
 | |
|             gridview.Columns.Add(myCol2);
 | |
|             gridview.Columns.Add(myCol5); 
 | |
|             gridview.Columns.Add(myCol3);
 | |
|            
 | |
|             //to show bottom scroll bar
 | |
|             gridview.OptionsView.ColumnAutoWidth = false;
 | |
|             gridview.BestFitColumns();
 | |
|             gridview.Focus();
 | |
|  
 | |
|         }
 | |
| 
 | |
|         
 | |
|         #endregion
 | |
| 
 | |
|   
 | |
| 
 | |
| 
 | |
|         /// <summary>  
 | |
|         /// loading data
 | |
|         /// </summary>  
 | |
|         private int loadCust()
 | |
|         {
 | |
|            // initialRequestOrders();
 | |
|             //this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView;
 | |
|             showWaitForm();
 | |
|             this.labelAddress.Text = "";
 | |
|             this.labelCust.Text = "";
 | |
|             btnAdd.Enabled = false;
 | |
|             try
 | |
|             {
 | |
|                 string custName = this.txtCust.Text.Trim();
 | |
|                 bool isQueryNotChanged = lastQuery.Equals(custName);
 | |
|                 this.pager1.PageCurrent = isQueryNotChanged ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值
 | |
|                 int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1);
 | |
|                 int end = (pager1.PageSize * pager1.PageCurrent);
 | |
|                 lastQuery = custName;
 | |
| 
 | |
|                 DataSet ds = tmsClient.getAvalibleCusts(currentLineId, custName, start, end);
 | |
|                 closeClient();
 | |
| 
 | |
|                 dtCust = 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[orderFieldName] };
 | |
|                 bool firstLoad = !isQueryNotChanged || this.gridcontrolCusts.DataSource == null;
 | |
|                 this.gridcontrolCusts.DataSource = dtCust.DefaultView;
 | |
| 
 | |
|                 initialDataGridLogColumns(this.gridViewCust);
 | |
|                 //update selected row index to the last updated one.
 | |
|                /*
 | |
|                 if (false && !string.IsNullOrEmpty( currentOrder))
 | |
|                 {
 | |
|                     selectedRowIndex = -1;
 | |
|                     DataRow dr = dt.Rows.Find(currentOrder);
 | |
|                     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)
 | |
|                 {
 | |
|                     gridView1.FocusedRowHandle = 0;
 | |
|                     gridView1.SelectRow(0);
 | |
|                     setCurrentRequestDetail();
 | |
|                 }
 | |
|                 */
 | |
|                 setCurrentCustDetail();
 | |
|                 closeWaitForm();
 | |
|                 return cnt;
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e,e.Message);
 | |
|             }
 | |
| 
 | |
|             closeWaitForm();
 | |
|             return 0;// lgt.getRowCount(query);
 | |
|             // return lgt.GetGoodType.QueryCount(); 
 | |
| 
 | |
|         }
 | |
| 
 | |
|           
 | |
| 
 | |
|         /// <summary>  
 | |
|         /// 分页控件产生的事件  
 | |
|         /// </summary>  
 | |
|         private int pager_EventPaging(DeiNiu.Controls.pager.EventPagingArg e)
 | |
|         {
 | |
|            // selectedCustIndex = 0; //reset currentRowIndex
 | |
|             return loadCust();
 | |
|         }
 | |
| 
 | |
|         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
 | |
| 
 | |
|         }
 | |
|         
 | |
|         
 | |
|         private void gridView1_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | |
|         {
 | |
|             if (gridView1.FocusedRowHandle <0 || gridView1.FocusedRowHandle == selectedRowIndex)
 | |
|             {
 | |
|                 if (gridView1.IsGroupRow(e.RowHandle)) //set first row of group selected
 | |
|                 {
 | |
|                     selectedRowIndex = gridView1.GetChildRowHandle(e.RowHandle, 0);
 | |
|                     setCurrentRequestDetail();
 | |
|                 }
 | |
|                  
 | |
|                     return; ;
 | |
|                 
 | |
|             }
 | |
|             selectedRowIndex = gridView1.FocusedRowHandle;
 | |
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | |
|             setCurrentRequestDetail();
 | |
|         }
 | |
| 
 | |
|         private void gridView1_DataSourceChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (selectedRowIndex >= 0 && dtLines.Rows.Count > selectedRowIndex)
 | |
|             {
 | |
|                 gridView1.FocusedRowHandle = selectedRowIndex;
 | |
|                 gridView1.MakeRowVisible(selectedRowIndex);
 | |
| 
 | |
|             }
 | |
|         }
 | |
|  
 | |
| 
 | |
|         protected void query()
 | |
|         {
 | |
|             pager1.Bind();
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void queryCust()
 | |
|         {
 | |
| 
 | |
|             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;
 | |
|             queryCust();
 | |
|         }
 | |
| 
 | |
|        
 | |
| 
 | |
|         private void updateObjects(List<WmsGoods> goods)
 | |
|         { 
 | |
|             showWaitForm();
 | |
|             //WaitFormService.Show(this); 
 | |
|             try
 | |
|             {
 | |
|              //   lgt.update(goods);
 | |
| 
 | |
|                 //get updated data 
 | |
|                 queryCust();
 | |
| 
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e.Message);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 // WaitFormService.Close();
 | |
|                 closeWaitForm();
 | |
|              
 | |
|             }
 | |
|              
 | |
| 
 | |
|         }
 | |
|         string currentLineName = "";
 | |
|         private bool getCurrentObject()
 | |
|         {
 | |
| 
 | |
|             lbCustName.Text = "";
 | |
| 
 | |
|             lbCustAddress.Text = "";
 | |
|             this.labelAddress.Text = "";
 | |
|             this.labelCust.Text = "";
 | |
|             btnAdd.Enabled = false;
 | |
|             //lbaddress.Text = "";
 | |
| 
 | |
|             currentLineName = "";
 | |
|             if (selectedRowIndex <0 || selectedRowIndex >= dtLines.Rows.Count)
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
|            
 | |
|           //  DataRow currentRow = dt.Rows[selectedRowIndex];
 | |
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]);
 | |
|             string filedName = string.IsNullOrEmpty(txtLineCust.Text.Trim()) ? "ID" : "lineId";
 | |
|             currentLineId = Convert.ToInt32(dr[filedName].ToString());
 | |
|             currentLineName = dr["name"].ToString();
 | |
|            
 | |
|          //   lbCustName.Text = dr["custName"].ToString();
 | |
| 
 | |
|           //  lbCustAddress.Text = dr["Address"].ToString(); 
 | |
| 
 | |
|         //    lbaddress.Text = dr["address"].ToString();
 | |
|              
 | |
|             return true;
 | |
| 
 | |
|         }
 | |
|        
 | |
|        
 | |
| 
 | |
| 
 | |
|         private void btnQuery_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             queryCust();
 | |
|         }
 | |
| 
 | |
|         private void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
 | |
|         {
 | |
|             if (gridView1.FocusedRowHandle <0 || gridView1.FocusedRowHandle == selectedRowIndex)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             selectedRowIndex = gridView1.FocusedRowHandle;
 | |
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | |
|             setCurrentRequestDetail();
 | |
|         }
 | |
| 
 | |
|         private void initialDataGrid()
 | |
|         {
 | |
|             gridView1.OptionsSelection.MultiSelect = true;//按shift / control 多选
 | |
|             this.gridView1.OptionsBehavior.AutoPopulateColumns = false;
 | |
|             this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
 | |
|             this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus;
 | |
|             this.gridView1.OptionsBehavior.Editable = false;
 | |
|             //    this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
 | |
| 
 | |
|             this.gridView1.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView1_FocusedRowObjectChanged);
 | |
|             this.gridView1.DataSourceChanged += new System.EventHandler(this.gridView1_DataSourceChanged);
 | |
| 
 | |
|             //show line number
 | |
|             this.gridView1.IndicatorWidth = 40;
 | |
|             this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | |
|             this.gridView2.IndicatorWidth = 40;
 | |
|             this.gridView2.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
 | |
|              this.gridViewCust.IndicatorWidth = 40;
 | |
|              this.gridViewCust.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;
 | |
| 
 | |
|              gridView1.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
 | |
|              gridViewCust.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
 | |
| 
 | |
|              this.gridView2.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView2_FocusedRowObjectChanged);
 | |
|              this.gridView2.DataSourceChanged += new System.EventHandler(this.gridView2_DataSourceChanged);
 | |
| 
 | |
|              this.gridViewCust.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridViewCust_FocusedRowObjectChanged);
 | |
|              this.gridViewCust.DataSourceChanged += new System.EventHandler(this.gridViewCust_DataSourceChanged);
 | |
| 
 | |
|            // this.gridView2.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView1_FocusedRowObjectChanged);
 | |
|           //  this.gridView2.DataSourceChanged += new System.EventHandler(this.gridView1_DataSourceChanged);
 | |
|              
 | |
|         }
 | |
|     
 | |
|        private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
 | |
|         { 
 | |
|                  
 | |
|             
 | |
|         }
 | |
|        void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
 | |
|        { 
 | |
|        }
 | |
| 
 | |
|        void gridView_RowCellStyle(object sender,DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
 | |
|        {
 | |
| 
 | |
|            
 | |
|        }
 | |
| 
 | |
|         private void setCurrentRequestDetail()
 | |
|         {
 | |
|             if (!getCurrentObject() || currentLineId <=0)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|            /// gridView1.FocusedRowHandle = selectedRowIndex;//
 | |
|           //  gridView1.SelectRow(selectedRowIndex);
 | |
|             showWaitForm();
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                 selectedCustIndex = -1;
 | |
|                 currentCustOrder = -1;
 | |
|                 selectedDetailRowIndex = -1;
 | |
|                 dtDetail = tmsClient.getLineCust(currentLineId);
 | |
|                 closeClient();
 | |
|                 string custFilter = string.IsNullOrEmpty(txtLineCust.Text.Trim()) ? "" : string.Format(" and custName like '%{0}%'", txtLineCust.Text.Trim());
 | |
|                 dtDetailViwer = dtDetail.DefaultView;
 | |
|                 dtDetailViwer.RowFilter =    string.IsNullOrEmpty(txtLineCust.Text.Trim()) ? "" : string.Format("custName like '%{0}%'", txtLineCust.Text.Trim());
 | |
| 
 | |
|                 this.gridControlDetail.DataSource = dtDetail;
 | |
|                 initialGridView2Columns(gridView2);
 | |
| 
 | |
|                 queryCust(); 
 | |
|                  
 | |
|             }
 | |
|             catch (Exception e)
 | |
|             {
 | |
|                 showErrorMsg(e.Message);
 | |
|             }
 | |
|             closeWaitForm();
 | |
| 
 | |
|         }
 | |
| 
 | |
| 
 | |
|         int selectedDetailRowIndex = -1;
 | |
| 
 | |
|         private void gridView2_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | |
|         {
 | |
|             if (gridView2.FocusedRowHandle < 0 || gridView2.FocusedRowHandle == selectedDetailRowIndex)
 | |
|             {
 | |
|                 if (gridView2.IsGroupRow(e.RowHandle)) //set first row of group selected
 | |
|                 {
 | |
|                     selectedDetailRowIndex = gridView1.GetChildRowHandle(e.RowHandle, 0);
 | |
|                     setCurrentLineDetail();
 | |
|                 }
 | |
| 
 | |
|                 return; ;
 | |
| 
 | |
|             }
 | |
|             selectedDetailRowIndex = gridView2.FocusedRowHandle;
 | |
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | |
|             setCurrentLineDetail();
 | |
|         }
 | |
| 
 | |
|         private void gridView2_DataSourceChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (selectedDetailRowIndex >= 0 && dtDetail.Rows.Count > selectedDetailRowIndex)
 | |
|             {
 | |
|                 gridView2.FocusedRowHandle = selectedDetailRowIndex;
 | |
|                 gridView2.MakeRowVisible(selectedDetailRowIndex);
 | |
| 
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|       
 | |
|         int currentCustOrder = -1;
 | |
|         int currentLineDetailId = -1;
 | |
|         private bool getCurrentDetailObject()
 | |
|         {
 | |
|             btnDel.Enabled = false;
 | |
|             btnUpdateLine.Enabled = false;
 | |
|             spinEdit1.Enabled = false;
 | |
|             int cnt = GetGridViewFilteredAndSortedData(gridView2).Count;
 | |
|             if (selectedDetailRowIndex < 0 || selectedDetailRowIndex >=cnt)// dtDetailViwer.Count)
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //  DataRow currentRow = dt.Rows[selectedRowIndex];
 | |
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView2)[selectedDetailRowIndex]);
 | |
|            
 | |
|             lbCustAddress.Text = dr["Address"].ToString();
 | |
|             lbCustName .Text = dr["custName"].ToString();
 | |
|             currentCustOrder = Convert.ToInt32(dr["lineOrder"].ToString());
 | |
|             currentLineDetailId = Convert.ToInt32(dr["ID"].ToString()); 
 | |
|             spinEdit1.Properties.MaxValue = dtDetail.Rows.Count;
 | |
|             spinEdit1.Value = currentCustOrder;
 | |
|             btnDel.Enabled = true;
 | |
|             spinEdit1.Enabled = true;
 | |
|             btnUpdateLine.Enabled = true;
 | |
| 
 | |
|             return true;
 | |
| 
 | |
|         }
 | |
|        
 | |
|        
 | |
| 
 | |
|         private void setCurrentLineDetail()
 | |
|         {
 | |
|             if ( currentLineId <= 0 ||!getCurrentDetailObject() )
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             /// gridView1.FocusedRowHandle = selectedRowIndex;//
 | |
|             //  gridView1.SelectRow(selectedRowIndex);
 | |
|          
 | |
|         }
 | |
| 
 | |
| 
 | |
|         int selectedCustIndex = -1;
 | |
|         private void gridViewCust_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
 | |
|         {
 | |
|             if (gridViewCust.FocusedRowHandle < 0 || gridViewCust.FocusedRowHandle == selectedCustIndex)
 | |
|             {
 | |
|                 if (gridViewCust.IsGroupRow(e.RowHandle)) //set first row of group selected
 | |
|                 {
 | |
|                     selectedCustIndex = gridViewCust.GetChildRowHandle(e.RowHandle, 0);
 | |
|                     setCurrentCustDetail();
 | |
|                 }
 | |
| 
 | |
|                 return; ;
 | |
| 
 | |
|             }
 | |
|             selectedCustIndex = gridViewCust.FocusedRowHandle;
 | |
|             // showErrorMsg("selection:"+ selectedRowIndex);
 | |
|             setCurrentCustDetail();
 | |
|         }
 | |
| 
 | |
|         private void gridViewCust_DataSourceChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (selectedCustIndex >= 0 && dtCust.Rows.Count > selectedCustIndex)
 | |
|             {
 | |
|                 gridViewCust.FocusedRowHandle = selectedCustIndex;
 | |
|                 gridViewCust.MakeRowVisible(selectedCustIndex);
 | |
| 
 | |
|             }
 | |
|         }  
 | |
|         string currentCustId = string.Empty; 
 | |
|         private bool getCurrentCustDetailObject()
 | |
|         {
 | |
| 
 | |
|             if (selectedCustIndex < 0 || selectedCustIndex >= dtCust.Rows.Count)
 | |
|             {
 | |
|                 return false;
 | |
|             }
 | |
| 
 | |
|             //  DataRow currentRow = dt.Rows[selectedRowIndex];
 | |
|             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridViewCust)[selectedCustIndex]);
 | |
|             currentCustId = dr["custId"].ToString();
 | |
|              this.labelAddress .Text = dr["Address"].ToString();
 | |
|             this.labelCust.Text = dr["custName"].ToString();
 | |
|             btnAdd.Enabled = true;
 | |
|             return true;
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void setCurrentCustDetail()
 | |
|         {
 | |
|             if ( !getCurrentCustDetailObject() || selectedCustIndex <= 0 )
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|            
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void btnIn_Click(object sender, EventArgs e)
 | |
|         {
 | |
|           
 | |
|             showWaitForm();
 | |
|             try
 | |
|             {
 | |
|                // lgOutReq.requestOutStock(selectedRequest.pickOrderNo);
 | |
|                 queryCust();
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 setCurrentRequestDetail();
 | |
|                 showErrorMsg(er.Message);
 | |
|             }
 | |
| 
 | |
|              
 | |
|           
 | |
| 
 | |
|             closeWaitForm();
 | |
|         }
 | |
| 
 | |
|         private void GoodsOutQueryForm_FormClosing(object sender, FormClosingEventArgs e)
 | |
|         {
 | |
|            // outClient.Close();
 | |
|           //  pickClient.Close();
 | |
|         }
 | |
| 
 | |
|         private void gridcontrolOderLogs_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void gridControlDetail_Click(object sender, EventArgs e)
 | |
|         {
 | |
|           
 | |
|         }
 | |
| 
 | |
|         private void btnQueryLines_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             queryLines();
 | |
|         }
 | |
|         
 | |
| 
 | |
|         void queryLines()
 | |
|         {
 | |
| 
 | |
|             currentCustOrder = -1;
 | |
|             dtLines = tmsClient.getLines(txtLineCust.Text);
 | |
|             closeClient();
 | |
|             DataView dv = dtLines.DefaultView;
 | |
|            // dv.RowFilter = " flag!=3001"; 
 | |
|             this.gridControl1.DataSource = dv;
 | |
|             initialDataGridColumns();
 | |
|             setCurrentRequestDetail();
 | |
|             getCurrentDetailObject();
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void btnSave_Click(object sender, EventArgs e)
 | |
|         { 
 | |
|             if (tmsClient.updateLineCustOrder(currentLineId,currentLineDetailId, currentCustOrder, newOrder))
 | |
|             {
 | |
|                 MessageBox.Show("调整成功");
 | |
|             }
 | |
| 
 | |
|             setCurrentRequestDetail();
 | |
|             closeClient();
 | |
|         }
 | |
| 
 | |
|         private void spinEdit1_EditValueChanged(object sender, EventArgs e)
 | |
|         { 
 | |
|             newOrder = Convert.ToInt32(spinEdit1.Value);  
 | |
|             btnSave.Enabled = (currentCustOrder != newOrder);
 | |
|              
 | |
|         }
 | |
| 
 | |
|         private void btnQueryCust_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             queryCust();// loadCust();
 | |
|         }
 | |
| 
 | |
|         private void btnAdd_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             getCurrentDetailObject();
 | |
|             currentCustOrder = currentCustOrder == dtDetail.Rows.Count ? currentCustOrder + 1 : currentCustOrder; //last one, plus 1
 | |
| 
 | |
|             currentCustOrder = currentCustOrder < 0 ? 1 : currentCustOrder;  //first one
 | |
|              
 | |
|             tmsClient.addLineCust(currentLineId, currentCustId, currentCustOrder);
 | |
| 
 | |
|             setCurrentRequestDetail();
 | |
|             queryCust();
 | |
|             closeClient();
 | |
|         }
 | |
| 
 | |
|         private void btnDel_Click(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
| 
 | |
|             DialogResult r = MessageBox.Show(string.Format("确定要从路线{0}中删除客户{1}吗?", currentLineName,lbCustName.Text), "确认删除", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
 | |
|             if (r == DialogResult.Yes)
 | |
|             {
 | |
| 
 | |
|                 try
 | |
|                 {
 | |
|                     string msg = "删除成功";
 | |
|                     if (tmsClient.removeCust(currentLineDetailId))
 | |
|                     {
 | |
|                         setCurrentRequestDetail();
 | |
|                         
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         msg = "删除失败";
 | |
|                     }
 | |
| 
 | |
|                     MessageBox.Show(msg);
 | |
|                 }
 | |
|                 catch (Exception er) {
 | |
| 
 | |
|                     showErrorMsg("删除失败:" + er.Message);
 | |
|                 
 | |
|                 }
 | |
|                 closeClient();
 | |
|                 ;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void btnReorder_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             try
 | |
|             {
 | |
|                 string msg = "排序成功";
 | |
|                 if (tmsClient.reOrderLine(currentLineId))
 | |
|                 {
 | |
|                     setCurrentRequestDetail();
 | |
| 
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     msg = "排序失败";
 | |
|                 }
 | |
| 
 | |
|                 MessageBox.Show(msg);
 | |
|             }
 | |
|             catch (Exception er)
 | |
|             {
 | |
|                 showErrorMsg("排序失败:" + er.Message);
 | |
|             } closeClient();
 | |
|         }
 | |
| 
 | |
|         private void bbiExport_ItemClick(object sender, ItemClickEventArgs e)
 | |
|         {
 | |
|             exportExcel(gridView2);
 | |
|         }
 | |
|     }
 | |
| } |