Update DrukujBilet.java
This commit is contained in:
parent
cf3488bd68
commit
76d923c5ab
@ -45,6 +45,9 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
DefaultTableModel defaultTableModel = new DefaultTableModel();
|
DefaultTableModel defaultTableModel = new DefaultTableModel();
|
||||||
|
|
||||||
public static void oknoDrukujBilet() {
|
public static void oknoDrukujBilet() {
|
||||||
|
|
||||||
|
//callClass.enterName();
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable() {
|
EventQueue.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -79,9 +82,8 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
protected int sek;
|
protected int sek;
|
||||||
protected int min;
|
protected int min;
|
||||||
protected int godz;
|
protected int godz;
|
||||||
//protected String OstatniIDbiletuString;
|
|
||||||
//protected int OstatniIDbiletuInt;
|
|
||||||
protected String dataIczas;
|
protected String dataIczas;
|
||||||
|
protected int IDuzytkownikaPrint;
|
||||||
|
|
||||||
public void zegar() {
|
public void zegar() {
|
||||||
Thread zegar = new Thread() {
|
Thread zegar = new Thread() {
|
||||||
@ -101,7 +103,7 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
int godz = cal.get(Calendar.HOUR);
|
int godz = cal.get(Calendar.HOUR);
|
||||||
|
|
||||||
lblClock.setText("Czas: "+godz+":"+min+":"+sek+" Data: "+day+"."+month+"."+year);
|
lblClock.setText("Czas: "+godz+":"+min+":"+sek+" Data: "+day+"."+month+"."+year);
|
||||||
dataIczas = year+"-"+month+"-"+day+" "+godz+":"+min+":"+sek;
|
dataIczas = year+"-"+month+"-"+day+" / "+godz+":"+min+":"+sek;
|
||||||
|
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
}
|
}
|
||||||
@ -118,6 +120,10 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
zegar();
|
zegar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printName(int recivediDuzytkownikaSet) {
|
||||||
|
IDuzytkownikaPrint = recivediDuzytkownikaSet;
|
||||||
|
}
|
||||||
|
|
||||||
private void initialize() throws SQLException {
|
private void initialize() throws SQLException {
|
||||||
|
|
||||||
conn=SQLiteConnection.dbConnector();
|
conn=SQLiteConnection.dbConnector();
|
||||||
@ -161,6 +167,7 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
ResultSet rs = pst.executeQuery();
|
ResultSet rs = pst.executeQuery();
|
||||||
table_1.setModel(DbUtils.resultSetToTableModel(rs));
|
table_1.setModel(DbUtils.resultSetToTableModel(rs));
|
||||||
|
|
||||||
|
|
||||||
JLabel lblId = new JLabel("ID");
|
JLabel lblId = new JLabel("ID");
|
||||||
lblId.setFont(new Font("Tahoma", Font.PLAIN, 25));
|
lblId.setFont(new Font("Tahoma", Font.PLAIN, 25));
|
||||||
lblId.setBounds(118, 14, 39, 28);
|
lblId.setBounds(118, 14, 39, 28);
|
||||||
@ -188,7 +195,7 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
txtrWybrano.setBackground(Color.WHITE);
|
txtrWybrano.setBackground(Color.WHITE);
|
||||||
txtrWybrano.setLineWrap(true);
|
txtrWybrano.setLineWrap(true);
|
||||||
txtrWybrano.setFont(new Font("Monospaced", Font.PLAIN, 20));
|
txtrWybrano.setFont(new Font("Monospaced", Font.PLAIN, 20));
|
||||||
txtrWybrano.setBounds(852, 37, 282, 51);
|
txtrWybrano.setBounds(852, 37, 287, 51);
|
||||||
TabelaMenu.add(txtrWybrano);
|
TabelaMenu.add(txtrWybrano);
|
||||||
txtrWybrano.setText("");
|
txtrWybrano.setText("");
|
||||||
|
|
||||||
@ -254,7 +261,7 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
txtrWybrano.setText("");
|
txtrWybrano.setText("");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnNewButton_1.setBounds(1000, 162, 149, 112);
|
btnNewButton_1.setBounds(990, 101, 149, 233);
|
||||||
TabelaMenu.add(btnNewButton_1);
|
TabelaMenu.add(btnNewButton_1);
|
||||||
|
|
||||||
JLabel lblInfo = new JLabel("INFO");
|
JLabel lblInfo = new JLabel("INFO");
|
||||||
@ -291,6 +298,9 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
d1 = d1+1;
|
d1 = d1+1;
|
||||||
textArea.setText(d1+" szt "+n1);
|
textArea.setText(d1+" szt "+n1);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
pst.close();
|
||||||
|
|
||||||
} catch (Exception e1){
|
} catch (Exception e1){
|
||||||
JOptionPane.showMessageDialog(null, e1);
|
JOptionPane.showMessageDialog(null, e1);
|
||||||
}
|
}
|
||||||
@ -310,6 +320,9 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
d2 = d2+1;
|
d2 = d2+1;
|
||||||
textArea_1.setText(d2+" szt "+n2);
|
textArea_1.setText(d2+" szt "+n2);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
pst.close();
|
||||||
|
|
||||||
} catch (Exception e1){
|
} catch (Exception e1){
|
||||||
JOptionPane.showMessageDialog(null, e1);
|
JOptionPane.showMessageDialog(null, e1);
|
||||||
}
|
}
|
||||||
@ -329,6 +342,9 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
d3 = d3+1;
|
d3 = d3+1;
|
||||||
textArea_2.setText(d3+" szt "+n3);
|
textArea_2.setText(d3+" szt "+n3);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
pst.close();
|
||||||
|
|
||||||
} catch (Exception e1){
|
} catch (Exception e1){
|
||||||
JOptionPane.showMessageDialog(null, e1);
|
JOptionPane.showMessageDialog(null, e1);
|
||||||
}
|
}
|
||||||
@ -348,6 +364,9 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
d4 = d4+1;
|
d4 = d4+1;
|
||||||
textArea_3.setText(d4+" szt "+n4);
|
textArea_3.setText(d4+" szt "+n4);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
pst.close();
|
||||||
|
|
||||||
} catch (Exception e1){
|
} catch (Exception e1){
|
||||||
JOptionPane.showMessageDialog(null, e1);
|
JOptionPane.showMessageDialog(null, e1);
|
||||||
}
|
}
|
||||||
@ -367,6 +386,9 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
d5 = d5+1;
|
d5 = d5+1;
|
||||||
textArea_4.setText(d5+" szt "+n5);
|
textArea_4.setText(d5+" szt "+n5);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
pst.close();
|
||||||
|
|
||||||
} catch (Exception e1){
|
} catch (Exception e1){
|
||||||
JOptionPane.showMessageDialog(null, e1);
|
JOptionPane.showMessageDialog(null, e1);
|
||||||
}
|
}
|
||||||
@ -386,6 +408,9 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
d6 = d6+1;
|
d6 = d6+1;
|
||||||
textArea_5.setText(d6+" szt "+n6);
|
textArea_5.setText(d6+" szt "+n6);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
pst.close();
|
||||||
|
|
||||||
} catch (Exception e1){
|
} catch (Exception e1){
|
||||||
JOptionPane.showMessageDialog(null, e1);
|
JOptionPane.showMessageDialog(null, e1);
|
||||||
}
|
}
|
||||||
@ -404,28 +429,6 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
|
|
||||||
/*
|
|
||||||
int count = 0;
|
|
||||||
while (rs.next()) {
|
|
||||||
count=count+1;
|
|
||||||
|
|
||||||
//columnData[0] = danie.getString("IDdania");
|
|
||||||
//columnData[1] = danie.getString("NazwaDania");
|
|
||||||
//columnData[2] = danie.getString("KosztDania");
|
|
||||||
|
|
||||||
//defaultTableModel.addRow(columnData);
|
|
||||||
|
|
||||||
//JToggleButton Baton = new JToggleButton(NazwaDania);
|
|
||||||
//Baton.setBounds(192, 66, 137, 25);
|
|
||||||
//MenuStolowkaZPM.getContentPane().add(Baton);
|
|
||||||
}
|
|
||||||
danie.close();
|
|
||||||
pst.close();
|
|
||||||
*/
|
|
||||||
//} catch (Exception e1){
|
|
||||||
// JOptionPane.showMessageDialog(null, e1);
|
|
||||||
//}
|
|
||||||
|
|
||||||
JButton btnNewButton = new JButton("Drukuj bilet");
|
JButton btnNewButton = new JButton("Drukuj bilet");
|
||||||
btnNewButton.setForeground(Color.BLACK);
|
btnNewButton.setForeground(Color.BLACK);
|
||||||
btnNewButton.setBackground(Color.GREEN);
|
btnNewButton.setBackground(Color.GREEN);
|
||||||
@ -435,48 +438,34 @@ public class DrukujBilet extends StolowkaZPM {
|
|||||||
|
|
||||||
btnNewButton.addActionListener(new ActionListener() {
|
btnNewButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
/*
|
if (sumaKoszt != 0) {
|
||||||
try {
|
try {
|
||||||
String query = "SELECT * FROM bilety";
|
String query="INSERT INTO bilety(KtoZabralID, DataCzas, KosztBiletu, CzyZaplacony) VALUES (?,?,?,?)";
|
||||||
PreparedStatement pst = conn.prepareStatement(query);
|
PreparedStatement pst = conn.prepareStatement(query);
|
||||||
ResultSet rs = pst.executeQuery();
|
pst.setInt(1, IDuzytkownikaPrint);
|
||||||
OstatniIDbiletuString = rs.getString("IDbiletu");
|
pst.setString(2, dataIczas);
|
||||||
int count = 0;
|
pst.setInt(3, sumaKoszt);
|
||||||
while (rs.next()) {
|
|
||||||
count=count+1;
|
|
||||||
}
|
|
||||||
if (count == 1) {
|
|
||||||
JOptionPane.showMessageDialog(null, OstatniIDbiletuString+" OSTATNI ROW");
|
|
||||||
}
|
|
||||||
//int OstatniIDbiletuInt = Integer.parseInt(OstatniIDbiletuString);
|
|
||||||
JOptionPane.showMessageDialog(null, OstatniIDbiletuString);
|
|
||||||
rs.close();
|
|
||||||
pst.close();
|
|
||||||
|
|
||||||
} catch (Exception e1){
|
|
||||||
JOptionPane.showMessageDialog(null, e1);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
try {
|
|
||||||
//OstatniIDbiletuInt = OstatniIDbiletuInt+1;
|
|
||||||
//String OstatniIDbiletuString = Integer.toString(OstatniIDbiletuInt);
|
|
||||||
String sumaKosztString = Integer.toString(sumaKoszt);
|
|
||||||
String query = "INSERT INTO bilety(KtoZabralID,DataCzas,KosztBiletu,CzyZaplacony) VALUES (?,?,?,?)";
|
|
||||||
PreparedStatement pst = conn.prepareStatement(query);
|
|
||||||
pst.setInt(1, 1);
|
|
||||||
pst.setDate(year, x);
|
|
||||||
pst.setInt(3, 36);
|
|
||||||
pst.setString(4, "nie");
|
pst.setString(4, "nie");
|
||||||
|
pst.execute();
|
||||||
|
JOptionPane.showMessageDialog(null, " ** "+IDuzytkownikaPrint+" ** "+dataIczas+" ** "+sumaKoszt+" ** "+"nie");
|
||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
//JOptionPane.showMessageDialog(null, " ** "+IDuzytkownika+" ** "+dataIczas+" ** "+sumaKosztString+" ** "+"nie");
|
|
||||||
MenuStolowkaZPM.setVisible(false);
|
MenuStolowkaZPM.setVisible(false);
|
||||||
|
|
||||||
} catch (Exception e1){
|
} catch (Exception e1){
|
||||||
JOptionPane.showMessageDialog(null, e1);
|
JOptionPane.showMessageDialog(null, e1);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
rs.close();
|
||||||
|
pst.close();
|
||||||
|
} catch(Exception e1) {
|
||||||
|
JOptionPane.showMessageDialog(null, e1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}});
|
}
|
||||||
|
}});
|
||||||
|
pst.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user