Update oknoPIN.java

This commit is contained in:
s441433 2019-01-08 22:18:04 +01:00
parent 7d2457a0ff
commit 3fae5fa42d

View File

@ -1,33 +1,37 @@
import java.awt.EventQueue;
import java.awt.Toolkit;
//import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Color;
import javax.swing.SwingConstants;
import javax.swing.BoxLayout;
import javax.swing.JTree;
import javax.swing.JSlider;
import javax.swing.JToggleButton;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.layout.FormSpecs;
import javax.swing.JTextField;
//import javax.swing.BoxLayout;
//import javax.swing.JTree;
//import javax.swing.JSlider;
//import javax.swing.JToggleButton;
//import com.jgoodies.forms.layout.FormLayout;
//import com.jgoodies.forms.layout.ColumnSpec;
//import com.jgoodies.forms.layout.RowSpec;
//import com.jgoodies.forms.layout.FormSpecs;
//import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.awt.event.ActionEvent;
import java.awt.Font;
public class oknoPIN {
public class oknoPIN extends StolowkaZPM {
private JFrame PodajPin;
private JPasswordField passwordField;
//public String Dalej;
/**
* Launch the application.
*/
public static void noweOkno() {
EventQueue.invokeLater(new Runnable() {
public void run() {
@ -41,17 +45,19 @@ public class oknoPIN {
});
}
/**
* Create the application.
*/
public oknoPIN() {
initialize();
Connection conn=null;
public oknoPIN () {
initialize2();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
private void initialize2 () {
//**************************************
conn=SQLiteConnection.dbConnector();
//**************************************
PodajPin = new JFrame();
PodajPin.setTitle("Podaj PIN");
PodajPin.setBounds(100, 100, 528, 306);
@ -77,10 +83,37 @@ public class oknoPIN {
JButton btnZaloguj = new JButton("Zaloguj");
btnZaloguj.setFont(new Font("Tahoma", Font.PLAIN, 50));
btnZaloguj.addActionListener(new ActionListener() {
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e) {
PodajPin.setVisible(false);
DrukujBilet wybierzMenu = new DrukujBilet();
wybierzMenu.oknoDrukujBilet();
try {
String query = "SELECT * FROM users WHERE RFID=? and Password=?";
PreparedStatement pst2 = conn.prepareStatement(query);
pst2.setString(1, "0000");
pst2.setString(2, passwordField.getText());
ResultSet pass = pst2.executeQuery();
int count = 0;
while (pass.next()) {
count=count+1;
}
if (count == 1) {
passwordField.setText("");
JOptionPane.showMessageDialog(PodajPin, "Zalogowano!");
PodajPin.setVisible(false);
DrukujBilet wybierzMenu = new DrukujBilet();
wybierzMenu.oknoDrukujBilet();
} else {
passwordField.setText("");
JOptionPane.showMessageDialog(PodajPin, "NIE Zalogowano!");
}
pass.close();
pst2.close();
} catch (Exception e1){
JOptionPane.showMessageDialog(null, e1);
passwordField.setText("");
}
}
});
btnZaloguj.setBounds(724, 298, 213, 69);