1187 lines
43 KiB
C#
1187 lines
43 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraBars;
|
|
using DevExpress.XtraGrid.Views.Base;
|
|
//using DeiNiu.wms.Logical;
|
|
using DeiNiu.wms.Data;
|
|
using DevExpress.XtraGrid.Columns;
|
|
|
|
using System.Threading;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraEditors.DXErrorProvider;
|
|
using DeiNiu.wms.Data.Model;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraEditors.Controls;
|
|
using DeiNiu.Utils;
|
|
using DeiNiu.wms.win.utils.print;
|
|
using DeiNiu.wms.win.ServiceReferenceStockOutPickRequest;
|
|
using Deiniu.win.elelab;
|
|
using DeiNiu.wms.win.ServiceReferenceStockOutRequest;
|
|
using DeiNiu.wms.win.waveRuleService;
|
|
|
|
|
|
namespace DeiNiu.wms.win
|
|
{
|
|
public partial class GoodsOutWave : BasicRibbonForm
|
|
{
|
|
|
|
|
|
printIn reqportPrint = new printIn() ;
|
|
|
|
// lWmsStock ls = new lWmsStock();
|
|
// lWmsOutPickRequest lgt = new lWmsOutPickRequest();
|
|
private string fieldName = WmsLocation.fields.locationId.ToString();
|
|
private string fieldGoodType = WmsLocation.fields.whGoodsType.ToString();
|
|
private string lastQuery = "";
|
|
string waveNo = "", lastWaveNo = "";
|
|
private DataTable dtRepOrders;
|
|
private int selectedRowIndex = -1;
|
|
|
|
bool autoOrder;
|
|
int lightId = 0;
|
|
int comId = 1;
|
|
|
|
public GoodsOutWave()
|
|
{
|
|
InitializeComponent();
|
|
initialControls();
|
|
// loadData();
|
|
|
|
}
|
|
|
|
#region initialControls
|
|
private void initialControls()
|
|
{
|
|
setDatePiker(dateEditFrom, dateEditTo);
|
|
initialComboBoxes();
|
|
initialPagerControls();
|
|
initialDataGrid();
|
|
initialQueryInput();
|
|
setValidationRule();
|
|
|
|
initialChannelLight();
|
|
// searchLight();
|
|
// swAutoOrder.IsOn = WmsConstants.AUTO_PICK_BATCH_PICK_ORDER;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 分页控件产生的事件
|
|
/// </summary>
|
|
private int pager_EventPaging(DeiNiu.Controls.pager.EventPagingArg e)
|
|
{
|
|
// selectedRowIndex = 0; //reset currentRowIndex
|
|
return setCurrentRequestDetail();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页控件产生的事件
|
|
/// </summary>
|
|
private int pager_EventPaging2(DeiNiu.Controls.pager.EventPagingArg e)
|
|
{
|
|
selectedRowIndex = 0; //reset currentRowIndex
|
|
return loadData();
|
|
}
|
|
|
|
private void initialPagerControls()
|
|
{
|
|
|
|
pager1.MaximumSize = new Size(0, 20);
|
|
pager1.EventPaging += new DeiNiu.Controls.pager.EventPagingHandler(pager_EventPaging);
|
|
#region DataGridView与Pager控件绑定
|
|
this.pager1.PageCurrent = 1;//当前页为第一页
|
|
pager1.PageSize = Utils.WmsConstants.PAGER_SIZE;//每页行数
|
|
|
|
#endregion
|
|
|
|
pager2.MaximumSize = new Size(0, 20);
|
|
pager2.EventPaging += new DeiNiu.Controls.pager.EventPagingHandler(pager_EventPaging2);
|
|
#region DataGridView与Pager控件绑定
|
|
this.pager2.PageCurrent = 1;//当前页为第一页
|
|
pager2.PageSize = Utils.WmsConstants.PAGER_SIZE;//每页行数
|
|
// this.pager2.Bind();//绑定
|
|
#endregion
|
|
this.pager2.Bind();//绑定
|
|
this.pager1.Bind();//绑定
|
|
}
|
|
|
|
|
|
|
|
private void initialComboBoxes()
|
|
{
|
|
|
|
initialComboBoxs(comboState, waveStatus);
|
|
Dictionary<int, string> dic = new Dictionary<int, string>();
|
|
|
|
dic[(int)enumStockRecordType.销售出库] = enumStockRecordType.销售出库.ToString();
|
|
dic[(int)enumStockRecordType.补零出库] = enumStockRecordType.补零出库.ToString();
|
|
dic[(int)enumStockRecordType.报废出库] = enumStockRecordType.报废出库.ToString();
|
|
dic[(int)enumStockRecordType.退供应商出库] = enumStockRecordType.退供应商出库.ToString();
|
|
dic[(int)enumStockRecordType.仓间调出] = enumStockRecordType.仓间调出.ToString();
|
|
|
|
initialComboBoxs(comRecType, dic);
|
|
|
|
waveRuleService.WcfWaveRule[] rules = wrClient.getWaveRules(enumWaveRuleType.普通波次);
|
|
closeClient();
|
|
|
|
dic = new Dictionary<int, string>();
|
|
|
|
foreach (WcfWaveRule rule in rules)
|
|
{
|
|
dic.Add(rule.ID, rule.ruleName);
|
|
}
|
|
|
|
initialComboBoxs(comWaveRule, dic);
|
|
|
|
WcfWaveRule rulex = wrClient.getCurrentActiveRule( enumWaveRuleType.普通波次 );
|
|
closeClient();
|
|
|
|
if (rulex.ID > 0)
|
|
{
|
|
int i=0;
|
|
foreach (Object item in comWaveRule.Properties.Items)
|
|
{
|
|
if (((Colitem)item).key == rulex.ID)
|
|
{
|
|
comWaveRule.SelectedItem = item;
|
|
// comboState.SelectedIndex = i;
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
|
|
this.spinWave.Value = rulex.interval;
|
|
}
|
|
|
|
}
|
|
|
|
private void setValidationRule()
|
|
{
|
|
// dxValidationProvider.SetValidationRule(comWarehouse, ValidationRules.notEmptyValidationRule);
|
|
//txtGoodType.Properties.MaxLength = 40;
|
|
//txtGoodDesc.Properties.MaxLength = 250;
|
|
//textEdit1.Properties.MaxLength = txtGoodType.Properties.MaxLength;
|
|
}
|
|
|
|
private void initialQueryInput()
|
|
{
|
|
|
|
}
|
|
|
|
private void initialDataGridColumns(GridView gridView)
|
|
{
|
|
setupGridView(gridView, false);
|
|
//setupGridView(gridView2, false,false);
|
|
//setupGridView(gridView3, false,false);
|
|
// gridviewGoodsType.PopulateColumns();
|
|
gridView.Columns.Clear();
|
|
// gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]);
|
|
GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
|
|
myCol0.Visible = false;
|
|
gridView.Columns.Add(myCol0);
|
|
GridColumn myCol1 = new GridColumn() { Caption = "波次号", Visible = true, FieldName = WmsWave.fields.waveNo.ToString() };
|
|
GridColumn myCol2 = new GridColumn() { Caption = "类型", Visible = true, FieldName = WmsWave.fields.type.ToString(),MinWidth=80 };
|
|
GridColumn myCol3 = new GridColumn() { Caption = "状态", Visible = true, FieldName = WmsWave.fields.state.ToString(), MinWidth = 60 };
|
|
GridColumn myCol4 = new GridColumn() { Caption = "时间", Visible = true, FieldName = "createtime", MinWidth = 120 };
|
|
|
|
|
|
gridView.Columns.Add(myCol1);
|
|
gridView.Columns.Add(myCol2);
|
|
gridView.Columns.Add(myCol3);
|
|
gridView.Columns.Add(myCol4);
|
|
|
|
//to show bottom scroll bar
|
|
gridView.OptionsView.ColumnAutoWidth = false;
|
|
gridView.BestFitColumns();
|
|
gridView.Focus();
|
|
|
|
//if (gridView1 == gridView)
|
|
//{
|
|
// this.gridView1.Focus(); ;
|
|
//}
|
|
|
|
|
|
// initialGridView2Columns();
|
|
// gridControl2.DataSource = null;
|
|
}
|
|
private void initialGridView2Columns(GridView gridview)
|
|
{
|
|
setupGridView(gridview, false, true, false);
|
|
gridview.FocusRectStyle = DrawFocusRectStyle.None;
|
|
// gridviewGoodsType.PopulateColumns();
|
|
gridview.Columns.Clear();
|
|
// gridviewGoodsType.Columns.Remove(gridviewGoodsType.Columns["DealerPrice"]);
|
|
GridColumn myCol0 = new GridColumn() { Caption = "ID", Visible = true, FieldName = "id" };
|
|
myCol0.Visible = false;
|
|
gridview.Columns.Add(myCol0);
|
|
/* GridColumn myCol1 = new GridColumn() { Caption = "商品编码", Visible = true, FieldName = WmsGoods.fields.goodsId.ToString() };
|
|
GridColumn myCol2 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = WmsGoods.exfields.goodsName.ToString() };
|
|
GridColumn myCol3 = new GridColumn() { Caption = "厂家", Visible = true, FieldName = WmsGoods.exfields.manufacturer.ToString() };
|
|
GridColumn myCol4 = new GridColumn() { Caption = "规格", Visible = true, FieldName = WmsGoods.exfields.spec.ToString() };
|
|
GridColumn myCol5 = new GridColumn() { Caption = "单位", Visible = true, FieldName = WmsGoods.exfields.unit.ToString() };
|
|
GridColumn myCol6 = new GridColumn() { Caption = "大包装数量", Visible = true, FieldName = WmsGoods.exfields.bigCount.ToString() };
|
|
GridColumn myCol7 = new GridColumn() { Caption = "剂型", Visible = true, FieldName = WmsGoods.exfields.type.ToString() };
|
|
GridColumn myCol8 = new GridColumn() { Caption = "商品类型", Visible = true, FieldName = WmsGoods.exfields.goodsTypeName.ToString() };
|
|
GridColumn myCol9 = new GridColumn() { Caption = "大零", Visible = true, FieldName = WmsGoods.fields.bulkMax.ToString() };
|
|
GridColumn myCol10 = new GridColumn() { Caption = "小整", Visible = true, FieldName = WmsGoods.fields.batchMax1.ToString() };
|
|
GridColumn myCol11 = new GridColumn() { Caption = "大整", Visible = true, FieldName = WmsGoods.fields.batchMax2.ToString() };
|
|
GridColumn myCol12 = new GridColumn() { Caption = "国药准字", Visible = true, FieldName = WmsGoods.exfields.regeditCode.ToString() };
|
|
|
|
GridColumn myCol13 = new GridColumn() { Caption = "小整数量", Visible = true, FieldName = WmsOutPickDetail.fields.batch1Count.ToString() };
|
|
GridColumn myCol131 = new GridColumn() { Caption = "大整数量", Visible = true, FieldName = WmsOutPickDetail.fields.batch2Count.ToString() };
|
|
|
|
GridColumn myCol14 = new GridColumn() { Caption = "批号", Visible = true, FieldName = WmsInRequestDetail.fields.batch.ToString() };
|
|
GridColumn myCol15 = new GridColumn() { Caption = "生产日期", Visible = true, FieldName = WmsInRequestDetail.fields.productDate.ToString() };
|
|
GridColumn myCol16 = new GridColumn() { Caption = "有效期", Visible = true, FieldName = WmsInRequestDetail.fields.validDate.ToString() };
|
|
|
|
GridColumn myCol17 = new GridColumn() { Caption = "状态", Visible = true, FieldName = gridview == gridView3 ? "state" : WmsOutPickDetail .fields.batchPickState.ToString() };
|
|
GridColumn myCol18 = new GridColumn() { Caption = "说明", Visible = true, FieldName = WmsInRequestDetail.fields.description.ToString() };
|
|
|
|
GridColumn myCol20 = new GridColumn() { Caption = "出库数量", Visible = true, FieldName = WmsOutPickLable.fields.count.ToString() };
|
|
GridColumn myCol21 = new GridColumn() { Caption = "集货货位", Visible = true, FieldName = WmsOutPickPort.fields.tranLocationId.ToString() };
|
|
*/
|
|
GridColumn myCol1 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = WmsGoods.exfields.goodsName.ToString() };
|
|
GridColumn myCol2 = new GridColumn() { Caption = "货位", Visible = true, FieldName = WmsOutPickLable.fields.locationId.ToString() };
|
|
GridColumn myCol3 = new GridColumn() { Caption = "状态", Visible = true, FieldName = "state" };
|
|
GridColumn myCol4 = new GridColumn() { Caption = "计划数量", Visible = true, FieldName = WmsOutPickPort.fields.count.ToString() };
|
|
GridColumn myCol5 = new GridColumn() { Caption = "拣货数量", Visible = true, FieldName = WmsOutPickPort.fields.pickCount.ToString() };
|
|
GridColumn myCol6 = new GridColumn() { Caption = "单位", Visible = true, FieldName = WmsGoods.exfields.unit.ToString() };
|
|
GridColumn myCol7 = new GridColumn() { Caption = "批号", Visible = true, FieldName = WmsInRequestDetail.fields.batch.ToString() };
|
|
GridColumn myCol8 = new GridColumn() { Caption = "分拣单", Visible = true, FieldName = "pickOrderNo" };
|
|
GridColumn myCol9 = new GridColumn() { Caption = "集货区", Visible = true, FieldName = "tranAreaName" };
|
|
GridColumn myCol10 = new GridColumn() { Caption = "集货货位", Visible = true, FieldName = WmsOutPickPort.fields.tranLocationId.ToString() };
|
|
GridColumn myCol11 = new GridColumn() { Caption = "skuId", Visible = true, FieldName = "skuId" };
|
|
GridColumn myCol12 = new GridColumn() { Caption = "sku", Visible = true, FieldName = "skuCode" };
|
|
GridColumn myCol13= new GridColumn() { Caption = "货主", Visible = true, FieldName = "ownerName" };
|
|
GridColumn myCol14 = new GridColumn() { Caption = "货位分区", Visible = true, FieldName = "partName" };
|
|
GridColumn myCol15 = new GridColumn() { Caption = "波次号", Visible = true, FieldName = "waveOrder" };
|
|
GridColumn myCol16 = new GridColumn() { Caption = "任务编号", Visible = true, FieldName = "jobNo" };
|
|
GridColumn myCol17 = new GridColumn() { Caption = "下架容器", Visible = true, FieldName = "flowNo" };
|
|
GridColumn myCol18 = new GridColumn() { Caption = "负责人", Visible = true, FieldName = "em_name" };
|
|
|
|
gridview.Columns.Add(myCol1);
|
|
gridview.Columns.Add(myCol2);
|
|
gridview.Columns.Add(myCol3);
|
|
gridview.Columns.Add(myCol4);
|
|
gridview.Columns.Add(myCol5);
|
|
gridview.Columns.Add(myCol6);
|
|
gridview.Columns.Add(myCol7);
|
|
gridview.Columns.Add(myCol14);
|
|
gridview.Columns.Add(myCol18);
|
|
gridview.Columns.Add(myCol16);
|
|
gridview.Columns.Add(myCol9);
|
|
gridview.Columns.Add(myCol10);
|
|
gridview.Columns.Add(myCol11);
|
|
gridview.Columns.Add(myCol8);
|
|
gridview.Columns.Add(myCol17);
|
|
// gridview.Columns.Add(myCol12);
|
|
// gridview.Columns.Add(myCol13);
|
|
|
|
gridview.Columns.Add(myCol15);
|
|
|
|
|
|
|
|
//to show bottom scroll bar
|
|
gridview.OptionsView.ColumnAutoWidth = false;
|
|
gridview.BestFitColumns();
|
|
// gridView2.Focus();
|
|
}
|
|
|
|
#endregion
|
|
|
|
int lastState = 0, state = 0;
|
|
/// <summary>
|
|
/// loading data
|
|
/// </summary>
|
|
private int loadData()
|
|
{
|
|
// this.gridControl3.DataSource = null;
|
|
int cnt = 0;
|
|
//initialRequestOrders();
|
|
//this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView;
|
|
showWaitForm();
|
|
|
|
|
|
string query ="";
|
|
try
|
|
{
|
|
|
|
query += (this.dateEditFrom.Text.Trim().Length == 0 ? "" : string.Format("{0} >= # '{1}';", "createtime", dateEditFrom.DateTime))
|
|
+ (this.dateEditTo.Text.Trim().Length == 0 ? "" : string.Format("{0} <= # '{1}';", "createtime", dateEditTo.DateTime));
|
|
|
|
query += (this.comboState.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", "state", ((Colitem)this.comboState.SelectedItem).key));
|
|
query += (this.comRecType.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", WmsWave.fields.type.ToString(), ((Colitem)this.comRecType.SelectedItem).key));
|
|
|
|
bool isQueryNotChanged = lastQuery.Equals(query);
|
|
|
|
|
|
this.pager2.PageCurrent = lastState == state ? this.pager2.PageCurrent : 1; //根据查询条件的变化给pager赋值
|
|
this.pager2.PageCurrent = this.pager2.PageCurrent > 0 ? this.pager2.PageCurrent : 1;
|
|
int start = (pager2.PageSize * (pager2.PageCurrent - 1) + 1);
|
|
int end = (pager2.PageSize * pager2.PageCurrent);
|
|
DataSet ds = pickClient.getWaves (query, start, end);
|
|
lastState = state ;
|
|
closeClient();
|
|
|
|
cnt = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString());
|
|
|
|
DtGv = ds.Tables[0];
|
|
|
|
DataView dv = DtGv.DefaultView;
|
|
|
|
|
|
DtGv.PrimaryKey = new DataColumn[] { DtGv.Columns["waveNo"] };
|
|
|
|
|
|
|
|
this.gridControl1.DataSource = dv;
|
|
initialDataGridColumns(gridView1);
|
|
//update selected row index to the last updated one.
|
|
|
|
/* if (!String.IsNullOrEmpty(waveNo))
|
|
{
|
|
selectedRowIndex = -1;
|
|
DataRow dr = DtGv.Rows.Find(waveNo);
|
|
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;
|
|
}else
|
|
// if (firstLoad)
|
|
{
|
|
gridView1.FocusedRowHandle = 0;
|
|
gridView1.SelectRow(0);
|
|
bindDetail();
|
|
} */
|
|
bindDetail();
|
|
closeWaitForm();
|
|
return cnt;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
showErrorMsg(e,e.Message);
|
|
}
|
|
|
|
closeWaitForm();
|
|
return 0;// lgt.getRowCount(query);
|
|
// return lgt.GetGoodType.QueryCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindDetail()
|
|
{
|
|
pager1.Bind();
|
|
}
|
|
private void setDataBack()
|
|
{
|
|
|
|
|
|
}
|
|
private bool validData()
|
|
{
|
|
bool isvalid = dxValidationProvider1.Validate();
|
|
|
|
// MessageBox.Show("goodtype is " + txtGoodType.Text +", is valid ? " + isvalid);
|
|
|
|
return isvalid;
|
|
//String gdtype = txtGoodType.Text.Trim();
|
|
//if (gdtype.Length == 0)
|
|
//{
|
|
|
|
// dxValidationProvider.Validate();
|
|
// return false;
|
|
//}
|
|
|
|
//return true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void gridView1_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
|
|
{
|
|
if (gridView1.FocusedRowHandle < 0 || gridView1.FocusedRowHandle == selectedRowIndex || isDataSourceChanged && selectedRowIndex > 0)
|
|
{
|
|
if (gridView1.IsGroupRow(e.RowHandle)) //set first row of group selected
|
|
{
|
|
selectedRowIndex = gridView1.GetChildRowHandle(e.RowHandle, 0);
|
|
bindDetail();// setCurrentRequestDetail();
|
|
}
|
|
isDataSourceChanged = false;
|
|
return;
|
|
|
|
}
|
|
isDataSourceChanged = false;
|
|
selectedRowIndex = gridView1.FocusedRowHandle;
|
|
// showErrorMsg("selection:"+ selectedRowIndex);
|
|
bindDetail();// setCurrentRequestDetail();
|
|
|
|
}
|
|
|
|
private void clearInputs()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
bool isDataSourceChanged = false;
|
|
private void gridView1_DataSourceChanged(object sender, EventArgs e)
|
|
{
|
|
isDataSourceChanged = true;
|
|
|
|
if (selectedRowIndex >= 0 && DtGv.Rows.Count > selectedRowIndex)
|
|
{
|
|
gridView1.FocusedRowHandle = selectedRowIndex;
|
|
gridView1.MakeRowVisible(selectedRowIndex);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void btnDelete_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
protected void query()
|
|
{
|
|
loadData();
|
|
}
|
|
|
|
|
|
private void queryGoods()
|
|
{
|
|
|
|
showWaitForm();
|
|
try
|
|
{
|
|
query();// loadData();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
showErrorMsg(e.Message);
|
|
}
|
|
finally
|
|
{
|
|
// WaitFormService.Close();
|
|
closeWaitForm();
|
|
bbQuery.Enabled = true;
|
|
}
|
|
|
|
}
|
|
|
|
private void bbQuery_ItemClick_1(object sender, ItemClickEventArgs e)
|
|
{
|
|
this.bbQuery.Enabled = false;
|
|
queryGoods();
|
|
}
|
|
|
|
|
|
|
|
private void updateObjects(List<WmsGoods> goods)
|
|
{
|
|
showWaitForm();
|
|
//WaitFormService.Show(this);
|
|
try
|
|
{
|
|
// lgt.update(goods);
|
|
|
|
//get updated data
|
|
query();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
showErrorMsg(e,e.Message);
|
|
}
|
|
finally
|
|
{
|
|
// WaitFormService.Close();
|
|
closeWaitForm();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private bool getCurrentObject()
|
|
{
|
|
if (selectedRowIndex <0 || selectedRowIndex >= DtGv.Rows.Count)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// DataRow currentRow = dt.Rows[selectedRowIndex];
|
|
DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]);
|
|
waveNo = dr.Row[1].ToString();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnQuery_Click(object sender, EventArgs e)
|
|
{
|
|
queryGoods();
|
|
}
|
|
|
|
private void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
|
|
{
|
|
if (gridView1.FocusedRowHandle <0 || gridView1.FocusedRowHandle == selectedRowIndex)
|
|
{
|
|
return;
|
|
}
|
|
selectedRowIndex = gridView1.FocusedRowHandle;
|
|
// showErrorMsg("selection:"+ selectedRowIndex);
|
|
bindDetail();// setCurrentRequestDetail();
|
|
}
|
|
|
|
private void initialDataGrid()
|
|
{
|
|
gridView1.OptionsSelection.MultiSelect = true;//按shift / control 多选
|
|
this.gridView1.OptionsBehavior.AutoPopulateColumns = false;
|
|
this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
|
|
this.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus;
|
|
this.gridView1.OptionsBehavior.Editable = false;
|
|
// this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
|
|
|
|
this.gridView1.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView1_FocusedRowObjectChanged);
|
|
this.gridView1.DataSourceChanged += new System.EventHandler(this.gridView1_DataSourceChanged);
|
|
|
|
//show line number
|
|
this.gridView1.IndicatorWidth = 40;
|
|
this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
|
|
//this.gridView3.IndicatorWidth = 40;
|
|
//this.gridView3.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
|
|
this.gridView3.IndicatorWidth = 40;
|
|
this.gridView3.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
|
|
|
|
|
|
gridView1.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
|
|
gridView3.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
|
{
|
|
|
|
|
|
|
|
|
|
if (e.Column.FieldName == WmsOutPickDetail.fields.batchPickState.ToString())
|
|
{
|
|
if (!pickStatus.ContainsValue(e.DisplayText))
|
|
{
|
|
|
|
int display = -100;
|
|
string disTxt = e.DisplayText;
|
|
|
|
try
|
|
{
|
|
display = Convert.ToInt32(e.DisplayText);
|
|
|
|
e.DisplayText = pickStatus[display];
|
|
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
// e.DisplayText = pickStatus.ContainsKey(display) ? pickStatus[display] : display+"";
|
|
|
|
}else if(e.Column.FieldName == WmsWave.fields.state.ToString()){
|
|
if (!pickOrNot.ContainsValue(e.DisplayText))
|
|
{
|
|
|
|
int display = -100;
|
|
string disTxt = e.DisplayText;
|
|
|
|
try
|
|
{
|
|
display = Convert.ToInt32(e.DisplayText);
|
|
|
|
e.DisplayText = pickOrNot[display];
|
|
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
// e.DisplayText = pickOrNot.ContainsKey(display) ? pickOrNot[display] : display+"";
|
|
}
|
|
else if (e.Column.FieldName == WmsWave.fields.type.ToString())
|
|
{
|
|
if (!enumStockRecordtype.ContainsValue(e.DisplayText))
|
|
{
|
|
|
|
int display = -100;
|
|
string disTxt = e.DisplayText;
|
|
|
|
try
|
|
{
|
|
display = Convert.ToInt32(e.DisplayText);
|
|
|
|
e.DisplayText = enumStockRecordtype[display];
|
|
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
// e.DisplayText = pickOrNot.ContainsKey(display) ? pickOrNot[display] : display+"";
|
|
}
|
|
else if (e.Column.FieldName == "productDate" || e.Column.FieldName == "validDate")
|
|
{
|
|
e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
|
|
}
|
|
else if (e.Column.FieldName == "createtime")
|
|
{
|
|
e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
|
|
}
|
|
|
|
|
|
|
|
}
|
|
void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
|
|
{
|
|
//var currentView = sender as GridView;
|
|
//if (currentView != null && e.RowHandle == currentView.FocusedRowHandle) return;
|
|
Rectangle r = e.Bounds;
|
|
if (e.Column.FieldName == "state")
|
|
{
|
|
string a = e.CellValue.ToString();
|
|
string b = e.DisplayText;
|
|
if (b.Equals("未分配货位"))
|
|
{
|
|
e.Appearance.ForeColor = Color.Red;
|
|
e.Appearance.DrawString(e.Cache, e.DisplayText, r);
|
|
e.Handled = true;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
void gridView_RowCellStyle(object sender,DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
|
|
{
|
|
|
|
var currentView = sender as GridView;
|
|
if( currentView == null){return;}
|
|
string state = "";
|
|
bool isGray = false;
|
|
bool isAlert = false;
|
|
|
|
if (currentView == gridView3)
|
|
{
|
|
state = currentView.GetDataRow(e.RowHandle)["state"].ToString().Trim();
|
|
|
|
|
|
isGray = Convert.ToInt32(state) == (int)enumPickState.已拣;
|
|
|
|
// isAlert = Convert.ToInt32(state) == (int)enumLabelPickState.notPicked;
|
|
}
|
|
else
|
|
{
|
|
state = currentView.GetDataRow(e.RowHandle)["batchPickState"].ToString().Trim();
|
|
isGray = Convert.ToInt32(state) == (int)enumOutStockPickStatus.正在分拣;
|
|
isAlert = Convert.ToInt32(state) == (int)enumOutStockPickStatus.复核异常;
|
|
}
|
|
/*
|
|
state = currentView.GetDataRow(e.RowHandle)["batchPickState"].ToString().Trim();
|
|
isGray = Convert.ToInt32(state) == (int)enumOutStockPickStatus.正在分拣;
|
|
isAlert = Convert.ToInt32(state) == (int)enumOutStockPickStatus.复核异常;
|
|
*/
|
|
bool isFocused = e.RowHandle == currentView.FocusedRowHandle;
|
|
DevExpress.Utils.AppearanceDefault rowStyle = null;
|
|
DevExpress.Utils.AppearanceDefault appBlueRed =
|
|
new DevExpress.Utils.AppearanceDefault (Color.White, Color.Red, Color.Empty, Color.Blue, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
|
|
DevExpress.Utils.AppearanceDefault appYB =
|
|
new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green);
|
|
|
|
DevExpress.Utils.AppearanceDefault alertFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Red, Color.Green, Color.Yellow);
|
|
DevExpress.Utils.AppearanceDefault alert = new DevExpress.Utils.AppearanceDefault(Color.Red, Color.White );
|
|
|
|
DevExpress.Utils.AppearanceDefault passedFocus = new DevExpress.Utils.AppearanceDefault(Color.White, Color.Gray);
|
|
DevExpress.Utils.AppearanceDefault passed = new DevExpress.Utils.AppearanceDefault(Color.Gray,Color.White);
|
|
|
|
|
|
|
|
if (isGray)
|
|
{
|
|
rowStyle = isFocused ? passedFocus : passed;
|
|
}
|
|
else if (isAlert)
|
|
{
|
|
rowStyle = isFocused ? alertFocus : alert;
|
|
}
|
|
|
|
|
|
DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, rowStyle);
|
|
/*
|
|
if (sender == this.gridView2)
|
|
{
|
|
if (this.gridView2.GetDataRow(e.RowHandle)["state"].ToString().Trim() == "2")
|
|
{
|
|
DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
|
|
}
|
|
}else if(sender == this.gridView1){
|
|
|
|
if ( state == "2")
|
|
{
|
|
if (currentView != null && e.RowHandle == currentView.FocusedRowHandle)
|
|
{
|
|
DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alertFocus);
|
|
}
|
|
else
|
|
{
|
|
DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, alert);
|
|
}
|
|
}
|
|
else if (state == "1")
|
|
{
|
|
DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, passed);
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
|
|
private int setCurrentRequestDetail()
|
|
{
|
|
|
|
if (!getCurrentObject() || String.IsNullOrEmpty(waveNo))
|
|
{
|
|
this.gridControl3.DataSource = null;
|
|
return 0;
|
|
}
|
|
/// gridView1.FocusedRowHandle = selectedRowIndex;//
|
|
// gridView1.SelectRow(selectedRowIndex);
|
|
showWaitForm();
|
|
|
|
try
|
|
{
|
|
this.pager1.PageCurrent = lastWaveNo == waveNo ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值
|
|
this.pager1.PageCurrent = this.pager1.PageCurrent > 0 ? this.pager1.PageCurrent : 1;
|
|
int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1);
|
|
int end = (pager1.PageSize * pager1.PageCurrent);
|
|
lastWaveNo = waveNo;
|
|
DataSet ds = pickClient.getWaveDetailPages( waveNo,start,end);
|
|
closeClient();
|
|
this.gridControl3.DataSource = ds.Tables[0];
|
|
initialGridView2Columns(gridView3);
|
|
// gridView1.Focus();
|
|
// this.selectedInvalidIndex = -1;
|
|
closeWaitForm();
|
|
return Convert.ToInt32( ds.Tables[1].Rows[0][0].ToString());
|
|
|
|
}
|
|
catch (Exception e)
|
|
{ closeWaitForm();
|
|
showErrorMsg(e.Message);
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
private void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
showWaitForm();
|
|
try
|
|
{
|
|
|
|
if (String.IsNullOrEmpty(waveNo))//&& selectedRequest.batchPickState == (int)enumOutStockPickStatus.待处理)
|
|
{
|
|
pickClient.startBatchPick(waveNo); //startPickBatchPickOrder(selectedRequest.pickOrderNo);
|
|
closeClient();
|
|
}
|
|
else
|
|
{
|
|
// showErrorMsg(string.Format("出库异常,当前出库单状态是{0}",
|
|
// Enum.GetName(typeof(enumOutStockPickStatus), selectedRequest.batchPickState) ));
|
|
}
|
|
|
|
|
|
// reqportPrint.printStockOutCode(pickClient.getPickOrderTmsInfo(selectedRequest.pickOrderNo));
|
|
|
|
// reqportPrint.printStockOutA4(pickClient.getBatchOutPickOrderPickDetails(selectedRequest.pickOrderNo));
|
|
closeClient();
|
|
|
|
query();
|
|
}
|
|
catch (Exception er)
|
|
{
|
|
bindDetail();// setCurrentRequestDetail();
|
|
showErrorMsg(er,er.Message);
|
|
closeClient();
|
|
}
|
|
|
|
|
|
|
|
|
|
closeWaitForm();
|
|
}
|
|
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(waveNo))
|
|
{
|
|
showErrorMsg("请选择波次记录");
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
// reqportPrint.printStockOutCode(pickClient.getPickOrderTmsInfo("PICK060000026285"));
|
|
reqportPrint.printStockOutCode(pickClient.getPickVolInfo(waveNo, (int)enumWhLocVol.小整),false); closeClient();
|
|
reqportPrint.printStockOutCode(pickClient.getPickVolInfo(waveNo, (int)enumWhLocVol.中整),false); closeClient();
|
|
reqportPrint.printStockOutCode(pickClient.getPickVolInfo(waveNo, (int)enumWhLocVol.大整),false); closeClient();
|
|
|
|
reqportPrint.printStockOutCode(pickClient.getPickSummary(waveNo, (int)enumWhLocVol.零库),false); closeClient();
|
|
|
|
|
|
|
|
closeClient();
|
|
}
|
|
catch (Exception er)
|
|
{
|
|
showErrorMsg(er, er.Message);
|
|
closeClient();
|
|
}
|
|
|
|
}
|
|
|
|
private void btnPrintReport_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// reqportPrint.printStockOutA4(pickClient.getBatchOutPickOrderPickDetails(selectedRequest.pickOrderNo));
|
|
// closeClient();
|
|
}
|
|
catch (Exception er)
|
|
{
|
|
showErrorMsg(er, er.Message);
|
|
closeClient();
|
|
}
|
|
}
|
|
|
|
private void btnOutStockAll_Click(object sender, EventArgs e)
|
|
{
|
|
showWaitForm();
|
|
foreach (DataRow dr in DtGv.Rows)
|
|
{
|
|
WmsInRequest wi = new WmsInRequest(dr);
|
|
|
|
try
|
|
{
|
|
//lgt.requestInStock(wi);
|
|
// pickClient.requestInStock(wi.orderNo);
|
|
|
|
}
|
|
catch (Exception er)
|
|
{
|
|
|
|
showErrorMsg(er.Message);
|
|
}
|
|
|
|
}
|
|
|
|
query();
|
|
|
|
|
|
}
|
|
|
|
private void GoodsInForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
|
|
closeClient();
|
|
closeChannelLight();
|
|
lightControl.exit_wms_sys();
|
|
|
|
}
|
|
|
|
protected new void gridview_GotFocus(object sender, EventArgs e)
|
|
{
|
|
if (sender == gridView1)
|
|
{
|
|
//grid4Valid.ForeColor = Color.Blue;
|
|
// gridView4Valid.OptionsSelection.EnableAppearanceHideSelection = true;
|
|
|
|
this.setCurrentRequestDetail();
|
|
switchGridViewRowSelection(gridView1, true);
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
switchGridViewRowSelection((GridView)sender, true);
|
|
}
|
|
|
|
}
|
|
|
|
private void btnForceClose_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// if (pickClient.completeBatchOut(this.selectedRequest.pickOrderNo))
|
|
{
|
|
// MessageBox.Show("出库成功");
|
|
}
|
|
// else
|
|
{
|
|
// showErrorMsg("出库失败");
|
|
}
|
|
// closeClient();
|
|
}
|
|
catch (Exception er)
|
|
{
|
|
showErrorMsg(er.Message);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void btnPickOrders_Click(object sender, EventArgs e)
|
|
{
|
|
loadData();
|
|
}
|
|
|
|
|
|
|
|
|
|
dnwms lightControl = new dnwms();
|
|
private void initialChannelLight()
|
|
{
|
|
lightControl.check_state = true;
|
|
lightControl.on_config_channel += new dnwms.config_channel(aa_on_config_channel);
|
|
lightControl.on_close_channel += new dnwms.close_channel(aa_on_close_channel);
|
|
lightControl.on_open_channel += new dnwms.open_channel(openChannelLightResult);
|
|
lightControl.on_dis_event += new dnwms.receive_dis_data(aa_on_receidata_channel);
|
|
// getLightId();
|
|
}
|
|
|
|
private void openChannelLight()
|
|
{
|
|
Model.open_channel_led id;
|
|
id.channel_id = lightId;
|
|
//id.config_word = led_rgb;
|
|
id.state = 1;
|
|
lightControl.write_open_channel_led(id);//write_config_channel_led
|
|
}
|
|
|
|
private void closeChannelLight()
|
|
{
|
|
Model.close_channel_led id;
|
|
id.channel_id =lightId;
|
|
//id.config_word = led_rgb;
|
|
|
|
id.state = 1;
|
|
lightControl.write_close_channel_led(id);//write_config_channel_led
|
|
}
|
|
|
|
private void openChannelLightResult( Model.open_channel_led data)
|
|
{
|
|
// MessageBox.Show("打开通道灯 成功");
|
|
}
|
|
void aa_on_close_channel(Model.close_channel_led data)
|
|
{
|
|
// MessageBox.Show("关闭通道灯 成功");
|
|
//throw new NotImplementedException();
|
|
}
|
|
void aa_on_config_channel(Model.config_channel_led data)
|
|
{
|
|
// MessageBox.Show("配置 id = " + data.channel_id.ToString() + "配置字 = " + data.config_word.ToString() + " 成功 ");
|
|
//throw new NotImplementedException();
|
|
}
|
|
void aa_on_receidata_channel(Model.uart_dis_data[] dis_data)
|
|
{
|
|
// MessageBox.Show("配置 id = " + data.channel_id.ToString() + "配置字 = " + data.config_word.ToString() + " 成功 ");
|
|
//throw new NotImplementedException();
|
|
}
|
|
|
|
List<int> lights = new List<int>();
|
|
void searchLight()
|
|
{
|
|
Model.modify_id id;
|
|
|
|
System.Threading.Thread.Sleep(50);
|
|
for (int i = 5000; i <= 5100; i++)
|
|
{
|
|
id.order = 0;
|
|
id.new_ele_id = 0;
|
|
id.old_ele_id = i;
|
|
id.state = 1;
|
|
bool ret = lightControl.search_light_id(id);
|
|
if (ret)
|
|
{
|
|
//textBox6.Text = textBox6.Text + "搜索到通道灯:" + i.ToString() + "\r\n";
|
|
//this.textBox6.Focus();//获取焦点
|
|
//this.textBox6.Select(this.textBox6.TextLength, 0);//光标定位到文本最后
|
|
//this.textBox6.ScrollToCaret();//滚动到光标处
|
|
lights.Add(i);
|
|
break;
|
|
// System.Threading.Thread.Sleep(50);
|
|
}
|
|
}
|
|
}
|
|
void getLightId()
|
|
{
|
|
for (int i = 0; i < 10; i++)//init com0-10
|
|
{
|
|
comId = Convert.ToByte(i);
|
|
|
|
if (lightControl.init_wms_sys(comId))
|
|
{
|
|
lights.Clear();
|
|
searchLight();
|
|
if (lights.Count > 0)
|
|
{
|
|
lightId = lights[0];
|
|
break;
|
|
}
|
|
}
|
|
System.Threading.Thread.Sleep(10);
|
|
}
|
|
// lbLightsInfo.Text = "";
|
|
if (lightId == 0)
|
|
{
|
|
// lbLightsInfo.Text = "没找到出库指示灯,请确认出库灯正确连接并工作正常";
|
|
// MessageBox.Show("没找到出库指示灯,请确认出库灯正确连接并工作正常");
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void updateLightColor(bool isAlert)
|
|
{
|
|
Model.config_channel_led id;
|
|
// byte led_rgb = 0;
|
|
|
|
byte blue = 2;
|
|
byte red = 0;
|
|
|
|
id.channel_id = Convert.ToInt32(5000);
|
|
id.config_word = isAlert ? red : blue;// led_rgb;
|
|
id.state = 1;
|
|
this.lightControl .write_config_channel_led(id);//write_config_channel_led
|
|
}
|
|
|
|
|
|
void setRule()
|
|
{
|
|
|
|
// waveRule.lineId = comboLines.SelectedIndex <= 0 ? -1 : ((Node)comboLines.SelectedItem).ID;
|
|
// waveRule.sales = comboSales.SelectedIndex <= 0 ? "" : comboSales.Text;
|
|
|
|
try
|
|
{
|
|
// pickClient.updateWaveRule(waveRule);
|
|
// closeClient();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
showErrorMsg(e, "出错了");
|
|
|
|
}
|
|
finally
|
|
{
|
|
closeClient();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
private void comboLines_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
setRule();
|
|
}
|
|
|
|
private void comboSales_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
setRule();
|
|
}
|
|
|
|
private void simpleButton2_Click(object sender, EventArgs e)
|
|
{
|
|
// showWaitForm();
|
|
// pickClient.createPDATasks();
|
|
// bool res= pickClient.createPickWaves();
|
|
// MessageBox.Show(" create wave "+res);
|
|
// closeClient();
|
|
// closeWaitForm();
|
|
// loadData();
|
|
}
|
|
|
|
|
|
private void btnDel_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btnQ_Click(object sender, EventArgs e)
|
|
{
|
|
pager2.Bind();
|
|
}
|
|
|
|
private void btnWaveStart_Click(object sender, EventArgs e)
|
|
{
|
|
WcfWaveRule waveRule = new WcfWaveRule();
|
|
|
|
waveRule.ID= ((Colitem) comWaveRule.SelectedItem).key;
|
|
|
|
waveRule.type = (int)enumWaveRuleType.普通波次;
|
|
waveRule.interval =(int) spinWave.Value;
|
|
|
|
if (waveRule.ID > 0)
|
|
{
|
|
|
|
bool rs = wrClient.setRule(waveRule);
|
|
bool a = rs;
|
|
}
|
|
else
|
|
{
|
|
showErrorMsg("请选择波次规则");
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
} |