예제 #1
0
        /// <summary>
        /// 根据管理员名字获取其ID
        /// </summary>
        /// <param name="adminName"></param>
        /// <returns></returns>
        public int GetIdByAdminName(string adminName)
        {
            string sql = "select aid from R_Admin where AName=@AName";

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@AName", adminName)
            };

            IDataReader reader = null;

            try {
                reader = SQLHelpers.TcAdmin().ExecuteReader(sql, parameters);
                if (reader.Read())
                {
                    MR_Admin mr_admin = Safe.Base.Utility.ModelConvertHelper <MR_Admin> .ToModel(reader);

                    return(mr_admin.AID);
                }
                else
                {
                    return(0);
                }
            } finally {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 根据用户名获取一个管理员信息实体
        /// <param name="aname">用户名</param>
        /// </summary>
        public MR_Admin GetModel(string aname, string ip)
        {
            Safe.Base.Contract.IDbHelper dbHelper = SQLHelpers.TcAdmin();
            try {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("select  top 1 AID,AName,ANickName,IP,Email,R_Admin.GID ,R_Admin.ALastTime from R_Admin ");
                strSql.Append(" where AName=@AName ");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@AName", aname)
                };
                DataTable dtbl = dbHelper.ExecuteFillDataTable(strSql.ToString(), parameters);
                if (dtbl.Rows.Count > 0)
                {
                    MR_Admin result = Safe.Base.Utility.ModelConvertHelper <MR_Admin> .ToModel(dtbl.Rows[0]);

                    dbHelper.ExecuteNonQuery("UPDATE R_Admin SET ALastTime=getdate() , IP=@ip Where AID=@aid", new SqlParameter("@aid", result.AID), new SqlParameter("@ip", ip));
                    return(result);
                }
                else
                {
                    return(null);
                }
            } finally {
                dbHelper.EndConnection();
            }
        }
예제 #3
0
        private void LoadChilds()
        {
            MR_Admin adminInfo = AdminPageStatic.GetLoginUserInfo();
            int      aid       = adminInfo.AID;
            int      gid       = adminInfo.GID;

            IRoleManage irm = GetInterface.GetIRoleManage();

            this.MenuTitle = irm.GetNode(this.PageId).PName;
            if (gid > 0)
            {
                this.Childs = SiteRuleCheck.GetAdminPages(aid, gid, PageId, true);
            }
            else if (gid == -1)
            {
                this.Childs = irm.GetList(PageId, false, true);
            }
            else
            {
                this.Childs = new List <MR_PageInfo>();
            }
            if (this.Childs == null)
            {
                this.Childs = new List <MR_PageInfo>();
            }
            rep_Nav.DataSource = this.Childs;
            rep_Nav.DataBind();
        }
예제 #4
0
 protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowIndex >= 0 && e.Row.RowIndex == this.gvList.EditIndex)
     {
         DropDownList ddl = (DropDownList)e.Row.FindControl("ddl_GroupList");
         ddl.DataSource     = this.GroupList;
         ddl.DataTextField  = "GName";
         ddl.DataValueField = "GID";
         ddl.DataBind();
         MR_Admin drv = (MR_Admin)e.Row.DataItem;
         int      gid = drv.GID;
         if (gid == -1)
         {
             ddl.Items.Add(new ListItem("超级管理员", "-1"));
             if (AdminPageStatic.GetLoginUserInfo().GID != -1)
             {
                 ddl.Enabled = false;
             }
             else
             {
                 ddl.Enabled = true;
             }
         }
         ddl.SelectedValue = gid.ToString();
     }
 }
예제 #5
0
 /// <summary>
 /// 管理员登录后台
 /// </summary>
 /// <param name="userName">登录名</param>
 /// <param name="userPwdMD5">密码密文</param>
 /// <param name="userIp">用户IP</param>
 /// <param name="model">输出值,当前登录用户的基本信息</param>
 /// <returns></returns>
 public bool Login(string userName, string userPwdMD5, string userIp, out MR_Admin model)
 {
     model = new DR_Admin().GetModel(userName, userPwdMD5, userIp);
     if (model == null || model.AID < 0)
     {
         return(false);
     }
     return(true);
 }
예제 #6
0
        /// <summary>
        /// 添加管理员
        /// </summary>
        /// <param name="aname"></param>
        /// <param name="apwd"></param>
        /// <param name="anickname"></param>
        /// <param name="email"></param>
        /// <param name="gid"></param>
        /// <returns></returns>
        public int Add(string aname, string apwd, string anickname, string email, int gid)
        {
            MR_Admin model = new MR_Admin();

            model.AName     = aname;
            model.APwd      = apwd.MD5();
            model.ANickName = anickname;
            model.Email     = email;
            model.GID       = gid;
            return(new DR_Admin().Add(model));
        }
예제 #7
0
        private void LoadMenus()
        {
            MR_Admin adminobj = AdminPageStatic.GetLoginUserInfo();
            int      adminid  = adminobj.AID;
            int      groupid  = adminobj.GID;

            IList <MR_PageInfo> info = new List <MR_PageInfo>();

            if (groupid > 0)
            {
                info = SiteRuleCheck.GetAdminPages(adminid, groupid, 0, false);
            }
            else if (groupid == -1)
            {
                IRoleManage irm = GetInterface.GetIRoleManage();
                info = irm.GetListToList(0, false);
            }
            else
            {
                Session["ErrInfo"] = "找不到用户组!";
                AdminPageStatic.RedirectToLoginPage(false);
                return;
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(" [");
            string span = "";

            if (info.Count > 0)
            {
                OnLoadId = info[0].PID;
            }
            foreach (MR_PageInfo tmp in info)
            {
                sb.Append(span);
                sb.Append("{");
                sb.AppendFormat(" 'Text': '{0}', 'Id': '{1}', 'URL': '{2}'", tmp.PName, tmp.PID, tmp.PUrl);
                sb.Append("}");
                span = ",";
            }
            sb.Append(" ]");
            this.Menus = sb.ToString();
        }
예제 #8
0
        /// <summary>
        /// 增加管理员信息
        /// 返回新增加的标识列,如果增加失败返回0
        /// </summary>
        public int Add(MR_Admin model)
        {
            string pname = "p_AddAdmin";

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@AName", model.AName),
                new SqlParameter("@APwd", model.APwd),
                new SqlParameter("@ANickName", model.ANickName),
                new SqlParameter("@Email", model.Email),
                new SqlParameter("@GID", model.GID)
            };

            object obj = SQLHelpers.TcAdmin().ExecuteNonQuery(pname, CommandType.StoredProcedure, parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #9
0
 /// <summary>
 /// 登录成功后,设置COOKIE
 /// </summary>
 /// <param name="model"></param>
 public static void SaveUserFormsCookie(MR_Admin model)
 {
     ZAuthentication.AuthHelper.SetUser(new ZAuthentication.UserTickModel(
                                            model.AName, model.GetJSON(), DateTime.Now, DateTime.Now.AddHours(3), StaticFunctions.GetUserIp()));
 }