private async void btnEliminar_Click(object sender, RoutedEventArgs e) { try { OracleCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("RUT_TRAB", OracleDbType.Varchar2, 100).Value = txtRut.Text; cmd.CommandText = "delete from trabajador where rut_trab = :RUT_TRAB"; try { int n = cmd.ExecuteNonQuery(); if (n > 0) { await this.ShowMessageAsync("eliminado", "Usuario eliminado correctamente"); VisualizarUsuario v = new VisualizarUsuario(); this.Close(); v.Show(); } } catch (Exception) { await this.ShowMessageAsync("Error", "no se pudo eliminar"); } } catch (Exception) { throw; } }
private void btnVolver_Click(object sender, RoutedEventArgs e) { VisualizarUsuario vu = new VisualizarUsuario(); vu.Show(); this.Close(); }
private void Button_Click(object sender, RoutedEventArgs e) { VisualizarUsuario vu = new VisualizarUsuario(nomUsuario); vu.Show(); this.Close(); }
private async void btnModificar_Click(object sender, RoutedEventArgs e) { try { OracleCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; if (txtNombre.Text.Replace(" ", string.Empty).Length >= 3) { cmd.Parameters.Add("NOMBRE_TRAB", OracleDbType.Varchar2, 100).Value = txtNombre.Text; } else { await this.ShowMessageAsync("Error", "el nombre debe tener mas de 3 caracteres!"); } if (txtApellido.Text.Replace(" ", string.Empty).Length >= 3) { cmd.Parameters.Add("APELLIDO_TRAB", OracleDbType.Varchar2, 100).Value = txtApellido.Text; } else { await this.ShowMessageAsync("Error", "el apellido debe tener mas de 3 caracteres!"); } if (dpFechaNacimiento.SelectedDate != null) { cmd.Parameters.Add("FECHA_NACIMIENTO", OracleDbType.Date).Value = dpFechaNacimiento.SelectedDate; } else { await this.ShowMessageAsync("Error", "la fecha de nacimiento debe ser valida!"); } if (txtCorreo.Text.Replace(" ", string.Empty) != null) { cmd.Parameters.Add("CORREO", OracleDbType.Varchar2, 100).Value = txtCorreo.Text; } else { await this.ShowMessageAsync("Error", "debe ingresar un correo!"); } if (txtNombreUsuario.Text.Replace(" ", string.Empty).Length >= 3) { cmd.Parameters.Add("NOM_USUARIO", OracleDbType.Varchar2, 100).Value = txtNombreUsuario.Text; } else { await this.ShowMessageAsync("Error", "el usuario debe tener mas de 3 caracteres!"); } if (txtContrasena.Password.Replace(" ", string.Empty).Length >= 6) { cmd.Parameters.Add("CONTRASENA_USUARIO", OracleDbType.Varchar2, 100).Value = txtContrasena.Password; } else { await this.ShowMessageAsync("Error", "la contraseña debe tener mas de 6 caracteres!"); } if (cboCargo.SelectedValue != null) { cmd.Parameters.Add("CARGO_TRABAJADOR_ID_CARGO", OracleDbType.Int32, 20).Value = cboCargo.SelectedValue; } else { await this.ShowMessageAsync("Error", "debe seleccionar un cargo!"); } if (cboEstadoCivil.SelectedValue != null) { cmd.Parameters.Add("ESTADO_CIVIL_ID_ESTAC", OracleDbType.Int32, 20).Value = cboEstadoCivil.SelectedValue; } else { await this.ShowMessageAsync("Error", "debe seleccionar un estado civil!"); } cmd.Parameters.Add("RUT_TRAB", OracleDbType.Varchar2, 100).Value = txtRut.Text; cmd.CommandText = "update trabajador set nombre_trab =:NOMBRE_TRAB,apellido_trab=:APELLIDO_TRAB,fecha_nacimiento=:FECHA_NACIMIENTO,correo=:CORREO,nom_usuario=:NOM_USUARIO,contrasena_usuario=:CONTRASENA_USUARIO,cargo_trabajador_id_cargo=:CARGO_TRABAJADOR_ID_CARGO,estado_civil_id_estac=:ESTADO_CIVIL_ID_ESTAC where rut_trab=:RUT_TRAB"; try { int n = cmd.ExecuteNonQuery(); if (n > 0) { await this.ShowMessageAsync("actualizado", "Usuario actualizado correctamente"); VisualizarUsuario v = new VisualizarUsuario(); this.Close(); v.Show(); } } catch (Exception) { await this.ShowMessageAsync("Error", "no se pudo actualizar"); } } catch (Exception) { throw; } }