using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using ButterfieldGardens.Web; public partial class admin_index : System.Web.UI.Page { long _nInventoryId = -1; protected void Page_Load(object sender, EventArgs e) { if (Session["USERID"] == null) { Response.Redirect("/admin/"); } Navigation objNav = new Navigation(); header.InnerHtml = objNav.GetAdminHeader(); adminNav.InnerHtml = objNav.GetAdminSubNavMenu("inventory"); footer.InnerHtml = objNav.GetFooter(false, false); Page.MaintainScrollPositionOnPostBack = true; } protected void SaveProperty(object sender, EventArgs e) { try { ValidateUserInput(); AddProperty(); Response.Redirect("/admin/edit-inventory-photos.aspx?i=" + _nInventoryId.ToString()); } catch (Exception ex) { DisplayErrorMessage(ex); } } public void ValidateUserInput() { Boolean isValid = true; if (txtTitle.Text.Equals("")) { isValid = false; } if (txtDescription.Text.Equals("")) { isValid = false; } if (txtPrice.Text.Equals("")) { isValid = false; } if (isValid.Equals(false)) { throw (new Exception("All fields are required for this form. Please try again.")); } } public void AddProperty() { cInventoryDAO objInvDAO = new cInventoryDAO(); cInventory objInv = new cInventory(); objInv.InventoryTitle = txtTitle.Text; objInv.InventoryDescription = txtDescription.Text; objInv.Price = txtPrice.Text; _nInventoryId = Convert.ToInt32(objInvDAO.AddInventory(objInv)); } public void DisplayErrorMessage(Exception exError) { Literal lit = new Literal(); lit.Text = exError.Message; lblNotify.Controls.Add(lit); lblNotify.CssClass = "error"; lblNotify.Visible = true; } }