Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var po = _iqcService.GetPackingPoModelAndPoNo(lblModelID.Text, txtPO.Text);

            if (po != null)
            {
                try
                {
                    _iqcService.UpdatePo(lblModelID.Text, txtPO.Text, int.Parse(txtQtyPO.EditValue.ToString()), null);
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBoxHelper.ShowMessageBoxError(ex.Message);
                }
            }
            else
            {
                try
                {
                    _iqcService.InsertPo(lblModelID.Text, txtPO.Text, int.Parse(txtQtyPO.EditValue.ToString()), null);
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBoxHelper.ShowMessageBoxError(ex.Message);
                }
            }
        }
Example #2
0
        private void txtModel_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (string.IsNullOrEmpty(txtModel.Text))
                {
                    Ultils.TextControlNotNull(txtModel, "Model");
                }
                else if (string.IsNullOrEmpty(txtPO.Text))
                {
                    Ultils.TextControlNotNull(txtPO, "PO");
                }
                else
                {
                    string input = txtModel.Text.Trim();
                    string po_no = txtPO.Text.Trim();

                    if (input.Length > 6 && input.Substring(0, 3) == "3N4")
                    {
                        input = input.Remove(0, 3);
                        string[] array = input.Split(separator: new[] { " " }, count: 4, options: StringSplitOptions.None);
                        string   model = $"{array[0]} {array[1]}";

                        _currentModel = _modelService.GetModelByName(model, FujiXerox);

                        if (_currentModel != null)
                        {
                            int quantity = 0;
                            if (checkFujiHP.Checked == true)
                            {
                                if ((_currentModel.ModelName == "105K 33480") || (_currentModel.ModelName == "105K 33470"))
                                {
                                    quantity = _currentModel.QuantityHP;
                                }
                                else
                                {
                                    MessageBoxHelper.ShowMessageBoxError("Vui lòng kiểm tra lại Models!");
                                    checkFujiHP.Checked = false;
                                }
                            }
                            else
                            {
                                quantity = _currentModel.Quantity;
                            }


                            lblQuantityModel.Text = $"/{quantity}";

                            if (!string.IsNullOrEmpty(po_no))
                            {
                                if (!GetQtyPoAndRemainsByWorkingOderAndPoNo(_currentModel.ModelID, po_no))
                                {
                                    _iqcService.InsertPo(_currentModel.ModelID, po_no, quantityPO, txtOperatorCode.Text);
                                    GetQtyPoAndRemainsByWorkingOderAndPoNo(_currentModel.ModelID, po_no);
                                }
                                else
                                {
                                    InsertOrUpdatePo(_currentModel.ModelID, model, po_no);
                                }
                                txtModel.Text = model;
                                txtBoxID.Focus();
                            }
                            else
                            {
                                Ultils.EditTextErrorMessage(txtModel, "PO NO không được để trống. Vui lòng bắn nhập vào PO NO!");
                            }
                        }
                        else
                        {
                            Ultils.EditTextErrorMessage(txtModel, "Model không tồn tại. Vui lòng kiểm tra lại!");
                            txtModel.ResetText();
                            txtModel.Focus();
                        }
                    }
                    else
                    {
                        Ultils.EditTextErrorMessage(txtModel, "Model không đúng định dạng. Vui lòng bắn lại!");
                    }
                }
            }
        }