private void AddShoppingItemToList(ShoppingItem item) { tableLayoutPanelShoppingItems.SuspendLayout(); RichTextBox description = GetRichTextBoxForItemList(); description.Text = item.TillDescription; Decimal cost = item.OfferPrice ?? item.RegularPrice; RichTextBox price = GetRichTextBoxForItemList(); price.Text = cost.ToString("C"); tableLayoutPanelShoppingItems.RowCount++; int nextRow = tableLayoutPanelShoppingItems.RowCount - 1; tableLayoutPanelShoppingItems.Controls.Add(description, 0, nextRow); tableLayoutPanelShoppingItems.Controls.Add(price, 1, nextRow); tableLayoutPanelShoppingItems.ResumeLayout(); }
private void UpdateMostRecentItem(ShoppingItem item) { richTextBoxLastScanned.Text = item.TillDescription; richTextBoxLastScanned.Text += Environment.NewLine; Decimal price = item.OfferPrice ?? item.RegularPrice; richTextBoxLastScanned.Text += price.ToString("C"); if (item.OfferPrice != null) { richTextBoxLastScanned.Text += " (special offer)"; } }
private void UpdateWithScannedProduct(ShoppingItem item) { m_ShoppingItems.Add(item); UpdateMostRecentItem(item); AddShoppingItemToList(item); UpdateTotalCost(); pictureBoxLoadingSpinny.Visible = false; }
private void LookupScannedItem(string barcode) { var db = new DatabaseAccess(); ShoppingItem newItem = new ShoppingItem(); try { newItem = db.GetItemDetails(barcode); } catch (Exception) { richTextBoxLastScanned.Text = "Couldn't find item. Seek assistance."; return; } UpdateWithScannedProductCallback update = new UpdateWithScannedProductCallback(UpdateWithScannedProduct); this.Invoke(update, new object[] { newItem }); }