public void BatchOff() { foreach (string barcode in vm.scancodes) { Item item = vm.GetItemInDB(barcode); item.Category = catForBatch; vm.SaveItem(item); } ErrorTxt.Visibility = Visibility.Hidden; Codes.Visibility = Visibility.Collapsed; ErrorCodes.Visibility = Visibility.Collapsed; //test CustomerName.Text = " "; vm.scancodes.Clear(); ClearInput(); }
//only this timer is operation now void timer2_Tick(object sender, EventArgs e) { timer2.Stop(); if (!ProcessBarcode()) { return; } string barcode = Barcode.Text; //check that the item is in the Assembly database if not then show message and allow more items //to be scanned try { assemblyInfo = vm.getItemInAssemblyDB(barcode); if (assemblyInfo == null) { ClearInput(); Errormsg.Text = string.Format(string.Format("Item has not been marked in {0}", barcode)); ErrorTxt.Background = new SolidColorBrush(Colors.Red); ErrorTxt.Visibility = Visibility.Visible; if (vm.BatchButtonText == "Batch Off") { vm.errorcodes.Add(barcode); ErrorCodes.Visibility = Visibility.Visible; } return; } vm.GetCustomer(assemblyInfo.CustomerID); CustomerName.Text = vm.activeCustomer.FirstName + " " + vm.activeCustomer.LastName; if (vm.BCSMode) { //check if the item is in BCS Codes item = vm.GetItemInDB(barcode); //if we are in batch mode then it must be already in BCS if (item == null && vm.BatchButtonText == "Batch Off") { vm.errorcodes.Add(barcode); ErrorCodes.Visibility = Visibility.Visible; ErrorTxt.Background = new SolidColorBrush(Colors.Red); Errormsg.Text = string.Format(string.Format("item {0} not in BCS", barcode)); ErrorTxt.Visibility = Visibility.Visible; ClearInput(); return; } } } catch (Exception e1) { BarcodeChars = 0; Errormsg.Text = string.Format(string.Format("Database logic error {0} {1}", barcode, e1.Message)); ErrorTxt.Visibility = Visibility.Visible; return; } logger.Info(string.Format("all data obtained for {0} ", barcode)); if (vm.BatchButtonText == "Batch Off") { vm.scancodes.Add(barcode); Codes.Visibility = Visibility.Visible; Errormsg.Text = string.Format("Scan {0} items and hit Batch off when finished", catForBatch.Name); ErrorTxt.Background = new SolidColorBrush(Colors.Gray); ClearInput(); return; } if (!vm.BCSMode) { SetupActions(); return; } bool route = false; for (int i = 0; i < assemblyInfo.rfid.Length; i++) { if (assemblyInfo.rfid[i] != ' ') { route = true; break; } } if (!route) //only look for next day if this is not a routed customer { bNextDay = vm.getNextdayBin(assemblyInfo); } if (bNextDay) { ButRow1.Children.Clear(); ButRow1.Visibility = Visibility.Visible; logger.Info("new item"); item = new Item() { BarCode = barcode, CustID = 0, ID = -1, CreationDate = DateTime.Now }; Button but = new Button() { Content = "Next Day Work", Height = ButtonHeight, Width = ButtonWidth, Visibility = Visibility.Visible }; but.Margin = new Thickness(0, 5, 5, 5); // but.Click += new RoutedEventHandler(but_Click); item.Category = vm.CleaningCats.Where(c => c.ID == 11).Single(); ButRow1.Children.Add(but); SetupActions(); return; } //a new item set the category to Unclassified or laundry if (item == null) { ButRow1.Children.Clear(); ButRow1.Visibility = Visibility.Visible; logger.Info("new item"); item = new Item() { BarCode = barcode, CustID = 0, ID = -1, CreationDate = DateTime.Now }; Button but = new Button() { Content = "Unclassified Work", Height = ButtonHeight, Width = ButtonWidth, Visibility = Visibility.Visible }; but.Margin = new Thickness(0, 5, 5, 5); but.Click += new RoutedEventHandler(but_Click); if (assemblyInfo.dept != "Laundry") //must be unclassifield dry cleaning { logger.Info("dry cleaning"); item.Category = vm.CleaningCats.Where(c => c.Name.StartsWith("Unclassified")).Single(); } else { logger.Info("laundry"); if (vm.activeCustomer.Starch == "H" || vm.activeCustomer.Starch == "M") { but.Content = "Starched Shirts"; } else { but.Content = "No Starch Shirts"; } //get category so we can place in the right bin item.Category = vm.CleaningCats.Where(c => c.Name == but.Content.ToString()).Single(); } ButRow1.Children.Add(but); SetupActions(); } else { //known item but first check if it is unknown as it needs to be categorized before proceeding ButRow1.Children.Clear(); ButRow2.Children.Clear(); ButRow1.Visibility = Visibility.Visible; if (item.Category.ID == vm.unknownCat.ID || vm.ReClassifyButtonText == "ReClassify Off" || vm.QuickReClassifyButtonText == "Quick Reclassify Off") { logger.Info("Classify"); vm.ReClassifyButtonText = "ReClassify On"; //this is a one time deal if (!vm.bLoggedIn) { Errormsg.Text = "Classify is a adminstrator action"; ErrorTxt.Visibility = Visibility.Visible; Barcode.Text = string.Empty; BarcodeChars = 0; return; } ButRow2.Visibility = Visibility.Visible; int ii = 0; foreach (Category cat in vm.CleaningCats) { if (cat.ID == vm.unknownCat.ID) { continue; } ii++; Button but = new Button() { Content = cat.Name, Height = ButtonHeight, Width = ButtonWidth, Visibility = Visibility.Visible }; but.Margin = new Thickness(0, 5, 5, 5); but.Click += new RoutedEventHandler(but_Click); if (ii < 5) { ButRow1.Children.Add(but); } else { ButRow2.Children.Add(but); } } } else //allow the garment to be placed in a bin { Button but = new Button() { Height = ButtonHeight, Width = ButtonWidth, Visibility = Visibility.Visible, IsEnabled = false }; if (assemblyInfo.dept != "Laundry") //if this is dry cleaning { Category cat = vm.CleaningCats.Where(c => c.ID == item.Category.ID).SingleOrDefault(); but.Content = cat.Name; } else //laundry then get the starch from the customer info as they might have changed in fabricare { if (vm.activeCustomer.Starch == "H" || vm.activeCustomer.Starch == "M") { but.Content = "Starched Shirts"; } else { but.Content = "No Starch Shirts"; } //set category so we can place in the right bin in fabricare setting item.Category = vm.CleaningCats.Where(c => c.Name == but.Content.ToString()).Single(); } ButRow1.Children.Add(but); SetupActions(); } } }