/// <summary> /// Metodo que actualiza un usuario. /// </summary> /// <param name="pEntidad">Entidad que tiene datos del usuario.</param> /// <returns>bool</returns> public bool UpdateUsuario(DtoUsuarioInsert pEntidad) { bool response = false; var urlClient = string.Format("/Api/Usuarios"); var restClient = new RestService(); var responseClient = restClient.PostAsync <Respuesta <DtoUsuarioInsert> >(urlClient, pEntidad); if (responseClient.CodigoError == 0) { response = false; } else { response = true; } return(response); }
public bool UpdateUsuario(DtoUsuarioInsert pEntidad) { return(this.oUsuario.UpdateUsuario(pEntidad)); }
public bool AddUsuario(DtoUsuarioInsert pEntidad) { return(this.oUsuario.AddUsuario(pEntidad)); }
private void UpdateUsuario() { try { if (this.cmbRol.SelectedIndex == 0) { MessageBox.Show("Seleccione un rol.", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.cmbRol.Focus(); } else if (string.IsNullOrEmpty(this.txtEmail.Text)) { MessageBox.Show("Ingrese email.", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtEmail.Focus(); } else if (!this.IsValidEmail(this.txtEmail.Text.Trim())) { MessageBox.Show("Email inválido", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtEmail.Focus(); } else if (string.IsNullOrEmpty(this.txtUsuario.Text)) { MessageBox.Show("Ingrese usuario.", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtUsuario.Focus(); } else if (string.IsNullOrEmpty(this.txtPassword.Text)) { MessageBox.Show("Ingrese contraseña.", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtPassword.Focus(); } else if (string.IsNullOrEmpty(this.txtConfirmarPasswrod.Text)) { MessageBox.Show("Ingrese contraseña.", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtConfirmarPasswrod.Focus(); } else if (this.txtPassword.Text.Trim() != this.txtConfirmarPasswrod.Text.Trim()) { MessageBox.Show("Contraseñas no coinciden", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtPassword.Focus(); } else if (this.cmbEmpleado.SelectedIndex == 0) { MessageBox.Show("Seleccione un empleado.", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.cmbRol.Focus(); } else { var data = new DtoUsuarioInsert() { Id = Convert.ToInt32(this.txtUsuarioId.Text), RoId = Convert.ToInt32(this.cmbRol.SelectedValue), Email = this.txtEmail.Text.Trim(), UsuarioName = this.txtUsuario.Text.Trim(), Password = this.txtPassword.Text.Trim(), IdEmpleado = 1, FechaRegistro = DateTime.Now, Estado = 1, Status = this.chkEstado.Checked == true ? 1 : 0 }; if (this.oUsuario.UpdateUsuario(data)) { this.GetUsuarios(); MessageBox.Show("Se actualizo correctamente", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Error,no se puedo actualizar", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show("Ocurrio un error comuniquese con el administrador.", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Error); } }