public void SaveItem(OnTheSpot.Models.Item item, bool savingPicture = false) { //Item item1 = Items.Where(i => i.BarCode == item.BarCode).SingleOrDefault(); //if (item1 == null) // Items.Add(item); db.SaveItem(item, savingPicture); }
//only this timer is operation now void timer2_Tick(object sender, EventArgs e) { timer2.Stop(); BarcodeChars = 0; if (!ProcessBarcode()) { return; } Mouse.OverrideCursor = Cursors.Wait; vm.barcode = Barcode.Text; vm.assemblyInfo = null; //check that the item is in the Assembly database if not then show message and allow more items //to be scanned try { vm.assemblyInfo = vm.getItemInAssemblyDB(Barcode.Text); if (vm.assemblyInfo == null) { BarcodeChars = 0; Errormsg.Text = string.Format(string.Format("Item has not been marked in {0}", Barcode.Text)); ErrorTxt.Visibility = Visibility.Visible; Mouse.OverrideCursor = null; return; } vm.GetCustomer(vm.assemblyInfo.CustomerID); item = vm.GetItemInDB(Barcode.Text); if (item == null) { Errormsg.Text = string.Format(string.Format("item is not in BCS {0} .. do not QA ", Barcode.Text)); ErrorTxt.Visibility = Visibility.Visible; Mouse.OverrideCursor = null; return; } if (vm.bLoggedIn) { vm.BarcodeEntered = true; } vm.ShowButtons = true; inter.Visibility = Visibility.Visible; NoteBox.Visibility = System.Windows.Visibility.Collapsed; vm.Note = string.Empty; if (item.Note != null && item.Note != string.Empty) { vm.Note = item.Note; NoteText.Text = item.Note; NoteBox.Visibility = Visibility.Visible; } DateTime date = (DateTime)vm.assemblyInfo.Duedate; DateTime future = DateTime.Now.AddDays(2); //always make the duedate standout duedate.Foreground = new SolidColorBrush(Colors.Red); duedate.FontSize = 36; if (date.Date <= DateTime.Now.Date) { duedate.Text = "TODAY"; } else { duedate.Text = date.DayOfWeek.ToString() + " " + date.Day; } vm.Duedate = duedate.Text; CustomerName.Text = vm.activeCustomer.FirstName + " " + vm.activeCustomer.LastName; //check if this is in Route int RFIDlen = vm.assemblyInfo.rfid.Length; bool route = false; for (int i = 0; i < vm.assemblyInfo.rfid.Length; i++) { if (vm.assemblyInfo.rfid[i] != ' ') { route = true; break; } } if (route) { store.Text = vm.store = "Route"; } else { store.Text = vm.store = vm.assemblyInfo.storeName; } } catch (Exception e1) { BarcodeChars = 0; Errormsg.Text = string.Format(string.Format("Database logic error {0} {1}", Barcode.Text, e1.Message)); ErrorTxt.Visibility = Visibility.Visible; Mouse.OverrideCursor = null; return; } Mouse.OverrideCursor = null; logger.Info(string.Format("all data obtained for {0} ", Barcode.Text)); //if there is a picture then display it if (item.picture == null) { return; } picture.Visibility = Visibility.Visible; if (employeeID == "1") { Note.Visibility = Visibility.Visible; Remove.Visibility = Visibility.Visible; } byte[] binaryData = Convert.FromBase64String(item.picture); bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.StreamSource = new MemoryStream(binaryData); bitmap.EndInit(); img.Source = bitmap; }