コード例 #1
0
        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();
        }
コード例 #2
0
        private void bwSave_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (controlAccount == null)
            {
                MessageBox.Show(string.Format("Wrong Security Code !"), "Infor", MessageBoxButton.OK, MessageBoxImage.Error);
                txtPassword.Focus();
                txtPassword.SelectAll();
                btnSave.IsEnabled = true;

                return;
            }

            //Create Log
            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}";

            LogHelper.CreateLog(string.Format(logBodyOldCarton, storingPerBarcode.ProductNo, storingPerBarcode.SizeNo, storingPerBarcode.CartonNo, storingPerBarcode.GrossWeight, storingPerBarcode.ActualWeight, storingPerBarcode.DifferencePercent, controlAccount.FullName));

            // Update DB
            StoringModel reWeighModel = new StoringModel();

            reWeighModel = storingPerBarcode;
            reWeighModel.ActualWeight = newWeight;

            if (StoringController.Insert(reWeighModel) == true)
            {
                Thread.Sleep(1500);
                MessageBox.Show(string.Format("Saved !"), "Infor", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show(string.Format("An Error Occur!"), "Infor", MessageBoxButton.OK, MessageBoxImage.Error);
            }


            this.Cursor       = null;
            btnSave.IsEnabled = true;

            txtProductNo.Text = "";
            txtSizeNo.Text    = "";
            txtCartonNo.Text  = "";

            txtNewWeight.Text = "0";
            txtOldWeight.Text = "0";

            txtBarcode.Focus();
            txtBarcode.SelectAll();
            btnBarcode.IsEnabled = true;
            btnBarcode.IsDefault = true;

            txtPassword.Password  = "";
            stkConfirm.Visibility = Visibility.Collapsed;
        }
コード例 #3
0
        private void InsertCarton()
        {
            double actualWeightFirstCarton = 0;

            Double.TryParse(tblActualWeight.Tag.ToString(), out actualWeightFirstCarton);
            var modelInsert = new StoringModel()
            {
                ProductNo         = productNo,
                Barcode           = barcode,
                SizeNo            = sizeNo,
                CartonNo          = cartonNo,
                ActualWeight      = actualWeightFirstCarton,
                GrossWeight       = 0,
                IsComplete        = completeCarton,
                DifferencePercent = 0,
                IsPass            = true,
                IssuesId          = 0,
                WorkerId          = account.UserName,
            };

            StoringController.Insert(modelInsert);
            if (completeCarton == true)
            {
                DefaultStatus();
            }
            else
            {
                IncompleteStatus();
            }

            // Highlight
            tblResult.Dispatcher.Invoke(new Action(() =>
            {
                tblResult.Foreground = Brushes.White;
                tblResult.Text       = string.Format("{0} - Add", modelInsert.CartonNo);
            }));
            brResult.Dispatcher.Invoke(new Action(() =>
            {
                brResult.Background = Brushes.Green;
            }));

            StoringCurrent insertCurrent = new StoringCurrent();

            insertCurrent.StoringModel = modelInsert;
            storingCurrentList.Add(insertCurrent);
        }
コード例 #4
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();
        }
コード例 #5
0
        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);
            }
        }