protected void Page_Load(object sender, EventArgs e) { //if (!Page.IsPostBack) //{ list = Session["Cart"] as List <Cart_Temp>; tong = String.Format("{0:0,0}", Cart_Temp.TongTien(list)); mylist.DataSource = list; mylist.DataBind(); if (Session["admin"] != null) { int id = Convert.ToInt32(Session["admin"].ToString()); users_info us = users_info.getBy_id(id); txtnguoidh.Text = us.fullname; txtEmailndh.Text = us.email; txtdcndh.Text = us.address; txtdtndh.Text = us.phone; txtnguoidh.ReadOnly = true; } else { txtnguoidh.ReadOnly = false; } //} }
private void BindRepeater() { //tong = Cart_Temp.TongTien(list); tong = String.Format("{0:0,0}", Cart_Temp.TongTien(list)); rptcartV.DataSource = list; rptcartV.DataBind(); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Cart_Temp ct = null; if (id != null) { ct = new Cart_Temp(); ct.pro = Products_info.getby_id(id); ct.amount = 1; if (Session["cart"] == null) { List <Cart_Temp> listP = new List <Cart_Temp>(); listP.Add(ct); Session["cart"] = listP; } else { List <Cart_Temp> listP2 = new List <Cart_Temp>(); listP2 = Session["cart"] as List <Cart_Temp>; if (!Cart_Temp.UpdateAmount(listP2, ct, 1)) { listP2.Add(ct); } Session["cart"] = listP2; } ScriptManager.RegisterStartupScript( this, this.GetType(), "alert", "alert('Sản phẩm đả được thêm vào giỏ hàng của bạn');location.href='default.aspx';", true); } }
protected void ImageButton1_Click1(object sender, ImageClickEventArgs e) { //Định nghĩa các thông tin cần thiết và tạo nút thanh toán String receiver = "*****@*****.**"; String comments = "Shop-T2"; String return_url = "https://nganluong.vn/"; String price = Cart_Temp.TongTien(list).ToString(); String product = "Sản Phẩm T2-Shop"; this.url_checkout += "?receiver=" + receiver + "&comments=" + comments + "&return_url=" + return_url + "&product=" + product + "&price=" + price; Response.Redirect(url_checkout); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Literal1.Text = LoadMenu(); } if (Session["Cart"] != null) { item = Session["Cart"] as List <Cart_Temp>; soluong = Cart_Temp.TongSoLuong(item); tong = String.Format("{0:0,0}", Cart_Temp.TongTien(item)); } }
protected void rptcartV_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.ToLower() == "update") { TextBox txtSl = (TextBox)e.Item.FindControl("txtSoluong"); string pid = e.CommandArgument.ToString(); Cart_Temp ct = Cart_Temp.FindProduct(list, int.Parse(pid)); if (ct != null) { ct.amount = int.Parse(txtSl.Text); if (Products_info.getby_id(pid).pcount < ct.amount) { ScriptManager.RegisterStartupScript( this, this.GetType(), "alert", "alert('Số lượng sản phẩm vượt quá số lượng cho phép');" + "location.href='default.aspx?page=cart';", true); ct.amount = 1; BindRepeater(); } else { BindRepeater(); } } } if (e.CommandName.ToLower() == "remove") { string pid = e.CommandArgument.ToString(); if (pid != null) { Cart_Temp.Delete(list, int.Parse(pid)); } BindRepeater(); } if (e.CommandName.ToLower() == "checkout") { if (Session["user"] == null) { Response.Redirect("AccLogin.aspx"); return; } Session["Cart"] = null; Response.Redirect("Default.aspx"); } }
protected void rptcartV_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.ToLower() == "update") { TextBox txtSl = (TextBox)e.Item.FindControl("txtSoluong"); string pid = e.CommandArgument.ToString(); Cart_Temp ct = Cart_Temp.FindProduct(list, int.Parse(pid)); if (ct != null) { ct.amount = int.Parse(txtSl.Text); } BindRepeater(); } if (e.CommandName.ToLower() == "remove") { string pid = e.CommandArgument.ToString(); if (pid != null) { Cart_Temp.Delete(list, int.Parse(pid)); } BindRepeater(); } if (e.CommandName.ToLower() == "checkout") { if (Session["user"] == null) { Response.Redirect("AccLogin.aspx"); return; } Session["Cart"] = null; Response.Redirect("Default.aspx"); } }