Exemplo n.º 1
0
        /// <summary>
        /// 修改系统用户
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateSysAdminUser(SysAdminUserModel model)
        {
            int    rowcount = 0;
            string sqltxt   = @"UPDATE  dbo.SysAdminUser
SET     UserName = @UserName ,
        UserStatus = @UserStatus ,
        UserEmail = @UserEmail ,
        TruethName = @TruethName ,
        UserPhone = @UserPhone ,
        GID = @GID ,
        GName = @GName ,
        LoginName = @LoginName ,
        PinYin=@PinYin,
        FirstPinYin=@FirstPinYin
WHERE   ID = @id";

            SqlParameter[] paramter =
            {
                new SqlParameter("@UserName",    model.UserName),
                new SqlParameter("@UserPwd",     model.UserPwd),
                new SqlParameter("@UserStatus",  model.UserStatus),
                new SqlParameter("@UserEmail",   model.UserEmail),
                new SqlParameter("@TruethName",  model.TruethName),
                new SqlParameter("@UserPhone",   model.UserPhone),
                new SqlParameter("@GID",         model.GID),
                new SqlParameter("@GName",       model.GName),
                new SqlParameter("@LoginName",   model.LoginName),
                new SqlParameter("@id",          model.ID),
                new SqlParameter("@FirstPinYin", model.FirstPinYin),
                new SqlParameter("@PinYin",      model.PinYin)
            };
            rowcount = helper.ExecuteSql(sqltxt, paramter);
            return(rowcount);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 新插入系统用户
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddNewSysAdminUser(SysAdminUserModel model)
        {
            int    rowcount = 0;
            string sqltxt   = @"INSERT  INTO dbo.SysAdminUser
        ( UserName ,
          UserPwd ,
          UserStatus ,
          UserEmail ,
          TruethName ,
          UserPhone ,
          Question ,
          Answer ,
          GID ,
          GName ,
          LoginName ,
          HeaderImg,
          PinYin,
          FirstPinYin
        )
VALUES  ( @UserName ,
          @UserPwd ,
          @UserStatus ,
          @UserEmail ,
          @TruethName ,
          @UserPhone ,
          @Question ,
          @Answer ,
          @GID ,
          @GName ,
          @LoginName ,
          @HeaderImg,
          @PinYin,
          @FirstPinYin
        )";

            SqlParameter[] paramter =
            {
                new SqlParameter("@UserName",    model.UserName),
                new SqlParameter("@UserPwd",     model.UserPwd),
                new SqlParameter("@UserStatus",  model.UserStatus),
                new SqlParameter("@UserEmail",   model.UserEmail),
                new SqlParameter("@TruethName",  model.TruethName),
                new SqlParameter("@UserPhone",   model.UserPhone),
                new SqlParameter("@Question",    model.Question),
                new SqlParameter("@Answer",      model.Answer),
                new SqlParameter("@GID",         model.GID),
                new SqlParameter("@GName",       model.GName),
                new SqlParameter("@LoginName",   model.LoginName),
                new SqlParameter("@HeaderImg",   model.HeaderImg),
                new SqlParameter("@PinYin",      model.PinYin),
                new SqlParameter("@FirstPinYin", model.FirstPinYin)
            };
            rowcount = helper.ExecuteSql(sqltxt, paramter);
            return(rowcount);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查询用户拥有的菜单权限
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public List <SysAdminMenuModel> GetUserAttributeMenu(SysAdminUserModel user)
        {
            List <SysAdminMenuModel> list = new List <SysAdminMenuModel>();
            string sqltxt = @"SELECT  A.PermissionType ,
        B.ID ,
        B.MenuAlt ,
        b.ActionName ,
        b.AreaName ,
        b.ControllerName ,
        b.FatherID ,
        b.FatherName ,
        b.LinkUrl ,
        b.MenuName ,
        b.MenuType ,
        b.SortIndex,
        B.MenuIcon,
       B.MenuStatus
FROM    dbo.SysAdminGrouprMenu A WITH ( NOLOCK )
        INNER JOIN dbo.SysAdminMenu B WITH ( NOLOCK ) ON A.MID = b.ID
WHERE   A.GID = @gid
        AND b.MenuStatus = 1
       AND A.PermissionType<>4
ORDER BY b.SortIndex ASC";

            SqlParameter[] paramter =
            {
                new SqlParameter("@gid", user.GID)
            };
            DataTable dt = helper.Query(sqltxt, paramter).Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    SysAdminMenuModel model = new SysAdminMenuModel();
                    model.ActionName     = item["ActionName"].ToString();
                    model.AreaName       = item["AreaName"].ToString();
                    model.ControllerName = item["ControllerName"].ToString();
                    model.FatherID       = string.IsNullOrWhiteSpace(item["FatherID"].ToString()) ? 0 : int.Parse(item["FatherID"].ToString());
                    model.FatherName     = item["FatherName"].ToString();
                    model.ID             = int.Parse(item["ID"].ToString());
                    model.LinkUrl        = item["LinkUrl"].ToString();
                    model.MenuAlt        = item["MenuAlt"].ToString();
                    model.MenuName       = item["MenuName"].ToString();
                    model.MenuStatus     = int.Parse(item["MenuStatus"].ToString());
                    model.MenuType       = int.Parse(item["MenuType"].ToString());
                    model.PermissionType = int.Parse(item["PermissionType"].ToString());
                    model.SortIndex      = string.IsNullOrWhiteSpace(item["SortIndex"].ToString()) ? 0 : int.Parse(item["SortIndex"].ToString());
                    model.MenuIcon       = item["MenuIcon"].ToString();
                    list.Add(model);
                }
            }
            return(list);
        }
Exemplo n.º 4
0
 public ActionResult UpdAdminUser(SysAdminUserModel UpdateUser)
 {
     if (UpdateUser != null)
     {
         UpdateUser.GName = UpdateUser.GName.Trim();
         string pinyin = PinYinConverter.Get(UpdateUser.UserName.Trim());
         UpdateUser.PinYin      = pinyin;
         UpdateUser.FirstPinYin = string.IsNullOrWhiteSpace(pinyin) ? "A" : pinyin.Substring(0, 1);
         int rowcount = mbll.UpdateSysAdminUser(UpdateUser);
     }
     return(RedirectToAction("AdminUser", "SysSettings", new { area = "AdminArea" }));
 }
Exemplo n.º 5
0
 public ActionResult AddAdminUser(SysAdminUserModel User)
 {
     if (User != null)
     {
         User.HeaderImg = "/img/avatars/avatar3.jpg";
         string defaultpwd = "123456";//创建默认密码
         User.UserPwd = DESEncrypt.Encrypt(defaultpwd, AppContent.SecrectStr);
         User.GName   = User.GName.Trim();
         string pinyin = PinYinConverter.Get(User.UserName.Trim());
         User.PinYin      = pinyin;
         User.FirstPinYin = string.IsNullOrWhiteSpace(pinyin) ? "A" : pinyin.Substring(0, 1);
         int rowcount = mbll.AddNewSysAdminUser(User);
     }
     return(RedirectToAction("AdminUser", "SysSettings", new { area = "AdminArea" }));
 }
Exemplo n.º 6
0
        /// <summary>
        /// 得到所有的系统用户
        /// </summary>
        /// <returns></returns>
        public List <SysAdminUserModel> GetAllSysAdminUser()
        {
            List <SysAdminUserModel> list = new List <SysAdminUserModel>();
            string    sqltxt = @"SELECT  ID ,
        UserName ,
        UserPwd ,
        UserStatus ,
        UserEmail ,
        TruethName ,
        UserPhone ,
        Question ,
        Answer ,
        GID ,
        GName ,
        LoginName ,
        HeaderImg ,
        CASE UserStatus
          WHEN 1 THEN '活动'
          ELSE '禁用'
        END AS UserStatusName,PinYin,FirstPinYin
FROM    dbo.SysAdminUser WITH ( NOLOCK )";
            DataTable dt     = helper.Query(sqltxt).Tables[0];

            foreach (DataRow item in dt.Rows)
            {
                SysAdminUserModel model = new SysAdminUserModel();
                model.Answer         = item["Answer"].ToString();
                model.GID            = int.Parse(item["GID"].ToString());
                model.GName          = item["GName"].ToString();
                model.HeaderImg      = item["HeaderImg"].ToString();
                model.ID             = int.Parse(item["ID"].ToString());
                model.LoginName      = item["LoginName"].ToString();
                model.Question       = item["Question"].ToString();
                model.TruethName     = item["TruethName"].ToString();
                model.UserEmail      = item["UserEmail"].ToString();
                model.UserName       = item["UserName"].ToString();
                model.UserPhone      = item["UserPhone"].ToString();
                model.UserPwd        = item["UserPwd"].ToString();
                model.UserStatus     = int.Parse(item["UserStatus"].ToString());
                model.UserStatusName = item["UserStatusName"].ToString();
                model.PinYin         = item["PinYin"].ToString();
                model.FirstPinYin    = item["FirstPinYin"].ToString();
                list.Add(model);
            }
            return(list);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 根据ID查询系统用户信息
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public SysAdminUserModel GetSingleAdminUser(int userid)
        {
            SysAdminUserModel model  = new SysAdminUserModel();
            string            sqltxt = @"SELECT  ID ,
        UserName ,
        UserPwd ,
        UserStatus ,
        UserEmail ,
        TruethName ,
        UserPhone ,
        Question ,
        Answer ,
        GID ,
        GName ,
        LoginName ,
        HeaderImg ,
        CASE UserStatus
          WHEN 1 THEN '活动'
          ELSE '禁用'
        END AS UserStatusName
FROM    dbo.SysAdminUser WITH ( NOLOCK )
WHERE ID=@id";

            SqlParameter[] paramter = { new SqlParameter("@id", userid) };
            DataTable      dt       = helper.Query(sqltxt, paramter).Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                model.Answer         = dt.Rows[0]["Answer"].ToString();
                model.GID            = int.Parse(dt.Rows[0]["GID"].ToString());
                model.GName          = dt.Rows[0]["GName"].ToString();
                model.HeaderImg      = dt.Rows[0]["HeaderImg"].ToString();
                model.ID             = int.Parse(dt.Rows[0]["ID"].ToString());
                model.LoginName      = dt.Rows[0]["LoginName"].ToString();
                model.Question       = dt.Rows[0]["Question"].ToString();
                model.TruethName     = dt.Rows[0]["TruethName"].ToString();
                model.UserEmail      = dt.Rows[0]["UserEmail"].ToString();
                model.UserName       = dt.Rows[0]["UserName"].ToString();
                model.UserPhone      = dt.Rows[0]["UserPhone"].ToString();
                model.UserPwd        = dt.Rows[0]["UserPwd"].ToString();
                model.UserStatus     = int.Parse(dt.Rows[0]["UserStatus"].ToString());
                model.UserStatusName = dt.Rows[0]["UserStatusName"].ToString();
            }
            return(model);
        }
