private void btnCartonNo_Click(object sender, RoutedEventArgs e) { Int32.TryParse(txtCartonNo.Text.Trim().ToString(), out cartonNo); if (cartonNumberingDetail_POList.Where(w => w.CartonNo == cartonNo).Count() == 0) { MessageBox.Show(String.Format("Kiểm Tra Lại PO: {0} , Thùng {1} !", productNo, cartonNo), "Input Error", MessageBoxButton.OK, MessageBoxImage.Error); HighLightTextblock(txtCartonNo, btnCartonNo); return; } var poAndCartonScanned = storingCurrentList.Where(w => w.StoringModel.ProductNo == productNo && w.StoringModel.CartonNo == cartonNo).FirstOrDefault(); if (poAndCartonScanned != null) { MessageBox.Show(String.Format("Thùng: {0}, PO: {1} Đã Được Nhập !", poAndCartonScanned.StoringModel.CartonNo, poAndCartonScanned.StoringModel.ProductNo), "Input Error", MessageBoxButton.OK, MessageBoxImage.Error); HighLightTextblock(txtProductNo, btnProductNo); txtCartonNo.IsEnabled = false; btnCartonNo.IsEnabled = false; return; } NoneHighLightTextblock(txtProductNo); // Add barcode range of PO to storingTempList. // If PO upload cartonnumberingdetail already, but not enough cartonno or wrong something. Remove POstoringtemplist. Then add PO to storingtemplist again. int serialCartonNewPO_0 = ConvertBarcodeToSerial(barcode) - cartonNo; foreach (var p in cartonNumberingDetail_POList) { storingTempList.RemoveAll(r => r.ProductNo == productNo && r.CartonNo == p.CartonNo); StoringTemp storingTemp = new StoringTemp() { SizeNo = p.SizeNo, ProductNo = productNo, CartonNo = p.CartonNo, SerialNo = serialCartonNewPO_0 + p.CartonNo, }; storingTempList.Add(storingTemp); } sizeNo = storingTempList.Where(w => w.ProductNo == productNo && w.CartonNo == cartonNo).FirstOrDefault().SizeNo; txtCartonNo.IsEnabled = false; btnCartonNo.IsEnabled = false; popInputSubPO.IsOpen = false; BarcodeProcess(); }
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++; } }