Esempio n. 1
0
        private void CompareWeight()
        {
            var currentCarton = new StoringModel()
            {
                ProductNo  = productNo,
                Barcode    = barcode,
                SizeNo     = sizeNo,
                CartonNo   = cartonNo,
                WorkerId   = account.UserName,
                IsComplete = true,
            };

            // get gross weight of the carton has same size with this carton.
            tblGrossWeight.Text = string.Format("{0}", firstCarton_Size_PO.ActualWeight);
            tblGrossWeight.Tag  = string.Format("{0}", firstCarton_Size_PO.ActualWeight);

            double grossWeight = 0;

            Double.TryParse(tblGrossWeight.Tag.ToString(), out grossWeight);
            double actualWeight = 0;

            Double.TryParse(tblActualWeight.Tag.ToString(), out actualWeight);

            if (grossWeight <= 0)
            {
                grossWeight = actualWeight;
            }

            currentCarton.GrossWeight  = grossWeight;
            currentCarton.ActualWeight = actualWeight;
            double percentDifference = actualWeight / grossWeight;

            tblDifferencePercent.Dispatcher.Invoke(new Action(() =>
                                                              tblDifferencePercent.Text = string.Format("{0}", Math.Round(100 * (percentDifference - 1), 2))
                                                              ));
            currentCarton.DifferencePercent = Math.Round(100 * (percentDifference - 1), 2);

            // if carton is OK
            if (percentDifference >= LIMITED_MIN && percentDifference <= LIMITED_MAX)
            {
                tblResult.Dispatcher.Invoke(new Action(() =>
                {
                    tblResult.Foreground = Brushes.White;
                    tblResult.Text       = string.Format("{0} - Pass", currentCarton.CartonNo);
                }));
                brResult.Dispatcher.Invoke(new Action(() =>
                {
                    brResult.Background = Brushes.Green;
                }));
                currentCarton.IsPass   = true;
                currentCarton.IssuesId = 0;

                StoringController.Insert(currentCarton);

                StoringCurrent storingCurrentModel = new StoringCurrent();
                storingCurrentModel.StoringModel = currentCarton;
                storingCurrentList.Add(storingCurrentModel);
            }
            // If current carton has problem (the weight is lower or higher than firstcarton)
            else
            {
                // Show highlight.
                if (percentDifference < LIMITED_MIN)
                {
                    tblResult.Dispatcher.Invoke(new Action(() =>
                    {
                        tblResult.Foreground = Brushes.Black;
                        tblResult.Text       = string.Format("{0} - Low", currentCarton.CartonNo);
                    }));
                    brResult.Dispatcher.Invoke(new Action(() =>
                    {
                        brResult.Background = Brushes.Yellow;
                    }));
                }
                else
                {
                    tblResult.Dispatcher.Invoke(new Action(() =>
                    {
                        tblResult.Foreground = Brushes.White;
                        tblResult.Text       = string.Format("{0} - Hi", currentCarton.CartonNo);
                    }));
                    brResult.Dispatcher.Invoke(new Action(() =>
                    {
                        brResult.Background = Brushes.Red;
                    }));
                }
                // tranfer this model to check problem, after that insert to db
                currentCarton.IsPass = false;
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    CheckIssuesWindow window = new CheckIssuesWindow(null, currentCarton, IssuesType.Issues.IssuesCompareWeight, factory);
                    window.ShowDialog();

                    StoringModel storingRecieve = window.storingCurrent;

                    StoringCurrent storingCurrent = new StoringCurrent();
                    storingCurrent.StoringModel   = storingRecieve;

                    storingCurrentList.Add(storingCurrent);
                }));
            }
            DefaultStatus();
        }
