public void FilterUsersTable() { UserSearchFilter filter = new UserSearchFilter { Name = name_filter.Text.ToString(), Surname = surname_filter.Text.ToString(), Email = email_filter.Text.ToString(), Username = surname_filter.Text.ToString(), Roles = new string[] { rol_filter.Text.ToString() }, IdDocument = document_filter.Text.ToString(), IdDocumentType = document_type_filter.Text.ToString() }; UserWSClient ws = new UserWSClient(); for (int indx = (userTable.RowCount * userTable.ColumnCount) - 1; indx >= userTable.ColumnCount; indx--) { userTable.Controls.RemoveAt(indx); } userTable.RowCount = 1; UserWS.editUserData[] users = ws.listUsersByFilter(new UserWS.Security { BinarySecurityToken = authToken }, new listUsersByFilter { arg1 = filter }); FillUsersTable(users); }
private void loginButton_Click(object sender1, EventArgs e) { string username = username_login.Text.ToString(); string password = password_login.Text.ToString(); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { showErrorMsg("Por favor, introduzca el nombre de usuario y contraseña", "Formulario no válido"); } else { UserWSClient ws = new UserWSClient(); try { string authToken = ws.login(username, password); if (string.IsNullOrEmpty(authToken)) { showErrorMsg("Credenciales de acceso incorrectas", "Login Incorrecto"); } else { this.Hide(); HomeForm homeForm = new HomeForm(authToken, this); homeForm.Closed += (s, args) => this.Close(); homeForm.Show(); } } catch (Exception ex) { showErrorMsg(ex.Message, "Error"); } } }
private void InitializeUserDocumentTypeCombobox() { UserWSClient ws = new UserWSClient(); UserWS.PersonIdDocumentType?[] types = ws.findPersonDocumentTypes(); if (types != null) { foreach (var type in types) { document_type_filter.Items.Add(type); } } }
private void InitializeUserRolesCombobox() { UserWSClient ws = new UserWSClient(); UserWS.UserRole?[] roles = ws.findUserRoles(); if (roles != null) { foreach (var rol in roles) { rol_filter.Items.Add(rol); } } }
private void DeleteUser(dynamic sender, EventArgs e) { var confirmResult = MessageBox.Show("Está a punto de eliminar un usuario. " + "Esta acción no se podrá deshacer. ¿Desea continuar con la operación?", "Confirmar borrado", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (confirmResult == DialogResult.Yes) { long id = sender.Tag; UserWSClient ws = new UserWSClient(); try { removeUserResponse response = ws.removeUser(new UserWS.Security { BinarySecurityToken = authToken }, new removeUser { arg1 = id, arg1Specified = true }); FilterUsersTable(); } catch (FaultException <UserWS.ElementNotFoundException> ex) { MessageBox.Show("Ha ocurrido un error. No se ha encontrado un usuario con id " + id + " en el sistema", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FaultException <UserWS.ArgumentException> ex) { MessageBox.Show("Ha ocurrido un error. No se ha recibido el id del usuario a eliminar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FaultException <UserWS.CannotRemoveElementException> ex) { MessageBox.Show("Ha ocurrido un error. No se puede eliminar al vendedor porque ha creado productos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void ActivateUser(dynamic sender, EventArgs e) { long id = sender.Tag.id; bool enabled = sender.Tag.enabled; UserWSClient ws = new UserWSClient(); try { if (enabled) { ws.disableAccount(new UserWS.Security { BinarySecurityToken = authToken }, new disableAccount { arg1 = id, arg1Specified = true }); } else { ws.enableAccount(new UserWS.Security { BinarySecurityToken = authToken }, new enableAccount { arg1 = id, arg1Specified = true }); } FilterUsersTable(); } catch (FaultException <UserWS.ArgumentException> ex) { MessageBox.Show("Ha ocurrido un error. No se ha recibido el id del usuario a eliminar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FaultException <UserWS.UnauthorizedAccessException> ex) { MessageBox.Show("Ha ocurrido un error. No está autorizado a realizar esta operación", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }