public string ValidateLoginIfo(string userName, string pwd, string isRemember = "false")
        {
            string returnValue;
            try
            {
                TblLoginInfo tblLoginInfo = new TblLoginInfo();

                string currentEncryptePwd = tblLoginInfo.EncryptSha(tblLoginInfo.EncryptMd5(HttpUtility.UrlDecode(pwd)));
                string currentUserName = HttpUtility.UrlDecode(userName).Trim();

                string dbEncryptePwd = tblLoginInfo.GetAll().OrderBy(a => a.ID).FirstOrDefault().Password.ToString();
                string dbUserName = tblLoginInfo.GetAll().OrderBy(a => a.ID).FirstOrDefault().UserName.ToString();

                if (!String.IsNullOrEmpty(currentEncryptePwd) && !String.IsNullOrEmpty(currentUserName) && !String.IsNullOrEmpty(dbEncryptePwd) && !String.IsNullOrEmpty(dbUserName))
                {
                    if (currentUserName == dbUserName)
                    {
                        if (currentEncryptePwd == dbEncryptePwd)
                        {
                            if (isRemember == "true")
                            {
                                FormsAuthentication.RedirectFromLoginPage(userName, true);
                            }
                            else
                            {
                                FormsAuthentication.RedirectFromLoginPage(userName, false);
                            }
                            returnValue = "true";

                            return returnValue;
                        }
                        else
                        {
                            returnValue = "false";
                            return returnValue;
                        }
                    }
                    else
                    {
                        returnValue = "false";
                        return returnValue;
                    }
                }
                else
                {
                    returnValue = "false";
                    return returnValue;
                }
            }
            catch
            {
                returnValue = "false";
                return returnValue;
            }
        }
 public JsonResult GetLoginInfo()
 {
     TblLoginInfo tblLoginInfo = new TblLoginInfo();
     Models.LoginInfo lgIn = new Models.LoginInfo()
     {
         ID = tblLoginInfo.GetAll().OrderByDescending(i => i.ID).FirstOrDefault().ID,
         UserName = tblLoginInfo.GetAll().OrderByDescending(i => i.UserName).FirstOrDefault().UserName
     };
     object loginInfo = lgIn;
     return Json(loginInfo, JsonRequestBehavior.AllowGet);
 }
 public JsonResult GetLoginInfo(bool status)
 {
     TblLoginInfo tblLoginInfo = new TblLoginInfo();
     UpdateStatus lgIn = new UpdateStatus()
     {
         ID = tblLoginInfo.GetAll().OrderByDescending(i => i.ID).FirstOrDefault().ID,
         UserName = tblLoginInfo.GetAll().OrderByDescending(i => i.UserName).FirstOrDefault().UserName,
         Status = status
     };
     object loginInfo = lgIn;
     return Json(loginInfo, JsonRequestBehavior.AllowGet);
 }
        public JsonResult UpdateLoginInfo(int id, string name, string newPwd, string currentPwd)
        {
            TblLoginInfo tblLoginInfo = new TblLoginInfo();

            string currentEncrypte = tblLoginInfo.EncryptSha(tblLoginInfo.EncryptMd5(HttpUtility.UrlDecode(currentPwd)));
            string dbEncrypte = tblLoginInfo.GetAll().OrderBy(a => a.ID).FirstOrDefault().Password.ToString();

            if (currentEncrypte == dbEncrypte)
            {
                string newPwdEncrypte = tblLoginInfo.EncryptSha(tblLoginInfo.EncryptMd5(HttpUtility.UrlDecode(newPwd)));
                Models.LoginInfo loginInfo = new Models.LoginInfo()
                {
                    ID = id,
                    UserName = HttpUtility.UrlDecode(name),
                    Password = newPwdEncrypte,
                    TransactionDate = DateTime.Now.ToString()
                };
                tblLoginInfo.Update(loginInfo);
                return GetLoginInfo();
            }
            else
            {
                return GetLoginInfo(false);
            }
        }