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 Delete_Click(object sender, EventArgs e) { ABCController controller = new ABCController(); FormTools ft = new FormTools(); try { controller.DeleteItem(ItemCodeTB.Text); ft.MessageBox(MessageBox, "Item delete successful", true); ft.ClearFields(Form.Controls); Panel1.Visible = false; } catch (Exception) { ft.MessageBox(MessageBox, "Item delete unsuccessful", false); } }
protected void Modify_Click(object sender, EventArgs e) { ABCController controller = new ABCController(); FormTools ft = new FormTools(); Item item = new Item(ItemCodeTB.Text, DescriptionTextBox.Text, decimal.Parse(UnitPriceTextBox.Text), int.Parse(QoHTextBox.Text), ActiveCB.Checked); try { controller.UpdateItem(item); ft.MessageBox(MessageBox, "Item update successful", true); ft.ClearFields(Form.Controls); Panel1.Visible = false; } catch (Exception) { ft.MessageBox(MessageBox, "Item update unsuccessful", false); } }
protected void Submit_Click(object sender, EventArgs e) { ABCController controller = new ABCController(); if (IsValid) { FormTools ft = new FormTools(); try { Customer cust = new Customer(int.Parse(CustomerIDTextBox.Text), CustomerNameTextBox.Text, AddressTextBox.Text, CityTextBox.Text, PostalCodeTextBox.Text, ProvinceTextBox.Text); controller.AddCustomer(cust); ft.MessageBox(MessageBox, "Customer add successful", true); ft.ClearFields(Form.Controls); } catch (Exception) { ft.MessageBox(MessageBox, "Customer add unsuccessful", false); } } }
protected void LookupBtn_Click(object sender, EventArgs e) { ABCController controller = new ABCController(); bool found = false; FormTools ft = new FormTools(); if (IsValid) { try { Customer cust = controller.LookupCustomer(int.Parse(CustomerIDTextBox.Text)); if (!string.IsNullOrEmpty(cust.CustomerName)) { found = true; Panel1.Visible = true; CustIDTB.Text = cust.CustomerID + ""; CustomerNameTextBox.Text = cust.CustomerName; AddressTextBox.Text = cust.Address; CityTextBox.Text = cust.City; PostalCodeTextBox.Text = cust.PostalCode; ProvinceTextBox.Text = cust.Province; MessageBox.Text = ""; } else { Panel1.Visible = false; ft.MessageBox(MessageBox, "Customer not found", false); } } catch (Exception) { ft.MessageBox(MessageBox, "Customer lookup unsuccessful", false); } } if (!found) { ft.MessageBox(MessageBox, "Customer lookup unsuccessful", 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); } }
protected void Submit_Click(object sender, EventArgs e) { ABCController controller = new ABCController(); if (IsValid) { FormTools ft = new FormTools(); Item item = new Item(ItemCodeTextBox.Text, DescriptionTextBox.Text, decimal.Parse(UnitPriceTextBox.Text), int.Parse(QoHTextBox.Text), ActiveCB.Checked); try { controller.AddItem(item); ft.ClearFields(Form.Controls); ft.MessageBox(MessageBox, "Item add successful", true); // QoH is df to 0 QoHTextBox.Text = "0"; //MessageBox.Text = ""; } catch (Exception) { ft.MessageBox(MessageBox, "Item add unsuccessful", false); } } }
protected void Modify_Click(object sender, EventArgs e) { ABCController controller = new ABCController(); FormTools ft = new FormTools(); Customer cust = new Customer(int.Parse(CustIDTB.Text), CustomerNameTextBox.Text, AddressTextBox.Text, CityTextBox.Text, PostalCodeTextBox.Text, ProvinceTextBox.Text); //try { controller.UpdateCustomer(cust); ft.MessageBox(MessageBox, "Customer update successful", true); ft.ClearFields(Form.Controls); Panel1.Visible = false; } //catch (Exception) { //ft.MessageBox(MessageBox, "Customer update unsuccessful", false); } }