protected void BtnSubmit_Click(object sender, EventArgs e) { string ItemID = TxtItemID.Text; string uom = InventoryLogic.GetUnitsOfMeasure(ItemID); string supplier1 = DdlSupplier1.SelectedValue; string supplier2 = DdlSupplier2.SelectedValue; string supplier3 = DdlSupplier3.SelectedValue; double price1; double price2; double price3; bool isprice1legit = false; if (Double.TryParse(TxtPriceS1.Text, out price1) && price1 > 0) { isprice1legit = true; } bool isprice2legit = false; if (Double.TryParse(TxtPriceS2.Text, out price2) && price2 > 0) { isprice2legit = true; } bool isprice3legit = false; if (Double.TryParse(TxtPriceS3.Text, out price3) && price3 > 0) { isprice3legit = true; } string input = TxtItemID.Text; if (supplier1 != string.Empty) { if (isprice1legit) { if (supplier2 != string.Empty) { if (supplier1 != supplier2) { if (isprice2legit) { if (supplier3 != string.Empty) { if (supplier1 != supplier3 && supplier2 != supplier3) { if (isprice3legit) { InventoryLogic.UpdateSupplierCatalogue(supplier1, ItemID, price1, 1); if (InventoryLogic.DoesSupplierExistInSupplierCatalogueForItemID(2, ItemID)) { InventoryLogic.UpdateSupplierCatalogue(supplier2, ItemID, price2, 2); } else { InventoryLogic.AddSupplierCatalogue(supplier2, ItemID, price2, 2, uom); } if (InventoryLogic.DoesSupplierExistInSupplierCatalogueForItemID(3, ItemID)) { InventoryLogic.UpdateSupplierCatalogue(supplier3, ItemID, price3, 3); } else { InventoryLogic.AddSupplierCatalogue(supplier3, ItemID, price3, 3, uom); } Response.Redirect("ViewCatalogue.aspx"); } else { statusMessage.Text = "Please enter a valid price for 3rd Supplier"; statusMessage.Visible = true; statusMessage.ForeColor = Color.Red; } } else { statusMessage.Text = "Please choose different suppliers"; statusMessage.Visible = true; statusMessage.ForeColor = Color.Red; } } else { InventoryLogic.UpdateSupplierCatalogue(supplier1, ItemID, price1, 1); if (InventoryLogic.DoesSupplierExistInSupplierCatalogueForItemID(2, ItemID)) { InventoryLogic.UpdateSupplierCatalogue(supplier2, ItemID, price2, 2); } else { InventoryLogic.AddSupplierCatalogue(supplier2, ItemID, price2, 2, uom); } if (InventoryLogic.DoesSupplierExistInSupplierCatalogueForItemID(3, ItemID)) { InventoryLogic.DeleteSupplierCatalogue(3, ItemID); } Response.Redirect("ViewCatalogue.aspx"); } } else { statusMessage.Text = "Please enter a valid price for 2nd Supplier"; statusMessage.Visible = true; statusMessage.ForeColor = Color.Red; } } else { statusMessage.Text = "Please choose different suppliers"; statusMessage.Visible = true; statusMessage.ForeColor = Color.Red; } } else { InventoryLogic.UpdateSupplierCatalogue(supplier1, ItemID, price1, 1); if (InventoryLogic.DoesSupplierExistInSupplierCatalogueForItemID(2, ItemID)) { InventoryLogic.DeleteSupplierCatalogue(2, ItemID); } if (InventoryLogic.DoesSupplierExistInSupplierCatalogueForItemID(3, ItemID)) { InventoryLogic.DeleteSupplierCatalogue(3, ItemID); } Response.Redirect("ViewCatalogue.aspx"); } } else { statusMessage.Text = "Please enter a valid price for 1st Supplier"; statusMessage.Visible = true; statusMessage.ForeColor = Color.Red; } } else { statusMessage.Text = "Please choose a supplier"; statusMessage.Visible = true; statusMessage.ForeColor = Color.Red; } }