protected void Page_Load(object sender, EventArgs e) { FormsAuthenticationHelper.AuthenticateUserWithReturnUrl(); connstring = Client.ConnectionString(HttpContext.Current.Session["clientid"].ToString()); if (Int32.Parse(Session[Constant.SESSION_USERTYPE].ToString().Trim()) != (int)Constant.USERTYPE.BUYER) { Response.Redirect("../unauthorizedaccess.aspx"); } if (!(Page.IsPostBack)) { PageTitle.InnerText = String.Format(Constant.TITLEFORMAT, "Registered Products"); lblMessage.Text = ""; BrandsTransaction brand = new BrandsTransaction(); ServicesTransaction serv = new ServicesTransaction(); SubCategory sub = new SubCategory(); ddlBrand.DataSource = brand.GetAllBrands(connstring); ddlBrand.DataTextField = "BrandName"; ddlBrand.DataValueField = "BrandId"; ddlBrand.DataBind(); ListItem lst = new ListItem(); lst.Text = "Select Brands"; lst.Value = ""; ddlBrand.Items.Insert(0, lst); ddlServices.DataSource = serv.GetAllServices(connstring); ddlServices.DataTextField = "ServiceName"; ddlServices.DataValueField = "ServiceId"; ddlServices.DataBind(); ListItem lst1 = new ListItem(); lst1.Text = "Select Services"; lst1.Value = ""; ddlServices.Items.Insert(0, lst1); ddlSubCategory.DataSource = sub.GetAllSubCategories(connstring); ddlSubCategory.DataTextField = "SubCategoryName"; ddlSubCategory.DataValueField = "SubCategoryId"; ddlSubCategory.DataBind(); ListItem lst2 = new ListItem(); lst2.Text = "Select Sub-category"; lst2.Value = ""; ddlSubCategory.Items.Insert(0, lst2); dvFooter.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { FormsAuthenticationHelper.AuthenticateUserWithReturnUrl(); connstring = HttpContext.Current.Session["ConnectionString"].ToString(); if (Int32.Parse(Session[Constant.SESSION_USERTYPE].ToString().Trim()) != (int)Constant.USERTYPE.ADMINISTRATOR) { Response.Redirect("../unauthorizedaccess.aspx"); } if (!(Page.IsPostBack)) { if (Session["SKU"] != null) { ViewState["SKU"] = Session["SKU"].ToString().Trim(); } BrandsTransaction brand = new BrandsTransaction(); ServicesTransaction serv = new ServicesTransaction(); SubCategory sub = new SubCategory(); CategoryTransaction c = new CategoryTransaction(); ServicesTransaction s = new ServicesTransaction(); UnitOfMeasurementTransaction u = new UnitOfMeasurementTransaction(); ddlUnitOfMeasure.DataSource = u.GetAllUnitsOfMeasurement(connstring); ddlUnitOfMeasure.DataTextField = "UnitOfMeasureName"; ddlUnitOfMeasure.DataValueField = "UnitOfMeasureID"; ddlUnitOfMeasure.DataBind(); ddlUnitOfMeasure.Items.Insert(0, ""); ddlCategory.DataSource = c.GetAllCategories(connstring); ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataValueField = "CategoryId"; ddlCategory.DataBind(); ddlCategory.Items.Insert(0, ""); ddlSubCategory.DataSource = sub.GetAllSubCategories(connstring); ddlSubCategory.DataTextField = "SubCategoryName"; ddlSubCategory.DataValueField = "SubCategoryId"; ddlSubCategory.DataBind(); ddlSubCategory.Items.Insert(0, ""); ddlBrand.DataSource = brand.GetAllBrands(connstring); ddlBrand.DataTextField = "BrandName"; ddlBrand.DataValueField = "BrandId"; ddlBrand.DataBind(); ddlBrand.Items.Insert(0, ""); ddlServiceType.DataSource = s.GetAllServices(connstring); ddlServiceType.DataTextField = "ServiceName"; ddlServiceType.DataValueField = "ServiceId"; ddlServiceType.DataBind(); ddlServiceType.Items.Insert(0, ""); if (ViewState["SKU"] != null) { ProductsTransaction p = new ProductsTransaction(); Product po = new Product(); po = p.QueryProductBySKU(ViewState["SKU"].ToString().Trim(), connstring); txtSKU.Enabled = false; txtSKU.Text = po.SKU.Trim(); txtItemName.Text = po.ItemName.Trim(); txtProductDescription.Text = po.ProductDescription.Trim(); ddlUnitOfMeasure.SelectedIndex = ddlUnitOfMeasure.Items.IndexOf(ddlUnitOfMeasure.Items.FindByValue(po.UnitOfMeasure.Trim())); ddlCategory.SelectedIndex = ddlCategory.Items.IndexOf(ddlCategory.Items.FindByValue(po.Category.Trim())); ddlSubCategory.SelectedIndex = ddlSubCategory.Items.IndexOf(ddlSubCategory.Items.FindByValue(po.SubCategory.Trim())); ddlBrand.SelectedIndex = ddlBrand.Items.IndexOf(ddlBrand.Items.FindByValue(po.Brand.Trim())); ddlServiceType.SelectedIndex = ddlServiceType.Items.IndexOf(ddlServiceType.Items.FindByValue(po.ServiceType.Trim())); btnDelete.Visible = true; } } }