| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 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.ServiceReferenceGoods; | 
					
						
							|  |  |  |  | using DeiNiu.wms.win.ViechleService; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace DeiNiu.wms.win | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class ViechlesForm : BasicRibbonForm | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  |         wcfViechle wViechle = new ViechleService.wcfViechle(); | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |       //  lWmsGoods lgt = new lWmsGoods(); | 
					
						
							|  |  |  |  |         private string fieldName = WmsLocation.fields.locationId.ToString(); | 
					
						
							|  |  |  |  |         private string fieldGoodType = WmsLocation.fields.whGoodsType.ToString(); | 
					
						
							|  |  |  |  |         private string lastQuery = ""; | 
					
						
							|  |  |  |  |         private DataTable dt; | 
					
						
							|  |  |  |  |         private int selectedRowIndex = -1; | 
					
						
							|  |  |  |  |         List<TmsViechle> selectedViechles; | 
					
						
							|  |  |  |  |         private int selectedViechleId = 0; | 
					
						
							|  |  |  |  |         private string selectedViechleNo = ""; | 
					
						
							|  |  |  |  |   | 
					
						
							|  |  |  |  |         private decimal length, width, height, weight = 0m; | 
					
						
							|  |  |  |  |         public ViechlesForm() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             InitializeComponent(); | 
					
						
							|  |  |  |  |             initialControls(); | 
					
						
							|  |  |  |  |             //    loadData(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #region initialControls | 
					
						
							|  |  |  |  |         private void initialControls() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             initialComboBoxes(); | 
					
						
							|  |  |  |  |             initialPagerControls(); | 
					
						
							|  |  |  |  |             initialDataGrid(); | 
					
						
							|  |  |  |  |             initialQueryInput();  | 
					
						
							|  |  |  |  |             setValidationRule(); | 
					
						
							|  |  |  |  |             this.lcgSetup.Expanded = false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void initialComboBoxes() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //initial comboboxedits with dic | 
					
						
							|  |  |  |  |             Node[] nds = { }; | 
					
						
							|  |  |  |  |             DataTable dt = Park.getDictionary(false); | 
					
						
							|  |  |  |  |             if (dt.Rows.Count == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             DataRow[] drs = dt.Select("flag >0"); | 
					
						
							|  |  |  |  |             foreach (DataRow dr in drs) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 int flag = Convert.ToInt32(dr["flag"].ToString()); | 
					
						
							|  |  |  |  |                 int parentId = Convert.ToInt32(dr["id"].ToString()); | 
					
						
							|  |  |  |  |                 DataRow[] drss = Park.getDictionary(false).Select("parentId =" + parentId); | 
					
						
							|  |  |  |  |                 switch (flag) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     case 3002: | 
					
						
							|  |  |  |  |                         initialComboBoxs(this.comVolumeQ, drss); // volume | 
					
						
							|  |  |  |  |                         initialComboBoxs(this.comVolumeUpdate, drss,false); //                        | 
					
						
							|  |  |  |  |                         initialComboBoxs(this.comVolume, drss,false); // | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                     case 3008: | 
					
						
							|  |  |  |  |                         initialComboBoxs(this.comLoadQ, drss); // load capicity | 
					
						
							|  |  |  |  |                         initialComboBoxs(this.comLoadUpdate, drss, false); //            | 
					
						
							|  |  |  |  |                         initialComboBoxs(this.comLoad, drss, false); //            | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                     case 3005: | 
					
						
							|  |  |  |  |                         initialComboBoxs(this.comTypeQ, drss); // load capicity | 
					
						
							|  |  |  |  |                         initialComboBoxs(this.comTypeUpdate, drss, false); //            | 
					
						
							|  |  |  |  |                         initialComboBoxs(this.comType, drss, false); //            | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                 }  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             initialComboBoxs(this.comBoStatus, viechleStatus, false); //    | 
					
						
							|  |  |  |  |             initialComboBoxs(this.comTranStatusQ, viechleTranStatus); // | 
					
						
							|  |  |  |  |             initialComboBoxs(this.comActive, viechleStatus); // | 
					
						
							|  |  |  |  |             initialComboBoxs(this.comTransStatus, viechleTranStatus,false); // | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |        | 
					
						
							|  |  |  |  |         private void setValidationRule() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |           //  dxValidationProvider.SetValidationRule(comWarehouse, ValidationRules.notEmptyValidationRule); | 
					
						
							|  |  |  |  |             //txtGoodType.Properties.MaxLength = 40; | 
					
						
							|  |  |  |  |             //txtGoodDesc.Properties.MaxLength = 250; | 
					
						
							|  |  |  |  |             //textEdit1.Properties.MaxLength = txtGoodType.Properties.MaxLength; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void initialQueryInput() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |        | 
					
						
							|  |  |  |  |         private void initialDataGridColumns() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             setupGridView(gridView1, true); | 
					
						
							|  |  |  |  |             //   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 = TmsViechle.fields.viechleId.ToString()}; | 
					
						
							|  |  |  |  |             GridColumn myCol2 = new GridColumn() { Caption = "载重", Visible = true, FieldName = TmsViechle.fields.load.ToString() +"Name" }; | 
					
						
							|  |  |  |  |             GridColumn myCol3 = new GridColumn() { Caption = "容积", Visible = true, FieldName = TmsViechle.fields.volume.ToString()+"Name" }; | 
					
						
							|  |  |  |  |             GridColumn myCol4 = new GridColumn() { Caption = "类型", Visible = true, FieldName = TmsViechle.fields.airCondition.ToString() + "Name" }; | 
					
						
							|  |  |  |  |             GridColumn myCol5 = new GridColumn() { Caption = "车辆状态", Visible = true, FieldName = TmsViechle.fields.state.ToString() }; | 
					
						
							|  |  |  |  |             GridColumn myCol51 = new GridColumn() { Caption = "运输状态", Visible = true, FieldName = TmsViechle.fields.transState.ToString() }; | 
					
						
							|  |  |  |  |             GridColumn myCol52 = new GridColumn() { Caption = "在运单号", Visible = true, FieldName = TmsViechle.fields.transOrder.ToString() }; | 
					
						
							|  |  |  |  |             GridColumn myCol15 = new GridColumn() { Caption = "长cm", Visible = true, FieldName = TmsViechle.fields.length.ToString() }; | 
					
						
							|  |  |  |  |             GridColumn myCol16 = new GridColumn() { Caption = "宽cm", Visible = true, FieldName = TmsViechle.fields.width.ToString() }; | 
					
						
							|  |  |  |  |             GridColumn myCol17 = new GridColumn() { Caption = "高cm", Visible = true, FieldName = TmsViechle.fields.height.ToString() }; | 
					
						
							|  |  |  |  |             GridColumn myCol18 = new GridColumn() { Caption = "重kg", Visible = true, FieldName = TmsViechle.fields.weight.ToString() }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol1); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol2); | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |           | 
					
						
							|  |  |  |  |       | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol5); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol51); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol52); | 
					
						
							|  |  |  |  |   | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol4);   | 
					
						
							|  |  |  |  |           | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol3); | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol15); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol16); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol17); | 
					
						
							|  |  |  |  |             this.gridView1.Columns.Add(myCol18);  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //to show bottom scroll bar | 
					
						
							|  |  |  |  |             gridView1.OptionsView.ColumnAutoWidth = false; | 
					
						
							|  |  |  |  |             gridView1.BestFitColumns(); | 
					
						
							|  |  |  |  |             gridView1.Focus(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //自动列宽 | 
					
						
							|  |  |  |  |             //gridView1.OptionsView.ColumnAutoWidth = false; | 
					
						
							|  |  |  |  |             //this.gridView1.BestFitColumns(); | 
					
						
							|  |  |  |  |             //this.gridView1.Columns[2].MinWidth = 500; | 
					
						
							|  |  |  |  |             //this.gridView1.Columns[1].BestFit(); | 
					
						
							|  |  |  |  |             //for (int I = 0; I < gridView1.Columns.Count; I++) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //     this.gridView1.Columns[I].BestFit() | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary>   | 
					
						
							|  |  |  |  |         /// loading data | 
					
						
							|  |  |  |  |         /// </summary>   | 
					
						
							|  |  |  |  |         private int loadData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             showWaitForm(); | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |                 // this.splashScreenManager1.ShowWaitForm(); | 
					
						
							|  |  |  |  |                 string query = (this.comVolumeQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", TmsViechle.fields.volume.ToString(), ((Node)this.comVolumeQ.SelectedItem).ID)) | 
					
						
							|  |  |  |  |                     + (this.comLoadQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", TmsViechle.fields.load.ToString(), ((Node)this.comLoadQ.SelectedItem).ID)) | 
					
						
							|  |  |  |  |                       + (this.comTypeQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", TmsViechle.fields.airCondition.ToString(), ((Node)this.comTypeQ.SelectedItem).ID)) | 
					
						
							|  |  |  |  |                        + (this.comActive.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", TmsViechle.fields.state.ToString(), ((Colitem)this.comActive.SelectedItem).key)) | 
					
						
							|  |  |  |  |                         + (this.comTranStatusQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", TmsViechle.fields.transState.ToString(), ((Colitem)this.comTranStatusQ.SelectedItem).key)) | 
					
						
							|  |  |  |  |                       + (this.txtViechleNoQ.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", TmsViechle.fields.viechleId.ToString(), filtRiskChar(txtViechleNoQ.Text.Trim()))); | 
					
						
							|  |  |  |  |                                            ; | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |                 this.pager1.PageCurrent = lastQuery.Equals(query) ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值 | 
					
						
							|  |  |  |  |                 int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1); | 
					
						
							|  |  |  |  |                 int end = (pager1.PageSize * pager1.PageCurrent); | 
					
						
							|  |  |  |  |                 lastQuery = query; | 
					
						
							|  |  |  |  |                 DataSet ds = vclient.Query(query, start, end); | 
					
						
							|  |  |  |  |                 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"] }; | 
					
						
							|  |  |  |  |                 this.gridControl1.DataSource = dt.DefaultView; | 
					
						
							|  |  |  |  |                 initialDataGridColumns(); | 
					
						
							|  |  |  |  |                 //update selected row index to the last updated one. | 
					
						
							|  |  |  |  |                 if (wViechle.id > 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     DataRow dr = dt.Rows.Find(wViechle.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; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 closeWaitForm(); | 
					
						
							|  |  |  |  |                 return cnt;// lgt.getRowCount(query); | 
					
						
							|  |  |  |  |                 // return lgt.GetGoodType.QueryCount();  | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg(er,er.Message); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return 0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         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 = 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;//每页行数   | 
					
						
							|  |  |  |  |             this.pager1.Bind();//绑定   | 
					
						
							|  |  |  |  |             #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         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.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); | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |             gridView1.CustomColumnDisplayText += gridView1_CustomColumnDisplayText; | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  |             //show line number | 
					
						
							|  |  |  |  |             this.gridView1.IndicatorWidth = 40; | 
					
						
							|  |  |  |  |             this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView1_CustomDrawRowIndicator); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         //显示行的序号     | 
					
						
							|  |  |  |  |         private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (e.Info.IsRowIndicator && e.RowHandle >= 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 e.Info.DisplayText = (e.RowHandle + 1).ToString(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         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); | 
					
						
							|  |  |  |  |                     getCurrentObject(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 return; ; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             selectedRowIndex = gridView1.FocusedRowHandle; | 
					
						
							|  |  |  |  |           getCurrentObject(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private bool getCurrentObject() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |    | 
					
						
							|  |  |  |  |             if (selectedRowIndex < 0 || selectedRowIndex >= dt.Rows.Count) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //  DataRow currentRow = dt.Rows[selectedRowIndex]; | 
					
						
							|  |  |  |  |             DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]); | 
					
						
							|  |  |  |  |             selectedViechleId = Convert.ToInt32( dr["ID"].ToString()); | 
					
						
							|  |  |  |  |             selectedViechleNo =  dr[TmsViechle.fields.viechleId.ToString()].ToString() ; | 
					
						
							|  |  |  |  |             //    lbaddress.Text = dr["address"].ToString(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  |       | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void gridView1_DataSourceChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (selectedRowIndex >= 0 && dt.Rows.Count > selectedRowIndex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 gridView1.FocusedRowHandle = selectedRowIndex; | 
					
						
							|  |  |  |  |                 gridView1.MakeRowVisible(selectedRowIndex); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void clearInputs() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (e.Column.FieldName == "state") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (!viechleStatus.ContainsValue(e.DisplayText)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     int display = -100; | 
					
						
							|  |  |  |  |                     string disTxt = e.DisplayText; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     try | 
					
						
							|  |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |                         display = Convert.ToInt32(e.DisplayText); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                         e.DisplayText = viechleStatus[display]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     catch | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         return; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } else if (e.Column.FieldName == "transState") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (!viechleTranStatus.ContainsValue(e.DisplayText)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     int display = -100; | 
					
						
							|  |  |  |  |                     string disTxt = e.DisplayText; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     try | 
					
						
							|  |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |                         display = Convert.ToInt32(e.DisplayText); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                         e.DisplayText = viechleTranStatus[display]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     catch | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         return; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |      | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         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,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<TmsViechle> vies) | 
					
						
							|  |  |  |  |         {  | 
					
						
							|  |  |  |  |             showWaitForm(); | 
					
						
							|  |  |  |  |             //WaitFormService.Show(this);  | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 List<wcfViechle> wViechles = new List<wcfViechle>(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 foreach (TmsViechle tv in vies) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     wViechles.Add(getWcfViechles(tv)); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 wcfViechle[] wcfgoods = wViechles.ToArray(); | 
					
						
							|  |  |  |  |                 vclient.update(wcfgoods); | 
					
						
							|  |  |  |  |                 closeClient(); | 
					
						
							|  |  |  |  |                // lgt.update(wgoods); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 //get updated data  | 
					
						
							|  |  |  |  |                 query(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception e) | 
					
						
							|  |  |  |  |             {  closeClient(); | 
					
						
							|  |  |  |  |                 showErrorMsg(e,e.Message); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             finally | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 // WaitFormService.Close(); | 
					
						
							|  |  |  |  |                 closeWaitForm(); | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private bool getCurrentObjects() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             int[] selectedRows = gridView1.GetSelectedRows(); | 
					
						
							|  |  |  |  |             selectedViechles = new List<TmsViechle>(); | 
					
						
							|  |  |  |  |             foreach (int i in selectedRows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DataRow currentRow = dt.Rows[i]; | 
					
						
							|  |  |  |  |                 selectedViechles.Add(new TmsViechle(currentRow)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (selectedRows.Length == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("请至少选择一个商品条目"); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |   | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |         private void btnUpdateGoodType_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (this.comVolumeUpdate.SelectedIndex == -1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("请选择商品类型"); | 
					
						
							|  |  |  |  |                 comVolumeUpdate.Focus(); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |           if(  getCurrentObjects() && setVol()   ){ | 
					
						
							|  |  |  |  |              DialogResult r =  MessageBox.Show(string.Format("确定要更新选中的{0}条 volume 为 '{1}' 吗?", | 
					
						
							|  |  |  |  |                                                  selectedViechles.Count, ((Node)this.comVolumeUpdate.SelectedItem).name),  | 
					
						
							|  |  |  |  |                                               "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |              if (r == DialogResult.Yes) | 
					
						
							|  |  |  |  |              { | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |                  updateObjects(selectedViechles); | 
					
						
							|  |  |  |  |              } | 
					
						
							|  |  |  |  |           } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void bbSaveAll_ItemClick(object sender, ItemClickEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             saveAll(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void btnQuery_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.query(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void btnSaveAll_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             saveAll(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void saveAll() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (getCurrentObjects() && setAireConditionType() && setSizeWeight() && setVol()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条商品类型、容积、尺寸重量、load 等信息吗?", | 
					
						
							|  |  |  |  |                                                                  selectedViechles.Count), "确认修改", | 
					
						
							|  |  |  |  |                                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 if (r == DialogResult.Yes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     updateObjects(selectedViechles); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void txtpinyin_KeyUp(object sender, KeyEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (e.KeyCode == Keys.Enter) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 loadData(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         wcfViechle getWcfViechles(TmsViechle tmsViechle) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             wcfViechle tv = new wcfViechle(); | 
					
						
							|  |  |  |  |             tv.id = tmsViechle.ID; | 
					
						
							|  |  |  |  |             tv.airCondition = tmsViechle.airCondition; | 
					
						
							|  |  |  |  |             tv.driver = tmsViechle.driver; | 
					
						
							|  |  |  |  |             tv.height = tmsViechle.height; | 
					
						
							|  |  |  |  |             tv.width = tmsViechle.width; | 
					
						
							|  |  |  |  |             tv.viechleId = tmsViechle.viechleId; | 
					
						
							|  |  |  |  |             tv.volume = tmsViechle.volume; | 
					
						
							|  |  |  |  |             tv.load = tmsViechle.load; | 
					
						
							|  |  |  |  |             tv.length = tmsViechle.length; | 
					
						
							|  |  |  |  |             tv.weight = tmsViechle.weight; | 
					
						
							|  |  |  |  |             tv.driver = tmsViechle.driver; | 
					
						
							|  |  |  |  |             tv.state = tmsViechle.state; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return tv; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void btnModifyRepType_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (this.comLoadUpdate.SelectedIndex == -1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("请选择 load "); | 
					
						
							|  |  |  |  |                 comLoadUpdate.Focus(); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (getCurrentObjects() && setAireConditionType()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条车辆载重为 '{1}' 吗?", | 
					
						
							|  |  |  |  |                                                     selectedViechles.Count, ((Node)this.comLoadUpdate.SelectedItem).name), | 
					
						
							|  |  |  |  |                                                  "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 if (r == DialogResult.Yes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     updateObjects(selectedViechles); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private bool setAireConditionType() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (!validData()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (this.comTypeUpdate.SelectedIndex == -1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (TmsViechle tv in selectedViechles) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     tv.airCondition = ((Node)this.comTypeUpdate.SelectedItem).ID; | 
					
						
							|  |  |  |  |                     //  good.operater = Park.currentUser.GetEmployee.ID; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg(er,er.Message); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private bool setVol() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (!validData()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (this.comVolumeUpdate.SelectedIndex == -1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (TmsViechle tv in selectedViechles) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     tv.volume = ((Node)this.comVolumeUpdate.SelectedItem).ID; | 
					
						
							|  |  |  |  |                     //  good.operater = Park.currentUser.GetEmployee.ID; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg(er.Message); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private bool setSizeWeight() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!validSize()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (TmsViechle tv in selectedViechles) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     DataRow currentRow = dt.Rows.Find(tv.ID); | 
					
						
							|  |  |  |  |                     tv.weight = weight; | 
					
						
							|  |  |  |  |                     tv.height = height; | 
					
						
							|  |  |  |  |                     tv.width = width; | 
					
						
							|  |  |  |  |                     tv.length = length;   | 
					
						
							|  |  |  |  |                     | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg(er.Message); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private bool validSize() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             {  | 
					
						
							|  |  |  |  |                 height =  Convert.ToDecimal(txtHeight.Text.Trim()); | 
					
						
							|  |  |  |  |                 width = Convert.ToDecimal(txtWidth.Text.Trim()); | 
					
						
							|  |  |  |  |                 length = Convert.ToDecimal(txtLength.Text.Trim()); | 
					
						
							|  |  |  |  |                 weight = Convert.ToDecimal(txtWeight.Text.Trim());  | 
					
						
							|  |  |  |  |                 return true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("尺寸或load重量设置错误!"); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void btnUpdateSize_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (getCurrentObjects() && setSizeWeight()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条che liang 尺寸、重量信息吗?", selectedViechles.Count), "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 if (r == DialogResult.Yes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     updateObjects(selectedViechles); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void btnUPdateAirecondition_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (this.comTypeUpdate.SelectedIndex == -1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("请选择 aire condition type"); | 
					
						
							|  |  |  |  |                 comTypeUpdate.Focus(); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (getCurrentObjects() && setAireConditionType()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条 airecondition 为 '{1}' 吗?", | 
					
						
							|  |  |  |  |                                                     selectedViechles.Count, ((Node)this.comTypeUpdate.SelectedItem).name), | 
					
						
							|  |  |  |  |                                                  "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 if (r == DialogResult.Yes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     updateObjects(selectedViechles); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void btnAdd_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (txtViechleNo.Text.Trim().Length < 5) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg("che pai is required "); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             wcfViechle wv = new wcfViechle(); | 
					
						
							|  |  |  |  |             wv.viechleId = txtViechleNo.Text.Trim(); | 
					
						
							|  |  |  |  |             wv.volume = ((Node)comVolume.SelectedItem).ID; | 
					
						
							|  |  |  |  |             wv.load = ((Node)comLoad.SelectedItem).ID; | 
					
						
							|  |  |  |  |             wv.airCondition = ((Node) comType.SelectedItem).ID; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showWaitForm(); | 
					
						
							|  |  |  |  |                 vclient.add(wv); | 
					
						
							|  |  |  |  |                 closeClient(); | 
					
						
							|  |  |  |  |                 closeWaitForm(); | 
					
						
							|  |  |  |  |                 MessageBox.Show("成功"); | 
					
						
							|  |  |  |  |                 query(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             {  | 
					
						
							|  |  |  |  |                 closeWaitForm(); | 
					
						
							|  |  |  |  |                 showErrorMsg(er,"" + er.Message); | 
					
						
							|  |  |  |  |                 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void btnDel_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if ( selectedViechleId >0 ) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DialogResult r = MessageBox.Show(string.Format("确定要删除'{0}' 吗?", selectedViechleNo), | 
					
						
							|  |  |  |  |                                                  "确认删除", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 if (r == DialogResult.Yes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     wViechle.id = selectedViechleId; | 
					
						
							|  |  |  |  |                     try | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         showWaitForm(); | 
					
						
							|  |  |  |  |                         if (vclient.delete(wViechle)) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             MessageBox.Show("删除成功!"); | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         query(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     catch (Exception er) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         MessageBox.Show("删除失败!" + er.Message); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     finally | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         closeWaitForm(); | 
					
						
							|  |  |  |  |                         closeClient(); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private bool setViechleStatus() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (!validData()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (this.comBoStatus.SelectedIndex == -1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (TmsViechle tv in selectedViechles) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     tv.state = ((Colitem)this.comBoStatus.SelectedItem).key; | 
					
						
							|  |  |  |  |                     //  good.operater = Park.currentUser.GetEmployee.ID; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg(er.Message); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void btnUpdateStates_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (getCurrentObjects() && setViechleStatus()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条车辆状态为 '{1}' 吗?", | 
					
						
							|  |  |  |  |                                                     selectedViechles.Count, ((Colitem)this.comBoStatus.SelectedItem).value), | 
					
						
							|  |  |  |  |                                                  "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 if (r == DialogResult.Yes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     updateObjects(selectedViechles); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void btnModifyTranStatus_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (getCurrentObjects() && setViechleTranStatus()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条车辆运输状态为 '{1}' 吗?", | 
					
						
							|  |  |  |  |                                                     selectedViechles.Count, ((Colitem)this.comBoStatus.SelectedItem).value), | 
					
						
							|  |  |  |  |                                                  "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 if (r == DialogResult.Yes) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     updateObjects(selectedViechles); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private bool setViechleTranStatus() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (!validData()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (this.comTransStatus.SelectedIndex == -1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (TmsViechle tv in selectedViechles) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     tv.state = ((Colitem)this.comTransStatus.SelectedItem).key; | 
					
						
							|  |  |  |  |                     //  good.operater = Park.currentUser.GetEmployee.ID; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 showErrorMsg(er.Message); | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |