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();
|
||||
|
||||
public static void oknoDrukujBilet() {
|
||||
|
||||
//callClass.enterName();
|
||||
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
@ -79,9 +82,8 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
protected int sek;
|
||||
protected int min;
|
||||
protected int godz;
|
||||
//protected String OstatniIDbiletuString;
|
||||
//protected int OstatniIDbiletuInt;
|
||||
protected String dataIczas;
|
||||
protected int IDuzytkownikaPrint;
|
||||
|
||||
public void zegar() {
|
||||
Thread zegar = new Thread() {
|
||||
@ -101,7 +103,7 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
int godz = cal.get(Calendar.HOUR);
|
||||
|
||||
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);
|
||||
}
|
||||
@ -118,6 +120,10 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
zegar();
|
||||
}
|
||||
|
||||
public void printName(int recivediDuzytkownikaSet) {
|
||||
IDuzytkownikaPrint = recivediDuzytkownikaSet;
|
||||
}
|
||||
|
||||
private void initialize() throws SQLException {
|
||||
|
||||
conn=SQLiteConnection.dbConnector();
|
||||
@ -161,6 +167,7 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
ResultSet rs = pst.executeQuery();
|
||||
table_1.setModel(DbUtils.resultSetToTableModel(rs));
|
||||
|
||||
|
||||
JLabel lblId = new JLabel("ID");
|
||||
lblId.setFont(new Font("Tahoma", Font.PLAIN, 25));
|
||||
lblId.setBounds(118, 14, 39, 28);
|
||||
@ -188,7 +195,7 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
txtrWybrano.setBackground(Color.WHITE);
|
||||
txtrWybrano.setLineWrap(true);
|
||||
txtrWybrano.setFont(new Font("Monospaced", Font.PLAIN, 20));
|
||||
txtrWybrano.setBounds(852, 37, 282, 51);
|
||||
txtrWybrano.setBounds(852, 37, 287, 51);
|
||||
TabelaMenu.add(txtrWybrano);
|
||||
txtrWybrano.setText("");
|
||||
|
||||
@ -254,7 +261,7 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
txtrWybrano.setText("");
|
||||
}
|
||||
});
|
||||
btnNewButton_1.setBounds(1000, 162, 149, 112);
|
||||
btnNewButton_1.setBounds(990, 101, 149, 233);
|
||||
TabelaMenu.add(btnNewButton_1);
|
||||
|
||||
JLabel lblInfo = new JLabel("INFO");
|
||||
@ -291,6 +298,9 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
d1 = d1+1;
|
||||
textArea.setText(d1+" szt "+n1);
|
||||
|
||||
rs.close();
|
||||
pst.close();
|
||||
|
||||
} catch (Exception e1){
|
||||
JOptionPane.showMessageDialog(null, e1);
|
||||
}
|
||||
@ -310,6 +320,9 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
d2 = d2+1;
|
||||
textArea_1.setText(d2+" szt "+n2);
|
||||
|
||||
rs.close();
|
||||
pst.close();
|
||||
|
||||
} catch (Exception e1){
|
||||
JOptionPane.showMessageDialog(null, e1);
|
||||
}
|
||||
@ -329,6 +342,9 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
d3 = d3+1;
|
||||
textArea_2.setText(d3+" szt "+n3);
|
||||
|
||||
rs.close();
|
||||
pst.close();
|
||||
|
||||
} catch (Exception e1){
|
||||
JOptionPane.showMessageDialog(null, e1);
|
||||
}
|
||||
@ -348,6 +364,9 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
d4 = d4+1;
|
||||
textArea_3.setText(d4+" szt "+n4);
|
||||
|
||||
rs.close();
|
||||
pst.close();
|
||||
|
||||
} catch (Exception e1){
|
||||
JOptionPane.showMessageDialog(null, e1);
|
||||
}
|
||||
@ -367,6 +386,9 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
d5 = d5+1;
|
||||
textArea_4.setText(d5+" szt "+n5);
|
||||
|
||||
rs.close();
|
||||
pst.close();
|
||||
|
||||
} catch (Exception e1){
|
||||
JOptionPane.showMessageDialog(null, e1);
|
||||
}
|
||||
@ -386,6 +408,9 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
d6 = d6+1;
|
||||
textArea_5.setText(d6+" szt "+n6);
|
||||
|
||||
rs.close();
|
||||
pst.close();
|
||||
|
||||
} catch (Exception e1){
|
||||
JOptionPane.showMessageDialog(null, e1);
|
||||
}
|
||||
@ -404,28 +429,6 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
rs.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");
|
||||
btnNewButton.setForeground(Color.BLACK);
|
||||
btnNewButton.setBackground(Color.GREEN);
|
||||
@ -435,48 +438,34 @@ public class DrukujBilet extends StolowkaZPM {
|
||||
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
/*
|
||||
if (sumaKoszt != 0) {
|
||||
try {
|
||||
String query = "SELECT * FROM bilety";
|
||||
String query="INSERT INTO bilety(KtoZabralID, DataCzas, KosztBiletu, CzyZaplacony) VALUES (?,?,?,?)";
|
||||
PreparedStatement pst = conn.prepareStatement(query);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
OstatniIDbiletuString = rs.getString("IDbiletu");
|
||||
int count = 0;
|
||||
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.setInt(1, IDuzytkownikaPrint);
|
||||
pst.setString(2, dataIczas);
|
||||
pst.setInt(3, sumaKoszt);
|
||||
pst.setString(4, "nie");
|
||||
pst.execute();
|
||||
JOptionPane.showMessageDialog(null, " ** "+IDuzytkownikaPrint+" ** "+dataIczas+" ** "+sumaKoszt+" ** "+"nie");
|
||||
rs.close();
|
||||
pst.close();
|
||||
//JOptionPane.showMessageDialog(null, " ** "+IDuzytkownika+" ** "+dataIczas+" ** "+sumaKosztString+" ** "+"nie");
|
||||
MenuStolowkaZPM.setVisible(false);
|
||||
|
||||
} catch (Exception 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