public ActionResult Create(TaiKhoan taikhoan)
        {
            if (ModelState.IsValid)
            {
                taikhoan.An = false;
                taikhoan.NgayTao = DateTime.Today;
                db.TaiKhoans.Add(taikhoan);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.MaLoaiTK = new SelectList(db.LoaiTaiKhoans, "MaLoaiTK", "LoaiTK", taikhoan.MaLoaiTK);
            return View(taikhoan);
        }
 public ActionResult Login(TaiKhoan taikhoan)
 {
     if (ModelState.IsValid)
     {
         foreach (var taikhoans in db.TaiKhoans)
         {
             if (taikhoan.TenTK == taikhoans.TenTK && taikhoan.MatKhau == taikhoans.MatKhau && taikhoans.MaLoaiTK==1 && taikhoans.An == false || taikhoans.An == null  )
                 Session["LogedName"] = taikhoans.HoTen;
                 return RedirectToAction("Index", "QTTaiKhoan");
         }
         return RedirectToAction("Login");
     }
     ViewBag.MaLoaiTK = new SelectList(db.LoaiTaiKhoans, "MaLoaiTK", "LoaiTK", taikhoan.MaLoaiTK);
     return View(taikhoan);
 }
 public ActionResult Login(TaiKhoan taikhoan,FormCollection coll)
 {
     //if (ModelState.IsValid)
     //{
         foreach (var taikhoans in db.TaiKhoans)
         {
             if (coll["Tentk"] == taikhoans.TenTK && coll["Password"] == taikhoans.MatKhau)
             {
                 Session["MaTK"] = taikhoans.MaTK;
                 return RedirectToAction("Index", "Home");
             }
         }
         return RedirectToAction("Login");
     //}
     //ViewBag.MaLoaiTK = new SelectList(db.LoaiTaiKhoans, "MaLoaiTK", "LoaiTK", taikhoan.MaLoaiTK);
     //return View(taikhoan);
 }
 public ActionResult Login(TaiKhoan taikhoan)
 {
     if (ModelState.IsValid)
     {
         foreach (var taikhoans in db.TaiKhoans)
         {
             if (taikhoan.TenTK == taikhoans.TenTK && taikhoan.MatKhau == taikhoans.MatKhau)
             {
                 Session["FullName"] = taikhoans.HoTen;
                 Session["MaTK"] = taikhoans.MaTK;
                 return RedirectToAction("Index", "Home");
             }
         }
         return RedirectToAction("Login");
     }
     ViewBag.MaLoaiTK = new SelectList(db.LoaiTaiKhoans, "MaLoaiTK", "LoaiTK", taikhoan.MaLoaiTK);
     return View(taikhoan);
 }
 public ActionResult Edit(TaiKhoan taikhoan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(taikhoan).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.MaLoaiTK = new SelectList(db.LoaiTaiKhoans, "MaLoaiTK", "LoaiTK", taikhoan.MaLoaiTK);
     return View(taikhoan);
 }
        public ActionResult Register(TaiKhoan taikhoan)
        {
            if (ModelState.IsValid)
            {
                taikhoan.NgayTao = DateTime.Today;
                taikhoan.An = false;
                taikhoan.MaLoaiTK = 4;
                db.TaiKhoans.Add(taikhoan);
                db.SaveChanges();
                Session["FullName"] = taikhoan.HoTen;
                Session["MaTK"] = taikhoan.MaTK;
                return RedirectToAction("Index","Home");
            }

            ViewBag.MaLoaiTK = new SelectList(db.LoaiTaiKhoans, "MaLoaiTK", "LoaiTK", taikhoan.MaLoaiTK);
            return View(taikhoan);
        }