// GET: ThanhToan
 public ActionResult Index()
 {
     if (Session["TaiKhoan"] == null)
     {
         return(View("../DangNhap/Index"));
     }
     else
     {
         HoaDonDAO   dao = new HoaDonDAO();
         KinhContext db  = new KinhContext();
         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 KinhContext();

            Session["Title"]    = "Tìm Kiếm Theo Tên: " + tenMH;
            Session["Products"] = db.Kinhs.Where(i => i.Flag == true && i.TenKinh.Contains(tenMH)).ToList();
            return(RedirectToAction("Index", "MoHinhs"));
        }
Exemplo n.º 3
0
        public ActionResult MoHinh(int id)
        {
            Session["CTBrand"] = null;
            HomeDAO dao = new HomeDAO();
            var     db  = new KinhContext();
            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 KinhContext();
            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 KinhContext();
            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: ChiTietKinh
        public ActionResult Index(int id, int?page)
        {
            KinhContext db = new KinhContext();
            Kinh        mh = db.Kinhs.Find(id);

            mh.LuotXem++;
            db.SaveChanges();
            DanhGiaDAO dao = new DanhGiaDAO();

            Session["CTMoHinh"] = mh;
            if (page != null)
            {
                ViewBag.Roll = "roll";
            }
            return(View(dao.GetList(mh.MaKinh).ToPagedList(page ?? 1, 7)));
        }
        // GET: Paypal
        public ActionResult Index(string ten, string diachi, string SDT)
        {
            var       db     = new KinhContext();
            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.KinhId;
                temp.item_name   = item.Kinh.TenKinh;
                temp.quantity    = item.SoLuong / item.SoLuong;
                double thanhTien = item.ThanhTien - (item.ThanhTien * ((phanTram * 1.0) / 100));
                temp.amount = Math.Round(((thanhTien) * 1.0) / (1 * 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 KinhContext();
            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.Kinhs.Find(item.KinhId);
                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"));
        }
Exemplo n.º 9
0
 public HoaDonDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 10
0
 public DanhGiaDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 11
0
 public AdminDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 12
0
 public NSXDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 13
0
 public LoaiDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 14
0
 public ChartDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 15
0
 public HomeDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 16
0
 public KhuyenMaiDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 17
0
 public TaiKhoanDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 18
0
 public KinhDAO()
 {
     db = new KinhContext();
 }
Exemplo n.º 19
0
 public KhachHangDAO()
 {
     db = new KinhContext();
 }