protected void AddToCart_Click(object sender, EventArgs e) { // if item exists, add qty to cart ABCController controller = new ABCController(); bool found = false; FormTools ft = new FormTools(); if (IsValid) { try { Item item = controller.LookupItem(ItemCodeTextBox.Text); if (!string.IsNullOrEmpty(item.ItemCode)) { found = true; Dictionary <string, int> values = (Dictionary <string, int>)Session["cart"]; if (values != null) { int qty; if (values.TryGetValue(item.ItemCode, out qty)) { values[item.ItemCode] += int.Parse(QtyTextbox.Text); } else { values[item.ItemCode] = int.Parse(QtyTextbox.Text); } } else { values = new Dictionary <string, int>(); values[item.ItemCode] = int.Parse(QtyTextbox.Text); Session["cart"] = values; } ReloadTable(); } else { ft.MessageBox(MessageBox, "Item not found", false); } } catch (Exception) { ft.MessageBox(MessageBox, "Item lookup unsuccessful, not added to cart", false); } } if (!found) { ft.MessageBox(MessageBox, "Item lookup unsuccessful, not added to cart", false); } }
protected void LookupBtn_Click(object sender, EventArgs e) { ABCController controller = new ABCController(); bool found = false; FormTools ft = new FormTools(); if (IsValid) { try { Item item = controller.LookupItem(ItemCodeLookupTextBox.Text); if (!string.IsNullOrEmpty(item.ItemCode)) { found = true; Panel1.Visible = true; ItemCodeTB.Text = item.ItemCode; DescriptionTextBox.Text = item.Description; UnitPriceTextBox.Text = item.UnitPrice + ""; QoHTextBox.Text = item.QuantityOnHand + ""; ActiveCB.Checked = item.Active; MessageBox.Text = ""; } else { Panel1.Visible = false; ft.MessageBox(MessageBox, "Item not found", false); } } catch (Exception) { ft.MessageBox(MessageBox, "Item lookup unsuccessful", false); } } if (!found) { ft.MessageBox(MessageBox, "Item lookup unsuccessful", false); } }