Example #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;
            }
        }
Example #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            _shippings = new List <Shipping>();
            splashScreenManager1.ShowWaitForm();
            if (string.IsNullOrEmpty(txtSearch.Text))
            {
                splashScreenManager1.CloseWaitForm();
                Ultils.TextControlNotNull(txtSearch, "Nhập vào từ khóa cần tìm!");
                txtSearch.SelectAll();
            }
            else
            {
                if (comboBoxEditSearchByKey.EditValue.Equals("Production ID"))
                {
                    var shipping = _iqcService.GetShippingById(txtSearch.Text);
                    if (shipping != null)
                    {
                        _shippings.Add(shipping);
                        gridControlData.DataSource = _shippings;
                        splashScreenManager1.CloseWaitForm();
                        txtSearch.SelectAll();
                        txtSearch.Focus();
                        btnExports.Enabled = true;
                    }
                    else
                    {
                        splashScreenManager1.CloseWaitForm();
                        MessageBoxHelper.ShowMessageBoxWaring($"Không tìm thấy PCB nào với Production ID [{txtSearch.Text}]");
                        txtSearch.SelectAll();
                        txtSearch.Focus();
                    }
                }
                else if (comboBoxEditSearchByKey.EditValue.Equals("PO NO"))
                {
                    string strLength = txtSearch.Text;
                    if (strLength.Length >= 3)
                    {
                        if (strLength.Substring(0, 3).ToUpper() != "3N3")
                        {
                            splashScreenManager1.CloseWaitForm();
                            Ultils.EditTextErrorMessage(txtSearch, "PO phải bắt đầu bằng 3N3");
                            txtSearch.SelectAll();
                        }
                        else
                        {
                            _shippings = _iqcService.GetShippingsByPo(txtSearch.Text).ToList();

                            if (_shippings.Any())
                            {
                                gridControlData.DataSource = _shippings;
                                splashScreenManager1.CloseWaitForm();
                                txtSearch.SelectAll();
                                txtSearch.Focus();
                                btnExports.Enabled = true;
                            }
                            else
                            {
                                splashScreenManager1.CloseWaitForm();
                                MessageBoxHelper.ShowMessageBoxWaring($"Không tìm thấy PCB nào với PO NO [{txtSearch.Text}]");
                                txtSearch.SelectAll();
                                txtSearch.Focus();
                            }
                        }
                    }
                }
                else if (comboBoxEditSearchByKey.EditValue.Equals("Box ID"))
                {
                    string strLength = txtSearch.Text;
                    if (strLength.Length >= 3)
                    {
                        if (strLength.Substring(0, 3).ToUpper() != "F00")
                        {
                            splashScreenManager1.CloseWaitForm();
                            Ultils.EditTextErrorMessage(txtSearch, "BOX ID phải bắt đầu bằng F00");
                            txtSearch.SelectAll();
                        }
                        else
                        {
                            _shippings = _iqcService.GetShippingsByBoxId(txtSearch.Text).ToList();

                            if (_shippings.Any())
                            {
                                gridControlData.DataSource = _shippings;
                                splashScreenManager1.CloseWaitForm();
                                txtSearch.SelectAll();
                                txtSearch.Focus();
                                btnDelBox.Enabled  = true;
                                btnExports.Enabled = true;
                            }
                            else
                            {
                                splashScreenManager1.CloseWaitForm();
                                MessageBoxHelper.ShowMessageBoxWaring($"Không tìm thấy PCB nào trong Box [{txtSearch.Text}]");
                                txtSearch.SelectAll();
                                txtSearch.Focus();
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Add PCB into Box
        /// </summary>
        /// <param name="boxid"></param>
        private void AddPcbToBox(string boxid)
        {
            splashScreenLoadData.ShowWaitForm();
            gridControlData.DataSource = null;
            if (!string.IsNullOrEmpty(txtAddPCB.Text))
            {
                if (_iqcService.CheckPcbExitsOnBoxOrShipCurrent(txtAddPCB.Text, _shippings))
                {
                    var shippings = _iqcService.GetShippingById(txtAddPCB.Text.Trim());
                    if (shippings == null)
                    {
                        var shipping = new Shipping()
                        {
                            ID          = Guid.NewGuid(),
                            Operator    = txtOperatorCode.Text,
                            Model       = gridLookUpEditModelID.EditValue.ToString(),
                            WorkingOder = txtWorkingOrder.Text,
                            Quantity    = 1,
                            BoxID       = boxid,
                            ProductID   = txtAddPCB.Text,
                            MacAddress  = txtAddPCB.Text,
                            DateCheck   = DateTime.Now,
                        };

                        if (_currentPo.QuantityRemain <= 0)
                        {
                            MessageBox.Show(@"Không thể nhập thêm cho PO này. Remain = 0\nVui lòng lưu lại dữ liệu!", @"Error Remains!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            ResetControls();
                        }
                        else
                        {
                            _shippings.Add(shipping);
                            gridControlData.DataSource = _shippings;
                            lblCountPCB.Text           = _shippings.Count.ToString(CultureInfo.InvariantCulture);
                            lblRemains.Text            = (int.Parse(lblRemains.Text) - 1).ToString(CultureInfo.InvariantCulture);
                            EnabledButonSave(true);
                            splashScreenLoadData.CloseWaitForm();
                            txtAddPCB.Text = string.Empty;
                        }
                    }
                    else
                    {
                        gridControlData.Refresh();
                        gridControlData.DataSource = _shippings;
                        splashScreenLoadData.CloseWaitForm();
                        MessageBoxHelper.ShowMessageBoxError($"PCB {txtAddPCB.Text} đã được xuất trước đó.\n" +
                                                             $"Box: {shippings.BoxID}\nN" +
                                                             $"Ngày xuất: {shippings.DateCheck}");
                        txtAddPCB.SelectAll();
                    }
                }
                else
                {
                    gridControlData.Refresh();
                    gridControlData.DataSource = _shippings;
                    splashScreenLoadData.CloseWaitForm();
                    MessageBoxHelper.ShowMessageBoxError($"PCB {txtAddPCB.Text} đã được nhập trong Box rồi. Vui lòng kiểm tra lại!");
                    txtAddPCB.SelectAll();
                }
            }
        }