Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;

            if (!IsPostBack)
            {
                if (Session["isadmin"] != null)
                {
                    if (int.Parse(Session["isadmin"].ToString()) == 1)
                    {
                        Response.Redirect("~/Admin/HomeAdmin.aspx");
                    }
                }
                if (Session["id"] != null)

                {
                    DataTable dt = Cart_products.getcart(int.Parse(Session["id"].ToString()));
                    if (dt.Rows.Count != 0)
                    {
                        gv_cart.DataSource = dt;
                        gv_cart.DataBind();
                        lbl_empty.Style.Add("display", "none");
                    }
                    else
                    {
                        btn_submit.Style.Add("display", "none");
                        btn_cancel.Style.Add("display", "none");
                    }
                }
                if (Session["id"] == null)
                {
                    Response.Redirect("~/Annonymous/Home.aspx");
                }
            }
        }
Ejemplo n.º 2
0
        protected void gv_cart_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = (int)gv_cart.DataKeys[e.RowIndex].Value;

            Cart_products.remove(int.Parse(Session["id"].ToString()), id);
            gv_cart.DataSource = Cart_products.getcart(int.Parse(Session["id"].ToString()));
            gv_cart.DataBind();
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
 protected void btn_cancel_Click(object sender, EventArgs e)
 {
     Cart_products.empty(int.Parse(Session["id"].ToString()));
     gv_cart.DataSource = Cart_products.getcart(int.Parse(Session["id"].ToString()));
     gv_cart.DataBind();
 }
Ejemplo n.º 5
0
 protected void gv_cart_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     gv_cart.EditIndex  = -1;
     gv_cart.DataSource = Cart_products.getcart(int.Parse(Session["id"].ToString()));
     gv_cart.DataBind();
 }