commit 0afe1a02f27ac0a15c9edc4c1ecec83ed4548381 Author: edgar.juarez Date: Sun Mar 3 16:08:11 2024 -0600 avance1 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..4657635 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,17 @@ + + + + + mysql.8 + true + com.mysql.cj.jdbc.Driver + jdbc:mysql://db4free.net:3306/basecursos + + + + + + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/mezontleTeam.iml b/.idea/mezontleTeam.iml new file mode 100644 index 0000000..b9f5507 --- /dev/null +++ b/.idea/mezontleTeam.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..19d570b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..5561d96 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DatabaseManager.java b/DatabaseManager.java new file mode 100644 index 0000000..5002a0d --- /dev/null +++ b/DatabaseManager.java @@ -0,0 +1,30 @@ +import java.sql.*; + +public class DatabaseManager { + private static final String URL = "jdbc:mysql://db4free.net:3306/basecursos"; + private static final String USERNAME = "edgarivanjc"; + private static final String PASSWORD = "edgarivanJC12"; + + public static User getAuthenticatedUser(String nombre, String contrasena) { + User user = null; + try (Connection conexion = DriverManager.getConnection(URL, USERNAME, PASSWORD)) { + String consulta = "SELECT * FROM usuarios WHERE nombre = ? AND contrasena = ?"; + try (PreparedStatement statement = conexion.prepareStatement(consulta)) { + statement.setString(1, nombre); + statement.setString(2, contrasena); + try (ResultSet resultSet = statement.executeQuery()) { + if (resultSet.next()) { + int id = resultSet.getInt("id"); + String nombreUsuario = resultSet.getString("nombre"); + String email = resultSet.getString("email"); + String contrasenaUsuario = resultSet.getString("contrasena"); + user = new User(id, nombreUsuario, email, contrasenaUsuario); + } + } + } + } catch (SQLException ex) { + ex.printStackTrace(); + } + return user; + } +} diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..b5bf9c6 --- /dev/null +++ b/Main.java @@ -0,0 +1,13 @@ +import javax.swing.*; + +public class Main { + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> { + JFrame frame = new JFrame("Login"); + frame.setContentPane(new ventana1().panel); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + }); + } +} \ No newline at end of file diff --git a/User.java b/User.java new file mode 100644 index 0000000..22cceea --- /dev/null +++ b/User.java @@ -0,0 +1,45 @@ +public class User { + private int id; + private String nombre; + private String email; + private String contrasena; + + public User(int id, String nombre, String email, String contrasena) { + this.id = id; + this.nombre = nombre; + this.email = email; + this.contrasena = contrasena; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getContrasena() { + return contrasena; + } + + public void setContrasena(String contrasena) { + this.contrasena = contrasena; + } +} diff --git a/out/production/mezontleTeam/.idea/.gitignore b/out/production/mezontleTeam/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/out/production/mezontleTeam/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/out/production/mezontleTeam/.idea/dataSources.xml b/out/production/mezontleTeam/.idea/dataSources.xml new file mode 100644 index 0000000..4657635 --- /dev/null +++ b/out/production/mezontleTeam/.idea/dataSources.xml @@ -0,0 +1,17 @@ + + + + + mysql.8 + true + com.mysql.cj.jdbc.Driver + jdbc:mysql://db4free.net:3306/basecursos + + + + + + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/out/production/mezontleTeam/.idea/mezontleTeam.iml b/out/production/mezontleTeam/.idea/mezontleTeam.iml new file mode 100644 index 0000000..b9f5507 --- /dev/null +++ b/out/production/mezontleTeam/.idea/mezontleTeam.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/mezontleTeam/.idea/misc.xml b/out/production/mezontleTeam/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/out/production/mezontleTeam/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/mezontleTeam/.idea/modules.xml b/out/production/mezontleTeam/.idea/modules.xml new file mode 100644 index 0000000..19d570b --- /dev/null +++ b/out/production/mezontleTeam/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/mezontleTeam/.idea/uiDesigner.xml b/out/production/mezontleTeam/.idea/uiDesigner.xml new file mode 100644 index 0000000..5561d96 --- /dev/null +++ b/out/production/mezontleTeam/.idea/uiDesigner.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/mezontleTeam/.idea/vcs.xml b/out/production/mezontleTeam/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/out/production/mezontleTeam/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/mezontleTeam/Main.class b/out/production/mezontleTeam/Main.class new file mode 100644 index 0000000..1bc14d2 Binary files /dev/null and b/out/production/mezontleTeam/Main.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/AbstractLayout.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/AbstractLayout.class new file mode 100644 index 0000000..64aaced Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/AbstractLayout.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/DimensionInfo.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/DimensionInfo.class new file mode 100644 index 0000000..892e85b Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/DimensionInfo.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/GridConstraints.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/GridConstraints.class new file mode 100644 index 0000000..2822a32 Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/GridConstraints.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/GridLayoutManager.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/GridLayoutManager.class new file mode 100644 index 0000000..4e7d927 Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/GridLayoutManager.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/HorizontalInfo.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/HorizontalInfo.class new file mode 100644 index 0000000..dcd3df5 Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/HorizontalInfo.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/LayoutState.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/LayoutState.class new file mode 100644 index 0000000..db7d4fc Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/LayoutState.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/Spacer.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/Spacer.class new file mode 100644 index 0000000..fdf948f Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/Spacer.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/SupportCode$TextWithMnemonic.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/SupportCode$TextWithMnemonic.class new file mode 100644 index 0000000..f67d883 Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/SupportCode$TextWithMnemonic.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/SupportCode.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/SupportCode.class new file mode 100644 index 0000000..0a34b84 Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/SupportCode.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/Util.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/Util.class new file mode 100644 index 0000000..c033885 Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/Util.class differ diff --git a/out/production/mezontleTeam/com/intellij/uiDesigner/core/VerticalInfo.class b/out/production/mezontleTeam/com/intellij/uiDesigner/core/VerticalInfo.class new file mode 100644 index 0000000..bf0fb5a Binary files /dev/null and b/out/production/mezontleTeam/com/intellij/uiDesigner/core/VerticalInfo.class differ diff --git a/out/production/mezontleTeam/ventana1$1.class b/out/production/mezontleTeam/ventana1$1.class new file mode 100644 index 0000000..2bebf33 Binary files /dev/null and b/out/production/mezontleTeam/ventana1$1.class differ diff --git a/out/production/mezontleTeam/ventana1.class b/out/production/mezontleTeam/ventana1.class new file mode 100644 index 0000000..2fe4260 Binary files /dev/null and b/out/production/mezontleTeam/ventana1.class differ diff --git a/ventana1.form b/ventana1.form new file mode 100644 index 0000000..8407a8a --- /dev/null +++ b/ventana1.form @@ -0,0 +1,104 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ventana1.java b/ventana1.java new file mode 100644 index 0000000..8ffe435 --- /dev/null +++ b/ventana1.java @@ -0,0 +1,44 @@ +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class ventana1 { + JPanel panel; + private JTextField usuariol; + private JButton iniciarBoton; + private JButton registerBoton; + private JPasswordField contrasenal; + private JLabel usuarioLabel; + private JLabel contrasenaLabel; + private JLabel inicioText; + + public ventana1() { + iniciarBoton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String usuario = usuariol.getText(); + String contrasena = String.valueOf(contrasenal.getPassword()); + + // Realizar la autenticación con la base de datos + User user = DatabaseManager.getAuthenticatedUser(usuario, contrasena); + + if (user != null) { + JOptionPane.showMessageDialog(null, "Inicio de sesión exitoso"); + // Aquí puedes realizar otras acciones después de iniciar sesión correctamente + } else { + JOptionPane.showMessageDialog(null, "Usuario o contraseña incorrectos"); + } + } + }); + } + + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> { + JFrame frame = new JFrame("Login"); + frame.setContentPane(new ventana1().panel); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + }); + } +}