Пример #1
0
        public JsonResult LoginSystem()
        {
            #region 后台系统登录
            string UserName = RequestParameters.Pstring("UserName");
            string Password = RequestParameters.Pstring("Password");

            if (UserName.Length <= 0)
            {
                var sReturnModel = new ReturnMessageModel();
                sReturnModel.ErrorType      = 2;
                sReturnModel.MessageContent = "用户名不能为空.";
                return(Json(sReturnModel));
            }
            if (Password.Length <= 0)
            {
                var sReturnModel = new ReturnMessageModel();
                sReturnModel.ErrorType      = 2;
                sReturnModel.MessageContent = "密码不能为空.";
                return(Json(sReturnModel));
            }
            //  string retVal = "";
            #region
            try
            {
                var usersBll = new BLL_User();
                var item     = usersBll.GetObjectByUser(UserName, HashEncrypt.BgPassWord(Password));
                if (item != null)
                {
                    if (item.user_Sign == (int)StageMode.Normal)
                    {
                        Session["EQUI_USERID"] = HashEncrypt.EncryptQueryString(item.user_Id.ToString());

                        var sReturnModel = new ReturnMessageModel();
                        sReturnModel.ErrorType      = 1;
                        sReturnModel.MessageContent = "登录成功.";
                        return(Json(sReturnModel));
                    }
                    else
                    {
                        var sReturnModel = new ReturnMessageModel();
                        sReturnModel.ErrorType      = 2;
                        sReturnModel.MessageContent = "该账号已停用.";
                        return(Json(sReturnModel));
                    }
                    //  retVal = "该账号已停用."; //登录成功
                }
                else
                {
                    var sReturnModel = new ReturnMessageModel();
                    sReturnModel.ErrorType      = 2;
                    sReturnModel.MessageContent = "账号或密码错误.";
                    return(Json(sReturnModel));
                }
            }
            catch (Exception ex)
            {
                var sReturnModel = new ReturnMessageModel();
                sReturnModel.ErrorType      = 2;
                sReturnModel.MessageContent = "系统异常:" + ex.Message;
                return(Json(sReturnModel));
                //  retVal = "1系统异常:" ;
            }
            #endregion

            //if (retVal == "1")
            //{
            //    var sReturnModel = new ReturnMessageModel();
            //    sReturnModel.ErrorType = 1;
            //    sReturnModel.MessageContent = "登录成功.";
            //    return Json(sReturnModel);
            //}
            //else
            //{
            //    var sReturnModel = new ReturnMessageModel();
            //    sReturnModel.ErrorType = 2;
            //    sReturnModel.MessageContent = retVal;
            //    return Json(sReturnModel);
            //}
            #endregion
        }