// GET: ThanhToan public ActionResult Index() { if (Session["TaiKhoan"] == null) { return(View("../DangNhap/Index")); } else { HoaDonDAO dao = new HoaDonDAO(); SanPhamContext db = new SanPhamContext(); var tk = Session["TaiKhoan"] as KhachHang; var hd = dao.FindHD(tk.MaKH); if (hd != null) { if (dao.GetListCTHD(hd.MaHD).Count == 0) { ViewBag.Err = "Giỏ hàng trống không thể thanh toán, hãy mua gì đó"; return(View("../Home/Index")); } else { Session["HD"] = hd; return(View()); } } else { ViewBag.Err = "Giỏ hàng trống không thể thanh toán, hãy mua gì đó"; return(View("../Home/Index")); } } }
public ActionResult TimKiem(string tenMH) { var db = new SanPhamContext(); Session["Title"] = "Tìm Kiếm Theo Tên: " + tenMH; Session["Products"] = db.SanPhams.Where(i => i.Flag == true && i.TenSP.Contains(tenMH)).ToList(); return(RedirectToAction("Index", "MoHinhs")); }
public IActionResult Delete(int id) { int row = SanPhamContext.DeleteSanPham(id); if (row == 0) { return(RedirectToAction("Home/ThongBao")); } return(RedirectToAction("Index")); }
public IActionResult Update(SanPham sp) { int row = SanPhamContext.UpdateSanPham(sp); if (row == 0) { return(RedirectToAction("Home/ThongBao")); } return(RedirectToAction("Index")); }
public IActionResult Insert(SanPham sp) { int row = SanPhamContext.InsertSanPham(sp); if (row == 0) { //return RedirectToAction(actionName: "ThongBao", controllerName: "Home"); return(RedirectToAction("Home/ThongBao")); } return(RedirectToAction("Index")); }
public ActionResult MoHinh(int id) { Session["CTBrand"] = null; HomeDAO dao = new HomeDAO(); var db = new SanPhamContext(); var km = db.KhuyenMais.Find(id); Session["Title"] = "Mô Hình Của Chương Trình Khuyến Mãi: " + km.TenKM; Session["CTKhuyenMai"] = km; Session["Products"] = dao.GetListTheoKM(id); return(RedirectToAction("Index", "MoHinhs")); }
public ActionResult MoHinh(int id) { Session["CTKhuyenMai"] = null; HomeDAO dao = new HomeDAO(); var db = new SanPhamContext(); var brand = db.NSXs.Find(id); Session["CTBrand"] = brand; Session["Title"] = "Mô Hình Của " + brand.TenNSX; Session["Products"] = dao.GetListTheoNSX(id); return(RedirectToAction("Index", "MoHinhs")); }
// GET: Home public ActionResult Index() { var db = new SanPhamContext(); Log log = new Log(); log.KHId = 3; log.KhachHang = db.KhachHangs.Find(3); log.Ngay = DateTime.Now; log.HanhDong = "TKhachHang"; log.ChiTiet = "ádasfas"; db.Logs.Add(log); db.SaveChanges(); return(View()); }
// GET: ChiTietSanPham public ActionResult Index(int id, int?page) { SanPhamContext db = new SanPhamContext(); SanPham mh = db.SanPhams.Find(id); mh.LuotXem++; db.SaveChanges(); DanhGiaDAO dao = new DanhGiaDAO(); Session["CTMoHinh"] = mh; if (page != null) { ViewBag.Roll = "roll"; } return(View(dao.GetList(mh.MaSP).ToPagedList(page ?? 1, 7))); }
// GET: Paypal public ActionResult Index(string ten, string diachi, string SDT) { var db = new SanPhamContext(); HoaDonDAO dao = new HoaDonDAO(); var hd = Session["HD"] as HoaDon; var list = new List <Product>(); var tempHD = db.HoaDons.Find(hd.MaHD); tempHD.DiaChi = diachi; tempHD.SDT = SDT; tempHD.TenNguoiNhan = ten; double tong = 0; double phanTram = 0; foreach (var item in db.TichLuys.OrderByDescending(i => i.Diem).ToList()) { if (db.KhachHangs.Find(hd.KHId).DiemTichLuy >= item.Diem) { phanTram = item.PhanTram; break; } } var ls = dao.GetListCTHD(hd.MaHD); foreach (var item in ls) { tong = tong + item.ThanhTien; Product temp = new Product(); temp.item_number = item.SanPhamId; temp.item_name = item.SanPhams.TenSP; temp.quantity = item.SoLuong; double thanhTien = item.ThanhTien - (item.ThanhTien * ((phanTram * 1.0) / 100)); temp.amount = Math.Round(((thanhTien) * 1.0) / (22000 * 1.0), MidpointRounding.ToEven); list.Add(temp); } tempHD.TongTien = Math.Round((tong - (tong * ((7 * 1.0) / 100))), MidpointRounding.ToEven); db.SaveChanges(); return(View(list)); }
public ActionResult GetDataPaypal() { var db = new SanPhamContext(); var hd = Session["HD"] as HoaDon; var tempHD = db.HoaDons.Find(hd.MaHD); tempHD.TinhTrangHoaDon = "Đã Thanh Toán"; tempHD.TinhTrangDonHang = "Đang Giao Hàng"; tempHD.NgayTao = DateTime.Now; foreach (var item in db.ChiTietHoaDons.Where(i => i.HDId == hd.MaHD).ToList()) { var mh = db.SanPhams.Find(item.SanPhamId); mh.SoLuong = mh.SoLuong - item.SoLuong; db.SaveChanges(); } db.SaveChanges(); Session["HD"] = null; Session["ListCTHD"] = null; ViewBag.Err = "Thanh toán thành công"; return(View("../Home/Index")); }
public TaiKhoanDAO() { db = new SanPhamContext(); }
public SanPhamDAO() { db = new SanPhamContext(); }
public KhachHangDAO() { db = new SanPhamContext(); }
public ChartDAO() { db = new SanPhamContext(); }
public KhuyenMaiDAO() { db = new SanPhamContext(); }
public DanhGiaDAO() { db = new SanPhamContext(); }
public IActionResult Update(int id) { SanPham sp = SanPhamContext.FindSanPham(id); return(View(sp)); }
public IActionResult Insert() { List <object> list = SanPhamContext.GetMakms(); return(View(list)); }
public LogDAO() { db = new SanPhamContext(); }
public IActionResult Index() { List <SanPham> list = SanPhamContext.GetSanPhams(); return(View(list)); }
public NSXDAO() { db = new SanPhamContext(); }
public HoaDonDAO() { db = new SanPhamContext(); }
public AdminDAO() { db = new SanPhamContext(); }
public HomeDAO() { db = new SanPhamContext(); }