public ActionResult Create(DatHang dathang)
        {
            if (ModelState.IsValid)
            {
                dathang.NgayDat = DateTime.Today;
                dathang.GiaHan = 1;
                db.DatHangs.Add(dathang);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.MaBD = new SelectList(db.BangDias, "MaBD", "TenBD", dathang.MaBD);
            ViewBag.MaLoaiHinh = new SelectList(db.LoaiHinhGiaoDiches, "MaLoaiHinh", "TenLoaiHinh", dathang.MaLoaiHinh);
            ViewBag.MaTK = new SelectList(db.TaiKhoans, "MaTK", "TenTK", dathang.MaTK);
            return View(dathang);
        }
 public ActionResult GiaHan(DatHang dathang)
 {
     if (ModelState.IsValid)
     {
         dathang.GiaHan = dathang.GiaHan+1;
         db.Entry(dathang).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.MaBD = new SelectList(db.BangDias, "MaBD", "TenBD", dathang.MaBD);
     ViewBag.MaLoaiHinh = new SelectList(db.LoaiHinhGiaoDiches, "MaLoaiHinh", "TenLoaiHinh", dathang.MaLoaiHinh);
     ViewBag.MaTK = new SelectList(db.TaiKhoans, "MaTK", "TenTK", dathang.MaTK);
     return View(dathang);
 }
 public ActionResult Thue(int id)
 {
     if (Session["MaTK"].ToString() == "" || Session["MaTK"].ToString() == "2")
     {
         Session["Error"] = "Bạn chưa đăng nhập ! Hãy đăng nhập để đặt hàng.";
         Response.Redirect(@"~\Home\Error");
     }
     else
     {
         var dathang = new DatHang();
         var bangdia = db.BangDias.Find(id);
         bangdia.LuotThue = bangdia.LuotThue + 1;
         dathang.MaLoaiHinh = 2;
         dathang.MaTK = Convert.ToInt32(Session["MaTK"].ToString());
         dathang.MaBD = id;
         dathang.Tra = false;
         dathang.NgayDat = DateTime.Today;
         dathang.GiaHan = 1;
         if (ModelState.IsValid)
         {
             db.Entry(bangdia).State = EntityState.Modified;
             db.DatHangs.Add(dathang);
             db.SaveChanges();
         }
         return View(dathang);
     }
     return RedirectToAction("Login", "Account");
 }