Exemple #1
0
        private void txtProductionID_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                _dateTimeCheck = DateTime.Now;
                if (string.IsNullOrEmpty(txtProductID.Text))
                {
                    SetErrorStatus("NG", $"Label không được để trống!");
                    Ultils.EditTextErrorNoMessage(txtProductID);
                }
                else
                {
                    string productionId = txtProductID.Text.Trim();
                    if (productionId.Length <= 16)
                    {
                        SetErrorStatus("NG", $"Error! Label không đúng định dạng!");
                        txtProductID.SelectAll();
                        Ultils.EditTextErrorNoMessage(txtProductID);
                    }
                    else
                    {
                        if (productionId.Contains(lblCurentModel.Text) && productionId.Contains(lblSerialNo.Text))
                        {
                            if (Program.CurrentUser.OperationID == 1)
                            {
                                var production = _oqcService.GetLogByProductionId(productionId);
                                if (production != null)
                                {
                                    SetErrorStatus("NG",
                                                   $"PCB [{txtProductID.Text}] đã có trong hệ thống. Vui lòng kiểm tra lại\n" +
                                                   $"Box ID: {production.BoxID}");
                                    txtProductID.ResetText();
                                    Ultils.EditTextErrorNoMessage(txtProductID);
                                }
                                else
                                {
                                    bool _checkMes = false;
                                    var  checkMes  = _mesService.Get_WORK_ORDER_ITEMS_By_BoardNo(productionId);
                                    if (checkMes != null)
                                    {
                                        if (checkMes.BOARD_STATE > 1)
                                        {
                                            _checkMes = true;
                                        }
                                    }

                                    if (!_checkMes)
                                    {
                                        if (checkModelCUS.Checked == true)
                                        {
                                            txtModelCUS.Focus();
                                        }
                                        else
                                        {
                                            InsertLog(txtBoxID.Text.Trim());
                                        }
                                    }
                                    else
                                    {
                                        SetErrorStatus("NG", $"NG WIP. Vui lòng kiểm tra lại!");
                                        Ultils.EditTextErrorNoMessage(txtProductID);
                                    }
                                }
                            }
                            else if (Program.CurrentUser.OperationID >= 2)
                            {
                                InsertLog(txtBoxID.Text.Trim());
                            }
                        }
                        else
                        {
                            SetErrorStatus("NG", $"Sai Label. Vui lòng kiểm tra lại!");
                            Ultils.EditTextErrorNoMessage(txtProductID);
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void txtProductionID_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                _dateTimeCheck = DateTime.Now;

                // Nếu PCB rỗng, thì thông báo lỗi
                if (string.IsNullOrEmpty(txtProductID.Text))
                {
                    SetErrorStatus("NG", $"Label không được để trống!");
                    Ultils.EditTextErrorNoMessage(txtProductID);
                }
                else if (string.IsNullOrEmpty(txtBoxID.Text))
                {
                    SetErrorStatus("NG", $"Box không được để trống!");
                    Ultils.EditTextErrorNoMessage(txtBoxID);
                }
                else
                {
                    string productionId = txtProductID.Text.Trim();
                    // Nếu chuỗi PCB có dộ dài mà nhỏ hơn 16,
                    // thì thông báo lỗi cho người dùng biết.
                    if (productionId.Length <= 16)
                    {
                        SetErrorStatus("NG", $"Error! Label không đúng định dạng!");
                        txtProductID.SelectAll();
                        Ultils.EditTextErrorNoMessage(txtProductID);
                    }
                    else
                    {
                        // Nếu PCB, giống với ModelName đang chạy,
                        string[] strSpit = productionId.Split(' ');
                        //string beginWidth=productionId.StartsWith()
                        if (strSpit[0] == lblCurentModel.Text && productionId.Contains(lblSerialNo.Text))
                        {
                            var production = _murataService.GetProducts_Murata_by_ID(productionId);
                            if (production != null)
                            {
                                SetErrorStatus("NG",
                                               $"PCB [{productionId}] đã có trong hệ thống. Vui lòng kiểm tra lại\n" +
                                               $"Box ID: {production.BoxID}");
                                txtProductID.ResetText();
                                Ultils.EditTextErrorNoMessage(txtProductID);
                            }
                            else
                            {
                                if (Program.CurrentUser.CheckItemOnWIP == true)
                                {
                                    var checkMes = _mesService.Get_WORK_ORDER_ITEMS_By_BoardNo(productionId);
                                    // Kiểm tra sự tồn tại của bản mạch có trên hệ thống WIP chưa?
                                    // Nếu có rồi thì thực hiện kiểm tra các bước tiếp theo
                                    if (checkMes != null)
                                    {
                                        // 1 => OK
                                        // 2 => NG
                                        // 3 => Discard

                                        // Nếu trạng thái bản mạch đang là 'NG'
                                        if (checkMes.BOARD_STATE == 2)
                                        {
                                            try
                                            {
                                                _murataService.DeleteLogByProductionId(productionId);
                                            }
                                            catch (Exception ex)
                                            {
                                                MessageBox.Show($"Delete error!\n{ex.Message}", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            }

                                            if (checkModelCUS.Checked == true)
                                            {
                                                txtModelCUS.Focus();
                                            }
                                            else
                                            {
                                                InsertLog(txtBoxID.Text);
                                            }
                                        }
                                        // Nếu trạng thái bản mạch đang là Discard
                                        else if (checkMes.BOARD_STATE == 3)
                                        {
                                            SetErrorStatus("NG", $"PCB [{productionId}] này đã được loại bỏ. Vui lòng kiểm tra lại!");
                                            Ultils.EditTextErrorNoMessage(txtProductID);
                                        }
                                        // Nếu bản mạch này đã finished
                                        else if (checkMes.IS_FINISHED == true)
                                        {
                                            SetErrorStatus("OK", $"[{productionId}] đã hoàn thành. Vui lòng kiểm tra lại!");
                                            Ultils.EditTextErrorNoMessage(txtProductID);
                                        }
                                        // Trạng thái bản mạch OK
                                        else if (checkMes.BOARD_STATE == 1)
                                        {
                                            if (checkModelCUS.Checked == true)
                                            {
                                                txtModelCUS.Focus();
                                            }
                                            else
                                            {
                                                InsertLog(txtBoxID.Text);
                                            }
                                        }
                                    }
                                    // Nếu bản mạch chưa có trên hệ thống WIP thì thông báo lỗi
                                    // cho người dùng
                                    else
                                    {
                                        SetErrorStatus("NG", $"[{productionId}]\nChưa khởi tạo trên WIP. Vui lòng kiểm tra lại!");
                                        Ultils.EditTextErrorNoMessage(txtProductID);
                                    }
                                }
                                else
                                {
                                    if (checkModelCUS.Checked == true)
                                    {
                                        txtModelCUS.Focus();
                                    }
                                    else
                                    {
                                        InsertLog(txtBoxID.Text);
                                    }
                                }
                            }
                        }
                        else
                        {
                            SetErrorStatus("NG", $"Sai Label. Vui lòng kiểm tra lại!");
                            Ultils.EditTextErrorNoMessage(txtProductID);
                        }
                    }
                }
            }
        }