Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Tak tylko dla sprawdzenia czy działa
            if (!Page.IsPostBack)
            {
                if (Session["usertoken"] == null)
                {
                    Response.Redirect("LoginForm.aspx");
                }
                else if (UserHandler.getAccessLevel(Session["usertoken"].ToString()) != AccessLevel.ADMIN && UserHandler.getAccessLevel(Session["usertoken"].ToString()) != AccessLevel.ROOT)
                {
                    lTest.Text = "Nie jesteś adminem.";
                }
                else
                {
                    gvUsers.DataSource = DatabaseHandler.selectTable("users");
                    gvUsers.DataBind();

                    gvProducts.DataSource = DatabaseHandler.selectTable("products");
                    gvProducts.DataBind();

                    gvOrders.DataSource = DatabaseHandler.selectTable("orders");
                    gvOrders.DataBind();


                    addCat.DataSource     = DatabaseHandler.selectTable("product_categories");
                    addCat.DataTextField  = "name";
                    addCat.DataValueField = "id";
                    addCat.DataBind();
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["usertoken"] == null)
            {
                //Response.Redirect("LoginForm.aspx");
                lLoggedIn.Text       = "Nie jesteś zalogowany";
                lbToAdmin.Visible    = false;
                lbToLogin.Visible    = true;
                bLogout.Visible      = false;
                lbToRegister.Visible = true;
                lbToLogin2.Visible   = true;
            }
            else if (UserHandler.getAccessLevel(Session["usertoken"].ToString()) == AccessLevel.ADMIN || UserHandler.getAccessLevel(Session["usertoken"].ToString()) == AccessLevel.ROOT)
            {
                lLoggedIn.Text       = "Zalogowano jako <b>" + UserHandler.getUsername(Session["usertoken"].ToString()) + "</b>";
                lbToAdmin.Visible    = true;
                lbToLogin.Visible    = false;
                bLogout.Visible      = true;
                lbToRegister.Visible = false;
                lbToLogin2.Visible   = false;
            }
            else
            {
                lLoggedIn.Text       = "Zalogowano jako <b>" + UserHandler.getUsername(Session["usertoken"].ToString()) + "</b>";
                lbToAdmin.Visible    = false;
                lbToLogin.Visible    = false;
                bLogout.Visible      = true;
                lbToRegister.Visible = false;
                lbToLogin2.Visible   = false;
            }

            if (!IsPostBack)
            {
                rProducts.DataSource = DatabaseHandler.selectTable("products");
                rProducts.DataBind();

                KatFilter.DataSource     = DatabaseHandler.selectTable("product_categories");
                KatFilter.DataTextField  = "name";
                KatFilter.DataValueField = "id";
                KatFilter.DataBind();
                int x = KatFilter.Items.Count;
                KatFilter.Items.Insert(x, new ListItem("Kategoria", "null"));
                KatFilter.SelectedValue = "null";
            }

            if (Session["basket"] == null)
            {
                Debug.WriteLine("Create new basket");
                Session["basket"] = new List <BasketItem>();
            }

            calculateBasketItemCount();
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Tak tylko dla sprawdzenia czy działa
            if (Session["usertoken"] == null)
            {
                Response.Redirect("LoginForm.aspx");
            }
            else if (UserHandler.getAccessLevel(Session["usertoken"].ToString()) != "ADMIN")
            {
                lTest.Text = "Nie jesteś adminem.";
            }
            else
            {
                gvUsers.DataSource = DatabaseHandler.selectTable("users");
                gvUsers.DataBind();

                gvProducts.DataSource = DatabaseHandler.selectTable("product_info");
                gvProducts.DataBind();

                gvOrders.DataSource = DatabaseHandler.selectTable("orders");
                gvOrders.DataBind();
            }
        }