Example #1
0
        /// <summary>
        /// Lưu dữ liệu
        /// </summary>
        private void SaveData()
        {
            splashScreenManagerSaveData.ShowWaitForm();
            foreach (var log in _shippings)
            {
                _iqcService.InsertShipping(txtOperatorCode.Text, gridLookUpEditModelID.EditValue.ToString(), txtWorkingOrder.Text, 1, txtPO.Text, txtBoxID.Text, log.ProductID, log.MacAddress);
            }
            // cập nhật lại số lượng Remains
            _iqcService.UpdateRemainsForPo(_currentPo.PO_NO, _currentPo.ModelID, int.Parse(lblRemains.Text));

            _shippings = new List <Shipping>();
            gridControlData.DataSource = null;
            EnableTextControls(true);
            VisibleControlAddPCB(false);
            EnabledButonSave(false);
            ResetControls();
            splashScreenManagerSaveData.CloseWaitForm();
        }
Example #2
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;
            }
        }