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 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; })); }