示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Populates the GridView with Catalog Information from the Database
            if (!this.IsPostBack)
            {
                // Removes display of column to add items to cart and asks the user to login
                if (Session["UserID"] == null || Session["SecurityLevel"] == "M" || Session["SecurityLevel"] == "S")
                {
                    CatalogGridView.Columns.RemoveAt(7);
                    CatalogGridView.Columns.RemoveAt(6);
                    CatalogGridView.Columns.RemoveAt(0);
                    if (Session["SecurityLevel"] != "M" || Session["SecurityLevel"] == "S")
                    {
                        lblLogin.Visible     = true;
                        btnLogin.Visible     = true;
                        btnAddToCart.Visible = false;
                        btnViewCart.Visible  = false;
                    }
                    else
                    {
                        btnAddToCart.Visible = false;
                        btnViewCart.Visible  = false;
                    }
                }

                List <CatalogItem> lCatItems = null;

                //Retrieve Catalog Items
                lCatItems = objBAL.GetCatalogItems(true);

                CatalogGridView.DataSource = lCatItems;
                CatalogGridView.DataBind();
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["SecurityLevel"] == "M")
            {
                try
                {
                    // Populates the GridView with Catalog Information from the Database
                    if (!this.IsPostBack)
                    {
                        // Displays the Catalog if the user is an Operations Manager

                        List <CatalogItem> lCatItems = null;

                        //Retrieve Catalog Items
                        lCatItems = objBAL.GetCatalogItems();

                        CatalogGridView.DataSource = lCatItems;
                        CatalogGridView.DataBind();
                    }
                }
                catch (Exception)
                {
                    lblError.Visible = true;
                }
            }
            else
            {
                Response.Redirect("~/NoAccess.aspx");
            }
        }