示例#1
0
        private void Clear()
        {
            dd = null;
            lblInvName.Text    = "";
            lblInvStd.Text     = "";
            lblProAddress.Text = "";
            lblEnterprise.Text = "";
            lblProDate.Text    = "";
            lblValidDate.Text  = "";
            lblScanedNum.Text  = "";

            //清空批次
            cmbBatch.DataSource = null;
            cmbBatch.Enabled    = false;

            txtCount.Text    = "";
            txtCount.Enabled = false;

            txtLable.Text     = "";
            txtCPosition.Text = "";

            //判断是否货位管理
            if (Bwhpos)
            {
                txtCPosition.Focus();
            }
            else
            {
                txtLable.Focus();
            }
        }
示例#2
0
        /// <summary>
        /// 输入扫描数量后回车
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtCount_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13 && txtCount.Text.Length > 0)
            {
                if (cmbBatch.SelectedItem == null)
                {
                    MessageBox.Show("请先确认批次!");
                    return;
                }
                //获取批次、货位、仓库编码
                string    batch     = (cmbBatch.SelectedItem as BatchInfo).Batch;
                string    cposition = txtCPosition.Text.Trim().ToUpper();
                Warehouse wh        = cmbWarehouse.SelectedItem as Warehouse;
                if (wh.cwhcode.Equals("-1"))
                {
                    MessageBox.Show("请重新选择仓库");
                    return;
                }
                string cwhcode = wh.cwhcode;
                if (txtCount.Text.Trim() == "")
                {
                    MessageBox.Show("未输入数量!");
                    txtCount.SelectAll();
                    txtCount.Focus();
                    return;
                }
                if (!isNumeric(txtCount.Text))
                {
                    MessageBox.Show("请输入数字!");
                    txtCount.SelectAll();
                    txtCount.Focus();
                    return;
                }
                if (Convert.ToDecimal(txtCount.Text) <= 0)
                {
                    MessageBox.Show("请输入正确的数量!");
                    txtCount.SelectAll();
                    txtCount.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(batch)) //txtcBatch.Text.Trim() == "")    // || lblProDate.Text == "" || lblValidDate.Text == "" )
                {
                    MessageBox.Show("请先确认批号");
                    cmbBatch.Focus();
                    return;
                }

                //如果有货位管理
                if (Bwhpos)
                {
                    Model.DispatchDetail ddtmp = dispatchlist.OperateDetails.Find(delegate(Model.DispatchDetail tdd) { return(tdd.cinvcode.Equals(dd.cinvcode) && tdd.invbatch.Equals(batch) && tdd.cposition.Equals(cposition)); });
                    if (ddtmp == null)
                    {
                        ddtmp = dd.CreateAttriveDetail();
                        //批次货位仓库编码
                        ddtmp.invbatch  = batch;
                        ddtmp.cposition = cposition;
                        ddtmp.cwhcode   = cwhcode;
                        decimal qty = Convert.ToDecimal(txtCount.Text);
                        if (qty <= ddtmp.iquantity - ddtmp.inewquantity - ddtmp.IFHQuantity && qty <= favailqtty)
                        {
                            ddtmp.inewquantity = qty;
                            dd.inewquantity   += qty;
                            //ddtmp.cwhcode = this.cmbWarehouse.SelectedValue.ToString();
                            dispatchlist.OperateDetails.Add(ddtmp);
                            btnDone.Enabled   = true;
                            btnSubmit.Enabled = true;
                            lblScanedNum.Text = dd.inewquantity.ToString("F2");
                            Clear();
                            //第一次提交成功后,仓库不可再选
                            if (cmbWarehouse.Enabled)
                            {
                                cmbWarehouse.Enabled = false;
                            }
                        }
                        else
                        {
                            MessageBox.Show("输入数量大于应发货数量或可发货数量,或大于此货位下该货物数量");
                            txtCount.SelectAll();
                            txtCount.Focus();
                        }
                    }
                    else
                    {
                        decimal qty = Convert.ToDecimal(txtCount.Text);

                        ///这里送去dd.inewquantity的数量:这个临时变量中已扫描数量不能表示该存货已扫描数量
                        ///而上面的是临时变量的已扫描数量,是因为临时变量是来源对象的拷贝与dd.inewquantity是一样的。
                        if (qty <= ddtmp.iquantity - dd.inewquantity - ddtmp.IFHQuantity && qty <= favailqtty - ddtmp.inewquantity)
                        {
                            ddtmp.inewquantity += qty;
                            dd.inewquantity    += qty;
                            lblScanedNum.Text   = dd.inewquantity.ToString("F2");
                            Clear();
                        }
                        else
                        {
                            MessageBox.Show("输入数量大于应发货数量或可发货数量,或大于此货位下该货物数量");
                            txtCount.SelectAll();
                            txtCount.Focus();
                        }
                    }
                }
                //没有货位管理
                //2012-10-17复制修改
                else
                {
                    Model.DispatchDetail ddtmp = dispatchlist.OperateDetails.Find(delegate(Model.DispatchDetail tdd) { return(tdd.cinvcode.Equals(dd.cinvcode) && tdd.invbatch.Equals(batch)); });
                    if (ddtmp == null)
                    {
                        ddtmp = dd.CreateAttriveDetail();
                        //批次货位仓库编码
                        ddtmp.invbatch = batch;
                        //ddtmp.cposition = cposition;
                        ddtmp.cwhcode = cwhcode;
                        decimal qty = Convert.ToDecimal(txtCount.Text);
                        if (qty <= ddtmp.iquantity - ddtmp.inewquantity - ddtmp.IFHQuantity && qty <= favailqtty)
                        {
                            ddtmp.inewquantity = qty;
                            dd.inewquantity   += qty;
                            //ddtmp.cwhcode = this.cmbWarehouse.SelectedValue.ToString();
                            dispatchlist.OperateDetails.Add(ddtmp);
                            btnDone.Enabled   = true;
                            btnSubmit.Enabled = true;
                            lblScanedNum.Text = dd.inewquantity.ToString("F2");
                            Clear();
                            //第一次提交成功后,仓库不可再选
                            if (cmbWarehouse.Enabled)
                            {
                                cmbWarehouse.Enabled = false;
                            }
                        }
                        else
                        {
                            MessageBox.Show("输入数量大于应发货数量或可发货数量");
                            txtCount.SelectAll();
                            txtCount.Focus();
                        }
                    }
                    else
                    {
                        decimal qty = Convert.ToDecimal(txtCount.Text);
                        if (qty <= ddtmp.iquantity - dd.inewquantity - ddtmp.IFHQuantity && qty <= favailqtty - ddtmp.inewquantity)
                        {
                            ddtmp.inewquantity += qty;
                            dd.inewquantity    += qty;
                            lblScanedNum.Text   = dd.inewquantity.ToString("F2");
                            Clear();
                        }
                        else
                        {
                            MessageBox.Show("输入数量大于应发货数量或可发货数量");
                            txtCount.SelectAll();
                            txtCount.Focus();
                        }
                    }
                }
            }
        }
