-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheliminarFuncion.java
More file actions
163 lines (135 loc) · 4.33 KB
/
Copy patheliminarFuncion.java
File metadata and controls
163 lines (135 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package Interfaces;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class eliminarFuncion implements ActionListener{
private JButton btnVolver,btnEliminar;
public JFrame frame;
private JTextField textNumero;
/**
* Launch the application.
*/
// CONECTA A LA BASE DE DATOS Y CONSIGUE EL CON
private Connection con = ConexionBD.conectar();
public PreparedStatement pstm = null;
ResultSet rs = null;
String query="";
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
eliminarFuncion window = new eliminarFuncion();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public eliminarFuncion() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
@SuppressWarnings({ })
private void initialize() {
frame = new JFrame();
frame.getContentPane().setFocusable(false);
frame.setBounds(100, 100, 960, 640);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(960,640);
frame.getContentPane().setLayout(null);
frame.getContentPane().setBackground(new Color(72,81,84));
JLabel lblEliminar = new JLabel("Eliminar funcion");
lblEliminar.setForeground(Color.WHITE);
lblEliminar.setFont(new Font("Arial", Font.BOLD, 40));
lblEliminar.setBounds(299, 45, 342, 72);
frame.getContentPane().add(lblEliminar);
btnVolver = new JButton("Volver");
btnVolver.setForeground(Color.WHITE);
btnVolver.setFont(new Font("Arial", Font.PLAIN, 20));
btnVolver.setFocusPainted(false);
btnVolver.setBorderPainted(false);
btnVolver.setBackground(new Color(171, 0, 51));
btnVolver.setBounds(10, 562, 139, 31);
frame.getContentPane().add(btnVolver);
btnVolver.addActionListener(this);
btnEliminar = new JButton("Eliminar");
btnEliminar.setBorderPainted(false);
btnEliminar.setFocusPainted(false);
btnEliminar.setForeground(Color.WHITE);
btnEliminar.setFont(new Font("Arial", Font.PLAIN, 17));
btnEliminar.setBackground(new Color(171, 0, 51));
btnEliminar.setBounds(389, 278, 149, 39);
frame.getContentPane().add(btnEliminar);
btnEliminar.addActionListener(this);
JLabel lblNumero = new JLabel("Numero de sala:");
lblNumero.setForeground(Color.WHITE);
lblNumero.setFont(new Font("Arial", Font.PLAIN, 20));
lblNumero.setBounds(335, 184, 170, 24);
frame.getContentPane().add(lblNumero);
textNumero = new JTextField();
textNumero.setBounds(491, 190, 96, 19);
frame.getContentPane().add(textNumero);
textNumero.setColumns(10);
}
@Override
public void actionPerformed(ActionEvent e) {
menuFunciones menuFunciones = new menuFunciones();
int opcion;
if(e.getSource()==btnEliminar) {
if(textNumero.getText().isEmpty()) {
JOptionPane.showMessageDialog(null,"Intreoducir bien el dato");
} else {
int sala = Integer.parseInt(textNumero.getText());
try {
query= "SELECT * FROM Funcion WHERE Num_Sala = ?";
pstm = con.prepareStatement(query);
pstm.setInt(1,sala);
rs = pstm.executeQuery();
if(rs.next()) {
query ="DELETE FROM Funcion WHERE Num_Sala = ?";
pstm = con.prepareStatement(query);
pstm.setInt(1,sala);
pstm.execute();
opcion = JOptionPane.showConfirmDialog(null, "Se ha eliminado exitosamente!. \n\n�Quiere eliminar otra funcion?\n","Eliminado",JOptionPane.YES_NO_OPTION);
}
else {
JOptionPane.showMessageDialog(null, "No se encuentra la Funcion");
}
rs.close();
pstm.close();
con.close();
} catch (SQLException e1) {
}
}
opcion = JOptionPane.NO_OPTION;
if(opcion==JOptionPane.YES_OPTION) {
textNumero.setText("");
}
else {
menuFunciones.frame.setVisible(true);
frame.dispose();
}
}
else {
menuFunciones.frame.setVisible(true);
frame.dispose();
}
}
}