Exemplo n.º 1
0
        public ActionResult Modify(string oldPassword, string newPassword, string confirmPassword)
        {
            UserInfo user     = Commom.ReadUserInfo();
            string   strError = string.Empty;

            user.PassWord = Common.Basic_Func.JiaMi(oldPassword);
            User_Func func = new User_Func();

            if (!func.UserLogin(ref user, ref strError))
            {
                ViewData["errorMsg"] = "原始密码不正确!";
                return(View("ModifyPassword"));
            }

            user.IsChangePwd = true;
            user.PassWord    = Common.Basic_Func.JiaMi(newPassword);
            user.RePassword  = Common.Basic_Func.JiaMi(confirmPassword);
            if (!func.ChangeUserPassword(user, ref strError))
            {
                // 数据有误
                ViewData["errorMsg"] = "修改密码失败:" + strError;
                return(View("ModifyPassword"));
            }
            else
            {
                // 数据有误
                ViewData["errorMsg"] = "修改成功退出重新登陆!";
                return(View("ModifyPassword"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Login(string userName, string password, string UserSelect, string remember_me)
        {
            UserInfo user = new UserInfo();

            user.UserNo   = userName;
            user.PassWord = Common.Basic_Func.JiaMi(password);
            string    strError = "";
            User_Func func     = new User_Func();

            if (func.UserLogin(ref user, ref strError))
            {
                HttpCookie hc = new HttpCookie("userinfo");
                hc["UserNo"] = user.UserNo;
                hc.Expires   = DateTime.Now.AddDays(2); //设置过期时间
                Response.Cookies.Add(hc);               //保存到客户端

                //// 登录成功
                //this.TempData["lstMenu"] = user.lstMenu;
                return(RedirectToAction("Home_Page", "HomePage_Main"));
            }
            else
            {
                // 登录失败
                //Custom.MessageWrite(Response, "用户名和密码不匹配,登录失败!");
                ViewData["Msg"] = "用户名和密码不匹配,登录失败!";
                return(View());
            }

            ////记住密码
            //loginService.RemberMe(Response, remember_me,UserSelect);

            ////从用户名Txt文档中取出历史记录显示在页面上
            //string[] Users = loginService.UsersOut(Response);
            //ViewData["Users"] = Users;

            //string MdPassword = com.md5(password);
            ////后台判断用户名和密码是否为空
            //if (String.IsNullOrEmpty(userName))
            //{
            //    Custom.MessageWrite(Response, "用户名不能为空!");
            //    return View();
            //}
            //if (String.IsNullOrEmpty(password))
            //{
            //    Custom.MessageWrite(Response, "密码不能为空!");
            //    return View();
            //}
            ////密码和用户名都输入了,数据库判断是否符合要求
            //if (!String.IsNullOrEmpty(userName) && !String.IsNullOrEmpty(password))
            //{
            //    if (loginService.checkUser(userName, MdPassword) == 1)
            //    {
            //        // 登录成功
            //        return RedirectToAction("Home_Page", "HomePage_Main");
            //    }
            //    else
            //    {
            //        if (loginService.checkUser(userName, MdPassword) == 2)
            //        {
            //            //用户名已经被注销,登录失败
            //            Custom.MessageWrite(Response, "该用户名已经被注销,请重新登录!");
            //        }
            //        else
            //        {
            //            // 登录失败
            //            Custom.MessageWrite(Response, "用户名和密码不匹配,登录失败!");
            //            return View();

            //        }
            //    }
            //}
            //return View();
        }
Exemplo n.º 3
0
        public bool UserLogin(ref UserInfo user, ref string strError)
        {
            User_Func tfunc = new User_Func();

            return(tfunc.UserLogin(ref user, ref strError));
        }