Ejemplo n.º 1
0
        /// <summary>
        /// 判断该用户是否存在
        /// </summary>
        /// <param name="context"></param>
        public void AdminUserIsExistRequest(HttpContext context)
        {
            var response = new ResponseMessage <string>();

            try
            {
                string userName = context.Request.Form["UserName"];
                string userPwd  = context.Request.Form["Pwd"];
                var    list     = _userInfoService.GetList().Where(y => y.UserName == userName && y.Pwd == userPwd);
                if (list != null)
                {
                    response.code  = 0;
                    response.msg   = "登陆成功";
                    response.model = list.FirstOrDefault().Role.ToString();
                    context.Response.Write(SerializeHelp.ToJson(response));
                }
                else
                {
                    response.code = 500;
                    response.msg  = "用户名或者密码错误";
                    context.Response.Write(SerializeHelp.ToJson(response));
                }
            }
            catch (Exception e)
            {
                _log.Error("判断该用户是否存在报错 56:" + e.Message);
                response.code = 500;
                response.msg  = "请求错误,请重试";
                context.Response.Write(SerializeHelp.ToJson(response));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button2_Click(object sender, EventArgs e)
        {
            string ids = selInfo();
            int    num = 0;

            if (ids.Length == 0)
            {
                Jscript.Alert("请选择要删除的记录!", this.Page);
                return;
            }
            string[] arr = ids.TrimEnd(',').Split(',');
            for (int i = 0; i < arr.Length; i++)
            {
                if (AdminUserService.Delete(Convert.ToInt32(arr[i])) > 0)
                {
                    num++;
                }
            }

            ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('成功删除" + num + "条记录!');", true);
            DataSet ds = AdminUserService.GetList("");

            if (ds.Tables[0].Rows.Count > 0)
            {
                this.repInfo.DataSource = ds;
                repInfo.DataBind();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 搜索用户
        /// </summary>
        /// <param name="context"></param>
        public void SeachUsersRequest(HttpContext context)
        {
            var username = context.Request["name"];
            var page     = context.Request.Form["page"];
            var index    = context.Request.Form["limit"];

            if (string.IsNullOrWhiteSpace(page) && string.IsNullOrWhiteSpace(index))
            {
                //排除超级管理员
                var list = _AdminUserService.GetList().Where(y => y.Role != 1 && y.UserName.Contains(username)).ToList();
                var res  = SerializeHelp.ToTableJson(list);
                context.Response.Write(res);
            }
            else
            {
                var list  = _AdminUserService.GetList().Where(y => y.Role != 1 && y.UserName.Contains(username));
                var list1 = list.Skip((int.Parse(page) - 1) * int.Parse(index)).Take(int.Parse(index)).ToList();
                var res   = SerializeHelp.ToTableJson(list1, list.Count());
                context.Response.Write(res);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 加载数据
        /// </summary>
        private void LoadData()
        {
            this.txtPass.Text      = "";
            this.txtPassAgain.Text = "";
            this.txtRealName.Text  = "";
            this.txtUserName.Text  = "";
            //加载角色
            DataSet dsRole = SysRoleService.GetList("");

            if (dsRole.Tables[0].Rows.Count > 0)
            {
                this.ddlRole.DataSource = dsRole;
                ddlRole.DataTextField   = "roleName";
                ddlRole.DataValueField  = "id";
                ddlRole.DataBind();
            }
            ddlRole.Items.Insert(0, new ListItem("请选择", "0"));
            if (Request.QueryString["useAdmin"] != null)
            {
                string useAdmin = Request.QueryString["useAdmin"];
                if (useAdmin == "1")
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('操作成功!');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('操作失败!');", true);
                }
            }
            if (Request.QueryString["delAdmin"] != null)
            {
                string delAdmin = Request.QueryString["delAdmin"];
                if (delAdmin == "1")
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('删除成功!');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('删除失败!');", true);
                }
            }
            DataSet ds = AdminUserService.GetList("");

            if (ds.Tables[0].Rows.Count > 0)
            {
                this.repInfo.DataSource = ds;
                repInfo.DataBind();
            }
        }