634 lines
20 KiB
C#
634 lines
20 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;
|
|
|
|
namespace DeiNiu.wms.win
|
|
{
|
|
public partial class CustomerSetup : BasicRibbonForm
|
|
{
|
|
|
|
|
|
|
|
private string lastQuery = "";
|
|
|
|
private int selectedRowIndex = -1;
|
|
|
|
private bool isShowingInRequest = true;
|
|
public CustomerSetup()
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
try
|
|
{
|
|
initialControls();
|
|
}
|
|
catch (Exception er)
|
|
{
|
|
showErrorMsg(er);
|
|
}
|
|
|
|
// loadData();
|
|
|
|
}
|
|
#region initialControls
|
|
private void initialControls()
|
|
{
|
|
initialComboBoxes();
|
|
initialPagerControls();
|
|
initialDataGrid();
|
|
initialQueryInput();
|
|
setValidationRule();
|
|
|
|
|
|
|
|
}
|
|
private void initialComboBoxes()
|
|
{
|
|
|
|
|
|
initialComboBoxs(this.comBoxTypeQ, customerTypes); //商品类型
|
|
|
|
Node[] nds = { };
|
|
DataTable dt = Park.getDictionary(false);
|
|
if (dt.Rows.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
DataRow[] drs = dt.Select("flag >0");
|
|
foreach (DataRow dr in drs)
|
|
{
|
|
int flag = Convert.ToInt32(dr["flag"].ToString());
|
|
int parentId = Convert.ToInt32(dr["id"].ToString());
|
|
DataRow[] drss = Park.getDictionary(false).Select("parentId =" + parentId);
|
|
switch (flag)
|
|
{
|
|
case 6003:
|
|
|
|
initialComboBoxs(this.comBoxJd, drss, true); //集货分组
|
|
initialComboBoxs(this.comJhtimeq, drss, true); //集货分组
|
|
break;
|
|
case 6004:
|
|
initialComboBoxs(this.comJdanHour, drss, true);//集单时间
|
|
initialComboBoxs(this.comJdQ, drss, true);//集单时间
|
|
break;
|
|
case 6005:
|
|
initialComboBoxs(this.comInterval, drss, true);//interval
|
|
initialComboBoxs(this.comIntervalQ, drss, true);//interval
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
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 };
|
|
this.gridView1.Columns.Add(colChk);
|
|
|
|
if (gridView == gridView1)
|
|
{
|
|
GridColumn myCol1 = new GridColumn() { Caption = "名称", Visible = true, FieldName ="custName" };
|
|
GridColumn myCol2 = new GridColumn() { Caption = "代码", Visible = true, FieldName = "custId" };
|
|
GridColumn myCol3 = new GridColumn() { Caption = "地址", Visible = true, FieldName = "address" };
|
|
GridColumn myCol4 = new GridColumn() { Caption = "联系人", Visible = true, FieldName = "contact" };
|
|
GridColumn myCol5 = new GridColumn() { Caption = "电话", Visible = true, FieldName = "phone1" };
|
|
GridColumn myCol6 = new GridColumn() { Caption = "传真", Visible = true, FieldName ="fax" };
|
|
GridColumn myCol8 = new GridColumn() { Caption = "状态", Visible = true, FieldName = "status" };
|
|
GridColumn myCol7 = new GridColumn() { Caption = "发票号码", Visible = true, FieldName = "invoiceNo" };
|
|
GridColumn myCol9 = new GridColumn() { Caption = "发票抬头", Visible = true, FieldName ="invoiceHead" };
|
|
GridColumn myCol10= new GridColumn() { Caption = "发票地址", Visible = true, FieldName = "invoiceAddress" };
|
|
GridColumn myCol11 = new GridColumn() { Caption = "类型", Visible = true, FieldName = "custType" };
|
|
|
|
GridColumn myCol12 = new GridColumn() { Caption = "集单分组", Visible = true, FieldName = "pickGroupName" };
|
|
GridColumn myCol13 = new GridColumn() { Caption = "集单时间", Visible = true, FieldName = "pickStartonName" };
|
|
GridColumn myCol14 = new GridColumn() { Caption = "发货间隔", Visible = true, FieldName = "pickIntervalName" };
|
|
|
|
GridColumn myCol15 = new GridColumn() { Caption = "最近发货", Visible = true, FieldName = "lastOutTime" };
|
|
|
|
|
|
|
|
gridView.Columns.Add(myCol1);
|
|
gridView.Columns.Add(myCol2);
|
|
gridView.Columns.Add(myCol11);
|
|
gridView.Columns.Add(myCol12);
|
|
gridView.Columns.Add(myCol13);
|
|
gridView.Columns.Add(myCol14);
|
|
gridView.Columns.Add(myCol5);
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
|
|
// this.gridView1.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;
|
|
}
|
|
|
|
|
|
#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()
|
|
{
|
|
|
|
//this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView;
|
|
showWaitForm();
|
|
|
|
try
|
|
{
|
|
// this.splashScreenManager1.ShowWaitForm();
|
|
string query = (this.txtOrderNo.Text.Trim().Length == 0 ? "" : string.Format("{0} =#'{1}';", "custName", filtRiskChar(txtOrderNo.Text.Trim())))
|
|
+ (this.comBoxTypeQ.SelectedIndex <= 0 ? "" : string.Format("{0} = #{1};", "custType", ((Colitem)comBoxTypeQ.SelectedItem).key))
|
|
+ (this.comJdQ.SelectedIndex == 0 ? "" : string.Format("{0} =#'{1}';", Customer.fields.pickStartOn.ToString(), ((Node)this.comJdQ.SelectedItem).ID))
|
|
+ (this.comJhtimeq.SelectedIndex ==0 ? "" : string.Format("{0} =#'{1}';", Customer.fields.pickGroup.ToString(), ((Node)this.comJhtimeq.SelectedItem).ID))
|
|
+ (this.comIntervalQ.SelectedIndex == 0 ? "" : string.Format("{0} =#'{1}';", Customer.fields.pickInterval.ToString(), ((Node)this.comIntervalQ.SelectedItem).ID))
|
|
;
|
|
bool isQueryNotChanged = lastQuery.Equals(query);
|
|
this.pager1.PageCurrent = isQueryNotChanged ? this.pager1.PageCurrent : 1; //根据查询条件的变化给pager赋值
|
|
int start = (pager1.PageSize * (pager1.PageCurrent - 1) + 1);
|
|
int end = (pager1.PageSize * pager1.PageCurrent);
|
|
lastQuery = query;
|
|
DataSet ds = custClient.query(query, start, end);// lgt.Query(query, start, end);
|
|
closeClient();
|
|
DtGv = ds.Tables[0];
|
|
int cnt = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString());
|
|
//DtGv = lgt.Query(query, start, end); //string.IsNullOrEmpty(query) ? lgt.GetGooDtGvype.getAllData(start, end) : lgt.g;
|
|
addCheckField(DtGv);//add checkbox
|
|
DtGv.PrimaryKey = new DataColumn[] { DtGv.Columns["ID"] };
|
|
bool firstLoad = !isQueryNotChanged || this.gridControl1.DataSource == null;
|
|
this.gridControl1.DataSource = DtGv.DefaultView;
|
|
// initialDataGridColumns(gridView1);
|
|
//update selected row index to the last updated one.
|
|
gridView1.BestFitColumns();
|
|
|
|
|
|
closeWaitForm();
|
|
return cnt;
|
|
}
|
|
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()
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
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()
|
|
{
|
|
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.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();
|
|
}
|
|
|
|
|
|
|
|
private void barBiSyncGoods_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
initailErpData();
|
|
}
|
|
/// <summary>
|
|
/// 同步erp 信息
|
|
/// </summary>
|
|
private void initailErpData()
|
|
{
|
|
|
|
showWaitForm("正在同步Owner信息");
|
|
try
|
|
{
|
|
|
|
|
|
closeWaitForm();
|
|
query();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.WriteLog(this.GetType(), e);
|
|
// showErrorMsg(e.Message);
|
|
closeWaitForm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool validOwner( )
|
|
{
|
|
|
|
return true;
|
|
}
|
|
|
|
private void btnUpdateOwner_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (getSelectedIds())
|
|
{
|
|
custClient.updateJdGroup(selectedIds.ToArray(), comBoxJd.SelectedIndex>0?((Node)comBoxJd.SelectedItem).ID:0);
|
|
}
|
|
query();
|
|
|
|
}
|
|
|
|
private void btnUpdateHour_Click(object sender, EventArgs e)
|
|
{
|
|
if (getSelectedIds())
|
|
{
|
|
custClient.updateJdHourPoint(selectedIds.ToArray(), comJdanHour.SelectedIndex > 0 ? ((Node)comJdanHour.SelectedItem).ID : 0 );
|
|
}
|
|
query();
|
|
}
|
|
|
|
private void btnInterval_Click(object sender, EventArgs e)
|
|
{
|
|
if (getSelectedIds())
|
|
{
|
|
custClient.updatePickInterval(selectedIds.ToArray(), comInterval.SelectedIndex > 0 ? ((Node)comInterval.SelectedItem).ID : 0 );
|
|
}
|
|
query();
|
|
}
|
|
|
|
private void btnExport_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
exportExcel(gridView1);
|
|
}
|
|
}
|
|
} |