Update StolowkaZPM.java

This commit is contained in:
s441433 2019-01-09 01:35:11 +01:00
parent 11838626a5
commit c0b9ad4878

View File

@ -1,46 +1,28 @@
//import javax.swing.*;
//import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
//import javax.swing.JLayeredPane;
//import javax.swing.JOptionPane;
//import javax.swing.JTextField;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
//import java.awt.Image;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import javax.swing.JPasswordField; import javax.swing.JPasswordField;
import javax.swing.JTextField;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
//import java.awt.event.FocusListener;
import java.awt.*; import java.awt.*;
//import javax.swing.JPanel;
//import com.jgoodies.forms.layout.FormLayout;
//import com.jgoodies.forms.layout.ColumnSpec;
//import com.jgoodies.forms.layout.RowSpec;
//import javax.swing.JDesktopPane;
//import javax.swing.JToolBar;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
//import java.sql.*;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
//import javax.swing.JPanel;
public class StolowkaZPM { public class StolowkaZPM {
private JFrame frmStolowkaZpm; private JFrame frmStolowkaZpm;
private JLabel lblNewLabel; private JLabel lblNewLabel;
//public String Dalej; protected String Dalej;
//private JLabel podajPINlabel;
//private JLabel pinView;
//private String Dalej;
//public StolowkaZPM() {Dalej=null;}
//public StolowkaZPM(String n) {Dalej=n;}
//public StolowkaZPM(StolowkaZPM P) {Dalej=P.Dalej;}
//public String GetDalej() {return Dalej;}
/** /**
* Launch the application. * Launch the application.
@ -109,11 +91,28 @@ public class StolowkaZPM {
frmStolowkaZpm.getContentPane().add(lblZbliKartDo); frmStolowkaZpm.getContentPane().add(lblZbliKartDo);
lblZbliKartDo.setFont(new Font("Tahoma", Font.PLAIN, 40)); lblZbliKartDo.setFont(new Font("Tahoma", Font.PLAIN, 40));
JPasswordField rfidView = new JPasswordField(); JTextField rfidView = new JTextField();
rfidView.setHorizontalAlignment(SwingConstants.CENTER); rfidView.setHorizontalAlignment(SwingConstants.CENTER);
frmStolowkaZpm.getContentPane().add(rfidView); frmStolowkaZpm.getContentPane().add(rfidView);
rfidView.setFont(new Font("Tahoma", Font.PLAIN, 50)); rfidView.setFont(new Font("Tahoma", Font.PLAIN, 50));
rfidView.setToolTipText("numer karty"); rfidView.setToolTipText("numer karty");
JLabel podajPINlabel = new JLabel("PODAJ PIN (4 CYFRY)");
podajPINlabel.setHorizontalAlignment(SwingConstants.CENTER);
frmStolowkaZpm.getContentPane().add(podajPINlabel);
podajPINlabel.setFont(new Font("Tahoma", Font.PLAIN, 40));
JPasswordField pinView = new JPasswordField();
pinView.setHorizontalAlignment(SwingConstants.CENTER);
frmStolowkaZpm.getContentPane().add(pinView);
pinView.setFont(new Font("Tahoma", Font.PLAIN, 50));
pinView.setToolTipText("PIN");
JButton btnZaloguj = new JButton("Zaloguj");
btnZaloguj.setFont(new Font("Tahoma", Font.PLAIN, 50));
btnZaloguj.setBounds(724, 298, 213, 69);
frmStolowkaZpm.getContentPane().add(btnZaloguj);
rfidView.addActionListener(new ActionListener() { rfidView.addActionListener(new ActionListener() {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -121,52 +120,62 @@ public class StolowkaZPM {
//************************************** //**************************************
try { try {
String query = "SELECT * FROM users WHERE RFID=?"; String query = "SELECT * FROM users WHERE RFID=? AND Blokada=?";
PreparedStatement pst = conn.prepareStatement(query); PreparedStatement pst = conn.prepareStatement(query);
pst.setString(1, rfidView.getText()); pst.setString(1, rfidView.getText());
pst.setString(2, "false");
ResultSet rFID = pst.executeQuery(); ResultSet rFID = pst.executeQuery();
String Dalej = rFID.getString("PIN"); String Dalej = rFID.getString("PIN");
String imie = rFID.getString("User");
int count = 0; int count = 0;
while (rFID.next()) { while (rFID.next()) {
count=count+1; count=count+1;
} }
if (count == 1) { if (count == 1) {
//rfidView.setText("");
rfidView.setText(imie);
//JOptionPane.showMessageDialog(frmStolowkaZpm, "Zalogowano!"); //JOptionPane.showMessageDialog(frmStolowkaZpm, "Zalogowano!");
//JOptionPane.showMessageDialog(frmStolowkaZpm, Dalej); //JOptionPane.showMessageDialog(frmStolowkaZpm, Dalej);
//oknoPIN wpiszPin = new oknoPIN(); //oknoPIN wpiszPin = new oknoPIN();
//wpiszPin.noweOkno(); //wpiszPin.noweOkno();
//frmStolowkaZpm.remove(lblZbliKartDo);
//frmStolowkaZpm.remove(rfidView);
frmStolowkaZpm.remove(lblZbliKartDo); /*
JLabel podajPINlabel = new JLabel("PODAJ PIN (4 CYFRY)"); JLabel podajPINlabel = new JLabel("PODAJ PIN (4 CYFRY)");
podajPINlabel.setHorizontalAlignment(SwingConstants.CENTER); podajPINlabel.setHorizontalAlignment(SwingConstants.CENTER);
frmStolowkaZpm.getContentPane().add(podajPINlabel); frmStolowkaZpm.getContentPane().add(podajPINlabel);
podajPINlabel.setFont(new Font("Tahoma", Font.PLAIN, 40)); podajPINlabel.setFont(new Font("Tahoma", Font.PLAIN, 40));
frmStolowkaZpm.remove(rfidView);
JPasswordField pinView = new JPasswordField(); JPasswordField pinView = new JPasswordField();
pinView.setHorizontalAlignment(SwingConstants.CENTER); pinView.setHorizontalAlignment(SwingConstants.CENTER);
frmStolowkaZpm.getContentPane().add(pinView); frmStolowkaZpm.getContentPane().add(pinView);
pinView.setFont(new Font("Tahoma", Font.PLAIN, 50)); pinView.setFont(new Font("Tahoma", Font.PLAIN, 50));
pinView.setToolTipText("numer karty"); pinView.setToolTipText("PIN");
JButton btnZaloguj = new JButton("Zaloguj"); JButton btnZaloguj = new JButton("Zaloguj");
btnZaloguj.setFont(new Font("Tahoma", Font.PLAIN, 50)); btnZaloguj.setFont(new Font("Tahoma", Font.PLAIN, 50));
btnZaloguj.setBounds(724, 298, 213, 69); btnZaloguj.setBounds(724, 298, 213, 69);
frmStolowkaZpm.getContentPane().add(btnZaloguj); frmStolowkaZpm.getContentPane().add(btnZaloguj);
*/
btnZaloguj.addActionListener(new ActionListener() { btnZaloguj.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try { try {
String Dalej1 = pinView.getText(); String Dalej1 = pinView.getText();
if(Dalej.equals(Dalej1)){
DrukujBilet wybierzMenu = new DrukujBilet(); rfidView.setText("");
wybierzMenu.oknoDrukujBilet();}
else{
pinView.setText(""); pinView.setText("");
if(Dalej.equals(Dalej1)){
DrukujBilet wybierzMenu = new DrukujBilet();
wybierzMenu.oknoDrukujBilet();
}else{
//JOptionPane.showMessageDialog(frmStolowkaZpm, Dalej1); //JOptionPane.showMessageDialog(frmStolowkaZpm, Dalej1);
//JOptionPane.showMessageDialog(frmStolowkaZpm, Dalej); //JOptionPane.showMessageDialog(frmStolowkaZpm, Dalej);
} }
@ -212,6 +221,7 @@ public class StolowkaZPM {
} else { } else {
rfidView.setText(""); rfidView.setText("");
pinView.setText("");
//JOptionPane.showMessageDialog(frmStolowkaZpm, "NIE Zalogowano!"); //JOptionPane.showMessageDialog(frmStolowkaZpm, "NIE Zalogowano!");
} }
rFID.close(); rFID.close();