private void chkActive_CheckedChanged(object sender, EventArgs e) { try { SBFAApi agent = new SBFAApi(); using (new OperationContextScope(agent.context)) { sbfa.UserActionResponse response = agent.operation.UpdateUser(SBFAMain.currentUsername, ((chkActive.Checked)? "enable" : "disable")); chkActive.Checked = response.actionStatus; } } catch { ShowErrorMessage("Failed to update status"); } }
private void btnSave_Click(object sender, EventArgs e) { if (txtUsername.Text == "" || txtName.Text == "") { ShowErrorMessage("Please enter all main fields"); return; } if (!chkDefaultPassword.Checked && (txtPassword.Text != txtConfirm.Text)) { ShowErrorMessage("Password mismatch"); return; } try { SBFAApi agent = new SBFAApi(); using (new OperationContextScope(agent.context)) { string password = ""; if (chkDefaultPassword.Checked) { password = agent.operation.DefaultPassword(); } else { password = txtPassword.Text; } sbfa.UserActionResponse response = agent.operation.AddUser(txtUsername.Text, password, Globals.GetComboBoxValue(cmbStakeholder), cmbRoleGroups.Text, txtName.Text, txtSurname.Text, txtEmail.Text, txtMobile.Text, chkPasswordExpires.Checked, chkActive.Checked, chkLocked.Checked); if (response.actionStatus) { txtName.Text = ""; txtSurname.Text = ""; txtUsername.Text = ""; txtEmail.Text = ""; txtMobile.Text = ""; txtPassword.Text = ""; } else { ShowErrorMessage(response.responseMessage); } } } catch { ShowErrorMessage("There has been an error saving user"); } }