Exemplo n.º 8
0
        public ActionResult Login(LoginViewModel model)
        {
            SysAdminUserModel user = new SysAdminUserModel();

            user.LoginName     = model.LoginId;
            user.UserPwd       = DESEncrypt.Encrypt(model.Pass, AppContent.SecrectStr);//加密密码
            user.LastLoginTime = DateTime.Now;
            user.LastLoginIP   = ComClass.GetIP();
            SysAdminUserModel result = bll.GetUserForLogin(user);

            if (result.LoginResult.StartsWith("0"))
            {
                model.loginresult = result.LoginResult.Substring(1);
            }
            else
            {
                HttpCookie aCookie = new HttpCookie("skin_color");
                aCookie.Value   = result.WebSkin;
                aCookie.Expires = DateTime.Now.AddHours(1);
                Response.Cookies.Add(aCookie);
                List <SysAdminMenuModel> usermenu = bll.GetUserAttributeMenu(result);
                result.UserPwd = "";
                SessionLoginModel sessionmodel = new SessionLoginModel();
                sessionmodel.User      = result;
                sessionmodel.UserMenus = usermenu;
                Session[AppContent.SESSION_LOGIN_NAME] = sessionmodel;
                string url = Url.Action("LoginOut", "IndexPub");
                if (!string.IsNullOrWhiteSpace(model.returnurl) && !model.returnurl.Contains(url))
                {
                    return(Redirect(model.returnurl));
                }
                else
                {
                    return(RedirectToAction("Index", "Default", new { area = "AdminArea" }));
                }
            }
            this.ViewBag.Title       = SysAdminConfigHelper.GetConfigValue("管理后台登陆页标题");
            this.ViewBag.Description = SysAdminConfigHelper.GetConfigValue("管理后台登陆页描述");
            return(View(model));
        }
