示例#1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        var bll = new UserManagerBLL();

        var newUser = getUser(PageUtility.User, bll);

        if (newUser == null)
        {
            return;
        }

        try
        {
            if (string.IsNullOrEmpty(hdnEditingUserNo.Value.Trim()))
            {
                bll.AddUser(newUser);
            }
            else   ///修改用户操作
            {
                bll.ModifyUser(newUser);
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
            return;
        }

        Response.Redirect("UserManager.aspx");
    }
示例#2
0
    private UserInfo GetUser(UserManagerBLL bll)
    {
        // 检查用户的输入情况
        if (string.IsNullOrEmpty(txtUserName.Text.Trim()) || string.IsNullOrEmpty(txtAlias.Text.Trim()))
        {
            lblError.Text = "请输入用户账号和用户姓名!";
            return(null);
        }
        if (!string.IsNullOrEmpty(txtEmail.Text.Trim()) && !ValidationUtility.IsValidEmail(txtEmail.Text.Trim()))
        {
            lblError.Text = "请输入有效的用户邮箱!";
            return(null);
        }

        var ret = PageUtility.User;

        ret.Alias       = txtAlias.Text.Trim();
        ret.Email       = txtEmail.Text.Trim();
        ret.Description = txtDescription.Text.Trim();

        ret.LastUpdByID   = ret.ID;
        ret.LastUpdByName = ret.Alias;
        ret.LastUpdDate   = DateTime.Now;

        return(ret);
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!PageUtility.IsLogin)
        {
            Response.Redirect("~/logout.aspx");
            return;
        }

        if (!IsPostBack)
        {
            var bll = new UserManagerBLL();

            // *******************************************************************
            // 检查id是否存在参数
            UserInfo selectedUser = null;
            if (!string.IsNullOrEmpty(Request["id"]))
            {
                selectedUser = bll.GetUser(int.Parse(Request["id"]));

                // 未找到对象
                if (selectedUser == null)
                {
                    Response.Redirect("~/common/erroraccess.aspx");
                }
            }

            // *******************************************************************
            // 显示要修改的模块内容

            bindOrg();  //显示构件数据
            bindRoleList(bll);
            displayUser(PageUtility.User, selectedUser);
        }
    }
示例#4
0
 private void bindRoleList(UserManagerBLL BLL)
 {
     chklstRoleList.DataSource     = BLL.GetCachingRoleList();
     chklstRoleList.DataTextField  = "RoleName";
     chklstRoleList.DataValueField = "ID";
     chklstRoleList.DataBind();
 }
示例#5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var bll = new UserManagerBLL();

            // 显示要修改的模块内容
            DisplayUser(PageUtility.User);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!PageUtility.IsLogin)
        {
            Response.Redirect("~/logout.aspx");
            return;
        }

        if (!IsPostBack)
        {
            var bll = new UserManagerBLL();

            // 绑定显示用户/会员列表
            BindUseList(bll, PageUtility.NAVIGATION_DEFAULT_PAGEINDEX, PageUtility.NAVIGATION_DEFAULT_PAGESIZE);
        }
    }
示例#7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         UserManager    um       = new UserManager();
         UserManagerBLL bll      = new UserManagerBLL();
         string         userName = Request["username"];
         string         passWord = Request["password"];
         um = bll.GetUserManagerByUserName(userName);
         if (um.UserName == userName && um.UserPwd == passWord)
         {
             Response.Redirect("Index.aspx");
         }
         else
         {
             Response.Redirect("Error.html");
         }
     }
 }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        var bll    = new UserManagerBLL();
        int userID = int.Parse(e.CommandArgument.ToString());

        try
        {
            switch (e.CommandName)
            {
            case "Edit":
                Response.Redirect("UserAdd.aspx?id=" + userID);
                break;

            case "Remove":

                bll.RemoveUser(userID);
                BindUseList(bll, Navigation1.PageIndex, Navigation1.PageSize);
                break;

            case "Lock":

                bll.LockUser(userID, true);
                BindUseList(bll, Navigation1.PageIndex, Navigation1.PageSize);
                break;

            case "Unlock":

                bll.LockUser(userID, false);
                BindUseList(bll, Navigation1.PageIndex, Navigation1.PageSize);
                break;

            case "Popedom":
                Response.Redirect("UserPopedomManager.aspx?id=" + userID);
                break;
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
            return;
        }
    }
    private void BindUseList(UserManagerBLL bll, int pageIndex, int pageSize)
    {
        bool?isAdmin = null;

        if (rbtnViewAdmin.Checked)
        {
            isAdmin = true;
        }
        else if (rbtnViewMember.Checked)
        {
            isAdmin = false;
        }

        int total;

        GridView1.DataSource = bll.GetUserList(string.Empty, false, isAdmin, null, pageIndex, pageSize, out total);
        GridView1.DataBind();

        Navigation1.DataBind(pageIndex, pageSize, total);
    }
示例#10
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        var bll = new UserManagerBLL();

        var newUser = GetUser(bll);

        if (newUser == null)
        {
            return;
        }

        try
        {
            bll.ModifyUser(newUser);
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
            return;
        }

        lblError.Text = "修改成功!";
    }
示例#11
0
    private UserInfo getUser(UserInfo loginedUser, UserManagerBLL BLL)
    {
        // 检查用户的输入情况
        if (string.IsNullOrEmpty(txtUserName.Text.Trim()) || string.IsNullOrEmpty(txtAlias.Text.Trim()))
        {
            lblError.Text = "请输入用户账号和用户姓名!";
            return(null);
        }
        if (!string.IsNullOrEmpty(txtEmail.Text.Trim()) && !ValidationUtility.IsValidEmail(txtEmail.Text.Trim()))
        {
            lblError.Text = "请输入有效的用户邮箱!";
            return(null);
        }

        if (ddlOrg.SelectedItem == null || string.IsNullOrEmpty(ddlOrg.SelectedValue))
        {
            lblError.Text = "请选择管理机构!";
            return(null);
        }

        var ret = new UserInfo
        {
            ID = 0,
            EncryptedPassword        = "",
            PasswordAnswer           = string.Empty,
            PasswordQuestion         = string.Empty,
            SessionIdentify          = Guid.NewGuid().ToString(),
            IsSystem                 = false,
            IsAdmin                  = true,
            IsApproved               = true,
            PopedomIDs               = string.Empty,
            FailedPwdAttemptCount    = 0,
            FailedPwdAttemptDate     = DateTime.Now,
            FailedAnswerAttemptCount = 0,
            FailedAnswerAttemptDate  = DateTime.Now,
            LastLoginDate            = DateTime.Now,
            LastLockoutDate          = DateTime.Now,
            LastActivityDate         = DateTime.Now,
            LastPwdChangedDate       = DateTime.Now,
            DisplayOrder             = 100,
            CreatedByID              = loginedUser.ID,
            CreatedByName            = loginedUser.Alias,
            CreatedDate              = DateTime.Now
        };

        // 如果是修改,则获取要修改的对象
        if (!string.IsNullOrEmpty(hdnEditingUserNo.Value.Trim()))
        {
            UserInfo existUser = BLL.GetUser(int.Parse(hdnEditingUserNo.Value.Trim()));
            if (existUser == null)
            {
                lblError.Text = "修改的对象未找到!请确认该对象是否被其它用户删除!";
                return(null);
            }
            ret = existUser;
        }

        ret.UserName = txtUserName.Text.Trim();

        ret.OrganizationId   = Convert.ToInt32(ddlOrg.SelectedValue);
        ret.OrganizationName = ddlOrg.SelectedItem.Text;

        ret.Alias       = txtAlias.Text.Trim();
        ret.Email       = txtEmail.Text.Trim();
        ret.Description = txtDescription.Text.Trim();
        ret.IsLockedOut = cbxIsLockout.Checked;

        // 加入会员的管理角色
        var roleList = new List <RoleInfo>();

        foreach (ListItem item in chklstRoleList.Items)
        {
            if (item.Selected)
            {
                ret.AddRole(int.Parse(item.Value.Trim()));
            }
        }

        ret.LastUpdByID   = loginedUser.ID;
        ret.LastUpdByName = loginedUser.Alias;
        ret.LastUpdDate   = DateTime.Now;

        return(ret);
    }