private void BuildSideNavMenu() { //Clear existing nav menu items TreeViewLeftNav.Nodes.Clear(); //Get the subcategory passed in by the query string Category cat = new Category(); cat.GetCategoryByID(Int32.Parse(Request.QueryString["id"])); //Get the parent category for this subcategory Category parentCat = new Category(); parentCat.GetCategoryByID(cat.ParentCategoryID); //Set the parent category TreeNode categoryNode = new TreeNode(); categoryNode.Text = parentCat.Name.ToString(); categoryNode.Expanded = true; TreeViewLeftNav.Nodes.Add(categoryNode); //Get all active categories List<Category> cats = cat.GetAllCategories(true); foreach (Category c in cats) { if (c.ParentCategoryID == parentCat.CategoryID) { TreeNode subCategoryNode = new TreeNode(); subCategoryNode.Text = c.Name.ToString(); subCategoryNode.Value = c.CategoryID.ToString(); categoryNode.ChildNodes.Add(subCategoryNode); } } }
protected void Page_Load(object sender, EventArgs e) { Category cat = new Category(); List<Category> cats = cat.GetAllCategories(true); foreach (var c in cats) { if (c.CategoryID == Int32.Parse(Request.QueryString["id"])) { subCatDiv.InnerHtml = "<h2>" + c.Name + "</h2>"; break; } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserID"] == null) { //Not logged in LabelWelcome.Text = "Welcome, Guest"; LinkButtonLoginLogout.Text = "Login"; } else { if (!Page.IsPostBack) { //Get the first name of the current user User user = new User(); user.GetUserByID(Convert.ToInt32(Session["UserID"])); LabelWelcome.Text = "Welcome, " + user.FirstName; //Change login button to logout LinkButtonLoginLogout.Text = "Logout"; } } if (!Page.IsPostBack) { //Get all active categories Category cat = new Category(); List<Category> cats = cat.GetAllCategories(true); foreach (var cs in cats) { MenuItem mi = new MenuItem(); MenuItem m = new MenuItem(); foreach (MenuItem main in appleNav.Items) { if (main.Text == "Categories") { m = main; break; } } if (cs.ParentCategoryID > 0) { foreach (MenuItem ms in m.ChildItems) { if (ms.Value == cs.ParentCategoryID.ToString()) { mi.Value = cs.ParentCategoryID.ToString(); mi.Text = cs.Name.ToString(); mi.NavigateUrl = "~/Category.aspx?id=" + cs.CategoryID; ms.ChildItems.Add(mi); break; } } } else { mi.Value = cs.CategoryID.ToString(); mi.Text = cs.Name.ToString(); mi.Selectable = false; m.ChildItems.Add(mi); } } } }
private void reloadGridView() { if (DropDownListDBTables.SelectedValue == "Administrators") { //Get all objects Administrator obj = new Administrator(); List<Administrator> list = obj.GetAllAdministrators(false); //Fill a rendered object list List<RenderAdministrator> renderedList = new List<RenderAdministrator>(); foreach (Administrator x in list) { renderedList.Add(new RenderAdministrator(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Audits") { //Get all objects Audit obj = new Audit(); List<Audit> list = obj.GetAllAudits(); //Fill a rendered object list List<RenderAudit> renderedList = new List<RenderAudit>(); foreach (Audit x in list) { renderedList.Add(new RenderAudit(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "AuditTypes") { //Get all objects AuditType obj = new AuditType(); List<AuditType> list = obj.GetAllAuditTypes(); //Fill a rendered object list List<RenderAuditType> renderedList = new List<RenderAuditType>(); foreach (AuditType x in list) { renderedList.Add(new RenderAuditType(x)); } GridViewDBTable.DataSource = renderedList; } if (DropDownListDBTables.SelectedValue == "Categories") { //Get all objects Category obj = new Category(); List<Category> list = obj.GetAllCategories(false); //Fill a rendered object list List<RenderCategory> renderedList = new List<RenderCategory>(); foreach (Category x in list) { renderedList.Add(new RenderCategory(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Configurations") { //Get all objects Configuration obj = new Configuration(); List<Configuration> list = obj.GetAllConfigurations(); //Fill a rendered object list List<RenderConfiguration> renderedList = new List<RenderConfiguration>(); foreach (Configuration x in list) { renderedList.Add(new RenderConfiguration(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "DeliveryType") { //Get all objects DeliveryType obj = new DeliveryType(); List<DeliveryType> list = obj.GetAllDeliveryTypes(); //Fill a rendered object list List<RenderDeliveryType> renderedList = new List<RenderDeliveryType>(); foreach (DeliveryType x in list) { renderedList.Add(new RenderDeliveryType(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "LangLabels") { //Get all objects LangLabel obj = new LangLabel(); List<LangLabel> list = obj.GetAllLangLabels(); //Fill a rendered object list List<RenderLangLabel> renderedList = new List<RenderLangLabel>(); foreach (LangLabel x in list) { renderedList.Add(new RenderLangLabel(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "OrderItems") { //Get all objects OrderItem obj = new OrderItem(); List<OrderItem> list = obj.GetAllOrderItems(); //Fill a rendered object list List<RenderOrderItem> renderedList = new List<RenderOrderItem>(); foreach (OrderItem x in list) { renderedList.Add(new RenderOrderItem(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Orders") { //Get all objects Order obj = new Order(); List<Order> list = obj.GetAllOrders(); //Fill a rendered object list List<RenderOrder> renderedList = new List<RenderOrder>(); foreach (Order x in list) { renderedList.Add(new RenderOrder(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "ProductDeliveryTypes") { //Get all objects ProductDeliveryType obj = new ProductDeliveryType(); List<ProductDeliveryType> list = obj.GetAllProductDeliveryTypes(); //Fill a rendered object list List<RenderProductDeliveryType> renderedList = new List<RenderProductDeliveryType>(); foreach (ProductDeliveryType x in list) { renderedList.Add(new RenderProductDeliveryType(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Products") { //Get all objects Product obj = new Product(); List<Product> list = obj.GetAllProducts(false); //Fill a rendered object list List<RenderProduct> renderedList = new List<RenderProduct>(); foreach(Product x in list) { renderedList.Add(new RenderProduct(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "StatesProvinces") { //Get all objects StateProvince obj = new StateProvince(); List<StateProvince> list = obj.GetAllStatesProvinces(); //Fill a rendered object list List<RenderStateProvince> renderedList = new List<RenderStateProvince>(); foreach (StateProvince x in list) { renderedList.Add(new RenderStateProvince(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Users") { //Get all objects User obj = new User(); List<User> list = obj.GetAllUsers(); //Fill a rendered object list List<RenderUser> renderedList = new List<RenderUser>(); foreach (User x in list) { renderedList.Add(new RenderUser(x)); } GridViewDBTable.DataSource = renderedList; } //Databind the new datasource obtained above GridViewDBTable.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Populate categories dropdown list Category cat = new Category(); List<Category> categories = cat.GetAllCategories(true); DropDownListCategory.DataSource = categories; DropDownListCategory.DataTextField = "Name"; DropDownListCategory.DataValueField = "CategoryID"; DropDownListCategory.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Obtain product code from query string string prodcd = Request.QueryString["prodcd"].ToString(); //Get product by its code Product prod = new Product(); prod.GetProductByCode(prodcd); //Populate categories dropdown list Category cat = new Category(); List<Category> categories = cat.GetAllCategories(true); DropDownListCategory.DataSource = categories; DropDownListCategory.DataTextField = "Name"; DropDownListCategory.DataValueField = "CategoryID"; DropDownListCategory.DataBind(); //Put product details into fields LabelProductCode.Text = Request.QueryString["prodcd"].ToString(); TextBoxName.Text = prod.Name.ToString(); TextBoxBrand.Text = prod.Brand.ToString(); TextBoxDescription.Text = prod.Description.ToString(); DropDownListCategory.SelectedValue = prod.CategoryID.ToString(); TextBoxMSRP.Text = prod.Msrp.ToString(); CheckBoxFreeShipping.Checked = Convert.ToBoolean(prod.IsFreeShipping); CheckBoxTaxFree.Checked = Convert.ToBoolean(prod.IsTaxFree); TextBoxQtyInStock.Text = prod.QuantityInStock.ToString(); CheckBoxQtyUnlimited.Checked = Convert.ToBoolean(prod.IsQuantityUnlimited); LabelCreated.Text = Convert.ToDateTime(prod.Created).ToShortDateString(); if (Convert.ToDateTime(prod.Modified) > DateTime.MinValue) { LabelModified.Text = Convert.ToDateTime(prod.Modified).ToShortDateString(); } else { LabelModified.Text = "N/A"; } //Attempt to display image (if it is found) try { Image1.ImageUrl = "~/Images/Product_Images/" + LabelProductCode.Text + ".jpg"; } catch (Exception) { Image1.ImageUrl = ""; } } }