Exemplo n.º 9
0
        public ActionResult Index(LoginViewModel model)
        {
            SysAdminUserModel user = new SysAdminUserModel();

            user.LoginName     = model.LoginId;
            user.UserPwd       = model.Pass;
            user.LastLoginTime = DateTime.Now;
            user.LastLoginIP   = ComClass.GetIP();
            SysAdminUserModel result = bll.GetUserForLogin(user);

            if (result.LoginResult.StartsWith("0"))
            {
                model.loginresult = result.LoginResult.Substring(1);
            }
            else
            {
                HttpCookie aCookie = new HttpCookie("skin_color");
                aCookie.Value   = result.WebSkin;
                aCookie.Expires = DateTime.Now.AddHours(1);
                Response.Cookies.Add(aCookie);
                List <SysAdminMenuModel> usermenu = bll.GetUserAttributeMenu(result);
                result.UserPwd = "";
                SessionLoginModel sessionmodel = new SessionLoginModel();
                sessionmodel.User      = result;
                sessionmodel.UserMenus = usermenu;
                Session[AppContent.SESSION_LOGIN_NAME] = sessionmodel;
                string url = Url.Action("LoginOut", "IndexPub");
                if (!string.IsNullOrWhiteSpace(model.returnurl) && !model.returnurl.Contains(url))
                {
                    return(Redirect(model.returnurl));
                }
                else
                {
                    return(RedirectToAction("Index", "Home", new { area = "" }));
                }
            }
            return(View(model));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 登录信息
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public SysAdminUserModel GetUserForLogin(SysAdminUserModel user)
        {
            SysAdminUserModel result = null;
            string            sqltxt = @"SELECT  ID ,
        UserName ,
        UserPwd ,
        UserStatus ,
        UserEmail ,
        TruethName ,
        UserPhone ,
        Question ,
        Answer ,
        GID ,
        GName,
        LoginName,HeaderImg,WebSkin,LastLoginIP,LastLoginTime,IsAdmin
FROM    dbo.SysAdminUser
WHERE LoginName=@loginname ";

            SqlParameter[] paramter =
            {
                new SqlParameter("@loginname", user.LoginName)
            };
            DataTable dt = helper.Query(sqltxt, paramter).Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                result               = new SysAdminUserModel();
                result.Answer        = dt.Rows[0]["Answer"].ToString();
                result.GID           = int.Parse(dt.Rows[0]["GID"].ToString());
                result.GName         = dt.Rows[0]["GName"].ToString();
                result.ID            = int.Parse(dt.Rows[0]["ID"].ToString());
                result.LoginName     = dt.Rows[0]["LoginName"].ToString();
                result.Question      = dt.Rows[0]["Question"].ToString();
                result.TruethName    = dt.Rows[0]["TruethName"].ToString();
                result.UserEmail     = dt.Rows[0]["UserEmail"].ToString();
                result.UserName      = dt.Rows[0]["UserName"].ToString();
                result.UserPhone     = dt.Rows[0]["UserPhone"].ToString();
                result.UserPwd       = dt.Rows[0]["UserPwd"].ToString();
                result.HeaderImg     = dt.Rows[0]["HeaderImg"].ToString();
                result.UserStatus    = int.Parse(dt.Rows[0]["UserStatus"].ToString());
                result.WebSkin       = string.IsNullOrWhiteSpace(dt.Rows[0]["WebSkin"].ToString()) ? "default" : dt.Rows[0]["WebSkin"].ToString();
                result.LastLoginIP   = string.IsNullOrWhiteSpace(dt.Rows[0]["LastLoginIP"].ToString()) ? "" : dt.Rows[0]["LastLoginIP"].ToString();
                result.LastLoginTime = string.IsNullOrWhiteSpace(dt.Rows[0]["LastLoginTime"].ToString()) ? DateTime.MinValue : DateTime.Parse(dt.Rows[0]["LastLoginTime"].ToString());
                result.IsAdmin       = dt.Rows[0]["IsAdmin"].ToString().ParseToInt(0);
                if (result.UserPwd != user.UserPwd)
                {
                    result.LoginResult = "0用户密码不正确";
                    return(result);
                }
                if (result.UserStatus == 0)
                {
                    result.LoginResult = "0用户已经被禁用";
                    return(result);
                }
                UpdateLoginMsg(user.LastLoginTime, user.LastLoginIP, result.ID);
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = "";
                    log.BehaviorSource = 2;
                    log.BehaviorType   = 1;
                    log.HOrderCode     = "";
                    log.MemberID       = result.ID;
                    log.MemberName     = result.UserName;
                    log.MemberPhone    = result.UserPhone;
                    log.ProcAmount     = 0;
                    log.Remark         = "管理员:" + result.UserName + "登陆";
                    int rowcount = UserBehaviorLogDAL.AddUserBehaviorLog(log);
                }
                catch { }
                result.LoginResult = "1";
            }
            else
            {
                result             = new SysAdminUserModel();
                result.LoginResult = "0无此用户";
                return(result);
            }
            return(result);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 查询用户拥有的菜单权限
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public List <SysAdminMenuModel> GetUserAttributeMenu(SysAdminUserModel user)
 {
     return(dal.GetUserAttributeMenu(user));
 }
Exemplo n.º 12
0
 /// <summary>
 /// 修改系统用户
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateSysAdminUser(SysAdminUserModel model)
 {
     return(dal.UpdateSysAdminUser(model));
 }
Exemplo n.º 13
0
 /// <summary>
 /// 新插入系统用户
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int AddNewSysAdminUser(SysAdminUserModel model)
 {
     return(dal.AddNewSysAdminUser(model));
 }
Exemplo n.º 14
0
 /// <summary>
 /// 登录信息
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public SysAdminUserModel GetUserForLogin(SysAdminUserModel user)
 {
     return(dal.GetUserForLogin(user));
 }