575 lines
17 KiB
C#
575 lines
17 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.ServiceReferenceInRequest;
|
|||
|
//using DeiNiu.wms.win.ServiceReferenceInRequestLocal;
|
|||
|
//using DeiNiu.wms.win.ServiceReferenceLot;
|
|||
|
using DeiNiu.wms.win.ServiceCustomer;
|
|||
|
using DeiNiu.wms.win.ServiceReferenceLot;
|
|||
|
using DeiNiu.wms.win.waveRuleService;
|
|||
|
using DeiNiu.wms.win.utils;
|
|||
|
using DeiNiu.wms.win.OrderService;
|
|||
|
|
|||
|
namespace DeiNiu.wms.win
|
|||
|
{
|
|||
|
public partial class StockOrder : BasicRibbonForm, IPicker
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
|
|||
|
private string lastQuery = "";
|
|||
|
|
|||
|
private int selectedRowIndex = -1;
|
|||
|
WcfWmsOrderRequest wcfRequest;
|
|||
|
private bool isShowingInRequest = true;
|
|||
|
public StockOrder()
|
|||
|
{
|
|||
|
|
|||
|
InitializeComponent();
|
|||
|
|
|||
|
initialControls();
|
|||
|
|
|||
|
// loadData();
|
|||
|
|
|||
|
}
|
|||
|
#region initialControls
|
|||
|
private void initialControls()
|
|||
|
{
|
|||
|
initialComboBoxes();
|
|||
|
initialPagerControls();
|
|||
|
initialDataGrid();
|
|||
|
initialQueryInput();
|
|||
|
setValidationRule();
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
private void initialComboBoxes()
|
|||
|
{
|
|||
|
initialComboBoxs(this.comType, orderType,false);
|
|||
|
}
|
|||
|
|
|||
|
private void setValidationRule()
|
|||
|
{
|
|||
|
// dxValidationProvider.SetValidationRule(comWarehouse, ValidationRules.notEmptyValidationRule);
|
|||
|
//txtGooDtGvype.Properties.MaxLength = 40;
|
|||
|
//txtGoodDesc.Properties.MaxLength = 250;
|
|||
|
//textEdit1.Properties.MaxLength = txtGooDtGvype.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 colChk = new GridColumn() { Caption = CheckBoxField, Visible = true, FieldName = CheckBoxField };
|
|||
|
gridView.Columns.Add(colChk);
|
|||
|
|
|||
|
if (gridView == gridView1)
|
|||
|
{
|
|||
|
|
|||
|
GridColumn myCol1 = new GridColumn() { Caption = "单号", Visible = true, FieldName ="orderNo" };
|
|||
|
GridColumn myCol2 = new GridColumn() { Caption = "商品ID", Visible = true, FieldName = "goodsId" };
|
|||
|
GridColumn myCol3 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = "goodsName" };
|
|||
|
GridColumn myCol4 = new GridColumn() { Caption = "生产日期", Visible = true, FieldName = "productDate" };
|
|||
|
GridColumn myCol5 = new GridColumn() { Caption = "失效日期", Visible = true, FieldName = "validDate" };
|
|||
|
GridColumn myCol6 = new GridColumn() { Caption = "数量", Visible = true, FieldName ="count" };
|
|||
|
GridColumn myCol7 = new GridColumn() { Caption = "价格", Visible = true, FieldName = "price" };
|
|||
|
GridColumn myCol8 = new GridColumn() { Caption = "出库房", Visible = true, FieldName = "whtype" };
|
|||
|
GridColumn myCol9 = new GridColumn() { Caption = "入库房", Visible = true, FieldName = "toWhType" };
|
|||
|
GridColumn myCol10 = new GridColumn() { Caption = "货位", Visible = true, FieldName = "locationId" };
|
|||
|
GridColumn myCol11 = new GridColumn() { Caption = "客户", Visible = true, FieldName = "custName" };
|
|||
|
|
|||
|
|
|||
|
|
|||
|
gridView.Columns.Add(myCol1);
|
|||
|
gridView.Columns.Add(myCol2);
|
|||
|
gridView1.Columns.Add(myCol3);
|
|||
|
gridView.Columns.Add(myCol4);
|
|||
|
gridView.Columns.Add(myCol5);
|
|||
|
gridView.Columns.Add(myCol6);
|
|||
|
|
|||
|
gridView.Columns.Add(myCol7);
|
|||
|
gridView1.Columns.Add(myCol8);
|
|||
|
gridView.Columns.Add(myCol9);
|
|||
|
gridView.Columns.Add(myCol10);
|
|||
|
gridView.Columns.Add(myCol11);
|
|||
|
}
|
|||
|
|
|||
|
//to show bottom scroll bar
|
|||
|
gridView.OptionsView.ColumnAutoWidth = false;
|
|||
|
gridView.BestFitColumns();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
private void initialRequestOrders()
|
|||
|
{
|
|||
|
showWaitForm();
|
|||
|
try{
|
|||
|
//custClient.getInRequests();
|
|||
|
// getInValidOrders();
|
|||
|
}
|
|||
|
//catch (DeiNiuTimeOutException te)
|
|||
|
//{
|
|||
|
//
|
|||
|
//}
|
|||
|
catch(Exception e){
|
|||
|
showErrorMsg(e.Message);
|
|||
|
}
|
|||
|
finally{
|
|||
|
closeWaitForm();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// loading data
|
|||
|
/// </summary>
|
|||
|
private int loadData()
|
|||
|
{
|
|||
|
if (wcfRequest == null || string.IsNullOrEmpty(wcfRequest.orderNo))
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
//this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView;
|
|||
|
showWaitForm();
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
DtGv = orderClient.getDetail(wcfRequest.orderNo);
|
|||
|
addCheckField(DtGv);//add checkbox
|
|||
|
// DtGv.PrimaryKey = new DataColumn[] { DtGv.Columns["ID"] };
|
|||
|
this.gridControl1.DataSource = DtGv.DefaultView;
|
|||
|
// initialDataGridColumns(gridView1);
|
|||
|
//update selected row index to the last updated one.
|
|||
|
gridView1.BestFitColumns();
|
|||
|
|
|||
|
|
|||
|
closeWaitForm();
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
showErrorMsg(e,e.Message);
|
|||
|
}
|
|||
|
|
|||
|
closeWaitForm();
|
|||
|
return 0;// lgt.getRowCount(query);
|
|||
|
// return lgt.GetGooDtGvype.QueryCount();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
private void bindDetail()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
private void setDataBack()
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
private bool validData()
|
|||
|
{
|
|||
|
bool isvalid = dxValidationProvider1.Validate();
|
|||
|
|
|||
|
// MessageBox.Show("gooDtGvype is " + txtGooDtGvype.Text +", is valid ? " + isvalid);
|
|||
|
|
|||
|
return isvalid;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 分页控件产生的事件
|
|||
|
/// </summary>
|
|||
|
private int pager_EventPaging(DeiNiu.Controls.pager.EventPagingArg e)
|
|||
|
{
|
|||
|
selectedRowIndex = -1; //reset currentRowIndex
|
|||
|
return loadData();
|
|||
|
}
|
|||
|
|
|||
|
private void initialPagerControls()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
bool isCheckedIn = false;
|
|||
|
private void gridView1_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
|
|||
|
{
|
|||
|
if (gridView1.FocusedRowHandle < 0 || gridView1.FocusedRowHandle == selectedRowIndex || gridView1.FocusedRowHandle==0 && isCheckedIn)
|
|||
|
{
|
|||
|
isCheckedIn = gridView1.FocusedRowHandle > 0;
|
|||
|
if (gridView1.IsGroupRow(e.RowHandle)) //set first row of group selected
|
|||
|
{
|
|||
|
selectedRowIndex = gridView1.GetChildRowHandle(e.RowHandle, 0);
|
|||
|
|
|||
|
}
|
|||
|
if (isCheckedIn)
|
|||
|
{
|
|||
|
isCheckedIn = false;
|
|||
|
}
|
|||
|
return;
|
|||
|
|
|||
|
}
|
|||
|
selectedRowIndex = gridView1.FocusedRowHandle;
|
|||
|
// showErrorMsg("selection:"+ selectedRowIndex);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void clearInputs()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private void gridView1_DataSourceChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (selectedRowIndex >= 0 && DtGv.Rows.Count > selectedRowIndex)
|
|||
|
{
|
|||
|
gridView1.FocusedRowHandle = selectedRowIndex;
|
|||
|
gridView1.MakeRowVisible(selectedRowIndex);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
int selectedInShipId = 0;
|
|||
|
int selectedShipIndex;
|
|||
|
string shipDate;
|
|||
|
|
|||
|
string selectedShipDriver = "";
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
private void btnDelete_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void query()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
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.Message);
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
// WaitFormService.Close();
|
|||
|
closeWaitForm();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
string lastSelectedId = "";
|
|||
|
private bool getCurrentObject()
|
|||
|
{
|
|||
|
if (selectedRowIndex <0 || selectedRowIndex >= DtGv.Rows.Count)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
// DataRow currentRow = DtGv.Rows[selectedRowIndex];
|
|||
|
DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedRowIndex]);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
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;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
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);
|
|||
|
gridView1.CustomColumnDisplayText += gridView2_CustomColumnDisplayText;
|
|||
|
initialDataGridColumns(gridView1);
|
|||
|
GridCheckEdit(gridView1, CheckBoxField, 50);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
// if (sender == gridView2)
|
|||
|
{
|
|||
|
if (e.Column.FieldName == "custType")
|
|||
|
{
|
|||
|
|
|||
|
if (!stockInLocationStatus.ContainsValue(e.DisplayText))
|
|||
|
{
|
|||
|
|
|||
|
int display = -100;
|
|||
|
string disTxt = e.DisplayText;
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
display = Convert.ToInt16(e.DisplayText);
|
|||
|
e.DisplayText = this.customerTypes[display];
|
|||
|
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
List<string> selectedIds = new List<string>();
|
|||
|
private bool getSelectedIds()
|
|||
|
{
|
|||
|
foreach (DataRow dr in DtGv.Rows)
|
|||
|
{
|
|||
|
string v = dr[CheckBoxField].ToString();
|
|||
|
bool b = String.IsNullOrEmpty(v) ? false : Convert.ToBoolean(v);
|
|||
|
if (b)
|
|||
|
{
|
|||
|
|
|||
|
selectedIds.Add(dr["ID"].ToString());
|
|||
|
}
|
|||
|
}
|
|||
|
if (selectedIds.Count == 0)
|
|||
|
{
|
|||
|
showErrorMsg(null, "请至少选择一个条目");
|
|||
|
return false;
|
|||
|
}
|
|||
|
return true;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private void GoodsInForm_FormClosing(object sender, FormClosingEventArgs e)
|
|||
|
{
|
|||
|
//closeClient();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
bool validOwner( )
|
|||
|
{
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
private void btnNew_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!validInput())
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
WcfWaveRule ruleObj = new WcfWaveRule();
|
|||
|
|
|||
|
|
|||
|
if (this.comType.SelectedIndex > 0)
|
|||
|
{
|
|||
|
ruleObj.type = ((Colitem)comType.SelectedItem).key;
|
|||
|
}
|
|||
|
|
|||
|
wrClient.add(ruleObj);
|
|||
|
closeClient();
|
|||
|
query();
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
bool validInput()
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
private void btnCreate_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
wcfRequest = new WcfWmsOrderRequest();
|
|||
|
|
|||
|
wcfRequest.orderType = ((Colitem)comType.SelectedItem).key;
|
|||
|
wcfRequest.requestBy = LoginInfo.UserId;
|
|||
|
lbOrderNo.Text = wcfRequest.orderNo =orderClient.add(wcfRequest);
|
|||
|
|
|||
|
btnPickItems.Enabled = ! String.IsNullOrEmpty(wcfRequest.orderNo);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void btnPickItems_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
StockPicker sp = new StockPicker();
|
|||
|
sp.pickOwner = this;
|
|||
|
sp.ShowDialog();
|
|||
|
}
|
|||
|
|
|||
|
public void setPickedData(DataTable dt)
|
|||
|
{
|
|||
|
if (String.IsNullOrEmpty(wcfRequest.orderNo))
|
|||
|
{
|
|||
|
showErrorMsg("请先创建单据");
|
|||
|
return;
|
|||
|
}
|
|||
|
WcfWmsOrderDetail od;
|
|||
|
List<WcfWmsOrderDetail> ods = new List<WcfWmsOrderDetail>();
|
|||
|
foreach (DataRow dr in dt.Rows)
|
|||
|
{
|
|||
|
od = getWcfObject( new WmsOrderDetail(dr));
|
|||
|
od.orderNo = wcfRequest.orderNo;
|
|||
|
ods.Add(od);
|
|||
|
}
|
|||
|
orderClient.addDetail(wcfRequest.orderType,ods.ToArray());
|
|||
|
loadData();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
WcfWmsOrderDetail getWcfObject(WmsOrderDetail dbObj)
|
|||
|
{
|
|||
|
|
|||
|
WcfWmsOrderDetail wcfObj = new WcfWmsOrderDetail();
|
|||
|
wcfObj.id = dbObj.ID;
|
|||
|
wcfObj.orderNo = dbObj.orderNo;
|
|||
|
wcfObj.skuId = dbObj.skuId;
|
|||
|
wcfObj.skuCode = dbObj.skuCode;
|
|||
|
wcfObj.goodsId = dbObj.goodsId;
|
|||
|
wcfObj.batch = dbObj.batch;
|
|||
|
wcfObj.productDate = dbObj.productDate;
|
|||
|
wcfObj.validDate = dbObj.validDate;
|
|||
|
wcfObj.count = dbObj.count;
|
|||
|
wcfObj.price = dbObj.price;
|
|||
|
wcfObj.state = dbObj.state;
|
|||
|
wcfObj.whtype = dbObj.whtype;
|
|||
|
wcfObj.toWhType = dbObj.toWhType;
|
|||
|
wcfObj.locationId = dbObj.locationId;
|
|||
|
wcfObj.description = dbObj.description;
|
|||
|
wcfObj.operater = dbObj.operater;
|
|||
|
|
|||
|
return wcfObj;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|