using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace DeiNiu.Wms.CE { public partial class StockReceive : basicForm { string preInOrder,goodsId = ""; DataTable dtPreIn,dtBulks; decimal bigCount, maxReceiveCnt ,maxValidCnt= 0; public StockReceive() { InitializeComponent(); //client = new WmsOutPickRequestClient(WcfHelp.getBasicBinding(), WcfHelp.getEndpoint("WmsOutPickRequestService")); } private void StockReceive_Load(object sender, EventArgs e) { initialData(); } void initialData() { initialFirstTabData(); initialSecondTabData(); initialThirdTabData(); initialFourthTabData(); textPreInNo.Focus(); //tb1.SelectedIndex = 1; } void initialFirstTabData() { textPreInNo.Focus(); lbvender.Text = lbVeNo.Text = lbPhone.Text = ""; } void initialSecondTabData() { txtReceiveGdBarcod.Focus(); lbGoodsName1.Text = lbPackcnt.Text = lbUnit.Text = lbArriveNum.Text = lbNotReceived.Text = txtWendu.Text = txtReceivePkgNum.Text = txtBulkCnt.Text = ""; chkZhitong.Checked = false; chkNoQc.Checked = false; } void initialThirdTabData() { txtValidGdBarcod.Focus(); lbGoodsName2.Text = txtBatchBoxCnt.Text = lbToValidCnt.Text = txtBatch.Text = txtSeedsNum.Text = lbSeedsCnt.Text = ""; } void initialFourthTabData() { txtPlateId.Focus(); txtSkuId.Text = txtPlateId.Text = lbGoodsName3.Text = txtPackCnt.Text = txtBulkCnt2.Text = ""; } private void dg1_DoubleClick(object sender, EventArgs e) { if (dg1.DataSource == null || dg1.CurrentRowIndex < 0) { return; } preInOrder = dg1[dg1.CurrentRowIndex, 0].ToString(); showTranPickRequests(); } void showTranPickRequests() { if (dg1.DataSource == null) { return; } if (dg1.CurrentRowIndex < 0) { return; } if (string.IsNullOrEmpty(preInOrder)) { return; } lbGoodsName1.Text = preInOrder; Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; try { dtBulks = client.getTransRequestsDetail(preInOrder,0); Cursor.Current = System.Windows.Forms.Cursors.Default; } catch (Exception er) { Cursor.Current = System.Windows.Forms.Cursors.Default; MessageBox.Show("发生错误:" + er.Message); return; } bindBg2(dtBulks); tb1.SelectedIndex = 1; txtReceiveGdBarcod.Focus(); lbGoodsName1.Text = dtBulks.Rows.Count> 0 ? preInOrder :""; } private void tb1_SelectedIndexChanged(object sender, EventArgs e) { if (tb1.SelectedIndex == 0) { bindBg1(); textPreInNo.Focus(); } else { txtReceiveGdBarcod.Focus(); } } private void dg1_CurrentCellChanged(object sender, EventArgs e) { } private void bindPreIn(string preInNo) { Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; try { dtPreIn = client.getPreInDetail(preInNo,LoginInfo.Account,LoginInfo.Password); dg1.DataSource = dtPreIn; } catch (Exception er) { Cursor.Current = System.Windows.Forms.Cursors.Default; MessageBox.Show("发生错误:" + er.Message); return; } Cursor.Current = System.Windows.Forms.Cursors.Default; dg1.TableStyles.Clear(); DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = dtPreIn.TableName; dg1.TableStyles.Add(ts); // [商品名称] ,[商品编码] ,[供应商],[主条码] ,[供应商名称] ,[预到号码] ,[直通商品] ,[上架数量] ,[预到数量] ,[验收数量] ,[温度],[车牌] ,[运单] ,[电话] ts.GridColumnStyles[0].Width = 100; ts.GridColumnStyles[1].Width = 30; ts.GridColumnStyles[2].Width = 30; ts.GridColumnStyles[3].Width = 0; ts.GridColumnStyles[4].Width = 0; ts.GridColumnStyles[5].Width = 0; ts.GridColumnStyles[6].Width = 0; ts.GridColumnStyles[9].Width = 80; ts.GridColumnStyles[11].Width =70; } private void bindBg2(DataTable dt) { dg2.DataSource = dt; dg2.TableStyles.Clear(); DataGridTableStyle dgts = new DataGridTableStyle(); dgts.MappingName = dt.TableName; // 必须用 ds.TableName, dt.TableSpace 不行!!!! dg2.TableStyles.Add(dgts); // [id],[分拣单],[整箱] ,[拼箱] ,[拼袋] ,[体积] ,[重量] ,[客户] ,[客户地址] ,[状态] dgts.GridColumnStyles[0].Width = 0; dgts.GridColumnStyles[1].Width = 100; dgts.GridColumnStyles[2].Width = 30; dgts.GridColumnStyles[3].Width = 30; dgts.GridColumnStyles[4].Width = 30; dgts.GridColumnStyles[5].Width = 35;//[体积] dgts.GridColumnStyles[6].Width = 35; dgts.GridColumnStyles[7].Width = 120; dgts.GridColumnStyles[8].Width = 180; // dg2.TableStyles[0].GridColumnStyles["pickOrderNo"].Width = 0; // dg2.TableStyles[0].GridColumnStyles["state"].Width = 0; // dg2.TableStyles[0].GridColumnStyles["状态"].Width = 70; txtReceiveGdBarcod.Focus(); } private void button1_Click(object sender, EventArgs e) { bindBg1(); } private void textPreInNo_KeyUp(object sender, KeyEventArgs e) { preInOrder = textPreInNo.Text; if (string.IsNullOrEmpty(preInOrder)) { textPreInNo.Focus(); return; } if (e.KeyCode == Keys.Enter || e.KeyCode ==Keys.Space) { bindPreIn(preInOrder); } } private void textGdbarcode_KeyUp(object sender, KeyEventArgs e) { string goodBarcod = txtReceiveGdBarcod.Text; if (e.KeyCode == Keys.Enter) { if (string.IsNullOrEmpty(goodBarcod)) { // MessageBox.Show("请选择运单"); txtReceiveGdBarcod.Focus(); return; } getDataByGoodsBarcode(goodBarcod); txtReceivePkgNum.Focus(); } } void getDataByGoodsBarcode(string goodsBarcod) { Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; DataTable dtPreDetail = client.getReceiveDetailByBarcode(goodBarcod); Cursor.Current = System.Windows.Forms.Cursors.Default; if (dtPreDetail.Rows.Count == 0) { MessageBox.Show("没找到数据"); initialSecondTabData(); txtReceiveGdBarcod.SelectAll(); txtReceiveGdBarcod.Focus(); return; } string packQty = dtPreDetail.Rows[0]["packingQty"].ToString(); lbGoodsName1.Text = lbGoodsName2.Text = lbGoodsName3.Text = dtPreDetail.Rows[0]["goodsName"].ToString(); goodsId = dtPreDetail.Rows[0]["goodsId"].ToString(); string isQc = dtPreDetail.Rows[0]["isQc"].ToString(); string isZhitong = dtPreDetail.Rows[0]["isZhitong"].ToString(); lbUnit.Text = dtPreDetail.Rows[0]["unit"].ToString(); lbArriveNum.Text = dtPreDetail.Rows[0]["newReceiveCount"].ToString(); lbNotReceived.Text = dtPreDetail.Rows[0]["newCount4Receive"].ToString(); lbToValidCnt.Text = dtPreDetail.Rows[0]["newCount4Valid"].ToString(); try { chkNoQc.Checked = Convert.ToInt16(isQc) != 0; chkZhitong.Checked = Convert.ToInt16(isZhitong) != 0; } catch (Exception er) { } try { bigCount = Convert.ToDecimal(packQty); maxReceiveCnt = Convert.ToDecimal(lbNotReceived.Text); maxValidCnt = Convert.ToDecimal(lbToValidCnt.Text); txtReceivePkgNum.Text = maxReceiveCnt / bigCount; } catch (Exception er) { bigCount = 1; } } private void btnReceive_Click(object sender, EventArgs e) { string pkcnt = txtReceivePkgNum.Text.Trim(); string tmp = txtWendu.Text.Trim(); string bulkcnt = txtBulkCnt.Text.Trim(); decimal packCount, bulkCount, temperature = -100; if (String.IsNullOrEmpty(pkcnt) && String.IsNullOrEmpty(bulkcnt)) { MessageBox.Show("请输入收货数量"); txtReceivePkgNum.Focus(); return; } try { if (!String.IsNullOrEmpty(pkcnt)) { packCount = Convert.ToDecimal(pkcnt); } } catch (Exception er) { } try { if (!String.IsNullOrEmpty(bulkcnt)) { bulkCount = Convert.ToDecimal(bulkcnt); } } catch (Exception er) { } try { if (!String.IsNullOrEmpty(bulkcnt)) { temperature = String.IsNullOrEmpty(txtWendu.Text.Trim()) ? 0 : Convert.ToDecimal(txtWendu.Text); } } catch (Exception er) { } decimal count = packCount * bigCount + bulkCount; if (count == 0) { MessageBox.Show("请输入收货数量"); txtReceivePkgNum.Focus(); return; } if (count > maxReceiveCnt) { MessageBox.Show("超过最大应收数量:" + maxReceiveCnt); txtReceivePkgNum.SelectAll(); txtReceivePkgNum.Focus(); } try { Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; decimal arriveCnt = Convert.ToDecimal(lbArriveNum.Text); int intype = 0;//pass bool rt= client.receiveDetail(preInOrder, goodsId, arriveCnt, count, 0, "", temperature, chkZhitong.Checked, 0); Cursor.Current = System.Windows.Forms.Cursors.Default; if (rt) { MessageBox.Show("收货成功!"); if (chkValid.Checked) { tb1.SelectedIndex = 2;//验收 txtValidGdBarcod.Text = txtReceiveGdBarcod.Text; lbGoodsName2.Text = lbGoodsName1.Text; } } } catch (Exception er) { MessageBox.Show("收货失败!"); Cursor.Current = System.Windows.Forms.Cursors.Default; } } private void txtValidGdBarcod_KeyUp(object sender, KeyEventArgs e) { string goodBarcod = txtValidGdBarcod.Text; if (e.KeyCode == Keys.Enter) { if (string.IsNullOrEmpty(goodBarcod)) { // MessageBox.Show("请选择运单"); txtValidGdBarcod.Focus(); return; } getDataByGoodsBarcode(goodBarcod); txtBatchBoxCnt.Text = maxValidCnt; txtBatchBoxCnt.Focus(); } } private void btnSeeds_Click(object sender, EventArgs e) { decimal batchCnt = 0; try{ batchCnt = Convert.ToDecimal(txtBatchCnt.Text.Trim()); } catch (Exception er) { MessageBox.Show("批次数量错误!"); txtBatchCnt.Focus(); return; } Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; decimal seedsNum = client.getValidSeedsCnt(batchCount, goodsId); Cursor.Current = System.Windows.Forms.Cursors.Default; lbSeedsCnt.Text = seedsNum + ""; txtSeedsNum.Text = seedsNum+""; } private void btnValid_Click(object sender, EventArgs e) { string batchBoxCnt = txtBatchBoxCnt.Text.Trim(); string batch = txtBatch.Text.Trim(); string batchCnt = txtBachCnt.Text.Trim(); string seedsCnt = txtSeedsNum.Text.Trim(); DateTime dtProd = dtpProduct.Value; DateTime dtValidTo = dtpValidTo.Value; decimal packCount, bulkCount, seedsCount = -100; if (String.IsNullOrEmpty(batchBoxCnt) && String.IsNullOrEmpty(batchCnt)) { MessageBox.Show("请输入收货数量"); txtBatchBoxCnt.Focus(); return; } try { if (!String.IsNullOrEmpty(batchBoxCnt)) { packCount = Convert.ToDecimal(batchBoxCnt); } } catch (Exception er) { MessageBox.Show("请输入正确收货数量"); txtBatchBoxCnt.Focus(); return; } try { if (!String.IsNullOrEmpty(batchCnt)) { bulkCount = Convert.ToDecimal(batchCnt); } } catch (Exception er) { MessageBox.Show("请输入正确收货数量"); txtBachCnt.Focus(); return; } try { if (!String.IsNullOrEmpty(seedsCnt)) { seedsCount = Convert.ToDecimal(seedsCnt); } } catch (Exception er) { MessageBox.Show("请输入正确收货数量"); txtSeedsNum.Focus(); return; } decimal count = packCount * bigCount + bulkCount; if (count == 0) { MessageBox.Show("请输入收货数量"); txtReceivePkgNum.Focus(); return; } if (count > maxReceiveCnt) { MessageBox.Show("超过最大应收数量:" + maxReceiveCnt); txtReceivePkgNum.SelectAll(); txtReceivePkgNum.Focus(); } try { Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; Cursor.Current = System.Windows.Forms.Cursors.Default; } catch (Exception er) { MessageBox.Show("验收失败"); Cursor.Current = System.Windows.Forms.Cursors.Default; return; } } } }