private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { MessageBoxResult result = MessageBox.Show("Đóng Chương Trình?", "Storing - System", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { serialPortReceive.Close(); ComPortHelper.WriteToPort(portWrite, "DIO[0]:VALUE=0\r\n"); ComPortHelper.WriteToPort(portWrite, "DIO[3]:VALUE=0\r\n"); } else { e.Cancel = true; } }
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(); }
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; }