示例#3
0
        private void txtLable_KeyPress(object sender, KeyPressEventArgs e)
        {
            //成品标签扫描
            if (e.KeyChar == 13 && txtLable.Text.Length > 0)
            {
                try
                {
                    //首先判断扫描的是一维条码还是二维条码,条件是否包含@
                    string   strBarcode = txtLable.Text.Trim();
                    string[] barcode    = new string[7] {
                        "", "", "", "", "", "", ""
                    };
                    if (strBarcode.IndexOf('@') == -1)//没有找到@,说明该条码是一维条码
                    {
                        string errMsg   = string.Empty;
                        string cInvCode = string.Empty;//存货编码
                        //根据一维条码查询存货编码
                        bool flag = Common.GetCInvCode(strBarcode, out cInvCode, out errMsg);
                        if (!flag)
                        {
                            MessageBox.Show("没有找到对应的存货编码!" + errMsg);
                            return;
                        }
                        barcode[2] = cInvCode;
                    }
                    else //二维码
                    {
                        barcode = strBarcode.Split('@');
                        ///根据20121109日讨论结果:以69码为主,根据69码查询对应的存货编码
                        string errMsg   = string.Empty;
                        string cInvCode = string.Empty;//存货编码
                        //根据一维条码查询存货编码
                        bool flag = Common.GetCInvCode(barcode[0], out cInvCode, out errMsg);
                        if (!flag)
                        {
                            MessageBox.Show("没有找到对应的存货编码!" + errMsg);
                            return;
                        }
                        barcode[2] = cInvCode;
                    }

                    ///在来源单据中查看存货编码为CInvCode
                    dd = dispatchlist.U8Details.Find(delegate(Model.DispatchDetail tdd) { return(tdd.cinvcode.Equals(barcode[2])); });
                    if (dd == null)
                    {
                        MessageBox.Show("条码错误:存货编码不在订单中");
                        txtLable.SelectAll();
                        txtLable.Focus();
                        txtCount.Enabled = false;
                    }
                    else
                    {
                        //首先判断是否有货位管理2012-10-17
                        if (Bwhpos)
                        {
                            //判断该货位下是否有此货物
                            p = list.Find(delegate(Position tp) { return(tp.cPosCode.Equals(txtCPosition.Text.Trim().ToUpper()) && tp.cInvCode.Equals(barcode[2])); });
                            if (p == null || p.iQuantity <= 0)
                            {
                                MessageBox.Show("此货位下没有该货物或货物数量为0");
                                return;
                            }
                        }

                        //绑定批次
                        GetBatchList(barcode[2], cmbWarehouse.SelectedValue.ToString(), txtCPosition.Text.Trim());

                        lblInvName.Text = dd.cinvname;
                        lblInvStd.Text  = dd.cinvstd;
                        //lblProAddress.Text = dd.cvenabbname; 2012-10-19改
                        lblProAddress.Text = dd.cdefine22;
                        lblEnterprise.Text = dd.cinvdefine1;
                        lblScanedNum.Text  = dd.inewquantity.ToString("F3");
                        if (barcode[3].Equals("") || barcode[4].Equals("") || barcode[5].Equals(""))
                        {
                            lblProDate.Text   = "";
                            lblValidDate.Text = "";
                            //txtcBatch.Enabled = true;
                            cmbBatch.Enabled = true;
                            txtCount.Enabled = true;
                            cmbBatch.Focus();
                            favailqtty = 0;
                        }
                        else
                        {
                            dd.invbatch = barcode[3];
                            bool flag = true;
                            //cmbBatch.SelectedValue = barcode[3];
                            foreach (object obj in cmbBatch.Items)
                            {
                                if ((obj as BatchInfo).Batch == barcode[3])
                                {
                                    cmbBatch.SelectedItem = obj;
                                    //如果找到对应的批次后,则cmbBatch设置为不可用
                                    flag = false;
                                    break;
                                }
                            }
                            //如果没有找到对应的批次,说明该货位下没有此批次不能继续
                            if (flag)
                            {
                                MessageBox.Show("批次不正确,可能此货位下没有该批次!");
                                return;
                            }
                            //GetSTOutInvBatch(dd, cmbWarehouse.SelectedValue.ToString(), barcode[2], barcode[3]);
                            //txtcBatch.Enabled = true;
                            cmbBatch.Enabled = flag;
                            txtCount.Enabled = true;
                            txtCount.SelectAll();
                            txtCount.Focus();
                        }
                        cmbBatch_SelectedIndexChanged(sender, e);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }