protected void btnSave_Click(object sender, EventArgs e) { this.lblMessage.Text = ""; //if (this.txtNewPassword.Text != this.txtNewPasswordConfirm.Text) //{ // this.lblMessage.Text = "新密码两次输入不一致,请确认!"; // return; //} //if (this.txtNewPassword.Text == "") //{ // this.lblMessage.Text = "必须输入密码!"; // return; //} Business.UserComponent uc = new UserComponent(); if (this.txtPassword.Text.Trim().Length == 0 || !uc.VerifyPassword(this.lblUserID.Text, this.txtPassword.Text.Trim())) { this.lblMessage.Text = "当前密码输入错误,请重新输入!"; return; } var user = uc.getUserById(this.hddId.Value); user.Psd = this.txtNewPassword.Text; if (uc.Update(user) > 0) { this.lblMessage.Text = "修改密码成功!"; } else { this.lblMessage.Text = "修改密码失败,请稍后再试!"; } }
protected void btnSave_Click(object sender, EventArgs e) { this.lblMessage.Text = ""; if (this.txtConfirmPassword.Text != this.txtPassword.Text) { this.lblMessage.Text = "密码不匹配,请确认!"; return; } if (this.lblId.Text == "") { if (this.txtPassword.Text == "") { this.lblMessage.Text = "新建用户,必须输入密码!"; return; } } JMReports.Entities.User user1 = new Entities.User(); user1.UserId = this.txtUserId.Text.Trim(); user1.RoleId = int.Parse(this.ddlRole.SelectedItem.Value); user1.Title = this.txtTitle.Text.Trim(); user1.Email = this.txtEmail.Text.Trim(); user1.Psd = this.txtPassword.Text.Trim(); Business.UserComponent uc = new UserComponent(); if (this.lblId.Text == "") { user1 = uc.Create(user1); if (user1.Id != 0) { this.lblMessage.Text = "用户新增成功!"; getUsers(); this.txtUserId.Text = ""; this.txtEmail.Text = ""; this.txtTitle.Text = ""; this.txtPassword.Text = ""; this.txtConfirmPassword.Text = ""; this.ddlRole.SelectedValue = ""; this.lblId.Text = ""; } } else { user1.Id = int.Parse(this.lblId.Text); int i = uc.Update(user1); if (i > 0) { this.lblMessage.Text = "用户修改成功!"; getUsers(); this.txtUserId.Text = ""; this.txtEmail.Text = ""; this.txtTitle.Text = ""; this.txtPassword.Text = ""; this.txtConfirmPassword.Text = ""; this.ddlRole.SelectedValue = ""; this.lblId.Text = ""; } } }