예제 #1
0
        public void GetAllProducts()
        {
            if (Convert.ToInt32(Session["UserId"]) == 0)
            {
                EmptyCart.Visible = true;
                CartItems.Visible = false;
            }
            else
            {
                EmptyCart.Visible = false;
                CartItems.Visible = true;

                List <CartItems_Result> objList = new List <CartItems_Result>();
                using (var entities = new ShoppingCartEntities())
                {
                    objList = entities.CartItems(Convert.ToInt32(Session["UserId"])).ToList <CartItems_Result>();
                }
                if (objList.Count != 0)
                {
                    EmptyCart.Visible = false;
                    CartItems.Visible = true;

                    Repeater1.DataSource = objList;
                    Repeater1.DataBind();
                }
                else
                {
                    EmptyCart.Visible = true;
                }
                CartItems.Visible = false;
            }
        }
예제 #2
0
        public void GetAllProducts()
        {
            List <ProductSelectsAll_Result> objList = new List <ProductSelectsAll_Result>();

            using (var entities = new ShoppingCartEntities())
            {
                objList = entities.ProductSelectsAll().ToList <ProductSelectsAll_Result>();
            }
            productList.DataSource = objList;
            productList.DataBind();
        }
예제 #3
0
        public void GetAllCartItems()
        {
            List <CartItems_Result> objList = new List <CartItems_Result>();

            using (var entities = new ShoppingCartEntities())
            {
                objList = entities.CartItems(Convert.ToInt32(Session["UserId"])).ToList <CartItems_Result>();
            }
            Repeater1.DataSource = objList;
            Repeater1.DataBind();
        }
예제 #4
0
 protected void btnAddtoCart_Command(object sender, CommandEventArgs e)
 {
     if (Convert.ToInt32(Session["UserId"]) != 0)
     {
         using (var entities = new ShoppingCartEntities())
         {
             entities.AddtoCart(Convert.ToInt32(Session["UserId"]), Convert.ToInt32(e.CommandArgument));
         }
         ClientScript.RegisterStartupScript(this.GetType(), "Message", "alert(Successfully added to cart ! ')", true);
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }
예제 #5
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            List <Authentication_Result> objList = new List <Authentication_Result>();

            using (var entities = new ShoppingCartEntities())
            {
                objList = entities.Authentication(txtUsername.Text.Trim(), txtPassword.Text.Trim()).ToList <Authentication_Result>();
            }
            if (objList.Count == 0)
            {
                Session["UserId"] = 0;
                lblError.Text     = "Invalid username or password";
            }
            else
            {
                Session["UserId"] = objList[0].UserId;
                Response.Redirect("Home.aspx");
            }
        }