Compare commits

...

5 Commits

Author SHA1 Message Date
Frantatita 8d1d8db6a0 Merge branch 'main' of https://git.gumoio.com/Juan.Lazaro/SIU_Dran_net 2024-05-09 09:56:39 -06:00
Frantatita 701b5c0e1d DAOTutor 2024-05-09 09:55:22 -06:00
Frantatita 8cca97e065 Merge branch 'main' of https://git.gumoio.com/Juan.Lazaro/SIU_Dran_net 2024-05-09 08:59:42 -06:00
Frantatita 8db0fd01b2 x 2024-05-09 08:59:20 -06:00
Frantatita 5efe884ede x 2024-05-08 08:52:07 -06:00
2 changed files with 133 additions and 1 deletions

View File

@ -0,0 +1,127 @@
package mx.uv.Controller;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import mx.uv.Model.Tutor;
public class DAOTutor {
private static Conexion cn = Conexion.getInstance();
public static List<Tutor> dameTutores() {
Statement stm = null;
ResultSet rs = null;
Connection conn = null;
List<Tutor> resultado = new ArrayList<>();
conn = cn.conectar();
try {
String sql = "SELECT * from tutor";
stm = conn.createStatement();
rs = stm.executeQuery(sql);
while (rs.next()) {
Tutor u = new Tutor(rs.getInt(1), rs.getString(2), rs.getString(3),rs.getString(4), rs.getString(5),rs.getString(6));
resultado.add(u);
}
} catch (Exception e) {
System.out.println(e);
} finally {
cerrarConexiones(null, conn);
}
return resultado;
}
public static boolean validarTutor(Tutor tutor){
Statement stm = null;
Connection conn = null;
boolean verificacion =false;
ResultSet rs = null;
conn = cn.conectar();
try {
String sql ="select * from tutor "
+ "where id= '"+tutor.getId()+"' and nombre='"+tutor.getNombre()+"'";
stm = (Statement) conn.createStatement();
rs = stm.executeQuery(sql);
if(rs.next()){
verificacion = true;
}else{
verificacion = false;
}
conn.close();
} catch (Exception ex) {
System.err.println(ex);
}
return verificacion;
}
public static boolean agregarTutor(Tutor tutor) {
PreparedStatement stm = null;
Connection conn = null;
boolean msj = false;
conn = cn.conectar();
try {
String sql = "INSERT INTO `tutor`(`nombre`,`apellido`,`parentesco`,`ocupacion`,`telefono`)VALUES(?,?,?,?,?);";
stm = (PreparedStatement) conn.prepareStatement(sql);
stm.setString(1, tutor.getNombre());
stm.setString(2, tutor.getApellido());
stm.setString(3, tutor.getParentesco());
stm.setString(4, tutor.getOcupacion());
stm.setString(5, tutor.getTelefono());
} catch (Exception e) {
System.out.println(e);
} finally {
//cerrarConexiones(stm, conn);
}
return msj;
}
private static void cerrarConexiones(PreparedStatement stm, Connection conn){
if(stm != null){
try {
stm.close();
} catch (Exception e) {
System.out.println(e);
}
stm = null;
}
try{
conn.close();
cn.cerrarConexion();
} catch (Exception e) {
System.out.println(e);
}
}
public static boolean eliminarTutor(Tutor tutor) {
return false;
}
public static boolean editarTutor(Tutor tutor) {
PreparedStatement stm = null;
Connection conn = null;
boolean verificacion = false;
conn = cn.conectar();
try{
String sql ="UPDATE `tutor` SET `nombre` = '"+tutor.getNombre()+"',`apellido` = '"+tutor.getApellido()+"',`parentesco` = '"+tutor.getParentesco()+"',`ocupacion` = '"+tutor.getOcupacion()+"', `telefono` = '"+tutor.getTelefono()+"';";
stm = conn.prepareStatement(sql);
stm.executeQuery();
verificacion = true;
} catch (SQLException ex){
System.out.println(ex);
} finally {
cerrarConexiones(stm, conn);
cn.cerrarConexion();
}
return verificacion;
}
}

View File

@ -2,9 +2,14 @@ import React from 'react'
import ReactDOM from 'react-dom/client'
import OfertaEducativa from './OfertaEducativa.jsx'
import './Registro.css'
import './login.css'
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<General/>
<OfertaEducativa/>
</React.StrictMode>,
)