コード例 #1
0
ファイル: CheckStock.cs プロジェクト: i-sync/FoodSupply
 /// <summary>
 /// 点击提交按钮事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     ///如果已扫描数据
     if (list.Count > 0)
     {
         try
         {
             string errMsg;
             Cursor.Current = Cursors.WaitCursor;
             bool flag = new BLL.CheckStock().SaveCheckVouch(list, out errMsg);
             if (!flag)
             {
                 MessageBox.Show("保存失败:" + errMsg);
             }
             else
             {
                 MessageBox.Show("保存成功!");
                 this.Close();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("失败:" + ex.Message);
         }
         finally
         {
             Cursor.Current = Cursors.Default;
         }
     }
 }
コード例 #2
0
ファイル: CheckStock.cs プロジェクト: i-sync/FoodSupply
        /// <summary>
        /// 扫描条码回车
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
        {
            string strBarCode = txtBarCode.Text.Trim();

            if (!string.IsNullOrEmpty(strBarCode) && e.KeyChar == (char)Keys.Enter)
            {
                //判断条码中是否包含分隔符
                if (strBarCode.IndexOf(Cast.Delimiter) < 0)
                {
                    MessageBox.Show("条码错误,没有分隔符!");
                    txtBarCode.Focus();
                    txtBarCode.SelectAll();
                    return;
                }
                //解析QR码
                barcode = strBarCode.Split(Cast.Delimiter);
                //判断条码是否正确
                if (barcode.Length < 4)
                {
                    MessageBox.Show("条码错误!");
                    txtBarCode.Focus();
                    txtBarCode.SelectAll();
                    return;
                }

                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    string errMsg;
                    //封装数据
                    checkVouchs          = new CheckVouchs();
                    checkVouchs.cCVCode  = cCVCode;
                    checkVouchs.cInvCode = barcode[0];
                    checkVouchs.cCVBatch = barcode[1];
                    //查询数据
                    bool flag = new BLL.CheckStock().SelectCheckVouch(ref checkVouchs, out errMsg);
                    if (!flag)
                    {
                        MessageBox.Show(errMsg);
                        txtBarCode.Focus();
                        txtBarCode.SelectAll();
                        return;
                    }
                    //绑定显示
                    lblInvName.Text  = checkVouchs.cInvName;
                    lblInvStd.Text   = checkVouchs.cInvStd;
                    lblcBatch.Text   = checkVouchs.cCVBatch;
                    lbldMDate.Text   = checkVouchs.dMadeDate.ToShortDateString();
                    lbldVDate.Text   = checkVouchs.dDisDate.ToShortDateString();
                    lblQuantity.Text = checkVouchs.iCVQuantity.ToString();

                    //盘点数据获取焦点
                    txtQuantity.Focus();
                    txtQuantity.SelectAll();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
        }