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.ServiceReferenceStockInRequest;//debug namespace DeiNiu.wms.win { public partial class GoodsPreReceive : BasicRibbonForm { printIn reportPrint = new printIn() ; // lWmsStock ls = new lWmsStock(); // lWmsInRequest lgt = new lWmsInRequest(); private string fieldName = WmsLocation.fields.locationId.ToString(); private string fieldGoodType = WmsLocation.fields.whGoodsType.ToString(); private string lastQuery = ""; // private DataTable dt; private DataTable dtship; // DataTable dtIndetail; private int selectedRowIndex = -1; private Erp_purch selectedRequest; private bool isShowingInRequest = true; int shipid; public GoodsPreReceive() { InitializeComponent(); try { initialControls(); } catch (Exception er) { showErrorMsg(er); } } #region initialControls private void initialControls() { setDatePiker(dateEditFrom, dateEditTo); initialComboBoxes(); initialPagerControls(); initialDataGrid(); initialQueryInput(); setValidationRule(); // textEditBarcode.GotFocus += new EventHandler(textEditBarcode_GotFocus); // textEditBarcode.MouseUp += new MouseEventHandler(textEditBarcode_MouseUp); } private void initialComboBoxes() { this.comboType.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; comboType.SelectedIndex = 0; this.comboState.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; Dictionary dic = new Dictionary(); dic.Add((int)enumInStockOrderStatus.待收货, enumInStockOrderStatus.待收货.ToString()); dic.Add((int)enumInStockOrderStatus.待验收, enumInStockOrderStatus.待验收.ToString()); initialComboBoxs(comboState, dic, false); /* Dictionary dic = Utils.Util.convertEnumToDic(typeof(enumInStockOrderStatus)); dic.Remove((int)enumInStockOrderStatus.订单明细日期错误); dic.Remove((int)enumInStockOrderStatus.待上架); dic.Remove((int)enumInStockOrderStatus.货位不足); dic.Remove((int)enumInStockOrderStatus.已入库); initialComboBoxs(comboType, dic,true); //默认选待收货状态 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 2017: // initialComboBoxs(this.combCache, drss,false); //缓存分区 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 initialGridView2Columns(GridView gridview) { setupGridView(gridview, false, true, false); // gridview.OptionsSelection.MultiSelect = false; gridview.FocusRectStyle = DrawFocusRectStyle.RowFocus; // 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 = Erp_purch_d.fields.goods_id.ToString() }; GridColumn myCol2 = new GridColumn() { Caption = "商品名称", Visible = true, FieldName = "goodsName",MinWidth=100}; GridColumn myCol3 = new GridColumn() { Caption = "生产厂家", Visible = true, FieldName ="manufacturer",MinWidth=120}; GridColumn myCol4 = new GridColumn() { Caption = "规格", Visible = true, FieldName = WmsGoods.exfields.spec.ToString(),MinWidth=80 }; 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() ,MinWidth=80}; GridColumn myCol13 = new GridColumn() { Caption = "订单数量", Visible = true, FieldName = Erp_purch_d.fields.count.ToString() }; GridColumn myCol132 = new GridColumn() { Caption = "应收数量", Visible = true, FieldName = "count4Valid" }; GridColumn myCol1321 = new GridColumn() { Caption = "借出数量", Visible = true, FieldName = "lackCount" }; GridColumn myCol131 = new GridColumn() { Caption = "收货数量", Visible = true, FieldName = Erp_purch_d.fields.receiveCount.ToString() }; GridColumn myCol133 = new GridColumn() { Caption = "拒收数量", Visible = true, FieldName = Erp_purch_d.fields.rejectCount.ToString() }; GridColumn myCol134 = new GridColumn() { Caption = "到货数量", Visible = true, FieldName = Erp_purch_d.fields.arriveCount.ToString() }; GridColumn myCol1342= new GridColumn() { Caption = "条码", Visible = true, FieldName = "barCode" }; GridColumn myCol1341 = new GridColumn() { Caption = "到货数量", Visible = true, FieldName = "newArriveCount" }; GridColumn myCol1343 = new GridColumn() { Caption = "收货数量", Visible = true, FieldName = "newReceiveCount" }; GridColumn myCol1344 = new GridColumn() { Caption = "验收数量", Visible = true, FieldName = "newValidCount" }; GridColumn myCol1345= new GridColumn() { Caption = "上架数量", Visible = true, FieldName = "newOnShelfCount" }; // 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 = "wms_state",MinWidth=90}; GridColumn myCol18 = new GridColumn() { Caption = "说明", Visible = true, FieldName = Erp_purch_d.fields.receiveRemark.ToString() }; // GridColumn myCol19 = new GridColumn() { Caption = "货位", Visible = true, FieldName = WmsOutPickLable.fields.locationId.ToString() }; // GridColumn myCol20 = new GridColumn() { Caption = "入库数量", Visible = true, FieldName = WmsOutPickLable.fields.count.ToString() }; // GridColumn myCol21 = new GridColumn() { Caption = "上架数量", Visible = true, FieldName = WmsInUpPort.fields.upCount.ToString() }; // GridColumn myCol22 = new GridColumn() { Caption = "上架说明", Visible = true, FieldName = WmsInUpPort.fields.description.ToString() }; // GridColumn myCol23 = new GridColumn() { Caption = "ABC", Visible = true, FieldName = "goodsABC" }; // GridColumn myCol24 = new GridColumn() { Caption = "箱", Visible = true, FieldName = "box" }; GridColumn myCol25 = new GridColumn() { Caption = "操作人", Visible = true, FieldName = "em_name" }; GridColumn myCol26 = new GridColumn() { Caption = "到货时间", Visible = true, FieldName = "createtime" }; GridColumn myCol27 = new GridColumn() { Caption = "需质检", Visible = true, FieldName = WmsGoods.exfields.isQc.ToString() }; GridColumn myCol28 = new GridColumn() { Caption = "直通商品", Visible = true, FieldName = WmsGoods.exfields.isZhitong.ToString() }; GridColumn myCol29 = new GridColumn() { Caption = "销售订单", Visible = true, FieldName = Erp_purch_d.fields.custPoNo.ToString(),MinWidth=100 }; GridColumn myCol30 = new GridColumn() { Caption = "销售数量", Visible = true, FieldName = Erp_purch_d.fields.custQty.ToString() }; GridColumn myCol31 = new GridColumn() { Caption = "销售客户", Visible = true, FieldName = "custName" }; GridColumn myCol32 = new GridColumn() { Caption = "到货通知单", Visible = true, FieldName = "preInOrderNo" }; GridColumn myCol33 = new GridColumn() { Caption = "双人验收", Visible = true, FieldName = "isDouChk" }; GridColumn myCol34 = new GridColumn() { Caption = "订单号码", Visible = true, FieldName = Erp_purch_d.fields.pur_order.ToString() }; GridColumn myCol35 = new GridColumn() { Caption = "单价", Visible = true, FieldName = "orderPrice" }; GridColumn myCol36 = new GridColumn() { Caption = "件数", Visible = true, FieldName ="boxcnt" }; GridColumn myCol37 = new GridColumn() { Caption = "启运时间", Visible = true, FieldName = "createtime" }; if (gridview == gridView3) { gridview.Columns.Add(myCol32); gridview.Columns.Add(myCol2); gridview.Columns.Add(myCol1341); gridview.Columns.Add(myCol1343); gridview.Columns.Add(myCol1344); gridview.Columns.Add(myCol1345); } else { GridColumn myCol22 = new GridColumn() { Caption = "直通商品", Visible = true, FieldName = "isZhitong" }; gridview.Columns.Add(colChk); gridview.Columns.Add(myCol37); gridview.Columns.Add(myCol34); // gridview.Columns.Add(myCol17); gridview.Columns.Add(myCol2); gridview.Columns.Add(myCol22); gridview.Columns.Add(myCol36); // gridview.Columns.Add(myCol14); gridview.Columns.Add(myCol13); gridview.Columns.Add(myCol132); gridview.Columns.Add(myCol1321); gridview.Columns.Add(myCol5); gridview.Columns.Add(myCol4); gridview.Columns.Add(myCol35); gridview.Columns.Add(myCol6); gridview.Columns.Add(myCol3); // gridview.Columns.Add(myCol7); gridview.Columns.Add(myCol12); gridview.Columns.Add(myCol1); gridview.Columns.Add(myCol18); } //to show bottom scroll bar gridview.OptionsView.ColumnAutoWidth = false; gridview.BestFitColumns(); // gridView2.Focus(); } private void initialGridView1Columns(GridView gridview) { setupGridView(gridview, false, false, false); gridview.FocusRectStyle = DrawFocusRectStyle.None; // gridviewGoodsType.PopulateColumns(); gridview.Columns.Clear(); GridColumn myCol1 = new GridColumn() { Caption = "供应商名称", Visible = true, FieldName ="venderName" }; GridColumn myCol2 = new GridColumn() { Caption = "联系人", Visible = true, FieldName = "contact", MinWidth = 100 }; GridColumn myCol3 = new GridColumn() { Caption = "电话", Visible = true, FieldName = "phone", MinWidth = 120 }; gridview.Columns.Add(myCol1); gridview.Columns.Add(myCol2); gridview.Columns.Add(myCol3); gridview.OptionsView.ColumnAutoWidth = false; gridview.BestFitColumns(); } #endregion private void initialRequestOrders() { showWaitForm(); try{ //inClient.getInRequests(); // getInValidOrders(); } //catch (DeiNiuTimeOutException te) //{ // //} catch(Exception e){ showErrorMsg(e.Message); } finally{ closeWaitForm(); } } /// /// loading data /// private int loadData() { this.gridControl2.DataSource = null; //this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView; // lbVender.Text = lbPhone.Text= lbContact.Text= ""; lbVender.Text =""; // lbOrderNo.Text = ""; clearShipInfo(); ChkState = false; //btnIn.Enabled = false; selectedRequest = null; currentPreNo = ""; /* if (selectedVenderIndex < 0 || dvVender == null || selectedVenderIndex > dvVender.Count) { return 0; } DataRowView drv = (DataRowView)(GetGridViewFilteredAndSortedData(gridView1)[selectedVenderIndex]); string vender = drv["vender"].ToString(); */ string vender = txtVenderNO.Text.Trim(); if (vender.Length==0) { return 0; } showWaitForm(); try { // string query = string.Format("vender = #'{0}';", vender) + (string.Format("{0} = #{1};", Erp_purch.fields.wms_state.ToString(), ((Colitem)comboState.SelectedItem).key)); string query = string.Format("vender = #'{0}';", vender) + (string.Format("{0} = #{1};", Erp_purch.fields.wms_state.ToString(), (int)enumInStockOrderStatus.待收货)); // query += " preInOrderNo is null"; bool isQueryNotChanged = lastQuery.Equals(query); //pager1.PageSize = 200; 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 = inClient.queryReceivesByVender(query, start, end);// lgt.Query(query, start, end); closeClient(); closeWaitForm(); DtGv = ds.Tables[0]; addCheckField(DtGv);//add checkbox // DtGv.PrimaryKey = new DataColumn[] { DtGv.Columns["ID"] }; int cnt = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString()); bool firstLoad = !isQueryNotChanged || this.gridControl2.DataSource == null; this.gridControl2.DataSource = DtGv.DefaultView; gridView2 .OptionsView.ColumnAutoWidth = false; gridView2.BestFitColumns(); //update selected row index to the last updated one. if (selectedRequest !=null) { selectedRowIndex = -1; DataRow dr = DtGv.Rows.Find(selectedRequest.ID); if (dr != null) { selectedRowIndex = DtGv.Rows.IndexOf(dr); } //gridView1.FocusedRowHandle = selectedRowIndex; }else // if (firstLoad) { selectedRowIndex = 0; } setCurrentRequestDetail(); /* * // initialGridView2Columns(gridView3); DataView dv = ds.Tables[0].DefaultView; if (dv.Count > 0) { currentPreNo = dv[0]["preInOrderNo"].ToString(); } //btnPrint.Enabled = !btnPreOk.Enabled; //this.btnShipIn .Enabled = shipid==0; //dv.RowFilter = ""; // this.gridControl3.DataSource = dv; setBtnPreEnable(); */ closeWaitForm(); return cnt; } catch (Exception e) { showErrorMsg(e,e.Message); } closeWaitForm(); return 0;// lgt.getRowCount(query); // return lgt.GetGoodType.QueryCount(); } DataTable dtVender; DataView dvVender; void queryVender() { if(this.txtVender.Text.Trim().Length == 0 && this.txtVenderNO.Text.Trim().Length == 0 ){ // showErrorMsg("请输入供应商或订单信息"); return ; } //this.gridviewGoodsType.DataSource = lgt.GetAllActiveData().Tables[0].DefaultView; showWaitForm(); lbVender.Text = ""; // lbOrderNo.Text = ""; clearShipInfo(); ChkState = false; // btnIn.Enabled = false; selectedRequest = null; currentPreNo = ""; gridControl2.DataSource = null; try { dtVender = inClient.getRequestByVenderPinyin(this.txtVender.Text.Trim(), enumInStockOrderStatus.待收货, this.comboType.SelectedIndex); dvVender = dtVender.DefaultView; // dvVender.RowFilter = string.Format("orderType={0}", this.comboType.SelectedIndex); gridControl1.DataSource = dvVender; initialGridView1Columns(gridView1); selectedVenderIndex = gridView1.FocusedRowHandle; query(); } catch(Exception er) { showErrorMsg(er); } closeWaitForm(); } private void bindDetail() { } private void setDataBack() { } private bool validData() { bool isvalid = dxValidationProvider1.Validate(); // MessageBox.Show("goodtype is " + txtGoodType.Text +", is valid ? " + isvalid); return isvalid; //String gdtype = txtGoodType.Text.Trim(); //if (gdtype.Length == 0) //{ // dxValidationProvider.Validate(); // return false; //} //return true; } /// /// 分页控件产生的事件 /// 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 } private void clearInputs() { } //to show in detail int selectedInIndex = -1; string goodsName; int selectedPdId; int selectedPurDetailId = -1; Erp_purch_d currentDetail = null; private void gridView2_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) { if (!isShowingInRequest) { return; } if (gridView2.FocusedRowHandle < 0 || gridView2.FocusedRowHandle == selectedInIndex) { if (gridView2.IsGroupRow(e.RowHandle)) //set first row of group selected { selectedInIndex = gridView2.GetChildRowHandle(e.RowHandle, 0); setCurrentRequestDetail(); } return; } selectedInIndex = gridView2.FocusedRowHandle; // showErrorMsg("selection:"+ selectedRowIndex); setCurrentRequestDetail(); } int selectedVenderIndex = -1; private void gridView1_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) { if (gridView1.FocusedRowHandle < 0 || gridView1.FocusedRowHandle == selectedVenderIndex) { if (gridView1.IsGroupRow(e.RowHandle)) //set first row of group selected { selectedVenderIndex = gridView1.GetChildRowHandle(e.RowHandle, 0); pager1.Bind(); } return; } selectedVenderIndex = gridView1.FocusedRowHandle; // showErrorMsg("selection:"+ selectedRowIndex); pager1.Bind(); } private void gridView2_DataSourceChanged(object sender, EventArgs e) { if (!isShowingInRequest) { return; } if (selectedInIndex >= 0)// && dtIndetail.Rows.Count > selectedInIndex) { gridView2.FocusedRowHandle = selectedInIndex; gridView2.MakeRowVisible(selectedInIndex); } } private bool getCurrentInObject() {/* if (!isShowingInRequest) { return false; } */ if (selectedInIndex < 0)// || selectedInIndex >= dtIndetail.Rows.Count) { return false; } // DataRow currentRow = dt.Rows[selectedRowIndex]; DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView2)[selectedInIndex]); goodsName = dr["GoodsName"].ToString(); selectedPdId = Convert.ToInt32(dr["id"].ToString()); currentDetail = new Erp_purch_d(dr.Row); return true; } int selectedInShipId = 0; int selectedShipIndex; string shipDate; string selectedShipDriver = ""; private void btnDelete_Click(object sender, EventArgs e) { } protected void query() { pager1.Bind(); txtVenderNO.SelectAll(); txtVenderNO.Focus(); } 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 goods) { showWaitForm(); //WaitFormService.Show(this); try { // lgt.update(goods); //get updated data query(); } catch (Exception e) { showErrorMsg(e.Message); } finally { // WaitFormService.Close(); closeWaitForm(); } } string lastSelectedPurOrder = ""; string fileLocation = ""; private bool getCurrentObject() { fileLocation =lastSelectedPurOrder= ""; if (selectedRowIndex < 0 || selectedRowIndex >= DtGv.Rows.Count) { return false; } // DataRow currentRow = dt.Rows[selectedRowIndex]; DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView2)[selectedRowIndex]); lastSelectedPurOrder = selectedRequest ==null? "" : selectedRequest.pur_order; fileLocation =dr["fileLocation"].ToString(); selectedRequest = new Erp_purch(dr.Row); // lbPhone.Text = dr["phone"].ToString(); // lbContact.Text = dr["contact"].ToString(); // this.gridControl2.DataSource = null; //btnIn.Enabled = false; return true; } private void btnQuery_Click(object sender, EventArgs e) { queryGoods(); } private void initialDataGrid() { this.gridView2.IndicatorWidth = 40; this.gridView2.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator); gridView2.CustomColumnDisplayText += gridView2_CustomColumnDisplayText; gridView2.CustomDrawCell += gridView_CustomDrawCell; gridView2.RowCellStyle += gridView_RowCellStyle; // this.gridView2.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView2_FocusedRowObjectChanged); // this.gridviewShip.FocusedRowObjectChanged += // new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridViewship_FocusedRowObjectChanged); initialGridView2Columns(gridView2); this.gridView1.IndicatorWidth = 20; this.gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView_CustomDrawRowIndicator); this.gridView1.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(this.gridView1_FocusedRowObjectChanged); GridCheckEdit(gridView2, CheckBoxField, 50); } int[] ids; protected override void calculateSelectedValue() { List lst = new List(); decimal money = 0m; for (int i = 0; i < gridView2.RowCount && i 0; ids = lst.ToArray(); } private void gridView2_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { // if (sender == gridView2) { if (e.Column.FieldName == "wms_state") { if (!stockInLocationStatus.ContainsValue(e.DisplayText)) { int display = -100; string disTxt = e.DisplayText; try { display = Convert.ToInt32(e.DisplayText); if (sender == gridView2) { e.DisplayText = this.enumReceiveDetailStatus[display]; } else { e.DisplayText = this.inRequestStatus[display]; } } catch { return; } } // return; // e.DisplayText = stockInLocationStatus.ContainsKey(display) ? stockInLocationStatus[display] : display+""; }else if (e.Column.FieldName == "isQc" || e.Column.FieldName == "isZhitong") { int display = -100; string disTxt = e.DisplayText; try { display = Convert.ToInt32(e.DisplayText); if (sender == gridView2) { e.DisplayText = (display == 1) ? "是" : "否"; } } catch { return; } } else if (e.Column.FieldName == "shipDate") { 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 == "wms_state" && e.CellValue !=null) { 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; } else if(b.Equals("已收货")) { e.Appearance.ForeColor = Color.Gray; 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;} if (!currentView.GetDataRow(e.RowHandle).Table.Columns.Contains("wms_state")) { return; } int state = Convert.ToInt32( currentView.GetDataRow(e.RowHandle)["wms_state"].ToString().Trim()); if (state == 0) { return; } 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 (state >= (int) enumReceiveStockDetailStatus.已验收 ) { rowStyle = isFocused ? passedFocus : passed; } else if (state == (int)enumReceiveStockDetailStatus.拒收 ) { 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 void setCurrentRequestDetail() { // this.gridControl3.DataSource = null; if (!getCurrentObject() || selectedRequest == null) { return; } lbVender.Text = selectedRequest.venderName; /// gridView1.FocusedRowHandle = selectedRowIndex;// // gridView1.SelectRow(selectedRowIndex); showWaitForm(); try { isShowingInRequest = true; // setCurrentVenderPreIn(); // btnIn.Enabled = selectedRequest.wms_state < (int)enumInStockOrderStatus.已验收; // clearShipInfo(); } catch (Exception e) { showErrorMsg(e.Message); } finally { closeClient(); } closeWaitForm(); } string currentPreNo=""; void setCurrentVenderPreIn() { currentPreNo = ""; DataTable dt2 = inClient.getReceivePreSumByVenderNotValided(selectedRequest.vender); closeClient(); initialGridView2Columns(gridView3); DataView dv = dt2.DefaultView; if (dv.Count > 0) { currentPreNo = dv[0]["preInOrderNo"].ToString(); } dv.RowFilter = "preInOrderNo is not null"; //btnPrint.Enabled = !btnPreOk.Enabled; //this.btnShipIn .Enabled = shipid==0; //dv.RowFilter = ""; this.gridControl3.DataSource = dt2 ; setBtnPreEnable(); } void setBtnPreEnable() { btnPreOk.Enabled = (gridView3.DataRowCount > 0) ;//&& shipid > 0; } void clearShipInfo() { /* if (selectedRequest ==null || lastSelectedPurOrder.Equals(selectedRequest.pur_order)) { return; } */ // gridcontrolShip.DataSource = null; selectedInShipId = 0; selectedShipIndex = -1; shipDate =""; selectedShipDriver = ""; shipid = 0; lbSumMoney.Text= lbShipId.Text = txtShipNo.Text = txtCompany.Text = txtDriverPhone.Text = txtTemp.Text = txtVeNumber.Text = ""; // lbShipInfo.Text = ""; } private void btnIn_Click(object sender, EventArgs e) { txtVenderNO.Text = ""; txtVenderNO.SelectAll(); txtVenderNO.Focus(); try { doReceive(); } catch (Exception er) { showErrorMsg(er); } } void doReceive() { if (shipid <= 0) { // showErrorMsg("请设置运输信息。"); // return; } // lastSelectedPurOrder = selectedRequest.pur_order; if (String.IsNullOrEmpty(WmsConstants.PRINTER_NAME_CODE)) { string msg = String.Format("没有定义条码打印机,请先设置条码打印机"); showErrorMsg(msg); return; } takeByVender();// takeAllOrder(); printPreOrder(); query(); // setCurrentRequestDetail() ; } private void GoodsInForm_FormClosing(object sender, FormClosingEventArgs e) { closeClient(); } protected new void gridview_GotFocus(object sender, EventArgs e) { switchGridViewRowSelection((GridView)sender, true); } private void barBiSyncGoods_ItemClick(object sender, ItemClickEventArgs e) { } private void takeByVender() { showWaitForm(); try { calculateSelectedValue(); } catch (Exception er) { } try { currentPreNo= inClient.receiveDetailsPre(selectedRequest.vender, selectedRequest.orderType, ids, shipid); closeClient(); // if (WmsConstants.IS_PRINT_PRENO) { // printIn.printSimple(currentPreNo, selectedRequest.venderName); } } catch (Exception er) { closeClient(); // setCurrentRequestDetail(); showErrorMsg(er.Message); } closeWaitForm(); } private void takeAllOrder() { int lastSelectedIndex = 0; showWaitForm(); try { // lgt.requestInStock(selectedRequest.orderNo); inClient.receiveByOrderPre(selectedRequest.pur_order, selectedRequest.vender,selectedRequest.orderType, "", shipid); closeClient(); lastSelectedIndex = gridView2.FocusedRowHandle; // query(); } catch (Exception er) { // setCurrentRequestDetail(); showErrorMsg(er.Message); } setCurrentRequestDetail(); gridView2.FocusedRowHandle = lastSelectedIndex; closeWaitForm(); } private void btnPrint_Click_1(object sender, EventArgs e) { } void printPreOrder(string preOrder="") { if (string.IsNullOrEmpty(preOrder) && string.IsNullOrEmpty(currentPreNo)) { showErrorMsg("没有到货通知打印"); return; } string toPrintNo = currentPreNo; if (!string.IsNullOrEmpty(preOrder)) { toPrintNo = preOrder; } showWaitForm(); try { //只打印未完成收货的明细,一张预到可对应一个采购单的多次收货 string venderName = selectedRequest != null ? selectedRequest.venderName.Trim().Length > 0 ? selectedRequest.venderName : selectedRequest.vender : "供应商没有名称"; printIn.printStockPreInCode(toPrintNo, venderName); } catch (Exception er) { showErrorMsg(er); } if (chkPrint.Checked) { try { //只打印未完成收货的明细,一张预到可对应一个采购单的多次收货 printIn.printStockPreInItemsCode(toPrintNo); } catch (Exception er) { showErrorMsg(er); } } closeWaitForm(); } private void btnPreOk_Click(object sender, EventArgs e) { showWaitForm(); try { string preNo = inClient.postPreIn(selectedRequest.vender, shipid); closeClient(); // printPreOrder(preNo); setCurrentVenderPreIn(); } catch (Exception er) { showErrorMsg(er); closeClient(); } closeWaitForm(); shipid = 0; clearShipInfo(); } string token = "EC-F6-D5-8A-4E-C5-9F-24-AB-51-E4-2B-D8-87-83-AA"; ServiceReferenceMobileTest.MobileClient _testClient; ServiceReferenceMobileTest.MobileClient testClient { get { if(_testClient==null){ _testClient = new ServiceReferenceMobileTest.MobileClient("BasicHttpBinding_IMobile", buildSvrAddress("MobileService.svc")); } return _testClient; } } void closTestClient() { _testClient.Close(); _testClient = null; } private void btnTestReceive_Click(object sender, EventArgs e) { bool rt = testClient.receiveDetail("PE2021073100000624", "0000103010", 1200, 1200, 0, "", 1, false, 0, LoginInfo.UserId, LoginInfo.Token); //DataTable dt = testClient.getPreInDetail("PE2021073000000580", 278, "32-D5-EB-5F-6D-D8-0E-0D-1A-6F-2B-DA-76-02-4A-56"); closTestClient(); } private void btnValidTest_Click(object sender, EventArgs e) { bool pass = true; bool issueLocations = true; string[] skuKeys = { "生产日期", "到期日期", "厂家批次" }; string[] skuValues = { "2021-1-16", "2022-1-11", "21016" }; try { decimal seedsNum = testClient.getValidSeedsCnt("0000100001 ", 1000); // enumValidInResult rt = (enumValidInResult)testClient.validIn("PE20210801000684", "100012", "0000100001", 200, 1, skuKeys, skuValues, pass, issueLocations, 282, LoginInfo.UserId, LoginInfo.Token); // enumValidInResult valid = rt; closTestClient(); } catch (Exception er) { showErrorMsg(er); } } private void btnInPlateTest_Click(object sender, EventArgs e) { enumRepResult result = (enumRepResult) testClient.repItemIn("A011160411", "8262", 5756, "210208", 54, 1161, LoginInfo.UserId, LoginInfo.Token); // DataTable dt = testClient.taskAssign(0, 0, true, 3, LoginInfo.UserId, LoginInfo.Token); // enumRepResult result = (enumRepResult)testClient.finishUpShelfItem("1", 3, 800, // "B02.06.01.13", "货位不可用", 278, LoginInfo.Token); // enumRepResult result = (enumRepResult)testClient.finishUpShelfItem("10001",2, 120, // "YL.01.01.15", "", LoginInfo.UserId, LoginInfo.Token); // enumRepResult valid = result; // closTestClient(); using (scheduledServiceTest.ScheduledServiceClient client = new scheduledServiceTest.ScheduledServiceClient()) { /* try { client.syncAndCreatePickRequest(enumOutStockRequestStatus.准备分拣); client.createPDAPickTasks(); client.createPickWaves(); } catch (Exception er) { showErrorMsg(er.Message); } */ } // DataTable dt= testClient.getTaskAssigned(278, -1, -1, true, 0); // int i= dt.Rows.Count; // i++; } private void simpleButton1_Click(object sender, EventArgs e) { bool rt = testClient.finishPickItem("100012", "WV2021072800058147", "PK2021072800058146", 3, 120, 278, "CC-15-91-CD-2D-85-B7-51-E1-B5-97-C3-EB-0E-6F-5D"); bool val = rt; closTestClient(); } private void simpleButton2_Click(object sender, EventArgs e) { // DataTable dt = testClient.repTodayDetails4Pick(); bool rt = testClient.finishPickItem("000000011", "", "RP020000048114", 2676, 300, 278, "0C-52-BD-F7-31-BD-F0-C9-47-DF-7E-1C-CE-AF-C7-66"); bool val = rt; closTestClient(); // enumRepResult result = (enumRepResult)testClient.repItemIn("YL.24.10.43", "G2199Y5WDIJ", 3463, "160401", 80, 2111, // 282, token); // int re = (int)result; // closTestClient(); } private void simpleButton3_Click(object sender, EventArgs e) { try { DataTable dtLocs = testClient.getLocations(3463, "", "G2199Y5WDIJ", "160401", 80); int cnt = dtLocs.Rows.Count; } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton4_Click(object sender, EventArgs e) { try { DataTable dtLocs = testClient.getData4Maintain("YL.26.06.45").Tables[0]; int cnt = dtLocs.Rows.Count; } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton5_Click(object sender, EventArgs e) { try { bool result = testClient.newPandianItem("PAN070000005224", "YL.26.06.45", 0, "6902015000001", "2020-6-1", "2020-6-1", 1, 282, token); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton6_Click(object sender, EventArgs e) { using (scheduledServiceTest.ScheduledServiceClient client = new scheduledServiceTest.ScheduledServiceClient()) { try { client.syncAndCreatePickRequest(enumOutStockRequestStatus.准备分拣); client.createPDAPickTasks(); client.createPickWaves(); } catch (Exception er) { showErrorMsg(er.Message); } } } private void simpleButton7_Click(object sender, EventArgs e) { outClient.updateTestData(); closeClient(); } private void simpleButton8_Click(object sender, EventArgs e) { try { DataTable dt = testClient.getTasks(1,-1,282,282, token); int cnt = dt.Rows.Count; showErrorMsg(cnt+""); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton9_Click(object sender, EventArgs e) { try { bool b_result = testClient.newMaintain(15568, 300, 300, "翻跺;除尘;", LoginInfo.UserId, LoginInfo.Token); showErrorMsg(b_result + ""); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void 解锁养护_Click(object sender, EventArgs e) { try { bool b_result = testClient.fixIssueData(1797, LoginInfo.UserId, token); showErrorMsg(b_result + ""); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton10_Click(object sender, EventArgs e) { try { DataTable b_result = testClient.getTransRequestsWithBulks(); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton11_Click(object sender, EventArgs e) { try { int result = testClient.regSeedsPlate("H-1-3-202", 1); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-203", 1); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-204", 1); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-205", 1); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-206", 1); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-207", 2); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-208", 2); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-209", 2); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-210", 2); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-211", 3); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-212", 3); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-213", 3); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-214", 4); showErrorMsg("" + (enumRegPlateResult)result); result = testClient.regSeedsPlate("H-1-3-215", 4); showErrorMsg("" + (enumRegPlateResult)result); showErrorMsg("" + (enumRegPlateResult)result); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void button1_Click(object sender, EventArgs e) { } private void simpleButton12_Click(object sender, EventArgs e) { try { string[] lst = testClient.getPartions(278); foreach (string s in lst) { } } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton13_Click(object sender, EventArgs e) { try { DataTable dt = testClient.getTaskAssigned(LoginInfo.UserId, 0, 0, true,0); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton14_Click(object sender, EventArgs e) { try { DataTable dt = testClient.taskAssign(0, 0, true,0, 278, token); //dt = testClient.repTodayDetails4Pick( ); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton15_Click(object sender, EventArgs e) { try { bool b = testClient.finishBatchValidateItem("PK2021072700058089", 1, 278, 278,LoginInfo.Token); string s= b.ToString(); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } private void simpleButton16_Click(object sender, EventArgs e) { try { string[] b; b = testClient.getPortAuths(282, "EF-AC-BD-1A-C1-41-67-17-FB-B7-CF-03-DA-25-76-AD"); string s = b.ToString(); } catch (Exception er) { showErrorMsg(er.Message); } closTestClient(); } int selectedVenderRowIndex; private void gridView3_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) { if (gridView3.FocusedRowHandle < 0 || gridView3.FocusedRowHandle == selectedVenderRowIndex) { return; } selectedVenderRowIndex = gridView3.FocusedRowHandle; DataRowView dr = (DataRowView)(GetGridViewFilteredAndSortedData(gridView3)[selectedVenderRowIndex]); currentPreNo = dr["preInOrderNo"].ToString(); } private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e) { printPreOrder(); } private void btnPic_Click(object sender, EventArgs e) { using (scheduledServiceTest.ScheduledServiceClient client = new scheduledServiceTest.ScheduledServiceClient()) { try { client.syncAndCreatePickRequest(enumOutStockRequestStatus.准备分拣); client.createPDAPickTasks(); client.createPickWaves(); } catch (Exception er) { showErrorMsg(er.Message); } } // testClient.finishUpShelfItem("", 28, 50, "A011140521", "", LoginInfo.UserId, LoginInfo.Token); // outClient.syncOrders(); // testClient.taskAssign(0, 0, true, 3, LoginInfo.UserId, LoginInfo.Token); // testClient.finishPickItem("", "", "RP21090114313", 1, 200, LoginInfo.UserId, LoginInfo.Token); //testClient.finishUpShelfItem("",1,100, showWaitForm(); Form frm = ((main)this.ParentForm).getOpenedForm("留存模板"); ImageViewForm spdf = frm == null ? new ImageViewForm() : (ImageViewForm)((main)this.ParentForm).getOpenedForm("留存模板"); spdf.Location1 = "https://iknow-pic.cdn.bcebos.com/a9d3fd1f4134970a9ad5dafe99cad1c8a6865db9?x-bce-process%3Dimage%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_jpg"; spdf.Location2 = "https://img2.baidu.com/it/u=2161036217,2729633347&fm=26&fmt=auto&gp=0.jpg"; string file1 =""; string file2 =""; if (!string.IsNullOrEmpty(fileLocation)) { string[] ss =fileLocation.Split(';'); if (ss.Length > 0) { file1 = ss[0]; } if (ss.Length > 1) { file2 = ss[1]; } spdf.Location1 =WmsConstants.FILE_SVR_PIC+ file1; spdf.Location2 = WmsConstants.FILE_SVR_PIC + file2; } spdf.Vender = lbVender.Text; spdf.setVender(); if (frm == null) { if (this.ParentForm != null) { ((main)this.ParentForm).OpenLink(spdf, "留存模板"); } } closeWaitForm(); } private void btnInPlateTest_Click_1(object sender, EventArgs e) { } private void barButtonItem1_ItemClick_1(object sender, ItemClickEventArgs e) { } private void txtVender_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) { return; } if (string.IsNullOrEmpty(txtVenderNO.Text)) { return; } // queryVender(); query(); } private void btnTestService_Click(object sender, EventArgs e) { // DataTable dt = testClient.taskAssign(0, 0, true, 3, LoginInfo.UserId, LoginInfo.Token); using (scheduledServiceTest.ScheduledServiceClient client = new scheduledServiceTest.ScheduledServiceClient()) { try { client.syncAndCreatePickRequest(enumOutStockRequestStatus.准备分拣); client.createPDAPickTasks(); client.createPickWaves(); } catch (Exception er) { showErrorMsg(er.Message); } } } } }