public ActionResult Index(string txtUsername, string txtPassword, string returnUrl = "/HeThong")
 {
     using (var db = new QLNHEntities())
     {
         string username = txtUsername.Trim().ToLower();
         var obj = db.admins.FirstOrDefault(x => x.email.ToLower() == username);
         if (obj != null)
         {
             if (obj.status_id == 1)
             {
                 if (Common.MaHoa(txtPassword.Trim()).Equals(obj.password))
                 {
                     Session["admss"] = obj.admin_id;
                     Session["admsstype"] = obj.admin_type;
                     Session["admssemail"] = obj.email;
                     if (!String.IsNullOrEmpty(returnUrl))
                     {
                         //Ghi log login
                         Common.NhatKiHeThong("Đăng nhập hệ thống", "Đăng nhập", "Login Form", "Đăng nhập hệ thống ");
                         return Redirect(returnUrl);
                     }
                     else
                     {
                         return Redirect("/HeThong");
                     }
                 }
                 else ViewBag.Alert = "Username or password is wrong";
             }
             else ViewBag.Alert = "This account is locked";
         }
         else ViewBag.Alert = "Username or password is wrong";
     }
     return View();
 }
Exemplo n.º 2
0
        public static bool CheckCity(QLNHEntities db, int cityId)
        {
            bool b = false;
            try
            {

            }
            catch (Exception)
            {
                b = false;
            }
            return b;
        }
Exemplo n.º 3
0
 public static bool ChekSuperAdmin()
 {
     bool status;
     try
     {
         using (var db = new QLNHEntities())
         {
             var adminId = (int)HttpContext.Current.Session["admss"];
             var adminEmail = (string)HttpContext.Current.Session["admssemail"];
             var obj = db.admins.FirstOrDefault(x => x.admin_id == adminId && x.email.Equals(adminEmail) && x.status_id == 1);
             if (obj != null && obj.admin_type == 1)
             {
                 status = true;
             }
             else
             {
                 status = false;
             }
         }
     }
     catch (Exception ex)
     {
         WriteLog(ex.Message + "\n" + ex.StackTrace);
         status = false;
     }
     // hien tai deu vao duoc
     status = true;
     return status;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Write log
 /// </summary>
 /// <param name="content">Log content</param>
 public static void WriteLog(string content)
 {
     using (QLNHEntities db = new QLNHEntities())
     {
         db.LogErrors.Add(new LogError()
         {
             Content = content,
             Created = DateTime.Now
         });
         db.SaveChanges();
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Ghi log he thong
        /// </summary>
        /// <param name="ChucNang">Chuc nang</param>
        /// <param name="HanhDong">Hanh Dong</param>
        /// <param name="DoiTuong">Doi tuong</param>
        /// <param name="NoiDung">Noi dung</param>
        /// <returns></returns>
        public static bool NhatKiHeThong(string ChucNang, string HanhDong, string DoiTuong, string NoiDung)
        {
            bool status  = true ;
            try
            {
                using (var db = new QLNHEntities())
                {
                    var adminId = (int)HttpContext.Current.Session["admss"];
                    var adminEmail = (string)HttpContext.Current.Session["admssemail"];
                    var nhatki = new ANhatKyHeThong();
                    nhatki.NguoiDung = (string)HttpContext.Current.Session["admssemail"];
                    nhatki.ThoiGian  = DateTime.Now;
                    nhatki.ChucNang = ChucNang;
                    nhatki.HanhDong = HanhDong;
                    nhatki.DoiTuong = DoiTuong;
                    nhatki.NoiDung = NoiDung;
                    db.ANhatKyHeThongs.Add(nhatki);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                WriteLog(ex.Message + "\n" + ex.StackTrace);
                status = false;
            }

            return status;
        }
Exemplo n.º 6
0
        public static String GetUserName()
        {
            var userid = Convert.ToInt32(HttpContext.Current.Session["UserID"]);
            using (var db = new QLNHEntities())
            {

                return "";
            }
        }
Exemplo n.º 7
0
 public static String GetCurrentUserName()
 {
     var userid = Convert.ToInt32(HttpContext.Current.Session["UserID"]);
     using (MyProject.Models.QLNHEntities db = new QLNHEntities())
     {
         return "Nguoi dung";
     }
 }