Ejemplo n.º 1
0
        public ActionResult ULogin()
        {
            try
            {
                string sUCode = Request["UserCode"];
                string sUPwd  = Request["Password"];

                TUserInfo  uinfo = TUserInfoBLL.ULogin(sUCode, sUPwd);
                JsonResult jr    = new JsonResult();
                if (uinfo == null)
                {
                    jr.Data = new { code = -1, errmsg = "用户名或密码错误" };
                    var url = "~/UserInfo/Index?ErrMsg=" + JsonHelper.SerializeObject(jr.Data);
                    Server.TransferRequest(url, true);
                    return(new EmptyResult());
                }
                else
                {
                    jr.Data = new { code = 1, userInfo = uinfo };
                    var url = "~/MainMenu/Index?userInfo=" + JsonHelper.SerializeObject(uinfo);

                    Server.TransferRequest(url, true);
                    //return RedirectToAction("Index", "MainMenu");
                    return(new EmptyResult());
                }
                //RedirectToAction("Index", "MainMenu");

                //return jr;
            }
            catch (Exception e)
            {
                LogHelper.WriteLog("ULogin", e);
                return(Content(JsonHelper.SerializeObject(new { code = -1, errmsg = "非常抱歉,登录失败" })));
            }
        }
Ejemplo n.º 2
0
        // GET: Maintain
        public ActionResult EditInfo()
        {
            List <TMaintainType> lm = new List <TMaintainType>();
            List <TUserInfo>     lu = new List <TUserInfo>();

            lm = TMaintainTypeBLL.UGetMaintainTypes(String.Empty);
            lu = TUserInfoBLL.UGetUserInfosByCondition("where UState = 1 and UID in (select distinct UID from tUserGroup where GID in (100002,100003,100004))");

            ViewBag.maintainType = lm;
            ViewBag.technicians  = lu;
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult UEditUserInfo()
        {
            string    userjson = Request["userInfo"];
            TUserInfo userdata = null;

            if ((userjson == null) || (userjson == String.Empty))
            {
                if (Request["UserCode"] == null || Request["UserCode"] == String.Empty ||
                    Request["Password"] == null || Request["Password"] == String.Empty
                    )
                {
                    return(RedirectToAction("Index", "UserInfo"));
                }
                else
                {
                    string sUCode = Request["UserCode"];
                    string sUPwd  = Request["Password"];

                    userdata = TUserInfoBLL.ULogin(sUCode, sUPwd);
                }
            }
            else
            {
                userdata = JsonHelper.DeserializeJsonToObject <TUserInfo>(Request["userInfo"]);
            }
            //判断是否有管理员权限
            bool IsCanEditInfo = false;

            foreach (var item in userdata.Usergroups)
            {
                if (item.GType == 1)
                {
                    IsCanEditInfo = true;
                }
            }
            if (IsCanEditInfo == false)
            {
                return(Content(JsonHelper.SerializeObject(new { code = -1, errmsg = "无该操作权限" })));
            }

            return(View());
        }
Ejemplo n.º 4
0
        // GET: MainMenu
        public ActionResult Index()
        {
            string    userjson = Request["userInfo"];
            TUserInfo userdata = null;

            if ((userjson == null) || (userjson == String.Empty))
            {
                if (Request["UserCode"] == null || Request["UserCode"] == String.Empty ||
                    Request["Password"] == null || Request["Password"] == String.Empty
                    )
                {
                    return(RedirectToAction("Index", "UserInfo"));
                }
                else
                {
                    string sUCode = Request["UserCode"];
                    string sUPwd  = Request["Password"];

                    userdata = TUserInfoBLL.ULogin(sUCode, sUPwd);
                }
            }
            else
            {
                userdata = JsonHelper.DeserializeJsonToObject <TUserInfo>(Request["userInfo"]);
            }

            if (userdata == null)
            {
                return(RedirectToAction("Index", "UserInfo"));
            }
            else
            {
                bool       bSaveUser     = false;
                HttpCookie pwdCookie     = null;
                HttpCookie uerCodeCookie = null;
                HttpCookie remberCookie  = null;
                if (Request.Cookies["UserCode"] != null)
                {
                    uerCodeCookie = Request.Cookies["UserCode"];
                }
                if (Request.Cookies["rememberUser"] != null)
                {
                    remberCookie = Request.Cookies["rememberUser"];
                    bSaveUser    = remberCookie.Value == "true";
                }
                if (Request.Cookies["Password"] != null)
                {
                    pwdCookie = Request.Cookies["Password"];
                }


                pwdCookie.Value    = Security.UGetMd5Str(userdata.Uid.ToString() + userdata.Upassword);
                pwdCookie.Path     = "/";
                uerCodeCookie.Path = "/";
                remberCookie.Path  = "/";


                if (bSaveUser)
                {
                    pwdCookie.Expires     = DateTime.Now.AddDays(15);
                    uerCodeCookie.Expires = DateTime.Now.AddDays(15);
                    remberCookie.Expires  = DateTime.Now.AddDays(15);
                }
                else
                {
                    pwdCookie.Expires     = DateTime.Now.AddDays(-1);
                    uerCodeCookie.Expires = DateTime.Now.AddDays(-1);
                    remberCookie.Expires  = DateTime.Now.AddDays(-1);
                }
                Response.Cookies.Add(pwdCookie);
                Response.Cookies.Add(uerCodeCookie);
                Response.Cookies.Add(remberCookie);

                return(View());
            }
        }