Exemple #1
0
        private bool ScanLabel()
        {
            string errMsg     = "";
            string cInvCode   = "";
            string strBarCode = txtLabel.Text.Trim().ToUpper();

            txtLabel.Text = "";
            string[] barcode = new string[7] {
                "", "", "", "", "", "", ""
            };
            try
            {
                if (strBarCode.IndexOf('@') == -1)
                {   //一维码
                    is2Code    = false;
                    barcode[0] = strBarCode;
                    if (!Common.GetCInvCode(strBarCode, out cInvCode, out errMsg))
                    {
                        MessageBox.Show("没有找到对应的存货编码!");
                        return(false);
                    }
                    barcode[2]      = cInvCode;
                    lblBarCode.Text = barcode[0];
                    txtLabel.Text   = barcode[2];
                    StockInDetail sd;
                    sd = tempSIO.U8Details.Find(delegate(StockInDetail sdd) { return(sdd.cInvCode == cInvCode); });
                    if (sd != null && sd.bInvBatch)
                    {
                        cbxBatch.Visible       = true;
                        cbxBatch.Enabled       = true;
                        batchList              = StockInBusiness.GetBatchInfo(cInvCode, "", tempSIO.Whcode);
                        cbxBatch.DataSource    = batchList;
                        cbxBatch.DisplayMember = "DisPlayMember";
                        cbxBatch.ValueMember   = "Batch";
                        if (cbxBatch.DataSource != null && cbxBatch.Items.Count > 0)
                        {
                            cbxBatch.SelectedIndex = 0;
                        }
                        else
                        {
                            MessageBox.Show("该仓库暂无存货!");
                            return(false);
                        }
                        lblBatch.Text = cbxBatch.SelectedValue.ToString();
                    }
                }
                else
                {   //二维码
                    is2Code          = true;
                    barcode          = strBarCode.Split('@');
                    cbxBatch.Visible = false;
                    cbxBatch.Enabled = false;
                    batchList        = null;
                    lblBatch.Enabled = true;
                    lblBatch.Visible = true;
                    if (!Common.GetCInvCode(barcode[0], out cInvCode, out errMsg))
                    {
                        MessageBox.Show("没有找到对应的存货编码!");
                        return(false);
                    }
                    barcode[2]      = cInvCode;
                    lblBarCode.Text = barcode[0];
                    txtLabel.Text   = barcode[2];
                    lblBatch.Text   = string.IsNullOrEmpty(barcode[3]) ? "" : barcode[3];
                    try
                    {
                        lblProDate.Text    = DateTime.Parse(barcode[4]).ToString("yyyy-MM-dd");
                        lblValityDate.Text = DateTime.Parse(barcode[5]).ToString("yyyy-MM-dd");
                    }
                    catch
                    {
                        lblProDate.Text    = Common.err_Time.ToString("yyy-MM-dd");
                        lblValityDate.Text = Common.err_Time.ToString("yyy-MM-dd");
                    }
                }
                if (barcode.Length < 7 || string.IsNullOrEmpty(barcode[6]))
                {
                    scanCount = 1;
                }
                else
                {
                    try { scanCount = decimal.Parse(barcode[6]); }
                    catch { scanCount = 1; }
                }
                return(true);
            }
            catch
            {
                Clear();
                MessageBox.Show("对不起,条码格式错误!");
                return(false);
            }
            finally { SetFocus(); }
        }