Ejemplo n.º 1
0
        protected void btn_Add_Click(object sender, EventArgs e)
        {
            if (Session["id"] != null)
            {
                int    user_id = int.Parse(Session["id"].ToString());
                Button btn     = sender as Button;
                int    prod_id = int.Parse(btn.CommandArgument.ToString());


                DataTable dt = new DataTable();
                dt = Cart_products.search(user_id, prod_id);

                if (dt.Rows.Count == 0)
                {
                    int i = Cart_products.insert(user_id, prod_id);
                }
                else
                {
                    int quant = (int)(dt.Rows[0]["quantity"]);

                    int l = Cart_products.change_quantity(user_id, prod_id, quant + 1);
                }
            }
            else
            {
                Lbl_cart.Text = "you are not allowed to add to you profile please login first.";
            }
        }
Ejemplo n.º 2
0
        protected void gv_cart_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            if (IsValid)

            {
                int prodid = (int)gv_cart.DataKeys[e.RowIndex].Value;
                int a      = int.Parse(((TextBox)gv_cart.Rows[e.RowIndex].FindControl("TextBox1")).Text);
                Cart_products.change_quantity(int.Parse(Session["id"].ToString()), prodid, a);
                gv_cart.EditIndex  = -1;
                gv_cart.DataSource = Cart_products.getcart(int.Parse(Session["id"].ToString()));
                gv_cart.DataBind();
            }
        }