Пример #1
0
        private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13)
            {
                if (_isScanOnefinished == true)
                {
                    txtBarCode.Text    = "";
                    _isScanOnefinished = false;
                }
                txtBarCode.Text = txtBarCode.Text + e.KeyChar;
                return;
            }
            else
            {
                _isScanOnefinished = true;
            }

            if (btnStartPutin.Enabled == true)
            {
                DlgHelper.ShowAlertMsgBox("请进行入库设置并点击开始入库后,再开始入库操作!", true);
                txtBarCode.Text = "";
                return;
            }
            var barCode = txtBarCode.Text.Trim();

            if (barCode.Length != 17)
            {
                DlgHelper.ShowAlertMsgBox("条形码长度有误!", true);
                return;
            }

            Console.Beep(5000, 1000);

            if (_recentBarcodeList.Contains(barCode))
            {
                //DlgHelper.ShowAlertMsgBox("产品编号重复!", true);
                return;
            }

            var isNumCorrect = PutInWarehouseBLL.IsSpeedChangeTypeNumRight(barCode, ((WebSpeedChangeBoxType)cbxProductType.SelectedItem).SpeedChangeBoxName);

            if (isNumCorrect == false)
            {
                DlgHelper.ShowAlertMsgBox("产品型号和当前设置的型号不一致!", true);
                return;
            }

            if ((int)lblCountStatistic.Tag >= int.Parse(txtCountLimit.Text.Trim()))
            {
                DlgHelper.ShowAlertMsgBox("已达到数量限制,不能入库!", true);
                return;
            }

            var numCheckResult = PutInWarehouseBLL.IsCurrentPutInInfoRight(barCode);

            if (numCheckResult == PutInResultEnum.仓库已经存在此货物)
            {
                DlgHelper.ShowAlertMsgBox(numCheckResult.ToString(), true);
                return;
            }
            else if (numCheckResult == PutInResultEnum.重复入库)
            {
                if (!PermissionCheckHelper.GetHighUserPermission("重复入库,需要高级权限!"))
                {
                    return;
                }
            }

            _recentBarcodeList.Add(txtBarCode.Text.Trim());

            if (_recentBarcodeList.Count == int.Parse(txtPrintCount.Text))
            {
                var saveResult = PrintTwoDimensioncode();
                if (!saveResult)
                {
                    DlgHelper.AlarmSound();
                    while (saveResult == false)
                    {
                        var dlgResult = MessageBox.Show("入库失败,请检查打印机和服务器状态后重试,点击重试!\n点击取消,需要重新入库这条二维码上的产品!", "重试", MessageBoxButtons.RetryCancel);
                        if (dlgResult == DialogResult.Retry)
                        {
                            saveResult = PrintTwoDimensioncode();
                        }
                        else
                        {
                            _recentBarcodeList.Clear();
                            return;
                        }
                    }
                }
            }

            SetCountStatisticProp((int)lblCountStatistic.Tag + 1);
        }