Esempio n. 2
0
        private void CompareWeight()
        {
            Dispatcher.Invoke(new Action(() =>
            {
                tblGrossWeight.Text = string.Format("{0}", storingPerBarcode.ActualWeight);
                tblGrossWeight.Tag  = string.Format("{0}", storingPerBarcode.ActualWeight);
            }));

            double grossWeight  = 0;
            double actualWeight = 0;

            Dispatcher.Invoke(new Action(() =>
            {
                Double.TryParse(tblGrossWeight.Tag.ToString(), out grossWeight);
                Double.TryParse(tblActualWeight.Tag.ToString(), out actualWeight);
            }));

            double percentDiffence = actualWeight / grossWeight;

            tblDifferencePercent.Dispatcher.Invoke(new Action(() => tblDifferencePercent.Text = string.Format("{0}", Math.Round(100 * (percentDiffence - 1), 2))));

            outputingInsert.ProductNo    = storingPerBarcode.ProductNo;
            outputingInsert.Barcode      = storingPerBarcode.Barcode;
            outputingInsert.CartonNo     = storingPerBarcode.CartonNo;
            outputingInsert.SizeNo       = storingPerBarcode.SizeNo;
            outputingInsert.GrossWeight  = grossWeight;
            outputingInsert.ActualWeight = actualWeight;
            outputingInsert.WorkerId     = account.UserName;


            outputingInsert.DifferencePercent = Math.Round(100 * (percentDiffence - 1), 2);
            // PASS
            if (percentDiffence >= LIMITED_MIN && percentDiffence <= LIMITED_MAX)
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    tblResult.Foreground = Brushes.White;
                    tblResult.Text       = string.Format("{0} - Pass", outputingInsert.CartonNo);
                    brResult.Background  = Brushes.Green;
                }));
                outputingInsert.IsPass   = true;
                outputingInsert.IssuesId = 0;

                if (OutputingController.Insert(outputingInsert) == false)
                {
                    MessageBox.Show("Insert Error!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                OutputingCurrent outputCurrentInsert = new OutputingCurrent();
                outputCurrentInsert.Outputing = outputingInsert;
                outputingCurrentList.Add(outputCurrentInsert);
            }
            else
            {
                outputingInsert.IsPass = false;
                //LOW
                if (percentDiffence < LIMITED_MIN)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        tblResult.Foreground = Brushes.Black;
                        tblResult.Text       = string.Format("{0} - Low", outputingInsert.CartonNo);
                        brResult.Background  = Brushes.Yellow;
                    }));
                }
                else
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        tblResult.Foreground = Brushes.White;
                        tblResult.Text       = string.Format("{0} - Hi", outputingInsert.CartonNo);
                        brResult.Background  = Brushes.Red;
                    }));
                }
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    CheckIssuesWindow window = new CheckIssuesWindow(outputingInsert, null, IssuesType.Issues.IssuesCompareWeight, factory);
                    window.ShowDialog();

                    OutputingModel outputRecieve          = window.outputingCurrent;
                    OutputingCurrent outputCurrentRecieve = new OutputingCurrent();
                    outputCurrentRecieve.Outputing        = outputRecieve;
                    outputingCurrentList.Add(outputCurrentRecieve);
                }));
            }
            Dispatcher.Invoke(new Action(() =>
            {
                txtBarCodeComplete.Focus();
                txtBarCodeComplete.SelectAll();
                btnBarcodeComplete.IsEnabled = true;
                btnBarcodeComplete.IsDefault = true;
            }));
        }
Esempio n. 3
0
        private void BarcodeProcess()
        {
            serialPortReceive.Close();
            firstCarton_Size_PO = new StoringModel();
            ComPortHelper.WriteToPort(portWrite, "DIO[0]:VALUE=0\r\n");
            ComPortHelper.WriteToPort(portWrite, "DIO[3]:VALUE=0\r\n");
            if (double.TryParse(txtMinActualWeight.Text, out minActualWeight) == false)
            {
                txtMinActualWeight.BorderBrush = Brushes.Red;
            }
            else
            {
                txtMinActualWeight.ClearValue(TextBox.BorderBrushProperty);
            }

            if (double.TryParse(txtMaxActualWeight.Text, out maxActualWeight) == false)
            {
                txtMaxActualWeight.BorderBrush = Brushes.Red;
            }

            else
            {
                txtMaxActualWeight.ClearValue(TextBox.BorderBrushProperty);
            }

            tblProductNo.Text = productNo;
            tblSizeItemQuantityCartonNo.Text = String.Format("Size: {0}\nCartonNo: {1} of {2}", sizeNo, cartonNo, GetMaxCarton(productNo));
            // check first carton of size of productno
            if (completeCarton == true)
            {
                var storingCurrent_POList = storingCurrentList.Where(w => w.StoringModel.ProductNo == productNo).Select(s => s.StoringModel).ToList();
                firstCarton_Size_PO = storingCurrent_POList.Where(w => w.SizeNo == sizeNo && w.IsPass == true && w.IsComplete == true).FirstOrDefault();
                var firstCartonProblem = new StoringModel()
                {
                    ProductNo         = productNo,
                    Barcode           = barcode,
                    SizeNo            = sizeNo,
                    CartonNo          = cartonNo,
                    WorkerId          = account.UserName,
                    ActualWeight      = 0,
                    GrossWeight       = 0,
                    DifferencePercent = 0,
                    IsComplete        = true
                };
                if (firstCarton_Size_PO == null)
                {
                    MessageBoxResult result = MessageBox.Show(string.Format("Đây Là Thùng Đầu Tiên Của Size: {0} ; PO#: {1}\n\nMở Thùng Và Kiểm Tra\n- SỐ LƯỢNG GIÀY\n- SIZE.\n\nClick OK để CÂN và tiếp tục, Nếu có vấn đề Click Cancel! ", sizeNo, productNo),
                                                              "Kiểm tra thùng đầu tiên của Size",
                                                              MessageBoxButton.OKCancel,
                                                              MessageBoxImage.Warning);
                    if (result == MessageBoxResult.OK)
                    {
                        serialPortReceive.Open();
                        insertFirstCarton_Size_PO = true;
                    }
                    if (result == MessageBoxResult.Cancel)
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            CheckIssuesWindow window = new CheckIssuesWindow(null, firstCartonProblem, IssuesType.Issues.IssuesFirstCartonOfSizeOfPO, factory);
                            window.ShowDialog();
                            StoringModel storingRecieve   = window.storingCurrent;
                            StoringCurrent storingCurrent = new StoringCurrent();
                            storingCurrent.StoringModel   = storingRecieve;
                            storingCurrentList.Add(storingCurrent);
                        }));
                    }
                }
                else
                {
                    serialPortReceive.Open();
                    compareCartonSameSize = true;
                }
            }
            else
            {
                serialPortReceive.Open();
                insertIncompleteCarton = true;
            }

            popInputSubPO.IsOpen         = false;
            btnBarcodeComplete.IsEnabled = false;
            btnCartonNo.IsEnabled        = false;
        }