protected void gvData_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string userName = e.CommandArgument.ToArrowString();
        string command  = e.CommandName;
        var    model    = SiteUserBLL.Select(userName);

        if (model.ValidateIsNull("该用户不存在!"))
        {
            BindData();
            return;
        }
        if (command == "UpdateRealName")
        {
            GridViewRow drv      = ((GridViewRow)(((LinkButton)(e.CommandSource)).Parent.Parent));
            string      realName = (gvData.Rows[drv.RowIndex].FindControl("tbRealName") as TextBox).Text;
            if (!realName.IsNullOrEmpty())
            {
                model.RealName = realName;
                SiteUserBLL.Update(model);
                MessageBox.Show("修改成功!");
            }
        }
        else if (command == "ReSetPwd")
        {
            model.Pwd = SiteUserBLL.AdminEncrypt("admin");
            SiteUserBLL.Update(model);
            MessageBox.Show("重置成功!");
        }
        else if (command == "Enable")
        {
            model.UserStatus = AdminStatus.Enable;
            SiteUserBLL.Update(model);
            MessageBox.Show("启用成功!");
        }
        else if (command == "Disabled")
        {
            model.UserStatus = AdminStatus.Disabled;
            SiteUserBLL.Update(model);
            MessageBox.Show("禁用成功!");
        }
        else if (command == "Del")
        {
            try
            {
                SiteUserBLL.Del(userName);
                MessageBox.Show("删除成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        BindData();
    }
Beispiel #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string userName  = tbUserName.Text.Trim();
        string pwd       = tbPwd.Text.Trim();
        string realName  = tbRealName.Text.Trim();
        string inviteNum = tbInviteNum.Text.Trim();

        string[] arr  = { userName, pwd, realName, inviteNum };
        string[] name = { "用户名", "密码", "真名", "邀请码" };

        if (arr.ValidateHasNullOrEmptyString(name))
        {
            return;
        }

        //判断用户名和邀请码是否唯一
        var user = SiteUserBLL.Select(userName);

        if (user.ValidateIsNotNull("该用户名已存在!请选择其他用户名!"))
        {
            return;
        }

        if (SiteUserBLL.InviteNumExist(inviteNum))
        {
            MessageBox.Show("该邀请码已存在!请选择其他验证码!");
            return;
        }

        TMS.SiteUserInfo model = new TMS.SiteUserInfo();
        model.InviteNum     = inviteNum;
        model.LastLoginIP   = "127.0.0.1";
        model.LastLoginTime = DateTime.Now;
        model.Name          = userName;
        model.Pwd           = SiteUserBLL.AdminEncrypt(pwd);
        model.RealName      = realName;
        model.Remarks       = "";
        model.RoleIDs       = "1";
        model.ThisLoginIP   = "127.0.0.1";
        model.ThisLoginTime = DateTime.Now;
        model.UserStatus    = AdminStatus.Enable;

        SiteUserBLL.Add(model);

        MessageBox.Show("添加成功!", "AdminEdit.aspx");
    }
Beispiel #3
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string oldPwd = tbOldPwd.Text.Trim();
        string pwd1   = tbNewPwd1.Text.Trim();
        string pwd2   = tbNewPwd2.Text.Trim();

        string[] arrString = new string[] { oldPwd, pwd1, pwd2 };
        string[] arrFields = new string[] { "旧密码", "新密码", "重复密码" };
        if (arrString.ValidateHasNullOrEmptyString(arrFields))
        {
            return;
        }

        if (pwd1.ValidateIsNotEqualTo(pwd2, "两次输入的密码不一致!"))
        {
            return;
        }


        var model = SiteUserBLL.Select(CurrentAdmin.UserName);

        if (model.ValidateIsNull("该用户不存在!"))
        {
            return;
        }

        string md5 = SiteUserBLL.AdminEncrypt(oldPwd);

        if (md5.ValidateIsNotEqualTo(model.Pwd, "旧密码不正确!"))
        {
            return;
        }

        if (SiteUserBLL.ChangePwd(model, pwd1))
        {
            MessageBox.Show("修改成功!请重新登陆!", "Login.aspx", "parent");
        }
        else
        {
            MessageBox.Show("修改失败!用户不存在!");
        }
    }