public ReturnPage() { InitializeComponent(); PageReturns.Focus(); PopulateItemList(); FillCategoryCombo(); FillItemList(itemDTOs); cartController.CancelTransaction(); }
/// <summary> /// Check for barcode reader key combinations when keys are pressed is entered /// </summary> /// <param name="sender">Object that triggered the event</param> /// <param name="e">Event details</param> private void HandleBarcodeScan(object sender, KeyEventArgs e) { // leftCtrl + B focus upcText and set reading to true if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.B)) { PageReturns.Focus(); scannerUPCString = ""; reading = true; } // leftCtrl + J take the UPC from UPCText and find the item if it exists // otherwise clear fields and prepare for new item entry else if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.J)) { if (reading) { // find the item associated with the upc entered ItemDTO item = itemDTOs .Cast <ItemDTO>() .Where(x => x.UPC.Equals(scannerUPCString)).FirstOrDefault(); if (item != null) { cartController.AddItem(item); UpdateTransactionView(); UpdateTotal(); } else { MessageBox.Show("Item Not Found!!!"); } } reading = false; } else if (reading && !Keyboard.IsKeyDown(Key.LeftCtrl)) { // get the character from the event item and add it to the current upc scannerUPCString += e.Key.ToString()[1]; } }