Esempio n. 1
0
        private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            storingList   = StoringController.SelectIsNotLoad();
            outputingList = OutputingController.SelectIsNotLoad();

            if (outputingList.Count > 0)
            {
                foreach (var outputInDB in outputingList)
                {
                    OutputingCurrent current = new OutputingCurrent();
                    current.Outputing = outputInDB;
                    outputingCurrentList.Add(current);
                }
            }
            else
            {
                OutputingModel outputingDefault = new OutputingModel()
                {
                    ProductNo         = "Default",
                    Barcode           = "Default",
                    SizeNo            = "Default",
                    CartonNo          = 0,
                    GrossWeight       = 0,
                    ActualWeight      = 0,
                    DifferencePercent = 0,
                    IsPass            = false,
                    WorkerId          = "Default",
                    IssuesId          = 0
                };

                OutputingCurrent currentDefault = new OutputingCurrent();
                currentDefault.Outputing = outputingDefault;
                outputingCurrentList.Add(currentDefault);
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            // Input
            double actualWeight = 0;
            int    cartonNo     = 0;

            Double.TryParse(txtActualWeight.Text.ToString(), out actualWeight);
            Int32.TryParse(txtCartonNo.Text.ToString(), out cartonNo);
            string sizeNo = txtSizeNo.Text.ToString();

            // Output

            if (mode == 1)
            {
                var overrideOutputCarton = receiveOutputModel;
                overrideOutputCarton.ActualWeight      = actualWeight;
                overrideOutputCarton.CartonNo          = cartonNo;
                overrideOutputCarton.SizeNo            = sizeNo;
                overrideOutputCarton.IsPass            = true;
                overrideOutputCarton.GrossWeight       = 0;
                overrideOutputCarton.DifferencePercent = 0;
                overrideOutputCarton.IssuesId          = 0;
                if (OutputingController.Insert(overrideOutputCarton) == false)
                {
                    MessageBox.Show("Error occurred!", "Infor", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                outputingCurrent = overrideOutputCarton;
            }

            if (mode == 2)
            {
                var overrideStoringCarton = receiveStoringModel;

                overrideStoringCarton.ActualWeight      = actualWeight;
                overrideStoringCarton.CartonNo          = cartonNo;
                overrideStoringCarton.SizeNo            = sizeNo;
                overrideStoringCarton.IsPass            = true;
                overrideStoringCarton.GrossWeight       = 0;
                overrideStoringCarton.DifferencePercent = 0;
                overrideStoringCarton.IssuesId          = 0;
                if (StoringController.Insert(overrideStoringCarton) == false)
                {
                    MessageBox.Show("Error occurred!", "Infor", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                storingCurrent = overrideStoringCarton;
            }
            MessageBox.Show("Thùng Đã Được Pass!\nPASSED!", "Infor", MessageBoxButton.OK, MessageBoxImage.Information);
            btnSave.IsEnabled           = false;
            groupUpdateCarton.IsEnabled = false;

            Thread.Sleep(2000);
            this.Close();
        }
Esempio n. 3
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. 4
0
        private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            storingWeighedList = StoringController.SelectIsNotLoad();
            outputtedList      = OutputingController.SelectIsNotLoad();

            int storingIndex = 1;

            foreach (StoringModel storing in storingWeighedList)
            {
                var current = new StoringCurrent()
                {
                    StoringModel = storing,
                };
                storingCurrentList.Add(current);

                Dispatcher.Invoke(new Action(() =>
                {
                    tempTitle  = string.Format("Downloading Carton: {0} / {1}", storingIndex, storingWeighedList.Count);
                    this.Title = tempTitle;
                }));

                storingIndex++;
            }

            // If this carton was outputted, allow reweigh
            if (outputtedList.Count > 0)
            {
                var barcodeOutputedList = outputtedList.Select(s => s.Barcode).Distinct().ToList();
                storingCurrentList.RemoveAll(r => barcodeOutputedList.Contains(r.StoringModel.Barcode));
            }

            var POScannedList = storingWeighedList.Where(w => w.Barcode.Contains(",") == false).Select(s => s.ProductNo).Distinct().ToList();

            // Create barcode temp
            int poCreatedIndex = 1;

            foreach (var PO in POScannedList)
            {
                var cartonNumberingDetail_POScannedList = CartonNumberingDetailController.Select(PO);
                // If total carton current in po equals total carton in cartonnumberingdetail. PO will be ignore.
                if (storingWeighedList.Where(w => w.ProductNo == PO).Count() == cartonNumberingDetail_POList.Count())
                {
                    poCreatedIndex++;
                    continue;
                }
                var firstStoringWeighedList = storingWeighedList.Where(w => w.ProductNo == PO).FirstOrDefault();
                int serialCarton_0          = ConvertBarcodeToSerial(firstStoringWeighedList.Barcode) - firstStoringWeighedList.CartonNo;
                int cartonIndex             = 1;
                foreach (var cartonDetail in cartonNumberingDetail_POScannedList)
                {
                    var storingTemp = new StoringTemp()
                    {
                        SizeNo    = cartonDetail.SizeNo,
                        ProductNo = cartonDetail.ProductNo,
                        CartonNo  = cartonDetail.CartonNo,
                        SerialNo  = serialCarton_0 + cartonDetail.CartonNo,
                    };
                    storingTempList.Add(storingTemp);

                    Dispatcher.Invoke(new Action(() =>
                    {
                        tempTitle = String.Format("Creating Barcode: {0} of {1} for {2} / {3} PO#",
                                                  cartonIndex,
                                                  cartonNumberingDetail_POScannedList.Select(s => s.CartonNo).Max(),
                                                  poCreatedIndex,
                                                  POScannedList.Count);
                        this.Title = tempTitle;
                    }));

                    cartonIndex++;
                }
                poCreatedIndex++;
            }
        }
Esempio n. 5
0
 //string gtnPONo = "", totalCartonInputedString = "", totalWeightString = "";
 private void bwReport_DoWork(object sender, DoWorkEventArgs e)
 {
     outputingPerPOList = OutputingController.SelectPerPO(productNo).OrderBy(o => o.CartonNo).ToList();
     storingPerPOList   = StoringController.SelectPerPO(productNo).OrderBy(o => o.CartonNo).ToList();
     accountList        = AccountController.Get();
 }
        private void bwInsertAndSendEmail_DoWork(object sender, DoWorkEventArgs e)
        {
            // Send Email
            mailAddressReceiveMessageList = MailAddressReceiveMessageController.Get();
            foreach (MailAddressReceiveMessageModel mailAddressReceiveMessage in mailAddressReceiveMessageList)
            {
                MailAddress mailAddressReceive = new MailAddress(mailAddressReceiveMessage.MailAddress, mailAddressReceiveMessage.Name);
                mailMessage.To.Add(mailAddressReceive);
            }

            string reason = "";

            reason = issuesList.Where(w => w.IssuesId == issuesId).Select(s => s.IssuesName).FirstOrDefault().ToString();
            string mailBody = "";

            // OUTPUT PROMBLEM
            if (receiveOutputModel != null)
            {
                mode = 1;
                receiveOutputModel.IssuesId = issuesId;
                // InsertDB
                if (OutputingController.Insert(receiveOutputModel) == false)
                {
                    MessageBox.Show("Insert Error!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                //CreatedLog
                string logBodyOldCarton = "Production No.: {0}, Size No.: {1}, Carton No.: {2}, Gross Weight: {3}kg, Actual Weight: {4}kg, Difference Percent: {5}%, Created By: {6}, Reason :{7}, Location {8}";
                LogHelper.CreateOutputLog(string.Format(logBodyOldCarton, receiveOutputModel.ProductNo, receiveOutputModel.SizeNo, receiveOutputModel.CartonNo, receiveOutputModel.GrossWeight, receiveOutputModel.ActualWeight, receiveOutputModel.DifferencePercent, findControlAccountModel.FullName, reason, electricScaleProfile.Location));

                // Created Email
                mailBody = @"<html><table border='1' style='width:100%'>
                                    <tr><td>ProductNo</td><td>SizeNo</td><td>CartonNo</td><td>Gross Weight</td><td>Actual Weight</td><td>Difference Percent</td><td>Check By</td><td>Location</td><td>Reason</td></tr>
                                    <tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3} kg</td><td>{4} kg</td><td>{5} %</td><td>{6}</td><td>{7}</td><td>{8}</td></tr>
                                    </table></html>";
                //string logBody = "Production No.:{0} Size No.:{1} Carton No.:{2} Gross Weight:{3}kg Actual Weight: {4}kg Difference Percent:{5}% Check by:{6} Reason:{7}";
                mailMessage.Subject = string.Format("STORING SYSTEM - OUTPUT PROMBLEM");
                mailMessage.Body    = string.Format(mailBody, receiveOutputModel.ProductNo, receiveOutputModel.SizeNo, receiveOutputModel.CartonNo, receiveOutputModel.GrossWeight, receiveOutputModel.ActualWeight, receiveOutputModel.DifferencePercent, findControlAccountModel.FullName, electricScaleProfile.Location, reason);

                outputingCurrent = receiveOutputModel;
            }

            // INPUT PROBLEM
            if (receiveStoringModel != null)
            {
                mode = 2;

                receiveStoringModel.IssuesId = issuesId;
                if (StoringController.Insert(receiveStoringModel) == false)
                {
                    MessageBox.Show("Insert Error!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (issuesType == IssuesType.Issues.IssuesFirstCartonOfSizeOfPO)
                {
                    mailBody         = @"<html><table border='1' style='width:100%'>
                                    <tr><td>ProductNo</td><td>SizeNo</td><td>CartonNo</td><td>Check By</td><td>Location</td><td>Reason</td></tr>
                                    <tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>
                                    </table></html>";
                    mailMessage.Body = string.Format(mailBody, receiveStoringModel.ProductNo, receiveStoringModel.SizeNo, receiveStoringModel.CartonNo, findControlAccountModel.FullName, electricScaleProfile.Location, reason);
                    //string logBody = "Production No.:{0} Size No.:{1} Carton No.:{2} Gross Weight:{3}kg Actual Weight: {4}kg Difference Percent:{5}% Check by:{6} Reason:{7}";
                    mailMessage.Subject = string.Format("STORING SYSTEM - INPUT PROBLEM - FIRST CARTON");
                }

                if (issuesType == IssuesType.Issues.IssuesCompareWeight)
                {
                    mailBody = @"<html><table border='1' style='width:100%'>
                                    <tr><td>ProductNo</td><td>SizeNo</td><td>CartonNo</td><td>Gross Weight</td><td>Actual Weight</td><td>Difference Percent</td><td>Check By</td><td>Location</td><td>Reason</td></tr>
                                    <tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3} kg</td><td>{4} kg</td><td>{5} %</td><td>{6}</td><td>{7}</td><td>{8}</td></tr>
                                    </table></html>";
                    //string logBody = "Production No.:{0} Size No.:{1} Carton No.:{2} Gross Weight:{3}kg Actual Weight: {4}kg Difference Percent:{5}% Check by:{6} Reason:{7}";
                    mailMessage.Subject = string.Format("STORING SYSTEM - INPUT PROMBLEM - WEIGHT");
                    mailMessage.Body    = string.Format(mailBody, receiveStoringModel.ProductNo, receiveStoringModel.SizeNo, receiveStoringModel.CartonNo, receiveStoringModel.GrossWeight, receiveStoringModel.ActualWeight, receiveStoringModel.DifferencePercent, findControlAccountModel.FullName, electricScaleProfile.Location, reason);

                    string logBodyOldCarton = "Production No.: {0}, Size No.: {1}, Carton No.: {2}, Gross Weight: {3}kg, Actual Weight: {4}kg, Difference Percent: {5}%, Created By: {6}, Reason :{7}, Location {8}";
                    LogHelper.CreateIssuesLog(string.Format(logBodyOldCarton, receiveStoringModel.ProductNo, receiveStoringModel.SizeNo, receiveStoringModel.CartonNo, receiveStoringModel.GrossWeight, receiveStoringModel.ActualWeight, receiveStoringModel.DifferencePercent, findControlAccountModel.FullName, reason, electricScaleProfile.Location));
                }
                storingCurrent = receiveStoringModel;
            }

            if (flagSending == false && mailMessage.To.Count > 0)
            {
                if (CheckInternetConnection.CheckConnection() == false)
                {
                    MessageBox.Show("Không có kết nối Internet!\nNo Internet Connection!", "Info", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
                smtpClient.SendAsync(mailMessage, mailMessage);
                flagSending = true;
                MessageBox.Show("Đã gửi Email!\nSent Email!", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }