예제 #1
0
        public static bool Insert(StoringModel model)
        {
            var @ProductNo         = new SqlParameter("@ProductNo", model.ProductNo);
            var @Barcode           = new SqlParameter("@Barcode", model.Barcode);
            var @SizeNo            = new SqlParameter("@SizeNo", model.SizeNo);
            var @CartonNo          = new SqlParameter("@CartonNo", model.CartonNo);
            var @GrossWeight       = new SqlParameter("@GrossWeight", model.GrossWeight);
            var @ActualWeight      = new SqlParameter("@ActualWeight", model.ActualWeight);
            var @DifferencePercent = new SqlParameter("@DifferencePercent", model.DifferencePercent);
            var @IsPass            = new SqlParameter("@IsPass", model.IsPass);
            var @WorkerId          = new SqlParameter("@WorkerId", model.WorkerId);
            var @IssuesId          = new SqlParameter("@IssuesId", model.IssuesId);
            var @IsComplete        = new SqlParameter("@IsComplete", model.IsComplete);

            StoringSystemEntities db = new StoringSystemEntities();

            if (db.ExecuteStoreCommand("EXEC spm_InsertStoring_3 @ProductNo, @Barcode, @SizeNo, @CartonNo, @GrossWeight, @ActualWeight, @DifferencePercent, @IsPass, @WorkerId, @IssuesId, @IsComplete",
                                       @ProductNo, @Barcode, @SizeNo, @CartonNo, @GrossWeight, @ActualWeight, @DifferencePercent, @IsPass, @WorkerId, @IssuesId, @IsComplete) >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        private void bwReport_DoWork(object sender, DoWorkEventArgs e)
        {
            string productNo = e.Argument.ToString();
            List <CartonNumberingModel>       cartonNumberingList       = CartonNumberingController.Get(productNo).ToList();
            List <CartonNumberingDetailModel> cartonNumberingDetailList = CartonNumberingDetailController.Select(productNo);
            List <StoringModel> storingList = StoringController.SelectPerPO(productNo);

            DataTable dtCartonNumbering = new CartonNumberingDataSet().Tables[0];
            DataTable dtStoring         = new StoringReportDataSet().Tables[0];

            foreach (CartonNumberingModel cartonNumbering in cartonNumberingList)
            {
                DataRow drCartonNumbering = dtCartonNumbering.NewRow();
                drCartonNumbering["ProductNo"] = cartonNumbering.ProductNo;
                drCartonNumbering["SizeNo"]    = cartonNumbering.SizeNo;
                drCartonNumbering["Quantity"]  = cartonNumbering.Quantity;
                StoringModel storingPerSize = storingList.Where(p => p.SizeNo == cartonNumbering.SizeNo).FirstOrDefault();
                if (storingPerSize != null)
                {
                    drCartonNumbering["GrossWeight"]       = storingPerSize.ActualWeight;
                    drCartonNumbering["FirstCartonOfSize"] = storingPerSize.CartonNo;
                }

                dtCartonNumbering.Rows.Add(drCartonNumbering);

                List <CartonNumberingDetailModel> cartonNumberingDetail_D1 = cartonNumberingDetailList.Where(c => c.SizeNo == cartonNumbering.SizeNo).ToList();
                for (int i = 1; i <= cartonNumberingDetail_D1.Count(); i++)
                {
                    CartonNumberingDetailModel cartonNumberingDetail = cartonNumberingDetail_D1[i - 1];
                    StoringModel storing = storingList.Where(p => p.CartonNo == cartonNumberingDetail.CartonNo).FirstOrDefault();

                    DataRow drStoring = dtStoring.NewRow();
                    drStoring["ProductNo"]    = cartonNumberingDetail.CartonNo;
                    drStoring["ProductNo"]    = cartonNumbering.ProductNo;
                    drStoring["SizeNo"]       = cartonNumbering.SizeNo;
                    drStoring["NumberOf"]     = i;
                    drStoring["StoringValue"] = string.Format("{0} |", cartonNumberingDetail.CartonNo);
                    if (storing != null)
                    {
                        drStoring["StoringValue"] = string.Format("{0} | {1}", cartonNumberingDetail.CartonNo, storing.ActualWeight);

                        drStoring["IsPass"] = storing.IsPass;
                    }
                    dtStoring.Rows.Add(drStoring);
                }
            }
            string storingDate    = "";
            string quantityCarton = "";

            if (storingList.Count() > 0 && cartonNumberingDetailList.Count() > 0)
            {
                storingDate    = string.Format("{0:dd/MM/yyyy}", storingList.FirstOrDefault().CreatedTime);
                quantityCarton = string.Format("{0} of {1}", storingList.Count(), cartonNumberingDetailList.Select(s => s.CartonNo).Max());
            }
            double totalWeight = storingList.Sum(p => p.ActualWeight);

            object[] results = { productNo, storingDate, dtCartonNumbering, dtStoring, totalWeight, quantityCarton };
            e.Result = results;
        }
        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();
        }
        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;
        }
예제 #5
0
        private void btnBarcodeComplete_Click(object sender, RoutedEventArgs e)
        {
            ClearValue();
            barcode           = txtBarCodeComplete.Text.Trim();
            storingPerBarcode = storingList.Where(w => w.Barcode == barcode).FirstOrDefault();
            if (storingPerBarcode == null)
            {
                MessageBox.Show("Thùng chưa được cân ở INPUT !", "Infor", MessageBoxButton.OK, MessageBoxImage.Information);
                HighLightTextblock(txtBarCodeComplete, btnBarcodeComplete);
                return;
            }

            outputingPerBarcode = outputingCurrentList.Where(w => w.Outputing.Barcode == barcode && w.Outputing.IsPass == true).Select(s => s.Outputing).FirstOrDefault();
            if (outputingPerBarcode != null)
            {
                MessageBox.Show("Thùng đã được cân !", "Infor", MessageBoxButton.OK, MessageBoxImage.Information);
                HighLightTextblock(txtBarCodeComplete, btnBarcodeComplete);
                return;
            }
            NoneHighLightTextblock(txtBarCodeComplete);

            tblProductNo.Text = storingPerBarcode.ProductNo;
            tblSizeItemQuantityCartonNo.Text = string.Format("Size: {0}\nCartonNo: {1}", storingPerBarcode.SizeNo, storingPerBarcode.CartonNo);

            serialPortReceive.Close();
            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);
            }

            serialPortReceive.Open();
        }
        public ReWeighCartonWindow()
        {
            storingPerBarcode = new StoringModel();
            controlAccount    = new ControlIssuesAccountModel();

            bwLoad                     = new BackgroundWorker();
            bwLoad.DoWork             += new DoWorkEventHandler(bwLoad_DoWork);
            bwLoad.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoad_RunWorkerCompleted);

            bwSave                     = new BackgroundWorker();
            bwSave.DoWork             += new DoWorkEventHandler(bwSave_DoWork);
            bwSave.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwSave_RunWorkerCompleted);

            electricScaleProfile = new ElectricScaleProfile();

            InitializeComponent();
        }
예제 #7
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);
        }
        public CheckIssuesWindow(OutputingModel _receiveOutputModel, StoringModel _receiveStoringModel, IssuesType.Issues _issuesType, string factory)
        {
            this.receiveStoringModel = _receiveStoringModel;
            this.receiveOutputModel  = _receiveOutputModel;
            this.issuesType          = _issuesType;
            this.factory             = factory;
            issuesList              = new List <IssuesModel>();
            electricScaleProfile    = new ElectricScaleProfile();
            findControlAccountModel = new ControlIssuesAccountModel();

            storingCurrent   = new StoringModel();
            outputingCurrent = new OutputingModel();

            mailAddressReceiveMessageList = new List <MailAddressReceiveMessageModel>();
            MailAddress mailAddressSend = new MailAddress("*****@*****.**", factory);

            smtpClient = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(mailAddressSend.Address, "Happy2018"),
                Timeout               = 10 * 1000,
            };
            smtpClient.SendCompleted += new SendCompletedEventHandler(smtpClient_SendCompleted);
            mailMessage = new MailMessage
            {
                From       = mailAddressSend,
                IsBodyHtml = true,
                Subject    = "Storing-System",
            };
            flagSending = false;

            bwInsertAndSendEmail                     = new BackgroundWorker();
            bwInsertAndSendEmail.DoWork             += new DoWorkEventHandler(bwInsertAndSendEmail_DoWork);
            bwInsertAndSendEmail.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwInsertAndSendEmail_RunWorkerCompleted);

            InitializeComponent();
        }
 private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
 {
     storingPerBarcode = StoringController.SelectByBarcode(barcode);
 }
예제 #10
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();
        }
예제 #11
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;
        }
        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);
            }
        }