Esempio n. 1
0
        /// <summary>
        /// Get all PCB in Box
        /// </summary>
        private void GetAll(string boxId)
        {
            if (!_iqcService.CheckBoxExits(boxId))
            {
                splashScreenManager1.ShowWaitForm();
                var logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                if (logs.Any())
                {
                    foreach (var log in logs)
                    {
                        var shipping = new Shipping()
                        {
                            Operator    = txtOperatorCode.Text,
                            Model       = gridLookUpEditModelID.Text,
                            WorkingOder = txtWorkingOrder.Text,
                            Quantity    = 1,
                            BoxID       = txtBoxID.Text,
                            ProductID   = log.ProductionID,
                            PO_NO       = txtPO.Text,
                            MacAddress  = log.MacAddress,
                            DateCheck   = DateTime.Now.Date
                        };

                        if (_iqcService.GetShippingById(log.ProductionID) == null)
                        {
                            if (CheckModels(shipping.ProductID))
                            {
                                _shippings.Add(shipping);
                            }
                            else
                            {
                                _pcbError.Add(shipping);
                            }
                        }
                        else
                        {
                            MessageBoxHelper.ShowMessageBoxError($"{log.ProductionID} đã được xuất trước đó. Vui lòng kiểm tra lại!");
                            txtBoxID.Focus();
                            break;
                        }
                    }
                    if (_pcbError.Any())
                    {
                        gridControlData.DataSource = _shippings;
                        splashScreenManager1.CloseWaitForm();
                        MessageBoxHelper.ShowMessageBoxError($"Box [{boxId}] có {logs.Count} PCB\n" +
                                                             $"Có {_pcbError.Count} PCB không dành cho Model [{gridLookUpEditModelID.Text}].\n" +
                                                             "Vui lòng kiểm tra lại!");
                        //EnableTextControls(false);
                        //VisibleControlAddPcb(true);
                        txtBoxID.SelectAll();
                        txtBoxID.Focus();
                    }
                    else
                    {
                        GetQtyPoAndRemainsByWorkingOderAndPoNo(gridLookUpEditModelID.EditValue.ToString(), txtPO.EditValue.ToString());
                        lblCountPCB.Text = _shippings.Count.ToString(CultureInfo.InvariantCulture);
                        lblRemains.Text  = (_currentPo.QuantityRemain - _shippings.Count).ToString(CultureInfo.InvariantCulture);
                        Thread.Sleep(200);
                        // Nếu số lượng đủ thì thực hiện lưu vào csdl
                        if (_shippings.Count == _currentModel.Quantity)
                        {
                            gridControlData.DataSource = _shippings;
                            splashScreenManager1.CloseWaitForm();
                            splashScreenManager2.ShowWaitForm();
                            foreach (var log in _shippings)
                            {
                                _iqcService.InsertShipping(txtOperatorCode.Text, gridLookUpEditModelID.EditValue.ToString(), txtWorkingOrder.Text, 1, txtPO.Text, txtBoxID.Text, log.ProductID, log.MacAddress);
                            }
                            _iqcService.UpdateRemainsForPo(_currentPo.PO_NO, _currentPo.ModelID, int.Parse(lblRemains.Text));
                            splashScreenManager2.CloseWaitForm();
                            InsertOrUpdatePo(gridLookUpEditModelID.EditValue.ToString(), gridLookUpEditModelID.Text, txtPO.Text);
                            gridControlData.DataSource = null;
                            _shippings       = new List <Shipping>();
                            txtBoxID.Text    = string.Empty;
                            lblCountPCB.Text = @"0";
                        }
                        else
                        {
                            if (_shippings.Count > _currentModel.Quantity)
                            {
                                int count = _shippings.Count - _currentModel.Quantity;
                                gridControlData.Refresh();
                                gridControlData.DataSource = _shippings;
                                splashScreenManager1.CloseWaitForm();
                                MessageBoxHelper.ShowMessageBoxError($"Vui lòng kiểm tra lại Box [{boxId}]\n." +
                                                                     $"Số lượng lớn hơn quy định {count} PCB!");
                                txtBoxID.SelectAll();
                            }
                            else
                            {
                                gridControlData.Refresh();
                                gridControlData.DataSource = _shippings;
                                splashScreenManager1.CloseWaitForm();
                                MessageBoxHelper.ShowMessageBoxWaring($"Số lượng trong Box [{boxId}] chưa đủ. Vui lòng nhập thêm!");
                                VisibleControlAddPcb(true);
                                EnableTextControls(false);
                            }
                        }
                    }
                }
                else
                {
                    splashScreenManager1.CloseWaitForm();
                    if (XtraMessageBox.Show("Vui lòng bắn từng PCB vào Box [" + boxId + "]!", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        EnableTextControls(false);
                        VisibleControlAddPcb(true);
                        txtAddPCB.Focus();
                    }
                    else
                    {
                        DialogResult = DialogResult.No;
                        txtBoxID.SelectAll();
                    }
                }
            }
            else
            {
                Ultils.EditTextErrorMessage(txtBoxID, $"Box [{boxId}] đã được nhập trước đó. Vui lòng kiểm tra lại!");
                txtBoxID.Text = string.Empty;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="boxId"></param>
        private void InsertLog(string boxId)
        {
            if (!string.IsNullOrEmpty(txtProductID.Text.Trim()) ||
                !string.IsNullOrEmpty(txtBoxID.Text.Trim()))
            {
                int    lineId       = Program.CurrentUser.LineID;
                int    operationId  = Program.CurrentUser.OperationID;
                string operatorId   = Program.CurrentUser.OperatorCode;
                string productionId = txtProductID.Text.Trim();

                string status = null;
                bool   judge  = false;
                if (checkPASS.Checked == true)
                {
                    status = "P";
                    judge  = true;
                }
                if (checkNG.Checked == true)
                {
                    status = "F";
                    judge  = false;
                }
                var logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                if (operationId == 1)
                {
                    // Nếu Box có dữ liệu của PCB
                    if (logs.Any())
                    {
                        var log = logs.SingleOrDefault(l => l.ProductionID == productionId);
                        // Nếu PCB mới bắn vào chưa có trong Box
                        if (log == null)
                        {
                            //string tmp = lblQuantityModel.Text.Replace("/", "");
                            //int countPcbInBox = int.Parse(lblCountPCB.Text);
                            //int quantity = int.Parse(tmp);

                            //if (logs.Count == quantity)
                            //{
                            //    SetErrorStatus("NG", $"Box [{txtBoxID.Text}] đã đủ số lượng. Vui lòng kiểm tra lại!");
                            //    Ultils.EditTextErrorNoMessage(txtBoxID);
                            //    txtProductID.ResetText();
                            //}
                            //else
                            //{
                            try
                            {
                                _iqcService.InsertLogs(productionId, lineId, "N/A", boxId, modelID, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), "N/A");

                                if (!_iqcService.CheckResultExits(productionId, operationId))
                                {
                                    _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                                }
                                else
                                {
                                    _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                                }
                                Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                                Ultils.CreateFileLogDirModelName(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                                logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                                gridControlData.Refresh();
                                gridControlData.DataSource = logs;
                                lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                                SetSuccessStatus("OK", $"Thành công!\nPCB [{txtProductID.Text}]");
                                ResetControls();
                                //if (logs.Count() == quantity)
                                //{
                                //    SetErrorStatus("NG", $"Box [{txtBoxID.Text}] đã đủ số lượng. Vui lòng lấy box mới!");
                                //    Ultils.EditTextErrorNoMessage(txtBoxID);
                                //    txtProductID.ResetText();
                                //}
                            }
                            catch (Exception ex)
                            {
                                SetErrorStatus("NG", "Model chưa có trong hệ thống!\nVui lòng nhập model này vào, và thử lại. \n" + ex.Message);
                                ResetControls();
                            }
                            //}
                        }
                        // Nếu có rồi thì thống báo lỗi
                        else
                        {
                            SetErrorStatus("NG", $"PCB [{txtProductID.Text}] này đã có trong Box rồi.\nVui lòng kiểm tra lại");
                            ResetControls();
                            gridControlData.Refresh();
                            gridControlData.DataSource = logs;
                            lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);
                        }
                    }
                    // Nếu Box chưa có dữ liệu gì, thực hiện insert
                    else
                    {
                        try
                        {
                            _iqcService.InsertLogs(productionId, lineId, "N/A", boxId, modelID, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), "N/A");

                            if (!_iqcService.CheckResultExits(txtProductID.Text, operationId))
                            {
                                _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                            }
                            else
                            {
                                _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                            }
                            Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                            Ultils.CreateFileLogDirModelName(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                            logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                            gridControlData.Refresh();
                            gridControlData.DataSource = logs;
                            lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                            SetSuccessStatus("OK", string.Format("Thêm thành công!\nPCB [{0}]", productionId));
                            ResetControls();
                        }
                        catch (Exception ex)
                        {
                            SetErrorStatus("NG", "Error Insert! \n" + ex.Message);
                            ResetControls();
                        }
                    }
                }
                else if (operationId >= 2)
                {
                    _iqcService.UpdateLogs(productionId, lineId, "N/A", boxId, modelID, null, operatorId, "N/A");
                    _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);

                    logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                    gridControlData.Refresh();
                    gridControlData.DataSource = logs;
                    lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                    SetSuccessStatus("OK", string.Format("Thành công!\nPCB [{0}] vừa được bắn lại lần {1}", productionId, operationId));
                    ResetControls();
                }
            }
            else
            {
                SetErrorStatus("NG", "Vui lòng nhập đủ thông tin!");
                txtProductID.Focus();
                txtProductID.SelectAll();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="boxId"></param>
        private void InsertLog(string boxId)
        {
            if (!string.IsNullOrEmpty(txtProductionID.Text.Trim()) ||
                !string.IsNullOrEmpty(txtMacAddress.Text.Trim()) ||
                !string.IsNullOrEmpty(txtJudge.Text.Trim()))
            {
                int    lineId      = Program.CurrentUser.LineID;
                int    operationId = Program.CurrentUser.OperationID;
                string operatorId  = Program.CurrentUser.OperatorCode;
                bool   judge       = txtJudge.Text.Trim() == "1";

                if (operationId == 1)
                {
                    var logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                    // Nếu Box có dữ liệu của PCB
                    if (logs.Any())
                    {
                        var log = logs.FirstOrDefault(l => l.ProductionID == txtProductionID.Text);
                        // Nếu PCB mới bắn vào chưa có trong Box
                        if (log == null)
                        {
                            if (!CheckProductionId(txtProductionID.Text, lblCurentModel.Text, lblSerialNo.Text))
                            {
                                SetErrorStatus(true, "NG", $"Error {lblCurentModel.Text} !\nPCB [{txtProductionID.Text}]\nnày khác với các PCB trong Box [{boxId}].\nVui lòng kiểm tra lại!");
                                txtProductionID.SelectAll();
                                Ultils.EditTextErrorNoMessage(txtProductionID);
                                txtJudge.ResetText();
                                txtMacAddress.ResetText();
                                txtBoxID.ResetText();
                            }
                            else
                            {
                                string tmp           = lblQuantityModel.Text.Replace("/", "");
                                int    countPcbInBox = int.Parse(lblCountPCB.Text);
                                int    quantity      = int.Parse(tmp);

                                if (countPcbInBox == quantity)
                                {
                                    SetErrorStatus(true, "OK", "Thùng đã đủ số lượng, vui lòng kiểm tra lại!");
                                    ResetControls();
                                }
                                else
                                {
                                    try
                                    {
                                        _iqcService.InsertLogs(txtProductionID.Text, lineId, txtMacAddress.Text, boxId, null, null, 1, operatorId);

                                        if (!_iqcService.CheckResultExits(txtProductionID.Text, operationId))
                                        {
                                            _iqcService.InsertResult(txtProductionID.Text, operationId, judge, operatorId);
                                        }
                                        else
                                        {
                                            _iqcService.UpdateResult(txtProductionID.Text, operationId, judge, operatorId);
                                        }
                                        var refeshData = _iqcService.GetLogs(boxId).ToList();
                                        gridControlData.Refresh();
                                        gridControlData.DataSource = refeshData;
                                        lblCountPCB.Text           = refeshData.Count.ToString(CultureInfo.InvariantCulture);

                                        SetSuccessStatus(true, "PASS", string.Format("Thêm thành công!\nPCB [{0}]", txtProductionID.Text));
                                        ResetControls();
                                    }
                                    catch (Exception ex)
                                    {
                                        SetErrorStatus(true, "NG", "Error Insert! \n" + ex.Message);
                                        ResetControls();
                                    }
                                }
                            }
                        }
                        // Nếu có rồi thì thống báo lỗi
                        else
                        {
                            SetErrorStatus(true, "NG", $"PCB [{txtProductionID.Text}] này đã có trong Box rồi.\nVui lòng kiểm tra lại");
                            ResetControls();
                            var refeshData = _oqcService.GetLogsByBoxId(boxId);
                            gridControlData.Refresh();
                            gridControlData.DataSource = refeshData;
                        }
                    }
                    // Nếu Box chưa có dữ liệu gì, thực hiện insert
                    else
                    {
                        try
                        {
                            _iqcService.InsertLogs(txtProductionID.Text, lineId, txtMacAddress.Text, boxId, null, null, 1, operatorId);

                            if (!_iqcService.CheckResultExits(txtProductionID.Text, operationId))
                            {
                                _iqcService.InsertResult(txtProductionID.Text, operationId, judge, operatorId);
                            }
                            else
                            {
                                _iqcService.UpdateResult(txtProductionID.Text, operationId, judge, operatorId);
                            }
                            var refeshData = _iqcService.GetLogs(boxId).ToList();
                            gridControlData.Refresh();
                            gridControlData.DataSource = refeshData;
                            lblCountPCB.Text           = refeshData.Count.ToString(CultureInfo.InvariantCulture);

                            SetSuccessStatus(true, "PASS", string.Format("Thêm thành công!\nPCB [{0}]", txtProductionID.Text));
                            ResetControls();
                        }
                        catch (Exception ex)
                        {
                            SetErrorStatus(true, "NG", "Error Insert! \n" + ex.Message);
                            ResetControls();
                        }
                    }
                }
                else if (operationId >= 2)
                {
                    _iqcService.UpdateLogs(txtProductionID.Text, lineId, txtMacAddress.Text, boxId, null, null, 1, operatorId);
                    _iqcService.InsertResult(txtProductionID.Text, operationId, judge, operatorId);

                    var refeshData = _iqcService.GetLogs(boxId).ToList();
                    gridControlData.Refresh();
                    gridControlData.DataSource = refeshData;
                    lblCountPCB.Text           = refeshData.Count.ToString(CultureInfo.InvariantCulture);

                    SetSuccessStatus(true, "PASS", string.Format("Thành công!\nPCB [{0}] vừa được bắn lại lần {1}", txtProductionID.Text, operationId));
                    ResetControls();
                }
            }
            else
            {
                SetErrorStatus(true, "NG", "Vui lòng nhập đủ thông tin!");
                txtProductionID.Focus();
            }
        }
Esempio n. 4
0
        private void SearchPCB(string searchKey)
        {
            splashScreenManager2.ShowWaitForm();
            if (string.IsNullOrEmpty(searchKey))
            {
                splashScreenManager2.CloseWaitForm();
                Ultils.TextControlNotNull(txtSearchPCB, "Nhập vào từ khóa cần tìm!");
                txtSearchPCB.SelectAll();
            }
            else
            {
                if (comboBoxEditSearchByKey.EditValue.Equals("Production ID"))
                {
                    var logs = _oqcService.GetLogsById(searchKey);
                    var list = new List <tbl_test_log>();
                    if (logs != null)
                    {
                        list.Add(logs);
                        gridControlData.DataSource = list;
                        btnDelete.Enabled          = true;
                        splashScreenManager2.CloseWaitForm();
                    }
                    else
                    {
                        splashScreenManager2.CloseWaitForm();
                        MessageBoxHelper.ShowMessageBoxWaring($"No results width ID:[{searchKey}]");
                        txtSearchPCB.SelectAll();
                        txtSearchPCB.Focus();
                    }
                }
                else if (comboBoxEditSearchByKey.EditValue.Equals("Box ID"))
                {
                    string strLength = txtSearchPCB.Text;
                    if (strLength.Length >= 3)
                    {
                        if (strLength.Substring(0, 3).ToUpper() != "F00")
                        {
                            splashScreenManager2.CloseWaitForm();
                            Ultils.EditTextErrorMessage(txtSearchPCB, "BOX ID phải bắt đầu bằng F00");
                            txtSearchPCB.SelectAll();
                        }
                        else
                        {
                            var logs = _oqcService.GetLogsByBoxId(searchKey).ToList();

                            if (logs.Any())
                            {
                                gridControlData.DataSource = logs;
                                btnDelete.Enabled          = true;
                                splashScreenManager2.CloseWaitForm();
                            }
                            else
                            {
                                splashScreenManager2.CloseWaitForm();
                                MessageBoxHelper.ShowMessageBoxWaring($"Không tìm thấy PCB nào trong Box [{searchKey}]");
                                txtSearchPCB.SelectAll();
                                txtSearchPCB.Focus();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        private void txtBoxID_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)
            {
                if (string.IsNullOrEmpty(txtBoxID.Text))
                {
                    Ultils.TextControlNotNull(txtBoxID, "Box");
                }
                else
                {
                    string strBoxId = txtBoxID.Text;
                    bool   judge    = txtJudge.Text.Trim() == "1";
                    if (strBoxId.Length >= 3)
                    {
                        if (strBoxId.Substring(0, 3).ToUpper() != "F00")
                        {
                            Ultils.EditTextErrorMessage(txtBoxID, "BOX ID phải bắt đầu bằng F00");
                            txtBoxID.SelectAll();
                        }
                        else
                        {
                            var currentBox = _oqcService.CheckBoxIdExits(txtBoxID.Text.Trim());
                            if (currentBox != null)
                            {
                                //var production = _oqcService.GetLogByProductionId(txtProductionID.Text);
                                if (_log.BoxID == txtBoxID.Text.Trim())
                                {
                                    string tmp           = lblQuantityModel.Text.Replace("/", "");
                                    int    countPcbInBox = int.Parse(lblCountPCB.Text);
                                    int    quantity      = int.Parse(tmp);

                                    //if (countPcbInBox == quantity)
                                    //{
                                    //    SetErrorStatus(true, "OK", "Thùng đã được kiểm tra xong. Vui lòng\nkiểm tra thùng khác!");
                                    //    txtProductionID.Focus();
                                    //    ResetControls();
                                    //}
                                    //else
                                    //{
                                    try
                                    {
                                        _oqcService.UpdateOQCCheck(_log, Program.CurrentUser.OperatorCode);
                                        if (txtJudge.Text.Trim() == "0")
                                        {
                                            _iqcService.UpdateResult(_log.ProductionID, Program.CurrentUser.OperationID, judge, Program.CurrentUser.OperatorCode);
                                        }
                                        var logs = _oqcService.GetLogsByBoxId(txtBoxID.Text.Trim()).Where(l => l.QA_Check);
                                        gridControlData.DataSource = logs;
                                        lblCountPCB.Text           = logs.Count().ToString();
                                        SetSuccessStatus(true, "OK", "Thành công!");
                                        ResetControls();
                                    }
                                    catch (Exception ex)
                                    {
                                        SetErrorStatus(true, "NG", $"Error update!\n {ex.Message}");
                                        txtBoxID.SelectAll();
                                        Ultils.EditTextErrorNoMessage(txtBoxID);
                                    }
                                    //}
                                }
                                else
                                {
                                    SetErrorStatus(true, "NG",
                                                   $"PCB [{txtProductionID.Text}] không nằm\ntrong Box: {txtBoxID.Text} này.\n" +
                                                   "Vui lòng kiểm tra lại.");
                                    txtBoxID.SelectAll();
                                    Ultils.EditTextErrorNoMessage(txtBoxID);
                                }
                            }
                            else
                            {
                                SetErrorStatus(true, "NG",
                                               $"Box [{txtBoxID.Text}] không tồn tại trong hệ thống.\n" +
                                               "Vui lòng kiểm tra lại.");
                                txtBoxID.SelectAll();
                                Ultils.EditTextErrorNoMessage(txtBoxID);
                            }
                        }
                    }
                    else
                    {
                        Ultils.EditTextErrorMessage(txtBoxID, "BOX ID không đúng!");
                        txtBoxID.SelectAll();
                    }
                }
            }
        }