1069 lines
35 KiB
C#
1069 lines
35 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.ServiceReferenceGoods;
|
||
using DeiNiu.wms.win.PlateService;
|
||
using DeiNiu.wms.win.utils.print;
|
||
using Microsoft.Reporting.WinForms;
|
||
|
||
|
||
namespace DeiNiu.wms.win
|
||
{
|
||
public partial class BoxForm : BasicRibbonForm
|
||
{
|
||
WmsPlateClient client
|
||
{
|
||
get
|
||
{
|
||
return new WmsPlateClient("BasicHttpBinding_IWmsPlate",
|
||
buildSvrAddress("WmsPlateService.svc"));
|
||
}
|
||
}
|
||
WcfWmsPlate wcfBox = new WcfWmsPlate();
|
||
|
||
// lWmsGoods lgt = new lWmsGoods();
|
||
private string fieldName = WmsLocation.fields.locationId.ToString();
|
||
private string fieldGoodType = WmsLocation.fields.whGoodsType.ToString();
|
||
private string lastQuery = "";
|
||
|
||
private int selectedRowIndex = -1;
|
||
List<WmsPlate> selectedBoxes;
|
||
private int selectedViechleId = 0;
|
||
private string selectedViechleNo = "";
|
||
|
||
private decimal length, width, height, weight = 0m;
|
||
public BoxForm()
|
||
{
|
||
InitializeComponent();
|
||
try
|
||
{
|
||
initialControls();
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
showErrorMsg(er);
|
||
}
|
||
// 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 = 2016");
|
||
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 2016:
|
||
initialComboBoxs(this.comColorQ, drss); // load capicity
|
||
initialComboBoxs(this.comColorUpdate, drss, false); //
|
||
initialComboBoxs(this.comColor, drss, false); //
|
||
break;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
initialComboBoxs(this.comTypeQ, plateLevel); // volume
|
||
initialComboBoxs(this.comTypeUpdate, plateLevel, false); //
|
||
initialComboBoxs(this.comType, plateLevel, false); //
|
||
|
||
initialComboBoxs(this.comBoStatus, plateStatus, false); //
|
||
initialComboBoxs(this.comStatusQ, plateStatus); //
|
||
//initialComboBoxs(this.comActive, viechleStatus); //
|
||
// initialComboBoxs(this.comColorUpdate, 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" };
|
||
GridColumn colChk = new GridColumn() { Caption = CheckBoxField, Visible = true, FieldName = CheckBoxField };
|
||
myCol0.Visible = false;
|
||
this.gridView1.Columns.Add(myCol0);
|
||
this.gridView1.Columns.Add(colChk);
|
||
GridColumn myCol1 = new GridColumn() { Caption = "编号", Visible = true, FieldName = WmsPlate.fields.plateId.ToString()};
|
||
// GridColumn myCol2 = new GridColumn() { Caption = "承重", Visible = true, FieldName = WmsPlate.fields.load.ToString() };
|
||
GridColumn myCol3 = new GridColumn() { Caption = "容积", Visible = true, FieldName = WmsPlate.fields.volume.ToString() };
|
||
GridColumn myCol4 = new GridColumn() { Caption = "类型", Visible = true, FieldName = WmsPlate.fields.type.ToString()+"Name" };
|
||
// GridColumn myCol5 = new GridColumn() { Caption = "状态", Visible = true, FieldName = WmsPlate.fields.state.ToString() + "Name" };
|
||
// GridColumn myCol51 = new GridColumn() { Caption = "分拣单", Visible = true, FieldName = WmsPlate.fields.pickOrderNo.ToString() };
|
||
|
||
// GridColumn myCol52 = new GridColumn() { Caption = "货位", Visible = true, FieldName = WmsPlate.fields.locationId.ToString() };
|
||
// GridColumn myCol53 = new GridColumn() { Caption = "运单号", Visible = true, FieldName = WmsPlate.fields.transNo.ToString() };
|
||
// GridColumn myCol54 = new GridColumn() { Caption = "分区", Visible = true, FieldName = WmsPlate.fields.partion.ToString() };
|
||
// GridColumn myCol55 = new GridColumn() { Caption = "波次号", Visible = true, FieldName = WmsPlate.fields.waveNo.ToString() };
|
||
GridColumn myCol56 = new GridColumn() { Caption = "颜色", Visible = true, FieldName = WmsPlate.fields.color.ToString() + "Name" };
|
||
|
||
GridColumn myCol15 = new GridColumn() { Caption = "长cm", Visible = true, FieldName = WmsPlate.fields.length.ToString() };
|
||
GridColumn myCol16 = new GridColumn() { Caption = "宽cm", Visible = true, FieldName = WmsPlate.fields.width.ToString() };
|
||
GridColumn myCol17 = new GridColumn() { Caption = "高cm", Visible = true, FieldName = WmsPlate.fields.height.ToString() };
|
||
// GridColumn myCol18 = new GridColumn() { Caption = "级别", Visible = true, FieldName = WmsPlate.fields.plateLevel.ToString() };
|
||
GridColumn myCol19 = new GridColumn() { Caption = "上层", Visible = true, FieldName = WmsPlate.fields.inPlate.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(myCol53);
|
||
this.gridView1.Columns.Add(myCol54);
|
||
this.gridView1.Columns.Add(myCol55);
|
||
*/
|
||
this.gridView1.Columns.Add(myCol56);
|
||
|
||
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);
|
||
this.gridView1.Columns.Add(myCol19);
|
||
|
||
//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};", WmsPlate.fields.volume.ToString(), ((Node)this.comVolumeQ.SelectedItem).flag))
|
||
+ (this.comTypeQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", WmsPlate.fields.type.ToString(), ((Colitem)this.comTypeQ.SelectedItem).key )
|
||
+ (this.comColorQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", WmsPlate.fields.color.ToString(), ((Node)this.comColorQ.SelectedItem).flag))
|
||
// + (this.comActive.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", WmsPlate.fields.state.ToString(), ((Colitem)this.comActive.SelectedItem).key))
|
||
+ (this.comStatusQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", WmsPlate.fields.state.ToString(), ((Colitem)this.comStatusQ.SelectedItem).key)));
|
||
|
||
query += (this.txtBoxNoQ.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", WmsPlate.fields.plateId.ToString(), filtRiskChar(txtBoxNoQ.Text.Trim())));
|
||
|
||
// string plateId = this.txtBoxNoQ.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", WmsPlate.fields.plateId.ToString(), filtRiskChar(txtBoxNoQ.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 = client.query(query, start, end);
|
||
client.Close();
|
||
DtGv = 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;
|
||
addCheckField(DtGv);//add checkbox
|
||
DtGv.PrimaryKey = new DataColumn[] { DtGv.Columns["ID"] };
|
||
this.gridControl1.DataSource = DtGv.DefaultView;
|
||
gridView1.BestFitColumns();
|
||
//update selected row index to the last updated one.
|
||
if (wcfBox.id > 0)
|
||
{
|
||
|
||
DataRow dr = DtGv.Rows.Find(wcfBox.id);
|
||
if (dr != null)
|
||
{
|
||
selectedRowIndex = DtGv.Rows.IndexOf(dr);
|
||
}
|
||
|
||
if (selectedRowIndex > 0 && DtGv.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);
|
||
initialDataGridColumns();
|
||
GridCheckEdit(gridView1, CheckBoxField, 50);
|
||
|
||
}
|
||
//显示行的序号
|
||
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 >= DtGv.Rows.Count)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
// DataRow currentRow = DtGv.Rows[selectedRowIndex];
|
||
DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]);
|
||
selectedViechleId = Convert.ToInt32( dr["ID"].ToString());
|
||
|
||
|
||
return true;
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
private void gridView1_DataSourceChanged(object sender, EventArgs e)
|
||
{
|
||
if (selectedRowIndex >= 0 && DtGv.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
|
||
{
|
||
display = Convert.ToInt16(e.DisplayText);
|
||
|
||
// 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
|
||
{
|
||
display = Convert.ToInt16(e.DisplayText);
|
||
|
||
// 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<WmsPlate> boxes)
|
||
{
|
||
showWaitForm();
|
||
//WaitFormService.Show(this);
|
||
try
|
||
{
|
||
|
||
List<WcfWmsPlate> wBoxs = new List<WcfWmsPlate>();
|
||
|
||
foreach (WmsPlate box in boxes)
|
||
{
|
||
|
||
wBoxs.Add(getWcfObject(box));
|
||
}
|
||
WcfWmsPlate[] wcfgoods = wBoxs.ToArray();
|
||
client.update(wcfgoods);
|
||
client.Close();
|
||
// lgt.update(wgoods);
|
||
|
||
//get updated data
|
||
query();
|
||
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
showErrorMsg(e,e.Message);
|
||
}
|
||
finally
|
||
{
|
||
// WaitFormService.Close();
|
||
closeWaitForm();
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
private bool getCurrentObjects()
|
||
{
|
||
int[] selectedRows = gridView1.GetSelectedRows();
|
||
selectedBoxes = new List<WmsPlate>();
|
||
|
||
foreach (DataRow dr in DtGv.Rows)
|
||
{
|
||
string v = dr[CheckBoxField].ToString();
|
||
bool b = String.IsNullOrEmpty(v) ? false : Convert.ToBoolean(v);
|
||
if (b)
|
||
{
|
||
selectedBoxes.Add(new WmsPlate(dr));
|
||
}
|
||
}
|
||
/*
|
||
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}' 吗?",
|
||
selectedBoxes.Count, ((Node)this.comVolumeUpdate.SelectedItem).name),
|
||
"确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||
if (r == DialogResult.Yes)
|
||
{
|
||
|
||
updateObjects(selectedBoxes);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
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 等信息吗?",
|
||
selectedBoxes.Count), "确认修改",
|
||
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||
if (r == DialogResult.Yes)
|
||
{
|
||
|
||
updateObjects(selectedBoxes);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void txtpinyin_KeyUp(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Enter)
|
||
{
|
||
loadData();
|
||
}
|
||
}
|
||
WmsPlate getDbObject(WcfWmsPlate wcfBox){
|
||
|
||
WmsPlate dbObj = new WmsPlate(wcfBox.id);
|
||
dbObj.ID = wcfBox.id;
|
||
|
||
dbObj.color = wcfBox.color;
|
||
dbObj.partion = wcfBox.partion;
|
||
dbObj.load = wcfBox.load;
|
||
dbObj.volume = wcfBox.volume;
|
||
dbObj.length = wcfBox.length;
|
||
dbObj.width = wcfBox.width;
|
||
dbObj.height = wcfBox.height;
|
||
dbObj.type = wcfBox.type;
|
||
dbObj.state = wcfBox.state;
|
||
|
||
|
||
return dbObj;
|
||
|
||
}
|
||
|
||
WcfWmsPlate getWcfObject(WmsPlate dbObj)
|
||
{
|
||
|
||
WcfWmsPlate wcfObj = new WcfWmsPlate();
|
||
wcfObj.id = dbObj.ID;
|
||
wcfObj.color = dbObj.color;
|
||
wcfObj.partion = dbObj.partion;
|
||
wcfObj.load = dbObj.load;
|
||
wcfObj.volume = dbObj.volume;
|
||
wcfObj.length = dbObj.length;
|
||
wcfObj.width = dbObj.width;
|
||
wcfObj.height = dbObj.height;
|
||
wcfObj.type = dbObj.type;
|
||
wcfObj.state = dbObj.state;
|
||
|
||
return wcfObj;
|
||
|
||
}
|
||
|
||
|
||
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}' 吗?",
|
||
selectedBoxes.Count, ((Node)this.comLoadUpdate.SelectedItem).name),
|
||
"确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||
if (r == DialogResult.Yes)
|
||
{
|
||
|
||
updateObjects(selectedBoxes);
|
||
}
|
||
}
|
||
}
|
||
|
||
private bool setAireConditionType()
|
||
{
|
||
|
||
|
||
if (!validData())
|
||
{
|
||
return false;
|
||
}
|
||
if (this.comTypeUpdate.SelectedIndex == -1)
|
||
{
|
||
return false;
|
||
}
|
||
try
|
||
{
|
||
foreach (WmsPlate tv in selectedBoxes)
|
||
{
|
||
tv.type = ((Colitem)this.comTypeUpdate.SelectedItem).key ;
|
||
tv.plateLevel = tv.type;
|
||
// 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 (WmsPlate tv in selectedBoxes)
|
||
{
|
||
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 (WmsPlate tv in selectedBoxes)
|
||
{
|
||
DataRow currentRow = DtGv.Rows.Find(tv.ID);
|
||
|
||
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 尺寸、重量信息吗?", selectedBoxes.Count), "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||
if (r == DialogResult.Yes)
|
||
{
|
||
updateObjects(selectedBoxes);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btnUPdateAirecondition_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.comTypeUpdate.SelectedIndex == -1)
|
||
{
|
||
showErrorMsg("请选择 容器类型");
|
||
comTypeUpdate.Focus();
|
||
return;
|
||
}
|
||
if (getCurrentObjects() && setAireConditionType())
|
||
{
|
||
DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条 容器类型 为 '{1}' 吗?",
|
||
selectedBoxes.Count, ((Colitem)this.comTypeUpdate.SelectedItem).value),
|
||
"确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||
if (r == DialogResult.Yes)
|
||
{
|
||
|
||
updateObjects(selectedBoxes);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btnAdd_Click(object sender, EventArgs e)
|
||
{
|
||
if (txtBoxCnt.Text.Trim().Length ==0)
|
||
{
|
||
showErrorMsg("请输入容器数量 ");
|
||
return;
|
||
}
|
||
|
||
|
||
|
||
WcfWmsPlate wv = new WcfWmsPlate();
|
||
|
||
// wv.volume = ((Node)comVolume.SelectedItem).ID;
|
||
wv.color = ((Node)comColor.SelectedItem).flag;
|
||
wv.type = ((Colitem)this.comType.SelectedItem).key;
|
||
wv.plateLevel = wv.type;
|
||
|
||
|
||
try
|
||
{
|
||
int cnt = Convert.ToInt16(txtBoxCnt.Text.Trim());
|
||
showWaitForm();
|
||
client.add(wv, cnt);
|
||
client.Close();
|
||
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)
|
||
{
|
||
wcfBox .id = selectedViechleId;
|
||
try
|
||
{
|
||
showWaitForm();
|
||
if (client.delete(wcfBox)>0)
|
||
{
|
||
MessageBox.Show("删除成功!");
|
||
}
|
||
query();
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
MessageBox.Show("删除失败!" + er.Message);
|
||
}
|
||
finally
|
||
{
|
||
closeWaitForm();
|
||
client.Close();
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
private bool setViechleStatus()
|
||
{
|
||
|
||
|
||
if (!validData())
|
||
{
|
||
return false;
|
||
}
|
||
if (this.comBoStatus.SelectedIndex == -1)
|
||
{
|
||
return false;
|
||
}
|
||
try
|
||
{
|
||
foreach (WmsPlate tv in selectedBoxes)
|
||
{
|
||
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}' 吗?",
|
||
selectedBoxes.Count, ((Colitem)this.comBoStatus.SelectedItem).value),
|
||
"确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||
if (r == DialogResult.Yes)
|
||
{
|
||
|
||
updateObjects(selectedBoxes);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btnModifyTranStatus_Click(object sender, EventArgs e)
|
||
{
|
||
if (getCurrentObjects() && setViechleTranStatus())
|
||
{
|
||
DialogResult r = MessageBox.Show(string.Format("确定要更新选中的{0}条车辆运输状态为 '{1}' 吗?",
|
||
selectedBoxes.Count, ((Colitem)this.comBoStatus.SelectedItem).value),
|
||
"确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||
if (r == DialogResult.Yes)
|
||
{
|
||
|
||
updateObjects(selectedBoxes);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
private bool setViechleTranStatus()
|
||
{
|
||
|
||
|
||
if (!validData())
|
||
{
|
||
return false;
|
||
}
|
||
if (this.comColorUpdate.SelectedIndex == -1)
|
||
{
|
||
return false;
|
||
}
|
||
try
|
||
{
|
||
foreach (WmsPlate tv in selectedBoxes)
|
||
{
|
||
tv.state = ((Colitem)this.comColorUpdate.SelectedItem).key;
|
||
// good.operater = Park.currentUser.GetEmployee.ID;
|
||
}
|
||
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
showErrorMsg(er.Message);
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
private void simpleButton2_Click(object sender, EventArgs e)
|
||
{
|
||
using (ServiceReferenceMobileTest.MobileClient mb = new ServiceReferenceMobileTest.MobileClient())
|
||
{
|
||
|
||
|
||
//int r= mb.regPartBox(1, "H-1-1-55", 1, "");
|
||
// int x = r;
|
||
|
||
try
|
||
{
|
||
DataTable d = mb.getPartionRequests(1, 1, "");
|
||
int x = d.Rows.Count;
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
showErrorMsg(er.Message);
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
|
||
{
|
||
|
||
printPlateId(DtGv);
|
||
|
||
}
|
||
|
||
void printPlateId(DataTable dt)
|
||
{
|
||
if (dt == null || getCurrentObjects() & selectedBoxes.Count == 0)
|
||
{
|
||
showErrorMsg("请先查询需要打印的数据,然后才能打印。");
|
||
return;
|
||
}
|
||
MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
|
||
DialogResult dl = MessageBox.Show(String.Format("确定要打印 {0}个标签吗?", selectedBoxes.Count), "print", messButton);
|
||
if (dl == DialogResult.OK)
|
||
{
|
||
//lgt.printLocations(dt);
|
||
string reportName = "singleSimpleCode128.rdlc";
|
||
Microsoft.Reporting.WinForms.ReportParameter[] parameters = new Microsoft.Reporting.WinForms.ReportParameter[3];
|
||
|
||
try
|
||
{
|
||
foreach (WmsPlate wp in selectedBoxes)
|
||
{
|
||
parameters[2] = new ReportParameter("flowNo128", Util.getCode128(wp.plateId));
|
||
parameters[1] = new ReportParameter("flowNo", wp.plateId);
|
||
parameters[0] = new ReportParameter("flowName", ((enumPlateLevel)wp.type).ToString());
|
||
|
||
BillPrint.Run(dt, reportName, PrinterType.code, parameters);
|
||
}
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
showErrorMsg(er.Message);
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
} |