public bool UpdateUser(UUserDto UpdateUser) { int result = _engine.ExecNonQueryProc("UpdateUser", new object[] { "id", UpdateUser.Id, "voterId", UpdateUser.VoterId, "fname", UpdateUser.Fname, "midname", UpdateUser.Mname, "lastname", UpdateUser.Lname, "contactnum", UpdateUser.ContactNum, "address", UpdateUser.Address, "role", UpdateUser.RoleId, "password", UpdateUser.Password }); return((result > 0) ? true : false); }
protected void register_submit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtVotersId.Text)) { txtVotersId.Focus(); Message("Please fill required field."); } else if (string.IsNullOrEmpty(txtFname.Text)) { txtFname.Focus(); Message("Please fill required field."); } else if (string.IsNullOrEmpty(txtMname.Text)) { txtMname.Focus(); Message("Please fill required field."); } else if (string.IsNullOrEmpty(txtLname.Text)) { txtLname.Focus(); Message("Please fill required field."); } else if (string.IsNullOrEmpty(txtContact.Text)) { txtContact.Focus(); Message("Please fill required field."); } else if (string.IsNullOrEmpty(drpRole.SelectedValue)) { drpRole.Focus(); Message("Please fill required field."); } else if (string.IsNullOrEmpty(txtPassword.Text)) { txtPassword.Focus(); Message("Please fill required field."); } else if (string.IsNullOrEmpty(txtConfirmPassword.Text)) { txtConfirmPassword.Focus(); Message("Please fill required field."); } else if (txtPassword.Text != txtConfirmPassword.Text) { Message("Password not match!."); } else { var users = _business.GetUsers().Where(x => x.VoterId == txtVotersId.Text).FirstOrDefault(); if (users != null) { var uUserDto = new UUserDto() { Id = int.Parse(HiddenField1.Value), VoterId = txtVotersId.Text, Fname = txtFname.Text, Mname = txtMname.Text, Lname = txtLname.Text, Address = txtAddress.Text, RoleId = int.Parse(drpRole.SelectedValue), ContactNum = txtContact.Text, Password = txtPassword.Text }; bool res = _business.UpdateUser(uUserDto); if (res) { Message("User information has been updated!"); return; } } var userDto = new UserDto() { VoterId = txtVotersId.Text, Fname = txtFname.Text, Mname = txtMname.Text, Lname = txtLname.Text, Address = txtAddress.Text, RoleId = int.Parse(drpRole.SelectedValue), ContactNum = txtContact.Text, Password = txtPassword.Text }; var result = _business.RegisterUser(userDto); if (result) { var lsitUsers = _business.GetUsers(); grdUsers.DataSource = lsitUsers; grdUsers.DataBind(); ClearControls(); Message("Insert User Successfull!"); } else { Message("Insert User Failed!"); } } }