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 { 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); LoadInventory(); MaintainScrollPositionOnPostBack = true; } public void LoadInventory() { cInventoryDAO objInvDAO = new cInventoryDAO(); cInventoryList objInvList = objInvDAO.GetInventoryList(); String rowClass = "odd"; int nInvCount = objInvList.count; for (int nInvIndex = 0; nInvIndex < nInvCount; nInvIndex++) { cInventory objInv = objInvList[nInvIndex]; TableRow tr = new TableRow(); tr.CssClass = rowClass; TableCell tcTitle = new TableCell(); TableCell tcListedOn = new TableCell(); TableCell tcAction = new TableCell(); tcListedOn.Text = objInv.ListedOn.ToShortDateString(); HyperLink lnk = new HyperLink(); lnk.Text = objInv.InventoryTitle; lnk.NavigateUrl = "/admin/edit-inventory.aspx?i=" + objInv.InventoryId.ToString(); tcTitle.Controls.Add(lnk); LinkButton lbtn = new LinkButton(); lbtn.Text = "Delete"; lbtn.OnClientClick = "return confirm(\"Are you sure you want to delete this inventory item?\");"; lbtn.Command += new CommandEventHandler(Delete_Inventory); lbtn.CommandName = "DeleteInventory"; lbtn.CommandArgument = objInv.InventoryId.ToString(); tcAction.Controls.Add(lbtn); Literal litActionSpacer = new Literal(); litActionSpacer.Text = "  |  "; tcAction.Controls.Add(litActionSpacer); HyperLink lImg = new HyperLink(); lImg.Text = "Edit Photos"; lImg.NavigateUrl = "/admin/edit-inventory-photos.aspx?i=" + objInv.InventoryId.ToString(); ; tcAction.Controls.Add(lImg); tr.Cells.Add(tcListedOn); tr.Cells.Add(tcTitle); tr.Cells.Add(tcAction); tblInventory.Rows.Add(tr); tcListedOn.Dispose(); tcTitle.Dispose(); tcAction.Dispose(); tr.Dispose(); if (rowClass.Equals("odd")) { rowClass = "even"; } else { rowClass = "odd"; } } } void Delete_Inventory(object sender, CommandEventArgs e) { cInventoryDAO objInvDAO = new cInventoryDAO(); cInventory objInv = new cInventory(); objInv.InventoryId = Convert.ToInt32(e.CommandArgument); objInvDAO.DeleteInventory(objInv); Response.Redirect("/admin/manage-inventory.aspx"); } }