1193 lines
40 KiB
C#
1193 lines
40 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;
|
||
using System.ServiceModel;
|
||
using DeiNiu.wms.win.service;
|
||
using System.ServiceModel.Description;
|
||
|
||
|
||
namespace DeiNiu.wms.win
|
||
{
|
||
public partial class GoodsOutTasksPrint : 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 dtPrint;
|
||
private int selectedRowIndex = -1;
|
||
|
||
bool autoOrder;
|
||
int lightId = 0;
|
||
int comId = 1;
|
||
|
||
public GoodsOutTasksPrint()
|
||
{
|
||
|
||
InitializeComponent();
|
||
initialControls();
|
||
// loadData();
|
||
startHost();
|
||
}
|
||
|
||
#region initialControls
|
||
private void initialControls()
|
||
{
|
||
|
||
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 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
|
||
|
||
|
||
this.pager1.Bind();//绑定
|
||
}
|
||
|
||
private void initialDataGrid()
|
||
{
|
||
this.gridView3.IndicatorWidth = 40;
|
||
this.gridView3.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator);
|
||
gridView3.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
|
||
|
||
}
|
||
|
||
|
||
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);
|
||
|
||
dic.Clear();
|
||
|
||
Node[] nds = { };
|
||
|
||
DataRow[] drs = Park.getDictionary(true).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 2005:
|
||
// initialComboBoxs(this.comPartion, drss);//分区
|
||
break;
|
||
|
||
case 3001:
|
||
initialComboBoxs(this.comLine, drss);//线路
|
||
break;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
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.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" };
|
||
GridColumn myCol19 = new GridColumn() { Caption = "分配人", Visible = true, FieldName = "分配人" };
|
||
GridColumn myCol20 = new GridColumn() { Caption = "件数", Visible = true, FieldName = "boxcnt" };
|
||
GridColumn myCol21 = new GridColumn() { Caption = "客户", Visible = true, FieldName = "customerName" };
|
||
GridColumn myCol22 = new GridColumn() { Caption = "线路", Visible = true, FieldName = "lineName" };
|
||
GridColumn myCol23 = new GridColumn() { Caption = "规格", Visible = true, FieldName = "spec" };
|
||
GridColumn myCol24 = new GridColumn() { Caption = "打印次数", Visible = true, FieldName = "printcnt" };
|
||
// gridview.Columns.Add(myCol24);
|
||
gridview.Columns.Add(myCol19);
|
||
gridview.Columns.Add(myCol14);
|
||
gridview.Columns.Add(myCol2);
|
||
gridview.Columns.Add(myCol3);
|
||
gridview.Columns.Add(myCol20);
|
||
gridview.Columns.Add(myCol4);
|
||
gridview.Columns.Add(myCol6);
|
||
gridview.Columns.Add(myCol23);
|
||
gridview.Columns.Add(myCol9);
|
||
gridview.Columns.Add(myCol22);
|
||
gridview.Columns.Add(myCol21);
|
||
gridview.Columns.Add(myCol10);
|
||
gridview.Columns.Add(myCol5);
|
||
|
||
gridview.Columns.Add(myCol1);
|
||
gridview.Columns.Add(myCol7);
|
||
gridview.Columns.Add(myCol8);
|
||
|
||
gridview.Columns.Add(myCol18);
|
||
gridview.Columns.Add(myCol16);
|
||
|
||
gridview.Columns.Add(myCol11);
|
||
|
||
gridview.Columns.Add(myCol17);
|
||
// gridview.Columns.Add(myCol12);
|
||
// gridview.Columns.Add(myCol13);
|
||
|
||
gridview.Columns.Add(myCol15);
|
||
gridview.Columns.Add(myCol21);
|
||
|
||
|
||
|
||
//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()
|
||
{
|
||
showWaitForm();
|
||
|
||
try
|
||
{
|
||
|
||
if (taskOrderType == (int)enumOutOrderType.补货出库)
|
||
{
|
||
dtPrint = pickClient.getRepTasks(taskTakeBy, taskPartion);
|
||
}
|
||
else
|
||
{
|
||
|
||
string query = (string.Format("takeBy = #{0};partion = #{1};orderType = #{2};"
|
||
, taskTakeBy, taskPartion, taskOrderType));
|
||
if (taskLineId > 0)
|
||
{
|
||
query += string.Format("isnull(lineId,0) = #{0};", taskLineId);
|
||
}
|
||
query += string.Format("{0} = #{1};", "state", 0);
|
||
query += //(this.comRecType.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", "recType", ((Colitem)this.comRecType.SelectedItem).key))
|
||
// + (this.txtTaskBy.Text.Trim().Length == 0 ? "" : string.Format("{0} like # '%{1}%';", "分配人", filtRiskChar(txtTaskBy.Text.Trim())))
|
||
// (this.comLine.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", "lineId", ((Node)this.comLine.SelectedItem).ID ))
|
||
(this.txtGoodsName.Text.Trim().Length == 0 ? "" : string.Format("{0} like # '%{1}%';", "goodsName", filtRiskChar(txtGoodsName.Text.Trim())))
|
||
+ (this.txtcustname.Text.Trim().Length == 0 ? "" : string.Format("{0} like # '%{1}%';", "customerName", filtRiskChar(txtcustname.Text.Trim())));
|
||
// + (this.comPartion.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", "part", ((Node)this.comPartion.SelectedItem).ID))
|
||
|
||
|
||
bool isQueryNotChanged = lastQuery.Equals(query);
|
||
|
||
|
||
this.pager1.PageCurrent = lastState == state ? 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);
|
||
|
||
DataSet ds = pickClient.getTasks(query, start, end);
|
||
lastState = state;
|
||
closeClient();
|
||
|
||
|
||
|
||
closeClient();
|
||
dtPrint = ds.Tables[0];
|
||
}
|
||
|
||
this.gridControl3.DataSource = dtPrint;
|
||
initialGridView2Columns(gridView3);
|
||
|
||
closeWaitForm();
|
||
return Convert.ToInt16(dtPrint.Rows.Count);
|
||
|
||
}
|
||
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 clearInputs()
|
||
{
|
||
|
||
}
|
||
|
||
|
||
bool isDataSourceChanged = false;
|
||
|
||
|
||
private void btnDelete_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
|
||
|
||
}
|
||
|
||
protected void query()
|
||
{
|
||
pager1.Bind();
|
||
}
|
||
|
||
|
||
private void queryGoods()
|
||
{
|
||
|
||
showWaitForm();
|
||
try
|
||
{
|
||
query();// loadData();
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
showErrorMsg(e.Message);
|
||
}
|
||
finally
|
||
{
|
||
// WaitFormService.Close();
|
||
closeWaitForm();
|
||
bbQuery.Enabled = true;
|
||
}
|
||
|
||
}
|
||
|
||
private void bbQuery_ItemClick_1(object sender, ItemClickEventArgs e)
|
||
{
|
||
this.bbQuery.Enabled = false;
|
||
queryGoods();
|
||
}
|
||
|
||
|
||
|
||
private void updateObjects(List<WmsGoods> goods)
|
||
{
|
||
showWaitForm();
|
||
//WaitFormService.Show(this);
|
||
try
|
||
{
|
||
// lgt.update(goods);
|
||
|
||
//get updated data
|
||
query();
|
||
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
showErrorMsg(e,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(gridView3)[selectedRowIndex]);
|
||
waveNo = dr.Row[1].ToString();
|
||
|
||
return true;
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
private void btnQuery_Click(object sender, EventArgs e)
|
||
{
|
||
queryGoods();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
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.ToInt16(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.ToInt16(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.ToInt16(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.ToInt16(state) == (int)enumPickState.已拣;
|
||
|
||
// isAlert = Convert.ToInt16(state) == (int)enumLabelPickState.notPicked;
|
||
}
|
||
else
|
||
{
|
||
state = currentView.GetDataRow(e.RowHandle)["batchPickState"].ToString().Trim();
|
||
isGray = Convert.ToInt16(state) == (int)enumOutStockPickStatus.正在分拣;
|
||
isAlert = Convert.ToInt16(state) == (int)enumOutStockPickStatus.复核异常;
|
||
}
|
||
/*
|
||
state = currentView.GetDataRow(e.RowHandle)["batchPickState"].ToString().Trim();
|
||
isGray = Convert.ToInt16(state) == (int)enumOutStockPickStatus.正在分拣;
|
||
isAlert = Convert.ToInt16(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.getTasks(waveNo, start, end);
|
||
closeClient();
|
||
this.gridControl3.DataSource = ds.Tables[0];
|
||
initialGridView2Columns(gridView3);
|
||
// gridView1.Focus();
|
||
// this.selectedInvalidIndex = -1;
|
||
closeWaitForm();
|
||
return Convert.ToInt16( 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)
|
||
{
|
||
// taskTakeBy = 278;
|
||
// taskPartion = 13;
|
||
if (taskOrderType == (int)enumOutOrderType.补货出库)
|
||
{
|
||
DataTable dt = pickClient.getRepTasks(taskTakeBy, taskPartion);
|
||
|
||
if (dt.Rows.Count == 0)
|
||
{
|
||
showErrorMsg("没有任务需要打印");
|
||
return;
|
||
}
|
||
|
||
string gd = this.txtGoodsName.Text.Trim().Length == 0 ? "1=1" : string.Format("{0} like '%{1}%' ", "goodsName", filtRiskChar(txtGoodsName.Text.Trim())) ;
|
||
string cm = this.txtcustname.Text.Trim().Length == 0 ? "1=1" : string.Format("{0} like '%{1}%' ", "customerName", filtRiskChar(txtcustname.Text.Trim()));
|
||
|
||
|
||
DataView dv =dt.DefaultView;
|
||
// dv.RowFilter = gd +" and " +cm;
|
||
|
||
showWaitForm();
|
||
try
|
||
{
|
||
reqportPrint.printStockRepPick(dv.ToTable("reptasks"), true);
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
showErrorMsg(er);
|
||
}
|
||
closeWaitForm();
|
||
closeClient();
|
||
|
||
return;
|
||
}
|
||
else if (dtPrint == null || dtPrint.Rows.Count == 0)
|
||
{
|
||
showErrorMsg("没有任务需要打印");
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
try
|
||
{
|
||
|
||
showWaitForm();
|
||
DataTable dt = dtPrint.DefaultView.ToTable();
|
||
foreach (DataRow dr in dt.Rows)
|
||
{
|
||
dr["barcode"] = Util.getCode128(dr["barcode"].ToString());
|
||
}
|
||
reqportPrint.printStockOutCode(dt, false);
|
||
closeWaitForm();
|
||
closeClient();
|
||
}
|
||
catch (Exception er)
|
||
{
|
||
showErrorMsg(er, er.Message);
|
||
closeClient();
|
||
}
|
||
closeWaitForm();
|
||
}
|
||
}
|
||
|
||
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)
|
||
{
|
||
if (host.State == CommunicationState.Opened)
|
||
{
|
||
host.Close();
|
||
}
|
||
closeClient();
|
||
closeChannelLight();
|
||
lightControl.exit_wms_sys();
|
||
|
||
}
|
||
|
||
|
||
|
||
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.ToInt16(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)
|
||
{
|
||
//taskOrderType = 0;
|
||
query();
|
||
}
|
||
//---- print service
|
||
private ServiceHost host = null;
|
||
string svrUrl = "http://127.0.0.1:9996/DNPrintSvc";
|
||
|
||
|
||
delegate void showStatus();
|
||
void startHost()
|
||
{
|
||
// lbStatus.Text = "服务启动失败";
|
||
try
|
||
{
|
||
// svrUrl = System.Configuration.ConfigurationManager.AppSettings["BaseUri"];
|
||
// wmsUrl = System.Configuration.ConfigurationManager.AppSettings["WMSuri"];
|
||
Uri baseAddress = new Uri(svrUrl);
|
||
PrintingService service = new PrintingService();
|
||
service.prtOutTaskCode += this.printOutTaskCode;
|
||
// service.lightUp += this.lightUp;
|
||
|
||
host = new ServiceHost(service, baseAddress);
|
||
// elelab.DNLights.lightOffEvent += testPicked;
|
||
|
||
WebHttpBinding binding = new WebHttpBinding();
|
||
ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IPrintingService), binding, baseAddress);
|
||
WebHttpBehavior httpBehavior = new WebHttpBehavior();
|
||
endpoint.Behaviors.Add(httpBehavior);
|
||
|
||
List<string> lstIp = Util.GetLocalIpAddress("InterNetwork");
|
||
|
||
|
||
host.Opened += delegate
|
||
{
|
||
// addLog("服务已启动");
|
||
if (InvokeRequired)
|
||
{
|
||
this.Invoke(new showStatus(delegate()
|
||
{
|
||
lbStatus.Text = "服务已启动";
|
||
lbUrl.Text = svrUrl; ;
|
||
lbIp.Text = lstIp[0] +":" +5;
|
||
}));
|
||
}
|
||
else
|
||
{
|
||
lbStatus.Text = "服务已启动";
|
||
lbUrl.Text = svrUrl;
|
||
lbIp.Text = lstIp[0] + ":" + 5;
|
||
}
|
||
};
|
||
host.Open();
|
||
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
// addLog("启动服务失败: " + e.Message);
|
||
MessageBox.Show("启动服务失败: " + e.Message);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
int taskTakeBy = 0, taskPartion = 0, taskLineId = 0, taskOrderType = 0;
|
||
|
||
//int taskTakeBy=305, taskPartion=21,taskLineId=0,taskOrderType=3;
|
||
|
||
public int printOutTaskCode(int userId, int partion, int lineId, int orderType)
|
||
{
|
||
this.Invoke(new showStatus(delegate()
|
||
{
|
||
clearInput();
|
||
addLog( string.Format("扫码用户ID:{0} , 货区:{1} ,线路:{2} ,类型:{3} " ,userId , partion,lineId,orderType));
|
||
}));
|
||
|
||
taskTakeBy = userId;
|
||
taskPartion = partion;
|
||
taskLineId = lineId;
|
||
taskOrderType = orderType;
|
||
query();
|
||
return 1;
|
||
}
|
||
|
||
void clearInput()
|
||
{
|
||
// comboState.SelectedIndex = 1;
|
||
// comboState.Enabled = false;
|
||
comLine.SelectedIndex = 0;
|
||
// comPartion.SelectedIndex = 0;
|
||
comRecType.SelectedIndex = 0;
|
||
txtcustname.Text = txtGoodsName.Text = "";
|
||
dtPrint = null;
|
||
lbStatus.Text = "";
|
||
|
||
}
|
||
delegate void showLog();
|
||
void addLog(string info)
|
||
{
|
||
if (InvokeRequired)
|
||
{
|
||
this.Invoke(new showLog(delegate()
|
||
{
|
||
doLogTxt(info);
|
||
}));
|
||
}
|
||
else
|
||
{
|
||
doLogTxt(info);
|
||
}
|
||
}
|
||
|
||
|
||
void doLogTxt(string info)
|
||
{
|
||
lbStatus.Text = info;
|
||
LogHelper.debug(this.GetType(),info);
|
||
|
||
}
|
||
|
||
|
||
}
|
||
} |