public ActionResult Login(LoginModel User, string returnUrl)
        {
            ViewBag.Error = null;
            if (ModelState.IsValid)
            {
                User.Password = PasswordHelper.EncryptData(User.Password);
                bool     IsActive = false;
                Employee employee = null;
                if (ManageAccount.ValidateUser(User, ref IsActive, ref employee))
                {
                    Session["username"]  = User.UserName;
                    Session["fullname"]  = employee.EmployeeName;
                    Session["empid"]     = employee.EmpID;
                    Session["ismanager"] = employee.IsManager;
                    if (User.RememberMe)
                    {
                        HttpCookie ckUserName = new HttpCookie("username");
                        ckUserName.Expires = DateTime.Now.AddSeconds(3600);
                        ckUserName.Value   = User.UserName.ToString();
                        Response.Cookies.Add(ckUserName);

                        HttpCookie ckPassword = new HttpCookie("password");
                        ckPassword.Expires = DateTime.Now.AddSeconds(3600);
                        ckPassword.Value   = User.Password.ToString();
                        Response.Cookies.Add(ckPassword);
                    }
                    if ((returnUrl != null) && (returnUrl != ""))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("DisplayPriority", "EmployeePriority"));
                    }
                }
                else
                {
                    if (IsActive == false)
                    {
                        ViewBag.Error = "Your account is inactive!";
                        return(View());
                    }
                    else
                    {
                        ViewBag.Error = "Invalid Credential!";
                        return(View());
                    }
                }
            }
            return(View());
        }
        //
        // GET: /Account/

        public ActionResult Login(string returnUrl)
        {
            Session.Remove("username");
            Session.Remove("fullname");
            Session.Remove("empid");
            Session.Remove("ismanager");
            Session.Remove("uploadReport");
            ViewBag.Error     = null;
            ViewBag.returnUrl = returnUrl;
            LoginModel User     = checkCookies();
            bool       IsActive = false;
            Employee   employee = null;

            if (User != null)
            {
                if (ManageAccount.ValidateUser(User, ref IsActive, ref employee))
                {
                    Session["username"]  = User.UserName;
                    Session["fullname"]  = employee.EmployeeName;
                    Session["empid"]     = employee.EmpID;
                    Session["ismanager"] = employee.IsManager;
                    return(RedirectToAction("DisplayPriority", "EmployeePriority"));
                }
                else
                {
                    if (Response.Cookies["username"] != null)
                    {
                        HttpCookie ckUserName = new HttpCookie("username");
                        ckUserName.Expires = DateTime.Now.AddDays(-1d);
                        Response.Cookies.Add(ckUserName);
                    }
                    if (Response.Cookies["password"] != null)
                    {
                        HttpCookie ckPassword = new HttpCookie("password");
                        ckPassword.Expires = DateTime.Now.AddDays(-1d);
                        Response.Cookies.Add(ckPassword);
                    }
                    //if (IsActive == false)
                    //{
                    //    ViewBag.Error = "Your account is inactive!";
                    //    return View();
                    //}
                    //else
                    //{
                    //    ViewBag.Error = "Invalid Credential!";
                    //    return View();
                    //}
                }
            }
            return(View());
        }