public string PopulateSuppliers() { try { if (Context.User.IsInRole("Administrator")) { List<SuppliersView> mySuppliers = new SuppliersLogic().RetrieveAllSuppliers().ToList(); string HTML = "<option value=\"0\">Select</option>"; foreach (SuppliersView mySupplier in mySuppliers) { HTML += "<option value=\"" + mySupplier.Id + "\">" + mySupplier.Supplier + "</option>"; } return HTML; } else { return ""; } } catch (Exception Exception) { throw Exception; } }
/// <summary> /// Occurs when the Supplier Grid View Selected Index is Changed /// Level: External /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvSuppliers_SelectedIndexChanged(object sender, EventArgs e) { try { lblServerSideError.Text = " "; btnAdd.Visible = false; btnUpdate.Visible = true; Supplier mySupplier = new SuppliersLogic().RetrieveSupplierByID(Convert.ToInt32(gvSuppliers.SelectedValue)); hdnID.Value = mySupplier.Id.ToString(); txtSupplier.Text = mySupplier.Supplier1; txtEmail.Text = mySupplier.Email; string[] mySplitAddress = mySupplier.StreetAddress.Split('|'); txtAddressLine1.Text = mySplitAddress[0]; txtAddressLine2.Text = mySplitAddress[1]; txtTown.Text = mySupplier.Town.Town1; txtPostcode.Text = mySupplier.Postcode; ddlCountry.SelectedValue = mySupplier.Town.Country.Id.ToString(); } catch (Exception Exception) { throw Exception; } }
protected void Page_Load(object sender, EventArgs e) { try { MaintainScrollPositionOnPostBack = true; LoadProducts = true; if (!Page.IsPostBack) { IQueryable<Category> myCategories = new CategoriesLogic().RetrieveAllChildCategories(); IQueryable<SuppliersView> mySuppliers = new SuppliersLogic().RetrieveAllSuppliers(); if ((mySuppliers.Count() > 0) && (myCategories.Count() > 0)) { gvProducts.DataSource = new ProductsLogic().RetrieveAllProducts(); gvProducts.DataBind(); ddlStatus.Items.Add(new ListItem("Active", "true")); ddlStatus.Items.Add(new ListItem("Inactive", "false")); ddlCategory.DataSource = myCategories; ddlCategory.DataTextField = "Category1"; ddlCategory.DataValueField = "Id"; ddlCategory.DataBind(); ddlCategory.Items.Insert(0, new ListItem("Select", "0")); ddlSupplier.DataSource = mySuppliers; ddlSupplier.DataTextField = "Supplier"; ddlSupplier.DataValueField = "Id"; ddlSupplier.DataBind(); ddlSupplier.Items.Insert(0, new ListItem("Select", "0")); LoadProducts = true; } else { lblServerSideError.Text = "Suppliers and Categories must be added in order to add Products"; LoadProducts = false; } } } catch (Exception Exception) { throw Exception; } }