protected void btnThanhToan_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["TenTK"]; if (cookie != null) { string tentk = cookie.Value; TaiKhoanDTO tk = TaiKhoanBUS.LayThongTinTK(tentk); HoaDonDTO hd = new HoaDonDTO(); hd.TenTaiKhoan = tentk; hd.NgayMua = DateTime.Now; hd.DiaChiGiaoHang = tk.DiaChi; hd.SdtGiaoHang = tk.SoDienThoai; hd.TongTien = GioHangBUS.TinhTongTienGH(tentk); hd.MaHD = HoaDonBUS.ThemHD(hd); DataTable dtbKQ = GioHangBUS.LayGH(tentk); foreach (DataRow dr in dtbKQ.Rows) { CTHoaDonDTO cthd = new CTHoaDonDTO(); cthd.MaHD = hd.MaHD; cthd.MaHoa = dr["MaHoa"].ToString(); cthd.SoLuong = Convert.ToInt32(dr["SoLuong"]); cthd.DonGia = Convert.ToInt32(dr["GiaTien"]); CTHoaDonBUS.ThemCTHD(cthd); } } }
protected void rptSanPham_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "ThemGH") { HttpCookie cookie = Request.Cookies["TenTK"]; if (cookie != null) { GioHangDTO gh = new GioHangDTO(); gh.TenTaiKhoan = cookie.Value; gh.MaSP = e.CommandArgument.ToString(); gh.SoLuong = 1; if (GioHangBUS.ThemGH(gh)) { Response.Redirect("GioHang.aspx"); } else { Response.Write("<script>alert('Thêm thất bại')</script>"); } } else { Response.Redirect("DangNhap.aspx"); } } }
public string CheckSoLuongCart(string idsizesanpham, int soluong) { GioHangBUS giohangbus = new GioHangBUS(); string thongbao = giohangbus.CheckSoLuongCart(idsizesanpham, soluong); return(thongbao); }
protected void grv_dondathang_RowDeleting(object sender, GridViewDeleteEventArgs e) { string sogh = grv_dondathang.DataKeys[e.RowIndex].Value.ToString(); GioHangBUS.giohang_delete(sogh); giohang_show(); }
protected void btnADD_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["TenTK"]; if (cookie != null) { GioHangDTO gh = new GioHangDTO(); gh.TenTaiKhoan = cookie.Value; gh.MaSP = lblMaSP.Text; gh.SizeGiay = DropDownList_size.SelectedItem.Text; gh.SoLuong = Convert.ToInt32(txtSoluong.Text); if (gh.SoLuong > Convert.ToInt32(lblSLTK.Text)) { Response.Write("<script>alert('Thêm thất bại')</script>"); } else if (GioHangBUS.ThemGH(gh)) { Response.Redirect("GioHang.aspx"); } else { Response.Write("<script>alert('Thêm thất bại')</script>"); } } else { Response.Redirect("DangNhap.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { ((Home)this.Master).isVisible = false; if (base._NguoiDungHienTai == null) { ((Home)this.Master).isLogIn = true; } else { ((Home)this.Master).isLogIn = false; } GioHangBUS gioHangBUS = new GioHangBUS(); GioHangDTO gioHang = new GioHangDTO(); gioHang.IdSanPham = int.Parse(Request.QueryString["IdSanPham"]); gioHang.CartGuid = CartGUID; gioHang.SoLuong = 1; gioHangBUS._gioHang = gioHang; try { gioHangBUS.Insert(); } catch { Response.Redirect("Trangloi.aspx"); } Response.Redirect("~/customer/cart"); }
protected void btnThanhToan_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["TenTK"]; if (cookie != null) { string tenTK = cookie.Value; HoaDonDTO hd = new HoaDonDTO(); hd.TenTaiKhoan = tenTK; hd.NgayMua = DateTime.Now; hd.DiaChiGiaoHang = "Tp.HCM"; hd.SDTGiaoHang = "0905939947"; hd.TongTien = GioHangBUS.TinhTongTienGH(tenTK); hd.MaHD = HoaDonBUS.ThemHD(hd); DataTable dtbKetQua = GioHangBUS.LayGH(tenTK); foreach (DataRow dr in dtbKetQua.Rows) { CTHoaDonDTO cthd = new CTHoaDonDTO(); cthd.MaHD = hd.MaHD; cthd.MaSP = dr["MaSP"].ToString(); cthd.SoLuong = Convert.ToInt32(dr["SoLuong"]); cthd.DonGia = Convert.ToInt32(dr["GiaTien"]); CTHoaDonBUS.ThemCTHD(cthd); } } }
public IActionResult Index(string id) { string idd = id ?? "B77D9CF5-E9A2-4D31-9490-25E4E3971C61"; //BUS SanPhamBUS sanphambus = new SanPhamBUS(); SizeSanPhamBUS sizesanphambus = new SizeSanPhamBUS(); GioHangBUS giohangbus = new GioHangBUS(); DiaChiBUS diachibus = new DiaChiBUS(); SanPham sanpham = sanphambus.GetSanPham(idd); DiaChi diachi = diachibus.GetDiaChiMer(sanpham.IdTaiKhoanNavigation.TenDangNhap); ViewBag.DiaChiMerchant = diachi; List <SizeSanPham> listsizesanpham = sizesanphambus.GetSize(idd); ViewBag.ListSizeSanPham = listsizesanpham; List <HangSanPham> hang = ctx.HangSanPham.ToList(); ViewBag.Hang = hang; List <SanPham> spmoi = sanphambus.GetSanPhams("", "", 1, 4); ViewBag.SanPhamMoi = spmoi; return(View(sanpham)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HienThiDanhMucSanPham(); cardArea.Visible = isVisible; slideShow.Visible = isVisible; imgAdv.Visible = isVisible; //lblOnline.Text = Application["SoNguoiOnLine"].ToString(); anonymous.Visible = isLogIn; authen.Visible = !isLogIn; dem = 0; GioHangDTO gioHang = new GioHangDTO(); gioHang.CartGuid = CartGUID; GioHangBUS gioHangBUS = new GioHangBUS(); gioHangBUS._gioHang = gioHang; gioHangBUS.Select(); GridView gridView = new GridView(); gridView.DataSource = gioHangBUS.KetQua; gridView.DataBind(); foreach (GridViewRow row in gridView.Rows) { dem += int.Parse(row.Cells[3].Text); } productQuantity.Text = dem.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { /*if (!Page.IsPostBack) * { * rptGioHang.DataSource = GioHangBUS.LayDSGioHang(tenTk); * rptGioHang.DataBind(); * }*/ HttpCookie cookie = Request.Cookies["TenTK"]; if (cookie != null) { string tenTK = cookie.Value; if (!Page.IsPostBack) { DataTable dtbKetQua = GioHangBUS.LayDSGioHang(tenTK); rptGioHang.DataSource = dtbKetQua; rptGioHang.DataBind(); lblTongTien.Text = GioHangBUS.TinhTongTienGH(tenTK).ToString(); } } else { Response.Redirect("DangNhap.aspx"); } }
protected void grv_dondathang_RowUpdating(object sender, GridViewUpdateEventArgs e) { string sogh = grv_dondathang.DataKeys[e.RowIndex].Value.ToString(); bool tinhtrang = ((CheckBox)grv_dondathang.Rows[e.RowIndex].FindControl("chk_tinhtrang")).Checked; GioHangBUS.giohang_update(sogh, tinhtrang); grv_dondathang.EditIndex = -1; giohang_show(); }
// GET: ThanhToan public ActionResult Index() { List <GioHang> ds = GioHangBUS.DanhSach(User.Identity.GetUserId()).ToList(); if (ds.Count() == 0) { return(RedirectToAction("../Shop/index")); } return(View(ds)); }
protected void grvGioHang_RowCommand(object sender, GridViewCommandEventArgs e) { string maHoa = e.CommandArgument.ToString(); if (e.CommandName == "Delete") { GioHangBUS.XoaitemGH(maHoa); Response.Redirect(Request.RawUrl); } }
public void AddQuantity(string tendangnhap, string idsizesanpham, int quantity) { if (tendangnhap != null && tendangnhap != "") { TaiKhoanBUS taikhoanbus = new TaiKhoanBUS(); TaiKhoan taikhoan = taikhoanbus.CheckTaiKhoan(tendangnhap); GioHangBUS giohangbus = new GioHangBUS(); giohangbus.AddQuantity(taikhoan.Id.ToString(), idsizesanpham, quantity); } }
public ActionResult CapNhat(string masanpham, string tensanpham, int soluong, int gia, string hinhchinh) { try { GioHangBUS.CapNhat(masanpham, User.Identity.GetUserId(), tensanpham, soluong, gia, hinhchinh); return(RedirectToAction("Index")); //them thanh cong } catch { return(RedirectToAction("../MobiShop/Index")); //them ko thanh cong } }
public ActionResult CapNhat(string masanpham, string tensanpham, int gia, int soluong) { try { GioHangBUS.CapNhat(masanpham, User.Identity.GetUserId(), gia, soluong, tensanpham); return(RedirectToAction("Index")); } catch { return(RedirectToAction("../Shop/Index")); } }
public ActionResult Xoa(string masanpham) { try { GioHangBUS.Xoa(masanpham, User.Identity.GetUserId()); return(RedirectToAction("index")); } catch { return(RedirectToAction("../Shop/index")); } }
public ActionResult Them(string masanpham, int soluong, int gia, string tensanpham) { try { GioHangBUS.Them(masanpham, User.Identity.GetUserId(), soluong, gia, tensanpham); return(RedirectToAction("index")); } catch { return(RedirectToAction("../Shop/index")); } }
public ActionResult Xoa(string masanpham) { try { GioHangBUS.Xoa(masanpham, User.Identity.GetUserId()); return(RedirectToAction("Index")); //them thanh cong } catch { return(RedirectToAction("../MobiShop/Index")); //them ko thanh cong } }
protected void gridgiohang_PageIndexChanging(object sender, GridViewPageEventArgs e) { gridgiohang.PageIndex = e.NewPageIndex; GioHangDTO gioHang = new GioHangDTO(); gioHang.CartGuid = CartGUID; GioHangBUS gioHangBUS = new GioHangBUS(); gioHangBUS._gioHang = gioHang; gioHangBUS.Select(); gioHangBUS.Select(); gridgiohang.DataSource = gioHangBUS.KetQua; gridgiohang.DataBind(); }
public IActionResult ChiTiet(string Ma) { SanPham sp = ctx.SanPham.Where(s => s.MaSanPham == Ma).SingleOrDefault(); SanPhamBUS sanphambus = new SanPhamBUS(); SizeSanPhamBUS sizesanphambus = new SizeSanPhamBUS(); GioHangBUS giohangbus = new GioHangBUS(); List <SizeSanPham> listsizesanpham = sizesanphambus.GetSize(Ma); ViewBag.ListSizeSanPham = listsizesanpham; List <HangSanPham> hang = ctx.HangSanPham.ToList(); ViewBag.Hang = hang; return(View("ChiTiet")); }
public ActionResult ThanhToan() { IEnumerable <v_GioHang> dsCTGH = GioHangBUS.DanhSach(User.Identity.GetUserId()); int TongTien = 0; foreach (var item in dsCTGH) { TongTien += (int)item.SoLuong * (int)item.GiaBan; } ViewBag.Total = TongTien; ViewBag.id = User.Identity.GetUserId(); // OrderBUS.Them(User.Identity.GetUserId(), TongTien); //GioHangBUS.remove(User.Identity.GetUserId()); return(View(dsCTGH)); }
public IActionResult DeleteFromCart(string idsizesanpham) { string checktendangnhap = HttpContext.Session.GetString("TenDangNhap"); if (checktendangnhap != null && checktendangnhap != "") { string tendangnhap = HttpContext.Session.GetString("TenDangNhap"); TaiKhoanBUS taikhoanbus = new TaiKhoanBUS(); TaiKhoan taikhoan = taikhoanbus.CheckTaiKhoan(tendangnhap); GioHangBUS giohangbus = new GioHangBUS(); string thongbao = giohangbus.DeleteFromCart(taikhoan.Id.ToString(), idsizesanpham); return(RedirectToAction("GioHang", "SanPham", new { tendangnhap = tendangnhap })); } return(RedirectToAction("Index", "Home")); }
protected void ddl_tinhtrang_SelectedIndexChanged(object sender, EventArgs e) { bool tinhtrang = true; if (ddl_tinhtrang.SelectedValue != "") { tinhtrang = bool.Parse(ddl_tinhtrang.SelectedValue); grv_dondathang.DataSource = GioHangBUS.giohang_selectBytinhtrang(tinhtrang); grv_dondathang.DataBind(); } else { giohang_show(); } }
public string AddToCart(string idsizesanpham, int soluong) { string checktendangnhap = HttpContext.Session.GetString("TenDangNhap"); if (checktendangnhap != null && checktendangnhap != "") { string tendangnhap = HttpContext.Session.GetString("TenDangNhap"); TaiKhoanBUS taikhoanbus = new TaiKhoanBUS(); TaiKhoan taikhoan = taikhoanbus.CheckTaiKhoan(tendangnhap); GioHangBUS giohangbus = new GioHangBUS(); string thongbao = giohangbus.AddToCart(taikhoan.Id.ToString(), idsizesanpham, soluong); return(thongbao); } return(""); }
protected void btn_tim_giohang_Bysogh_Click(object sender, EventArgs e) { string sogh = txt_sogh.Text; DataTable dt = GioHangBUS.giohang_selectBySogh(sogh); if (dt != null) { grv_dondathang.DataSource = dt; grv_dondathang.DataBind(); } else { Response.Write("<script>alert('Số giỏ hàng không tồn tại')</script>"); } }
//--------------------Thủ tục Delete()------------------ private void Delete(int id) { GioHangBUS gioHangBUS = new GioHangBUS(); GioHangDTO gioHang = new GioHangDTO(); gioHang.IdGioHang = id; gioHangBUS._gioHang = gioHang; try { gioHangBUS.Delete(); } catch { Response.Redirect("Trangloi.aspx"); } }
//------------Thủ tục Update------------------ private void Update(int id, int soluong) { GioHangBUS gioHangBUS = new GioHangBUS(); GioHangDTO gioHang = new GioHangDTO(); gioHang.SoLuong = soluong; gioHang.IdGioHang = id; gioHangBUS._gioHang = gioHang; try { gioHangBUS.Update(); } catch { Response.Redirect("Trangloi.aspx"); } }
public IActionResult GioHang(string tendangnhap, string cart) { string thongbao = ""; List <GioHang> list = new List <GioHang>(); GioHangBUS giohangbus = new GioHangBUS(); Dictionary <string, int> json = new Dictionary <string, int>(); if (cart != null && cart != "") { json = JsonConvert.DeserializeObject <Dictionary <string, int> >(cart); } if (tendangnhap != "" && tendangnhap != null) { TaiKhoanBUS taikhoanbus = new TaiKhoanBUS(); TaiKhoan taikhoan = taikhoanbus.CheckTaiKhoan(tendangnhap); if (json.Count > 0) { foreach (var item in json) { thongbao = giohangbus.AddToCartByStorage(taikhoan.Id.ToString(), item.Key, item.Value); } } list = giohangbus.GetGioHangs(tendangnhap); } else { if (json.Count > 0) { foreach (var item in json) { GioHang giohang = new GioHang(); giohang = giohangbus.AddSingleItem(item); list.Add(giohang); } } } List <HangSanPham> hang = ctx.HangSanPham.ToList(); ViewBag.Hang = hang; return(View(list)); }
private void HienThiGioHang() { GioHangDTO gioHang = new GioHangDTO(); gioHang.CartGuid = TaoCartGuid.LayCartGUID(); GioHangBUS gioHangBUS = new GioHangBUS(); gioHangBUS._gioHang = gioHang; try { gioHangBUS.Select(); gridgiohang.DataSource = gioHangBUS.KetQua; gridgiohang.DataBind(); } catch { Response.Redirect("Trangloi.aspx"); } }