public void GetAllCartItems() { if (Convert.ToInt32(Session["UserId"]) == 0) { EmptyCart.Visible = true; CartItems.Visible = false; } else { List <ShoppingCart_Result> objList = new List <ShoppingCart_Result>(); using (var entities = new ShoppingCartEntities()) objList = entities.ShoppingCart(Convert.ToInt32(Session["UserId"])).ToList <ShoppingCart_Result>(); if (objList.Count != 0) //cart table is not empty { EmptyCart.Visible = false; CartItems.Visible = true; CartList.DataSource = objList; //allocate data - objlist contain all the products CartList.DataBind(); //bind } else { EmptyCart.Visible = true; CartItems.Visible = false; } } }
protected void Button10_Click(object sender, EventArgs e) { using (var entities = new ShoppingCartEntities()) { entities.Checkout(Convert.ToInt32(Session["UserId"])); } ClientScript.RegisterStartupScript(this.GetType(), "Message", "alert('Sucessfully Checkout !')", true); }
public void GetAllProducts() { List <ProductSelectAll_Result> objList = new List <ProductSelectAll_Result>(); using (var entities = new ShoppingCartEntities()) { objList = entities.ProductSelectAll(). ToList <ProductSelectAll_Result>(); } productList.DataSource = objList; //allocate to data - objlist contain all the products productList.DataBind(); //bind }
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('Sucessfully added to cart !')", true); } else { Response.Redirect("login.aspx"); } }
protected void loginbutton_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; status.Text = "Invalid username or password"; } else { Session["UserId"] = objList[0].UserId; Response.Redirect("Home.aspx"); } }