-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMain.java
More file actions
85 lines (79 loc) · 3.45 KB
/
Main.java
File metadata and controls
85 lines (79 loc) · 3.45 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
package MedX;
import static MedX.ConnectDb.ConnectDb;
import static MedX.SystemID.getSystemMotherBoard_SerialNumber;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class Main {
static Connection conn=null;
static String username=null;
static String system_id=getSystemMotherBoard_SerialNumber();
public static void main(String[] args) {
//<editor-fold defaultstate="collapsed" desc="Look and feel setting code">
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);}
catch (InstantiationException ex) {java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);}
catch (IllegalAccessException ex) {java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);}
catch (javax.swing.UnsupportedLookAndFeelException ex) {java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);}
//</editor-fold>
conn=ConnectDb();
Check_Auto_Login();
}
private static void Check_Auto_Login(){
String auto_login="0";
String job=null;
try{
String query = "select username,auto_login from temp_users where system_id='"+system_id+"'";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
while(rs.next()){
username=rs.getString("username");
auto_login=rs.getString("auto_login");
}
rs.close();
stmt.close();
}catch(Exception e){System.out.println(e.getMessage());};
if(auto_login.equals("1")){
try{
String query = "select job from users where username='"+username+"'";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
while(rs.next()){
job=rs.getString("job");
}
rs.close();
stmt.close();
}catch(Exception e){System.out.println(e.getMessage());};
if(job.equals("Γιατρός")){
Doctor d = new Doctor(username,conn);
d.setVisible(true);
}
else if(job.equals("Νοσηλευτής")){
Nurse n = new Nurse(username,conn);
n.setVisible(true);
}
else if(job.equals("Γραμματέας")){
Secretary s = new Secretary(username,conn);
s.setVisible(true);
}
else if(job.equals("Αποθηκάριος")){
StoreKeeper s = new StoreKeeper(username,conn);
s.setVisible(true);
}
else if(job.equals("Διευθυντής")){
Manager m = new Manager(username,conn);
m.setVisible(true);
}
}
else {
LoginScreen l = new LoginScreen(conn);
l.setVisible(true);
}
}
}