Ejemplo n.º 1
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public Dictionary <string, object> Find(Guid ID)
        {
            tuser     = db.Find <T_Users>(w => w.uUsers_ID == ID);
            tuserrole = db.Find <T_UsersRoles>(w => w.uUsersRoles_UsersID == tuser.uUsers_ID);
            troles    = db.Find <T_Roles>(w => w.uRoles_ID == tuserrole.uUsersRoles_RoleID);

            tuser.cUsers_LoginPwd = "";
            var di = new ToJson().GetDictionary(new Dictionary <string, object>()
            {
                { "tuser", tuser },
                { "troles", troles },
                { "status", 1 }
            });

            di["dUsers_CreateTime"] = di["dUsers_CreateTime"].To_DateTimeString();
            return(di);
        }
Ejemplo n.º 2
0
        public ActionResult Checked(string username, string userpwd, string loginCode)
        {
            if (string.IsNullOrEmpty(username))
            {
                throw new MessageBox("请输入用户名", 500);
            }
            if (string.IsNullOrEmpty(userpwd))
            {
                throw new MessageBox("请输入密码", 500);
            }
            //if (string.IsNullOrEmpty(loginCode))
            //    throw new MessageBox("请输入验证码", 500);
            user = db.Find <T_Users>(w => w.cUsers_LoginName == "admin");

            if (Tools.getGuid(user.uUsers_ID).Equals(Guid.Empty))
            {
                throw new MessageBox("用户不存在", 500);
            }
            if (!Tools.getString(user.cUsers_LoginPwd).Trim().Equals(userpwd))//Tools.MD5Encrypt(userpwd)))//
            {
                throw new MessageBox("密码错误", 500);
            }
            //string code = Tools.GetCookie("loginCode");
            //if (string.IsNullOrEmpty(code))
            //    throw new MessageBox("验证码失效", 500);
            //if (!code.ToLower().Equals(loginCode))
            //    throw new MessageBox("验证码不正确", 500);

            tuserroles = db.Find <T_UsersRoles>(w => w.uUsersRoles_UsersID == user.uUsers_ID);

            troles = db.Find <T_Roles>(w => w.uRoles_ID == tuserroles.uUsersRoles_RoleID);

            Session["UserID"] = user.uUsers_ID;

            if (user.cUsers_LoginName.Equals("admin"))
            {
                Session["RoleID"] = "admin";
            }
            else
            {
                Session["RoleID"] = tuserroles.uUsersRoles_RoleID;
            }
            return(Json(new { status = 1, jumpurl = "/Admin/Home/" }, JsonRequestBehavior.DenyGet));
        }