Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hy360;
- import java.sql.*;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- public class Main {
- static int pas_id = 1010;
- static int cas_id = 2010;
- static int pts_id = 3010;
- static int cts_id = 4010;
- public static final String[] staff = {"Μόνιμος Διοικητικός Υπάλληλος", "Συμβασιούχος Διοικητικός Υπάλληλος", "Μόνιμο Μέλος Διδακτικού Προσωπικού", "Συμβασιούχο Μέλος Διαδακτικού Προσωπικού"};
- public static void add_staff() throws ClassNotFoundException, SQLException {
- String FirstName = JOptionPane.showInputDialog("Όνομα: ");
- String LastName = JOptionPane.showInputDialog("Επίθετο: ");
- String MaritalStatus = JOptionPane.showInputDialog("Συνολικά μέλη οικογένειας (π.χ.άγαμος 1 μελος):");
- String PersonelCategory;
- String Department = JOptionPane.showInputDialog("Τμήμα: ");
- String FirstWorkDay = JOptionPane.showInputDialog("Ημερομηνία πρόσληψης (ΗΗ/ΜΜ/ΧΧΧΧ): ") ;
- String Address = JOptionPane.showInputDialog("Διεύθυνση: ");
- String PhoneNumber = JOptionPane.showInputDialog("Αριθμός Τηλεφώνου: ");
- String BankAccount = JOptionPane.showInputDialog("Αριθμός Λογαριασμού: ") ;
- String BankName = JOptionPane.showInputDialog("Όνομα τράπεζας: ");
- String Script1;
- String Script2;
- JFrame frame = new JFrame();
- String s = (String) JOptionPane.showInputDialog(frame, "Σε ποιά μισθολογική κατηγορία ανήκει ο υπάλληλος;", "Επιλογή μισθολογικής κατηγορίας.",JOptionPane.QUESTION_MESSAGE, null, staff, staff[0]);
- Class.forName("com.mysql.cj.jdbc.Driver");
- String mysqlConnUrl = "jdbc:mysql://localhost:3306/employees";
- String mysqlUserName = "root";
- String mysqlPassword = "";
- Connection conn = DriverManager.getConnection(mysqlConnUrl, mysqlUserName , mysqlPassword);
- Statement st = conn.createStatement();
- if(s.equals("Μόνιμος Διοικητικός Υπάλληλος")) {
- PersonelCategory = "P.A.S."; // = Permanent Administrative Staff
- Script1 = "insert into employees values(" + "'" + pas_id + "', " + "'" + FirstName + "', " + "'" + LastName + "', " + "'" + Integer.parseInt(MaritalStatus) + "', " + "'" + PersonelCategory + "', " + "'" + Department + "', "
- + "'" + FirstWorkDay + "', " + "'" + Address + "', " + "'" + PhoneNumber + "', " + "'" + BankAccount + "', " + "'" + BankName + "')";
- System.out.println(Script1);
- st.executeUpdate(Script1);
- conn.close();
- mysqlConnUrl = "jdbc:mysql://localhost:3306/payroll_categories";
- conn = DriverManager.getConnection(mysqlConnUrl, mysqlUserName , mysqlPassword);
- st = conn.createStatement();
- Script2 = "insert into permanent_administrative_staff values(" + "'" + pas_id + "'," + "'" + 2000 + "')";
- System.out.println(Script2);
- st.executeUpdate(Script2);
- conn.close();
- pas_id++;
- }
- else if(s.equals("Συμβασιούχος Διοικητικός Υπάλληλος")) {
- PersonelCategory = "C.A.S."; // = Contracted Administrative Staff
- String ContractExpiry = JOptionPane.showInputDialog("Ημερομηνία λήξης σύμβασης (ΗΗ/ΜΜ/ΧΧΧΧ):");
- Script1 = "insert into employees values(" + "'" + pas_id + "', " + "'" + FirstName + "', " + "'" + LastName + "', " + "'" + Integer.parseInt(MaritalStatus) + "', " + "'" + PersonelCategory + "', " + "'" + Department + "', "
- + "'" + FirstWorkDay + "', " + "'" + Address + "', " + "'" + PhoneNumber + "', " + "'" + BankAccount + "', " + "'" + BankName + "')";
- System.out.println(Script1);
- st.executeUpdate(Script1);
- conn.close();
- mysqlConnUrl = "jdbc:mysql://localhost:3306/payroll_categories";
- conn = DriverManager.getConnection(mysqlConnUrl, mysqlUserName , mysqlPassword);
- st = conn.createStatement();
- Script2 = "insert into contracted_administrative_staff values(" + "'" + cas_id + "', " + "'" + FirstWorkDay + "', " + "'" + ContractExpiry + "'," +"'" + 2000 +"')";
- System.out.println(Script2);
- st.executeUpdate(Script2);
- conn.close();
- cas_id++;
- }
- else if(s.equals("Μόνιμο Μέλος Διδακτικού Προσωπικού")) {
- PersonelCategory = "P.T.S."; // = Permanent Teaching Staff
- Script1 = "insert into employees values(" + "'" + pts_id + "', " + "'" + FirstName + "', " + "'" + LastName + "', " + "'" + Integer.parseInt(MaritalStatus) + "', " + "'" + PersonelCategory + "', " + "'" + Department + "', "
- + "'" + FirstWorkDay + "', " + "'" + Address + "', " + "'" + PhoneNumber + "', " + "'" + BankAccount + "', " + "'" + BankName + "')";
- System.out.println(Script1);
- st.executeUpdate(Script1);
- conn.close();
- mysqlConnUrl = "jdbc:mysql://localhost:3306/payroll_categories";
- conn = DriverManager.getConnection(mysqlConnUrl, mysqlUserName , mysqlPassword);
- st = conn.createStatement();
- Script2 = "insert into permanent_teaching_staff values(" + "'" + pts_id + "'," + "'" + 3000 + "')";
- System.out.println(Script2);
- st.executeUpdate(Script2);
- conn.close();
- pts_id++;
- }
- else if(s.equals("Συμβασιούχο Μέλος Διαδακτικού Προσωπικού")) {
- PersonelCategory = "C.T.S."; // Contracted Teaching Staff
- String ContractExpiry = JOptionPane.showInputDialog("Ημερομηνία λήξης σύμβασης (ΗΗ/ΜΜ/ΧΧΧΧ):");
- Script1 = "insert into employees values(" + "'" + cts_id + "', " + "'" + FirstName + "', " + "'" + LastName + "', " + "'" + Integer.parseInt(MaritalStatus) + "', " + "'" + PersonelCategory + "', " + "'" + Department + "', "
- + "'" + FirstWorkDay + "', " + "'" + Address + "', " + "'" + PhoneNumber + "', " + "'" + BankAccount + "', " + "'" + BankName + "')";
- System.out.println(Script1);
- st.executeUpdate(Script1);
- conn.close();
- mysqlConnUrl = "jdbc:mysql://localhost:3306/payroll_categories";
- conn = DriverManager.getConnection(mysqlConnUrl, mysqlUserName , mysqlPassword);
- st = conn.createStatement();
- Script2 = "insert into contracted_teaching_staff values(" + "'" + cts_id + "', " + "'" + FirstWorkDay + "', " + "'" + ContractExpiry + "'," + "'" + 3000 +"')";
- System.out.println(Script2);
- st.executeUpdate(Script2);
- conn.close();
- cts_id++;
- }
- }
- public static void contract_renewal() {
- int id;
- String FName = JOptionPane.showInputDialog("Όνομα: ");
- String LName = JOptionPane.showInputDialog("Επίθετο: ");
- String FirstDay = JOptionPane.showInputDialog("Πρώτη ημέρα σύμβασης (ΗΗ/ΜΜ/ΧΧΧΧ): ");
- String LastDay = JOptionPane.showInputDialog("Τελευταία μέρα σύμβασης (ΗΗ/ΜΜ/ΧΧΧΧ): ");
- }
- public static void main(String[] lal) throws ClassNotFoundException, SQLException {
- add_staff();
- add_staff();
- add_staff();
- add_staff();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement