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 = ""; } } }