├── .idea ├── .name ├── .gitignore ├── vcs.xml ├── libraries │ └── postgresql_42_7_3.xml ├── misc.xml ├── modules.xml └── uiDesigner.xml ├── tourismagency.sql ├── postgresql-42.7.3.jar ├── src ├── App.java ├── core │ ├── ComboItem.java │ ├── Database.java │ └── Helper.java ├── business │ ├── SeasonManager.java │ ├── PensionManager.java │ ├── HotelManager.java │ ├── ReservationManager.java │ ├── UserManager.java │ └── RoomManager.java ├── entity │ ├── Pension.java │ ├── User.java │ ├── Season.java │ ├── Hotel.java │ ├── Reservation.java │ └── Room.java ├── view │ ├── LoginView.java │ ├── PensionView.java │ ├── Layout.java │ ├── HotelView.java │ ├── SeasonView.java │ ├── LoginView.form │ ├── PensionView.form │ ├── RoomView.java │ ├── RoomUpdateView.java │ ├── SeasonView.form │ ├── ReservationUpdateView.java │ ├── ReservationView.java │ ├── AdminView.java │ ├── HotelView.form │ ├── RoomView.form │ ├── RoomUpdateView.form │ └── AdminView.form └── dao │ ├── SeasonDao.java │ ├── PensionDao.java │ ├── UserDao.java │ ├── HotelDao.java │ ├── ReservationDao.java │ └── RoomDao.java ├── .gitignore ├── Tourism_Agency.iml └── README.md /.idea/.name: -------------------------------------------------------------------------------- 1 | Tourism_Agency -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /tourismagency.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremyardan/Tourism_Agency_Java_Swing/HEAD/tourismagency.sql -------------------------------------------------------------------------------- /postgresql-42.7.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremyardan/Tourism_Agency_Java_Swing/HEAD/postgresql-42.7.3.jar -------------------------------------------------------------------------------- /src/App.java: -------------------------------------------------------------------------------- 1 | import core.Helper; 2 | import view.LoginView; 3 | 4 | public class App { 5 | public static void main(String[] args) { 6 | 7 | // Opens the window for login 8 | LoginView loginView = new LoginView(); 9 | } 10 | } -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/libraries/postgresql_42_7_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### IntelliJ IDEA ### 2 | out/ 3 | !**/src/main/**/out/ 4 | !**/src/test/**/out/ 5 | 6 | ### Eclipse ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | bin/ 15 | !**/src/main/**/bin/ 16 | !**/src/test/**/bin/ 17 | 18 | ### NetBeans ### 19 | /nbproject/private/ 20 | /nbbuild/ 21 | /dist/ 22 | /nbdist/ 23 | /.nb-gradle/ 24 | 25 | ### VS Code ### 26 | .vscode/ 27 | 28 | ### Mac OS ### 29 | .DS_Store -------------------------------------------------------------------------------- /Tourism_Agency.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | A tourism agency system created with Java Swing and powered with PostgreSQL. 2 | 3 | You may create employee or admin accounts. Each account has different skills. 4 | 5 | Such as, 6 | 7 | Admins can create or delete two different account types, change roles and passcodes. 8 | 9 | On the employee side, you may add hotels, hotel stars, and different service features like "wi-fi" or "gym". 10 | 11 | An employee may create a reservation by entering season type, individual amount and price as currency amount. 12 | 13 | And of course editing or deleting for a reservation is possible as well. 14 | 15 | You may reach to the project video by clicking the link below; 16 | 17 | https://youtu.be/i96mvn4MCA4 18 | -------------------------------------------------------------------------------- /src/core/ComboItem.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | 4 | 5 | // logic of combo item is, this procedure is generally used in Java Swing for a visual interface. 6 | // with a list in combo box, we provide to the client multiple choices. 7 | // combo items are the values those located in combo box. this class, holds keys and values together for combo box. 8 | // so, we won't have to declare variables and key values for each item. 9 | public class ComboItem { 10 | private int key; 11 | private String value; 12 | 13 | // constructor with parameters 14 | public ComboItem(int key, String value) { 15 | this.key = key; 16 | this.value = value; 17 | } 18 | 19 | // default constructor 20 | public ComboItem(){ 21 | 22 | } 23 | 24 | // getters and setters 25 | public int getKey() { 26 | return key; 27 | } 28 | 29 | 30 | public void setKey(int key) { 31 | this.key = key; 32 | } 33 | 34 | 35 | public String getValue() { 36 | return value; 37 | } 38 | 39 | public void setValue(String value) { 40 | this.value = value; 41 | } 42 | 43 | 44 | public String toString(){ 45 | return this.value; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/core/Database.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | 8 | public class Database { 9 | private static Database instance = null; 10 | private Connection connection = null; 11 | 12 | // url for database 13 | private final String DB_URL = "jdbc:postgresql://localhost:5432/tourismagency"; 14 | 15 | //db user name 16 | private final String DB_USER = "postgres"; 17 | 18 | //db user pass 19 | private final String DB_PASS = "Postgre"; 20 | 21 | // method for establishing database connection 22 | private Database () { 23 | try { 24 | // to initialize the first value of connection, url, user and password are being hold. 25 | this.connection = DriverManager.getConnection(DB_URL,DB_USER,DB_PASS); 26 | } catch (SQLException e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | 31 | // returning the connection 32 | public Connection getConnection() { 33 | return connection; 34 | } 35 | 36 | // instance of connection process 37 | public static Connection getInstance(){ 38 | try { 39 | // checks if connection is null or closed 40 | if (instance == null || instance.getConnection().isClosed()) { 41 | // calls Database function 42 | instance = new Database(); 43 | } 44 | } catch (SQLException e) { 45 | // throws and exception 46 | e.printStackTrace(); } 47 | 48 | // and returning the connection 49 | return instance.getConnection(); 50 | 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/business/SeasonManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.SeasonDao; 5 | import entity.Season; 6 | 7 | import java.util.ArrayList; 8 | 9 | 10 | public class SeasonManager { 11 | 12 | 13 | SeasonDao seasonDao = new SeasonDao(); 14 | 15 | // brings season with specific id 16 | public Season getById(int id){ 17 | return this.seasonDao.getSeasonByID(id); 18 | } 19 | 20 | // brings the season with specific hotel id 21 | public ArrayList getSeasonsByOtelId(int id){return this.seasonDao.getSeasonsByOtelId(id);} 22 | 23 | // brings all seasons function 24 | public ArrayList findAll() 25 | {return this.seasonDao.findAll();} 26 | 27 | // the method that provides necessary information for table with generic data type as Object[] so, the array list may take 28 | // different type of objects 29 | public ArrayList getForTable(int size,ArrayList seasons){ 30 | ArrayList seasonList = new ArrayList<>(); 31 | for (Season obj : seasons){ 32 | int i = 0; 33 | Object[] rowObject = new Object[size]; 34 | rowObject[i++] = obj.getId(); 35 | rowObject[i++] = obj.getHotel_id(); 36 | rowObject[i++] = obj.getStart_date(); 37 | rowObject[i++] = obj.getFinish_date(); 38 | seasonList.add(rowObject); 39 | } 40 | return seasonList; 41 | } 42 | 43 | // adds the season record to db 44 | public boolean save(Season season){ 45 | if(season.getId()!=0){ 46 | Helper.showMsg("error"); 47 | } 48 | return this.seasonDao.save(season); 49 | } 50 | 51 | // deletes the season witj specific id 52 | public boolean delete(int id){ 53 | if(this.getById(id) == null){ 54 | Helper.showMsg(id + " ID kayıtlı model bulunamadı"); 55 | return false; 56 | } 57 | return this.seasonDao.delete(id); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/entity/Pension.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import core.ComboItem; 4 | 5 | // variables 6 | public class Pension { 7 | private int id; 8 | private String pension_type; 9 | private int hotel_id; 10 | 11 | // default constructor method 12 | public Pension() { 13 | } 14 | 15 | // constructor method with class variables 16 | public Pension(int id, String pension_type, int hotel_id) { 17 | this.id = id; 18 | this.pension_type = pension_type; 19 | this.hotel_id = hotel_id; 20 | } 21 | 22 | // getter and setter methods 23 | public int getId() { 24 | return id; 25 | } 26 | 27 | public void setId(int id) { 28 | this.id = id; 29 | } 30 | 31 | public String getPension_type() { 32 | return pension_type; 33 | } 34 | 35 | public void setPension_type(String pension_type) { 36 | this.pension_type = pension_type; 37 | } 38 | 39 | public int getHotel_id() { 40 | return hotel_id; 41 | } 42 | 43 | public void setHotel_id(int hotel_id) { 44 | this.hotel_id = hotel_id; 45 | } 46 | 47 | public ComboItem getComboItem(){ 48 | return new ComboItem(this.getId(), "Pension ID : "+ this.getId() + " Hotel ID : " + this.getHotel_id() + " Pension Type : " + this.getPension_type());} 49 | 50 | // stringify method 51 | // logic of this method is for us to see the contents of an object as a string with a meaning. 52 | // generally, .toString() method provides you an unclear prints such as memory sector. 53 | // with the logic above, we need to see the print with a meaning. 54 | // that is why, we need do exclude .toString() method with @Override and add this method for a meaningful output instead. 55 | @Override 56 | public String toString() { 57 | return "Pension{" + 58 | "id=" + id + 59 | ", pension_type='" + pension_type + '\'' + 60 | ", hotel_id=" + hotel_id + 61 | '}'; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/entity/User.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | // variables 4 | public class User { 5 | private int id; 6 | private String username; 7 | private String password; 8 | private String role; 9 | 10 | 11 | // default constructor method 12 | public User() { 13 | 14 | } 15 | 16 | 17 | // constructor method with class parameters 18 | public User(int id, String username, String pass, String role) { 19 | this.id = id; 20 | this.username = username; 21 | this.password = pass; 22 | this.role = role; 23 | } 24 | 25 | 26 | // getter and setter methods 27 | public int getId() { 28 | return id; 29 | } 30 | 31 | public void setId(int id) { 32 | this.id = id; 33 | } 34 | 35 | public String getUsername() { 36 | return username; 37 | } 38 | 39 | public void setUsername(String username) { 40 | this.username = username; 41 | } 42 | 43 | public String getPassword() { 44 | return password; 45 | } 46 | 47 | public void setPassword(String pass) { 48 | this.password = pass; 49 | } 50 | 51 | public String getRole() { 52 | return role; 53 | } 54 | 55 | public void setRole(String role) { 56 | this.role = role; 57 | } 58 | 59 | // stringify method 60 | // logic of this method is for us to see the contents of an object as a string with a meaning. 61 | // generally, .toString() method provides you an unclear prints such as memory sector. 62 | // with the logic above, we need to see the print with a meaning. 63 | // that is why, we need do exclude .toString() method with @Override and add this method for a meaningful output instead. 64 | @Override 65 | public String toString() { 66 | return "User{" + 67 | "id=" + id + 68 | ", username='" + username + '\'' + 69 | ", password='" + password + '\'' + 70 | ", role='" + role + '\'' + 71 | '}'; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/view/LoginView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.UserManager; 4 | import core.Helper; 5 | import entity.User; 6 | 7 | import javax.swing.*; 8 | 9 | public class LoginView extends Layout{ 10 | private JPanel wrapper; 11 | private JTextField tf_user; 12 | private JPasswordField tf_pass; 13 | private JButton btn_login; 14 | private JLabel lbl_user; 15 | private JLabel lbl_pass; 16 | private JPanel w_top; 17 | private JPanel w_bot; 18 | private UserManager userManager; 19 | 20 | 21 | // login view constructor 22 | public LoginView(){ 23 | this.add(wrapper); 24 | this.visualInitialize(450,450); 25 | this.userManager = new UserManager(); 26 | 27 | 28 | // a listener assigned to login button 29 | btn_login.addActionListener(e -> { 30 | JTextField[] checkFieldList = {this.tf_user,this.tf_pass}; 31 | // checks if necessary fields are filled 32 | if (Helper.isFieldListEmpty(checkFieldList)){ 33 | Helper.showMsg("fill"); 34 | 35 | // if credentials are not true ( if user could not be found), an error message will be thrown 36 | }else { 37 | User loginUser = this.userManager.findByLoging(this.tf_user.getText(),this.tf_pass.getText()); 38 | if (loginUser == null){ 39 | Helper.showMsg("notFound"); 40 | }else { 41 | // if user credentials are corresponds with admin information, admin view will be shown 42 | if (loginUser.getRole().equals("admin")){ 43 | AdminView adminView = new AdminView(loginUser); 44 | dispose(); 45 | // if user credentials are corresponds with employee information, employee view will be shown 46 | }else { 47 | EmployeeView employeeView = new EmployeeView(loginUser); 48 | dispose(); 49 | } 50 | } 51 | } 52 | }); 53 | } 54 | } -------------------------------------------------------------------------------- /src/view/PensionView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import business.PensionManager; 5 | import core.ComboItem; 6 | import core.Helper; 7 | import entity.Hotel; 8 | import entity.Pension; 9 | import entity.User; 10 | 11 | import javax.swing.*; 12 | 13 | public class PensionView extends Layout { 14 | private JPanel wrap; 15 | private JButton btn_save_pension; 16 | private JLabel lbl_pan_add_menu; 17 | private JComboBox cmb_persion; 18 | private JLabel lbl_hotel_id; 19 | private JComboBox cmb_hotel; 20 | private JTextField tf_hotel_name; 21 | private PensionManager pensionManager; 22 | private Pension pension; 23 | private HotelManager hotelManager; 24 | private Hotel hotel; 25 | private User user; 26 | 27 | 28 | // constructor 29 | public PensionView(int hotel_id) { 30 | 31 | this.hotel = new Hotel(); 32 | this.hotelManager = new HotelManager(); 33 | this.pensionManager = new PensionManager(); 34 | this.pension = new Pension(); 35 | this.add(wrap); 36 | this.visualInitialize(375, 250); 37 | for (Hotel hotel : this.hotelManager.findAll()) { 38 | this.cmb_hotel.addItem(hotel.getComboItem()); 39 | 40 | } 41 | 42 | // listener for save button 43 | this.btn_save_pension.addActionListener(e -> { 44 | boolean result = false; 45 | ComboItem selectedHotel = (ComboItem) cmb_hotel.getSelectedItem(); 46 | this.pension.setHotel_id(selectedHotel.getKey()); 47 | this.pension.setPension_type(cmb_persion.getSelectedItem().toString()); 48 | 49 | if (this.pension.getId() != 0) { 50 | result = this.pensionManager.update(this.pension); 51 | 52 | } else { 53 | result = this.pensionManager.save(this.pension); 54 | } 55 | if (result) { 56 | Helper.showMsg("done"); 57 | dispose(); 58 | } else { 59 | Helper.showMsg("error"); 60 | } 61 | }); 62 | } 63 | 64 | } 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/business/PensionManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.PensionDao; 5 | import entity.Hotel; 6 | import entity.Pension; 7 | import entity.Season; 8 | import entity.User; 9 | 10 | import java.util.ArrayList; 11 | 12 | 13 | 14 | public class PensionManager { 15 | PensionDao pensionDao = new PensionDao(); 16 | 17 | // method that brings pension with specific id 18 | public Pension getById(int id){ 19 | return this.pensionDao.getByID(id); 20 | } 21 | 22 | // method that brings all pensions 23 | public ArrayList findAll() {return this.pensionDao.findAll();} 24 | 25 | // method that brings pensions which have specific hotel id 26 | public ArrayList getPensionByOtelId(int id){return this.pensionDao.getPensionByOtelId(id);} 27 | 28 | // the method that provides necessary information for table with generic data type as Object[] so, the array list may take 29 | // different type of objects 30 | public ArrayList getForTable(int size,ArrayList pensions){ 31 | ArrayList pensionList = new ArrayList<>(); 32 | for (Pension obj : pensions){ 33 | int i = 0; 34 | Object[] rowObject = new Object[size]; 35 | rowObject[i++] = obj.getId(); 36 | rowObject[i++] = obj.getHotel_id(); 37 | rowObject[i++] = obj.getPension_type(); 38 | pensionList.add(rowObject); 39 | } 40 | return pensionList; 41 | } 42 | 43 | 44 | // send the pension record to database 45 | public boolean save(Pension pension){ 46 | if(pension.getId()!=0){ 47 | Helper.showMsg("error"); 48 | } 49 | return this.pensionDao.save(pension); 50 | } 51 | 52 | // updates pension record 53 | public boolean update(Pension pension) { 54 | if (this.getById(pension.getId()) == null) { 55 | Helper.showMsg(pension.getId() + " id could not found"); 56 | return false; 57 | } 58 | return this.pensionDao.update(pension); 59 | } 60 | 61 | // deletes pension record 62 | public boolean delete(int id){ 63 | if(this.getById(id) == null){ 64 | Helper.showMsg(id + " id could not found"); 65 | return false; 66 | } 67 | return this.pensionDao.delete(id); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/business/HotelManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.HotelDao; 5 | import entity.Hotel; 6 | 7 | import java.util.ArrayList; 8 | 9 | 10 | public class HotelManager { 11 | HotelDao hotelDao = new HotelDao(); 12 | 13 | // function that brings a hotel by its id 14 | public Hotel getById(int id){ 15 | return this.hotelDao.getByID(id); 16 | } 17 | 18 | // the method that brings all hotels 19 | public ArrayList findAll() {return this.hotelDao.findAll();} 20 | 21 | // the method that provides necessary information for table with generic data type as Object[] so, the array list may take 22 | // different type of objects 23 | public ArrayList getForTable(int size,ArrayList hotels){ 24 | ArrayList hotelList = new ArrayList<>(); 25 | for(Hotel obj : hotels){ 26 | int i = 0; 27 | Object[] rowObject = new Object[size]; 28 | rowObject[i++] = obj.getId(); 29 | rowObject[i++] = obj.getName(); 30 | rowObject[i++] = obj.getAddress(); 31 | rowObject[i++] = obj.getMail(); 32 | rowObject[i++] = obj.getPhone(); 33 | rowObject[i++] = obj.getStar(); 34 | rowObject[i++] = obj.isCar_park(); 35 | rowObject[i++] = obj.isWifi(); 36 | rowObject[i++] = obj.isPool(); 37 | rowObject[i++] = obj.isFitness(); 38 | rowObject[i++] = obj.isConcierge(); 39 | rowObject[i++] = obj.isSpa(); 40 | rowObject[i++] = obj.isRoom_service(); 41 | hotelList.add(rowObject); 42 | } 43 | return hotelList; 44 | } 45 | 46 | // add hotel records to database 47 | public boolean save(Hotel hotel){ 48 | if(hotel.getId()!=0){ 49 | Helper.showMsg("error"); 50 | } 51 | return this.hotelDao.save(hotel); 52 | } 53 | 54 | // delete the hotel with specific id 55 | public boolean delete(int id){ 56 | if(this.getById(id) == null){ 57 | Helper.showMsg(id + " id could not found"); 58 | return false; 59 | } 60 | return this.hotelDao.delete(id); 61 | } 62 | 63 | // function that updates the hotel record 64 | public boolean update(Hotel hotel){ 65 | if (this.getById(hotel.getId()) == null){ 66 | Helper.showMsg(hotel.getId() + " id could not found"); 67 | return false; 68 | } 69 | return this.hotelDao.update(hotel); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/core/Helper.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | 6 | public class Helper { 7 | 8 | // helper class 9 | 10 | 11 | // function to set messages 12 | public static void showMsg(String str) { 13 | 14 | String msg; 15 | String title = switch (str) { 16 | case "fill" -> { 17 | msg = "Please fill in all fields."; 18 | yield "Error!"; 19 | } 20 | case "done" -> { 21 | msg = "Successful"; 22 | yield "Done"; 23 | } 24 | case "notFound" -> { 25 | msg = str + " Not found!"; 26 | yield "Not found."; 27 | } 28 | case "error" -> { 29 | msg = "You Made a Wrong Transaction!"; 30 | yield "Error!"; 31 | } 32 | default -> { 33 | msg = str; 34 | yield "Message"; 35 | } 36 | }; 37 | 38 | JOptionPane.showMessageDialog(null, msg, title, JOptionPane.INFORMATION_MESSAGE); 39 | 40 | 41 | } 42 | 43 | 44 | // function to create a confirmation window to check if user is sure or not 45 | public static boolean confirm(String str){ 46 | 47 | String msg; 48 | if(str.equals("Sure")){ 49 | msg = "Are you sure?"; 50 | }else{ 51 | msg = str; 52 | } 53 | return JOptionPane.showConfirmDialog(null,msg,"Are you sure ?",JOptionPane.YES_NO_OPTION) == 0 ; 54 | } 55 | 56 | 57 | // with trim method, all empty strings are being excluded and is fieldempty function checks if jtextfield is empty. 58 | public static boolean isFieldEmpty(JTextField field) { 59 | return field.getText().trim().isEmpty(); 60 | } 61 | 62 | // checks if jtextfield array is empty 63 | public static boolean isFieldListEmpty(JTextField[] fieldList) { 64 | // with for loop, array objects are being controlled 65 | for (JTextField field : fieldList) { 66 | if (isFieldEmpty(field)) return true; 67 | } 68 | return false; 69 | } 70 | 71 | // arrange the location of window 72 | public static int getLocationPoint(String type, Dimension size) { 73 | return switch (type) { 74 | case "x" -> (Toolkit.getDefaultToolkit().getScreenSize().width - size.width) / 2; 75 | case "y" -> (Toolkit.getDefaultToolkit().getScreenSize().height - size.height) / 2; 76 | default -> 0; 77 | }; 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /src/entity/Season.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import core.ComboItem; 4 | 5 | import java.time.LocalDate; 6 | import java.util.Date; 7 | 8 | // variables 9 | public class Season { 10 | private int id; 11 | private int hotel_id; 12 | private LocalDate start_date; 13 | private LocalDate finish_date; 14 | private String season_type; 15 | 16 | // default constructor 17 | public Season() { 18 | } 19 | 20 | // constructor with class parameters 21 | public Season(int id, int hotel_id, String start_date, String finish_date,String season_type) { 22 | this.id = id; 23 | this.hotel_id = hotel_id; 24 | this.start_date = LocalDate.parse(start_date); 25 | this.finish_date = LocalDate.parse(finish_date); 26 | this.season_type = season_type; 27 | } 28 | 29 | // getter and setter methods 30 | 31 | public String getSeason_type() { 32 | return season_type; 33 | } 34 | 35 | public void setSeason_type(String season_type) { 36 | this.season_type = season_type; 37 | } 38 | 39 | 40 | public int getId() { 41 | return id; 42 | } 43 | 44 | public void setId(int id) { 45 | this.id = id; 46 | } 47 | 48 | public int getHotel_id() { 49 | return hotel_id; 50 | } 51 | 52 | public void setHotel_id(int hotel_id) { 53 | this.hotel_id = hotel_id; 54 | } 55 | 56 | public LocalDate getStart_date() { 57 | return start_date; 58 | } 59 | 60 | public void setStart_date(LocalDate start_date) { 61 | this.start_date = start_date; 62 | } 63 | 64 | public LocalDate getFinish_date() { 65 | return finish_date; 66 | } 67 | 68 | public void setFinish_date(LocalDate finish_date) { 69 | this.finish_date = finish_date; 70 | } 71 | 72 | public ComboItem getComboItem(){ 73 | return new ComboItem(this.getId(), "( Start Date: -> " + this.getStart_date() + " - "+" Finish Date: -> " + this.getFinish_date() + ")"); 74 | } 75 | 76 | // stringify method 77 | // logic of this method is for us to see the contents of an object as a string with a meaning. 78 | // generally, .toString() method provides you an unclear prints such as memory sector. 79 | // with the logic above, we need to see the print with a meaning. 80 | // that is why, we need do exclude .toString() method with @Override and add this method for a meaningful output instead. 81 | @Override 82 | public String toString() { 83 | return "Season{" + 84 | "id=" + id + 85 | ", hotel_id=" + hotel_id + 86 | ", start_date='" + start_date + '\'' + 87 | ", finish_date='" + finish_date + '\'' + 88 | '}'; 89 | } 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/business/ReservationManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.ReservationDao; 5 | import entity.Reservation; 6 | 7 | import java.util.ArrayList; 8 | 9 | 10 | public class ReservationManager { 11 | ReservationDao reservationDao = new ReservationDao(); 12 | 13 | // function that brings reservations with specific id 14 | public Reservation getById(int id){return this.reservationDao.getByID(id);} 15 | 16 | //function that brings reservations with specific hotel id 17 | public ArrayList getReservationByOtelId(int id){return this.reservationDao.getReservationByOtelId(id);} 18 | 19 | // function that brings all reservations 20 | public ArrayList findAll() {return this.reservationDao.findAll();} 21 | 22 | // the method that provides necessary information for table with generic data type as Object[] so, the array list may take 23 | // different type of objects 24 | public ArrayList getForTable(int size,ArrayList reservations){ 25 | ArrayList resList = new ArrayList<>(); 26 | for (Reservation obj : reservations){ 27 | int i = 0; 28 | Object[] rowObject = new Object[size]; 29 | rowObject[i++] = obj.getId(); 30 | rowObject[i++] = obj.getRoom_id(); 31 | rowObject[i++] = obj.getCheck_in_date(); 32 | rowObject[i++] = obj.getCheck_out_date(); 33 | rowObject[i++] = obj.getTotal_price(); 34 | rowObject[i++] = obj.getGuest_count(); 35 | rowObject[i++] = obj.getGuest_name(); 36 | rowObject[i++] = obj.getGuest_citizen_id(); 37 | rowObject[i++] = obj.getGuest_mail(); 38 | rowObject[i++] = obj.getGuest_phone(); 39 | 40 | resList.add(rowObject); 41 | } 42 | return resList; 43 | } 44 | 45 | // function that adds reservation record to db 46 | public boolean save(Reservation reservation){ 47 | if(reservation.getId()!=0){ 48 | Helper.showMsg("error"); 49 | } 50 | return this.reservationDao.save(reservation); 51 | } 52 | 53 | 54 | // function that deletes reservation record to db 55 | public boolean delete(int id){ 56 | if (this.getById(id)==null){ 57 | Helper.showMsg(" reservation could not found"); 58 | return false; 59 | } 60 | for (Reservation reservation:this.reservationDao.getByReservationId(id)){ 61 | this.reservationDao.delete(reservation.getId()); 62 | } 63 | return this.reservationDao.delete(id); 64 | } 65 | 66 | // function that updates reservation record on db 67 | 68 | public boolean update(Reservation reservation){ 69 | if(this.getById(reservation.getId()) == null){ 70 | Helper.showMsg("reservation could not found"); 71 | return false; 72 | } 73 | return this.reservationDao.update(reservation); 74 | } 75 | 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/view/Layout.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import core.Helper; 4 | 5 | import javax.swing.*; 6 | import javax.swing.table.DefaultTableModel; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.MouseEvent; 9 | import java.util.ArrayList; 10 | 11 | public class Layout extends JFrame { 12 | // initialization of visual interface 13 | public void visualInitialize(int width, int height) { 14 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 15 | // label of the windows 16 | this.setTitle("Hotel"); 17 | // width and height values 18 | this.setSize(width, height); 19 | // window location setter 20 | this.setLocation(Helper.getLocationPoint("x", this.getSize()), Helper.getLocationPoint("y", this.getSize())); 21 | // setting visibility to true 22 | this.setVisible(true); 23 | 24 | } 25 | 26 | public void createTable(DefaultTableModel model, JTable table, Object[] columns, ArrayList rows) { 27 | model.setColumnIdentifiers(columns); 28 | // set table as model 29 | table.setModel(model); 30 | table.getTableHeader().setReorderingAllowed(false); 31 | // max width 32 | table.getColumnModel().getColumn(0).setMaxWidth(75); 33 | table.setEnabled(false); 34 | 35 | 36 | // table clear by setting the count to 0 37 | DefaultTableModel clearModel = (DefaultTableModel) table.getModel(); 38 | clearModel.setRowCount(0); 39 | 40 | 41 | // Eğer satırlar null ise boş bir liste oluştur // if rows are empty, create a new arraylist(create a list) 42 | // and add rows to default table 43 | if (rows == null) { 44 | rows = new ArrayList<>(); 45 | } 46 | 47 | for (Object[] row : rows) { 48 | model.addRow(row); 49 | } 50 | } 51 | 52 | 53 | // method for row selection 54 | public int getTableSelectedRow(JTable table, int index) { 55 | int selectedRow = table.getSelectedRow(); 56 | // -1 indicates no row is selected 57 | if (selectedRow != -1) { 58 | try { 59 | return Integer.parseInt(table.getValueAt(selectedRow, index).toString()); 60 | } catch (NumberFormatException e) { 61 | // handling the NumberFormatException 62 | // returning a default value, such as -1, or implementing another error handling strategy 63 | System.err.println("NumberFormatException: " + e.getMessage()); 64 | return -1; 65 | } 66 | } else { 67 | // if no row is selected, returning a default value, such as -1, or implementing another error handling strategy 68 | return -1; 69 | } 70 | } 71 | 72 | 73 | // listener for table row selection 74 | public void tableRowSelect(JTable table) { 75 | table.addMouseListener(new MouseAdapter() { 76 | @Override 77 | public void mouseReleased(MouseEvent e) { 78 | int selected_row = table.rowAtPoint(e.getPoint()); 79 | table.setRowSelectionInterval(selected_row, selected_row); 80 | } 81 | }); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/view/HotelView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import core.Helper; 5 | import entity.Hotel; 6 | 7 | import javax.swing.*; 8 | 9 | // variables 10 | public class HotelView extends Layout { 11 | private JPanel wrap; 12 | private JLabel lbl_otel_save; 13 | private JTextField tf_name; 14 | private JTextField tf_mail; 15 | private JTextField tf_phone; 16 | private JTextField tf_adress; 17 | private JPanel pnl_left; 18 | private JRadioButton rbut_carpark; 19 | private JRadioButton rbut_wifi; 20 | private JRadioButton rbut_swim; 21 | private JRadioButton rbut_gym; 22 | private JRadioButton rbut_concierge; 23 | private JRadioButton rbut_spa; 24 | private JRadioButton rbut_roomservices; 25 | private JButton btn_save_add_menu; 26 | private JComboBox tf_star; 27 | private Hotel hotel; 28 | private HotelManager hotelManager; 29 | 30 | 31 | // hotel add section // constructor 32 | public HotelView() { 33 | this.hotelManager = new HotelManager(); 34 | this.hotel = new Hotel(); 35 | this.add(wrap); 36 | // frame initialization 37 | this.visualInitialize(500, 500); 38 | if(this.hotel.getId() != 0) { 39 | // if id is different from zero, 40 | // which means available in db, 41 | // information will be shown in visual interface 42 | // and lets user set it 43 | this.tf_name.setText(this.hotel.getName()); 44 | this.tf_mail.setText(this.hotel.getMail()); 45 | this.tf_phone.setText(this.hotel.getPhone()); 46 | this.tf_adress.setText(this.hotel.getAddress()); 47 | this.tf_star.setSelectedItem(this.hotel.getStar()); 48 | } 49 | btn_save_add_menu.addActionListener(e -> { 50 | 51 | // a jtextfield is created to check if all necessary fields are filled 52 | JTextField[] checkFieldList = {this.tf_name, this.tf_mail, this.tf_phone, this.tf_adress}; 53 | // if fields are empty, a message will be thrown 54 | if (Helper.isFieldListEmpty(checkFieldList)) { 55 | Helper.showMsg("fill"); 56 | // checks if record is successful. 57 | } else { 58 | boolean result = true; 59 | this.hotel.setName(this.tf_name.getText()); 60 | this.hotel.setMail(this.tf_mail.getText()); 61 | this.hotel.setPhone(this.tf_phone.getText()); 62 | this.hotel.setAddress(this.tf_adress.getText()); 63 | this.hotel.setStar((String)this.tf_star.getSelectedItem()); 64 | this.hotel.setCar_park(this.rbut_carpark.isSelected()); 65 | this.hotel.setWifi(this.rbut_wifi.isSelected()); 66 | this.hotel.setPool(this.rbut_swim.isSelected()); 67 | this.hotel.setFitness(this.rbut_gym.isSelected()); 68 | this.hotel.setConcierge(this.rbut_concierge.isSelected()); 69 | this.hotel.setSpa(this.rbut_spa.isSelected()); 70 | this.hotel.setRoom_service(this.rbut_roomservices.isSelected()); 71 | result = this.hotelManager.save(hotel); 72 | 73 | // if proccess is successful, a done message is being thrown and 74 | // window disposed 75 | if (result) { 76 | Helper.showMsg("done"); 77 | 78 | dispose(); 79 | 80 | } else { 81 | Helper.showMsg("error"); 82 | } 83 | } 84 | }); 85 | } 86 | } 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /src/view/SeasonView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import business.SeasonManager; 5 | import core.ComboItem; 6 | import core.Helper; 7 | import entity.Hotel; 8 | import entity.Season; 9 | 10 | import javax.swing.*; 11 | import javax.swing.text.MaskFormatter; 12 | import java.awt.event.ActionEvent; 13 | import java.awt.event.ActionListener; 14 | import java.text.ParseException; 15 | import java.time.DateTimeException; 16 | import java.time.LocalDate; 17 | import java.time.format.DateTimeFormatter; 18 | 19 | public class SeasonView extends Layout { 20 | private JPanel wrap; 21 | private JPanel wrap_season; 22 | private JButton btn_save_season; 23 | private JLabel lbl_hotel_id; 24 | private JFormattedTextField tf_season_start; 25 | private JFormattedTextField tf_season_finish; 26 | private JComboBox cmb_hotel_season; 27 | private HotelManager hotelManager; 28 | private Hotel hotel; 29 | private SeasonManager seasonManager; 30 | private Season season; 31 | 32 | // constructor 33 | public SeasonView() { 34 | this.hotelManager = new HotelManager(); 35 | this.hotel = new Hotel(); 36 | this.seasonManager = new SeasonManager(); 37 | this.season = new Season(); 38 | this.cmb_hotel_season.getSelectedItem(); 39 | this.add(wrap); 40 | this.visualInitialize(375, 300); 41 | 42 | // add all hotel names to combobox 43 | for (Hotel hotel : this.hotelManager.findAll()) { 44 | this.cmb_hotel_season.addItem(hotel.getComboItem()); 45 | } 46 | 47 | // button save listener. season start date, end date, and hotel id 48 | // will be added to db 49 | btn_save_season.addActionListener(new ActionListener() { 50 | @Override 51 | public void actionPerformed(ActionEvent e) { 52 | boolean result = false; 53 | ComboItem selectSeason = (ComboItem) cmb_hotel_season.getSelectedItem(); 54 | season.setHotel_id(selectSeason.getKey()); 55 | season.setSeason_type(cmb_hotel_season.getSelectedItem().toString()); 56 | JFormattedTextField[] checkDateList = {tf_season_start, tf_season_finish}; 57 | if (Helper.isFieldListEmpty(checkDateList)) { 58 | Helper.showMsg("fill"); 59 | } else { 60 | try { 61 | 62 | season.setStart_date(LocalDate.parse(tf_season_start.getText(), DateTimeFormatter.ofPattern("MM/dd/yyyy"))); 63 | season.setFinish_date(LocalDate.parse(tf_season_finish.getText(), DateTimeFormatter.ofPattern("MM/dd/yyyy"))); 64 | 65 | result = seasonManager.save(season); 66 | // an exception will be thrown if date is not in a valid format 67 | } catch (DateTimeException ex) { 68 | Helper.showMsg("Invalid date format"); 69 | return; 70 | } 71 | } 72 | if (result) { 73 | Helper.showMsg("done"); 74 | 75 | dispose(); 76 | } else { 77 | Helper.showMsg("error"); 78 | } 79 | } 80 | }); 81 | } 82 | 83 | // this method is for accept date input in specified format 84 | private void createUIComponents() throws ParseException { 85 | this.tf_season_start = new JFormattedTextField(new MaskFormatter("##/##/####")); 86 | this.tf_season_start.setText("11/11/2024"); 87 | this.tf_season_finish = new JFormattedTextField(new MaskFormatter("##/##/####")); 88 | this.tf_season_finish.setText("11/11/2024"); 89 | } 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/business/UserManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.UserDao; 5 | import entity.User; 6 | 7 | import java.util.ArrayList; 8 | 9 | 10 | public class UserManager { 11 | 12 | // new object for access to userdao (db) 13 | private final UserDao userDao; 14 | 15 | //constructor 16 | public UserManager() { 17 | this.userDao = new UserDao(); 18 | } 19 | 20 | // function that lets us find a user by username and pass 21 | public User findByLoging(String username, String password) { 22 | return this.userDao.findByLogin(username, password); 23 | 24 | } 25 | 26 | // the method that provides necessary information for table with generic data type as Object[] so, the array list may take 27 | // different type of objects 28 | public ArrayList getForTable(int size, ArrayList modelList) { 29 | ArrayList modelObjList = new ArrayList<>(); 30 | for (User obj : modelList) { 31 | int i = 0; 32 | Object[] rowObject = new Object[size]; 33 | rowObject[i++] = obj.getId(); 34 | rowObject[i++] = obj.getUsername(); 35 | rowObject[i++] = obj.getPassword(); 36 | rowObject[i++] = obj.getRole(); 37 | modelObjList.add(rowObject); 38 | } 39 | return modelObjList; 40 | 41 | } 42 | 43 | // function gets all users 44 | public ArrayList findAll() { 45 | return this.userDao.findAll(); 46 | } 47 | 48 | //function for adding user records to db 49 | public boolean save(User user) { 50 | if (this.getById(user.getId()) != null) { 51 | Helper.showMsg("error"); 52 | return false; 53 | } 54 | return this.userDao.save(user); 55 | } 56 | 57 | //function for update user records on db 58 | public boolean update(User user) { 59 | if (this.getById(user.getId()) == null) { 60 | Helper.showMsg(user.getId() + "ID kayıtlı model bulunamadı"); 61 | return false; 62 | } 63 | return this.userDao.update(user); 64 | } 65 | 66 | // function that gets the user with specific id 67 | public User getById(int id) { 68 | return this.userDao.getByID(id); 69 | } 70 | 71 | 72 | // deletion function for user 73 | public boolean delete(int id) { 74 | if (this.getById(id) == null) { 75 | Helper.showMsg(id + " ID kayıtlı model bulunamadı"); 76 | return false; 77 | } 78 | return this.userDao.delete(id); 79 | } 80 | 81 | // function for user search according to role 82 | public ArrayList searchForTable(String role) { 83 | // assuming there are going to be multiple users, the list will be held in an arraylist 84 | String select = "SELECT * FROM public.user"; 85 | // since the role is a string, generic type is being assigned as strimg 86 | ArrayList whereList = new ArrayList<>(); 87 | if (role != null) { 88 | // if user role is not null, sql stynthax is being added to query string like user_role='admin' by encapsulating 89 | // the query string 90 | whereList.add("user_role='" + role + "'"); 91 | } 92 | 93 | // creating a single string named wherestr by joining the elements of the wherelist 94 | String whereStr = String.join(" AND ", whereList); 95 | String query = select; 96 | // if there is no empty strinng, then WHERE clause is being appended to query 97 | if (whereStr.length() > 0) { 98 | query += " WHERE " + whereStr; 99 | } 100 | 101 | //then the query is passed to the selectbyquery method of userdao and relevant user data from db and returns 102 | // an arraylist. 103 | return this.userDao.selectByQuery(query); 104 | } 105 | } -------------------------------------------------------------------------------- /src/view/LoginView.form: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /src/view/PensionView.form: -------------------------------------------------------------------------------- 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 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/entity/Hotel.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import business.HotelManager; 4 | import core.ComboItem; 5 | 6 | 7 | // variables 8 | public class Hotel { 9 | private int id; 10 | private String name; 11 | private String address; 12 | private String mail; 13 | private String phone; 14 | private String star; 15 | private boolean wifi; 16 | private boolean car_park; 17 | private boolean pool; 18 | private boolean fitness; 19 | private boolean concierge; 20 | private boolean spa; 21 | private boolean room_service; 22 | private Pension pension; 23 | private HotelManager hotelManager; 24 | 25 | // default constructor 26 | public Hotel() { 27 | } 28 | 29 | // consturctor with class parameters 30 | public Hotel(int id, String name, String address, String mail, String phone, String star, boolean wifi, boolean car_park, boolean pool, boolean fitness, boolean concierge, boolean spa, boolean room_service) { 31 | HotelManager hotelManager = new HotelManager(); 32 | Pension pension = new Pension(); 33 | this.id = id; 34 | this.name = name; 35 | this.address = address; 36 | this.mail = mail; 37 | this.phone = phone; 38 | this.star = star; 39 | this.wifi = wifi; 40 | this.car_park = car_park; 41 | this.pool = pool; 42 | this.fitness = fitness; 43 | this.concierge = concierge; 44 | this.spa = spa; 45 | this.room_service = room_service; 46 | } 47 | 48 | // getter and setter methods 49 | 50 | public int getId() { 51 | return id; 52 | } 53 | 54 | public void setId(int id) { 55 | this.id = id; 56 | } 57 | 58 | public String getName() { 59 | return name; 60 | } 61 | 62 | public void setName(String name) { 63 | this.name = name; 64 | } 65 | 66 | public String getAddress() { 67 | return address; 68 | } 69 | 70 | public void setAddress(String address) { 71 | this.address = address; 72 | } 73 | 74 | public String getMail() { 75 | return mail; 76 | } 77 | 78 | public void setMail(String mail) { 79 | this.mail = mail; 80 | } 81 | 82 | public String getPhone() { 83 | return phone; 84 | } 85 | 86 | public void setPhone(String phone) { 87 | this.phone = phone; 88 | } 89 | 90 | public String getStar() { 91 | return star; 92 | } 93 | 94 | public void setStar(String star) { 95 | this.star = star; 96 | } 97 | 98 | public boolean isWifi() { 99 | return wifi; 100 | } 101 | 102 | public void setWifi(boolean wifi) { 103 | this.wifi = wifi; 104 | } 105 | 106 | public boolean isCar_park() { 107 | return car_park; 108 | } 109 | 110 | public void setCar_park(boolean car_park) { 111 | this.car_park = car_park; 112 | } 113 | 114 | public boolean isPool() { 115 | return pool; 116 | } 117 | 118 | public void setPool(boolean pool) { 119 | this.pool = pool; 120 | } 121 | 122 | public boolean isFitness() { 123 | return fitness; 124 | } 125 | 126 | public void setFitness(boolean fitness) { 127 | this.fitness = fitness; 128 | } 129 | 130 | public boolean isConcierge() { 131 | return concierge; 132 | } 133 | 134 | public void setConcierge(boolean concierge) { 135 | this.concierge = concierge; 136 | } 137 | 138 | public boolean isSpa() { 139 | return spa; 140 | } 141 | 142 | public void setSpa(boolean spa) { 143 | this.spa = spa; 144 | } 145 | 146 | public boolean isRoom_service() { 147 | return room_service; 148 | } 149 | 150 | public void setRoom_service(boolean room_service) { 151 | this.room_service = room_service; 152 | } 153 | 154 | public ComboItem getComboItem() { 155 | return new ComboItem(this.getId(), this.getName()); 156 | } 157 | 158 | // stringify method 159 | // logic of this method is for us to see the contents of an object as a string with a meaning. 160 | // generally, .toString() method provides you an unclear prints such as memory sector. 161 | // with the logic above, we need to see the print with a meaning. 162 | // that is why, we need do exclude .toString() method with @Override and add this method for a meaningful output instead. 163 | @Override 164 | public String toString() { 165 | return "Hotel{" + 166 | "id=" + id + 167 | ", name='" + name + '\'' + 168 | ", address='" + address + '\'' + 169 | ", mail='" + mail + '\'' + 170 | ", phone='" + phone + '\'' + 171 | ", star='" + star + '\'' + 172 | ", wifi=" + wifi + 173 | ", car_park=" + car_park + 174 | ", pool=" + pool + 175 | ", fitness=" + fitness + 176 | ", concierge=" + concierge + 177 | ", spa=" + spa + 178 | ", room_service=" + room_service + 179 | '}'; 180 | } 181 | 182 | } 183 | -------------------------------------------------------------------------------- /src/entity/Reservation.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import java.time.LocalDate; 4 | 5 | // variables 6 | public class Reservation { 7 | public int id; 8 | public int room_id; 9 | public LocalDate check_in_date; 10 | public LocalDate check_out_date; 11 | public double total_price; 12 | public int guest_count; 13 | public String guest_name; 14 | public String guess_citizen_id; 15 | public String guess_phone; 16 | public String guess_mail; 17 | private int adult_count; 18 | private int child_count; 19 | 20 | 21 | // default constructor method 22 | public Reservation() { 23 | } 24 | 25 | 26 | // constructor method with class variables 27 | public Reservation(int id, int room_id, LocalDate check_in_date, LocalDate check_out_date, double total_price, int guest_count, String guest_name, String guess_citizen_id, String guess_mail,String guess_phone) { 28 | this.id = id; 29 | this.room_id = room_id; 30 | this.check_in_date = check_in_date; 31 | this.check_out_date = check_out_date; 32 | this.total_price = total_price; 33 | this.guest_count = guest_count; 34 | this.guest_name = guest_name; 35 | this.guess_citizen_id = guess_citizen_id; 36 | this.guess_mail = guess_mail; 37 | this.guess_phone = guess_phone; 38 | } 39 | 40 | 41 | // getter and setter methods 42 | 43 | 44 | public String getGuess_citizen_id() { 45 | return guess_citizen_id; 46 | } 47 | 48 | public String getGuess_phone() { 49 | return guess_phone; 50 | } 51 | 52 | public String getGuess_mail() { 53 | return guess_mail; 54 | } 55 | 56 | public int getAdult_count() { 57 | return adult_count; 58 | } 59 | 60 | public void setAdult_count(int adult_count) { 61 | this.adult_count = adult_count; 62 | } 63 | 64 | public int getChild_count() { 65 | return child_count; 66 | } 67 | 68 | public void setChild_count(int child_count) { 69 | this.child_count = child_count; 70 | } 71 | 72 | public int getId() { 73 | return id; 74 | } 75 | 76 | public void setId(int id) { 77 | this.id = id; 78 | } 79 | 80 | public int getRoom_id() { 81 | return room_id; 82 | } 83 | 84 | public void setRoom_id(int room_id) { 85 | this.room_id = room_id; 86 | } 87 | 88 | public LocalDate getCheck_in_date() { 89 | return check_in_date; 90 | } 91 | 92 | public void setCheck_in_date(LocalDate check_in_date) { 93 | this.check_in_date = check_in_date; 94 | } 95 | 96 | public LocalDate getCheck_out_date() { 97 | return check_out_date; 98 | } 99 | 100 | public void setCheck_out_date(LocalDate check_out_date) { 101 | this.check_out_date = check_out_date; 102 | } 103 | 104 | public double getTotal_price() { 105 | return total_price; 106 | } 107 | 108 | public void setTotal_price(double total_price) { 109 | this.total_price = total_price; 110 | } 111 | 112 | public int getGuest_count() { 113 | return guest_count; 114 | } 115 | 116 | public void setGuest_count(int guest_count) { 117 | this.guest_count = guest_count; 118 | } 119 | 120 | public String getGuest_name() { 121 | return guest_name; 122 | } 123 | 124 | public void setGuest_name(String guest_name) { 125 | this.guest_name = guest_name; 126 | } 127 | 128 | public String getGuest_citizen_id() { 129 | return guess_citizen_id; 130 | } 131 | 132 | public void setGuess_citizen_id(String guess_citizen_id) { 133 | this.guess_citizen_id = guess_citizen_id; 134 | } 135 | 136 | public String getGuest_phone() { 137 | return guess_phone; 138 | } 139 | 140 | public void setGuess_phone(String guess_phone) { 141 | this.guess_phone = guess_phone; 142 | } 143 | 144 | public String getGuest_mail() { 145 | return guess_mail; 146 | } 147 | 148 | public void setGuess_mail(String guess_mail) { 149 | this.guess_mail = guess_mail; 150 | } 151 | 152 | // stringify method 153 | // logic of this method is for us to see the contents of an object as a string with a meaning. 154 | // generally, .toString() method provides you an unclear prints such as memory sector. 155 | // with the logic above, we need to see the print with a meaning. 156 | // that is why, we need do exclude .toString() method with @Override and add this method for a meaningful output instead. 157 | @Override 158 | public String toString() { 159 | return "Reservation{" + 160 | "id=" + id + 161 | ", room_id=" + room_id + 162 | ", check_in_date=" + check_in_date + 163 | ", check_out_date=" + check_out_date + 164 | ", total_price=" + total_price + 165 | ", guest_count=" + guest_count + 166 | ", guest_name='" + guest_name + '\'' + 167 | ", guess_citizen_id='" + guess_citizen_id + '\'' + 168 | ", guess_phone='" + guess_phone + '\'' + 169 | ", guess_mail='" + guess_mail + '\'' + 170 | '}'; 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/dao/SeasonDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Database; 4 | import entity.Season; 5 | 6 | import java.sql.*; 7 | import java.time.LocalDate; 8 | import java.util.ArrayList; 9 | 10 | 11 | public class SeasonDao { 12 | private final Connection connection; 13 | 14 | // constructor for access to database 15 | public SeasonDao() { 16 | this.connection = Database.getInstance(); 17 | } 18 | 19 | // function for having hotel seasons by hotel id 20 | public ArrayList getSeasonsByOtelId(int otelId) { 21 | ArrayList seasons = new ArrayList<>(); 22 | String query = "SELECT * FROM public.hotel_season WHERE hotel_id = ?"; 23 | 24 | try (PreparedStatement pr = connection.prepareStatement(query)) { 25 | // parameter assignment 26 | pr.setInt(1, otelId); 27 | ResultSet rs = pr.executeQuery(); 28 | // while query result has a next item, object is being returned through match function. 29 | while (rs.next()) { 30 | Season season = match(rs); 31 | seasons.add(season); 32 | } 33 | // if try block fails, an exception will be thrown 34 | } catch (SQLException e) { 35 | e.printStackTrace(); 36 | } 37 | 38 | return seasons; 39 | } 40 | 41 | // getter method for a season with spesific id 42 | public Season getSeasonByID(int id) { 43 | Season obj = null; 44 | String query = "SELECT * FROM public.hotel_season WHERE id = ? "; 45 | try { 46 | // parameter assignments 47 | PreparedStatement pr = this.connection.prepareStatement(query); 48 | pr.setInt(1, id); 49 | ResultSet rs = pr.executeQuery(); 50 | if (rs.next()) { 51 | // while query result has a next item, object is being returned through match function. 52 | obj = this.match(rs); 53 | } 54 | // if try block fails, an exception will be thrown 55 | } catch (SQLException e) { 56 | e.printStackTrace(); 57 | } 58 | return obj; 59 | } 60 | 61 | // matcher function for matching resultset and season obj 62 | //logic of match block is, the datas coming from result set, are being assigning to related objects 63 | public Season match(ResultSet rs) throws SQLException { 64 | Season obj = new Season(); 65 | obj.setId(rs.getInt("id")); 66 | obj.setHotel_id(rs.getInt("hotel_id")); 67 | obj.setStart_date(LocalDate.parse(rs.getString("start_date"))); 68 | obj.setFinish_date(LocalDate.parse(rs.getString("finish_date"))); 69 | 70 | 71 | return obj; 72 | } 73 | 74 | // getter method for all seasons 75 | public ArrayList findAll() { 76 | ArrayList seasonList = new ArrayList<>(); 77 | String sql = "SELECT * FROM public.hotel_season"; 78 | try { 79 | ResultSet rs = this.connection.createStatement().executeQuery(sql); 80 | // while result set has next, values are being added to season list through match method and 81 | // returns as season list into array list 82 | while (rs.next()) { 83 | 84 | seasonList.add(this.match(rs)); 85 | } 86 | // if try block fails an exception will be thrown 87 | } catch (SQLException e) { 88 | e.printStackTrace(); 89 | } 90 | 91 | return seasonList; 92 | } 93 | 94 | // season adder method 95 | public boolean save(Season season){ 96 | String query = "INSERT INTO public.hotel_season"+ 97 | "("+ 98 | "hotel_id,"+ 99 | "start_date," + 100 | "finish_date"+ 101 | ")"+ 102 | "VALUES (?,?,?)"; 103 | try { 104 | PreparedStatement pr = connection.prepareStatement(query); 105 | // parameter assignment 106 | pr.setInt(1,season.getHotel_id()); 107 | pr.setDate(2, Date.valueOf(season.getStart_date())); 108 | pr.setDate(3, Date.valueOf(season.getFinish_date())); 109 | // checks if return is not equals to -1. Thus, if it is not equals to -1, that means there is a 110 | //row affected with this action and row is added. 111 | return pr.executeUpdate() != -1; 112 | 113 | // if try bloc fails, an exception will be thrown 114 | } catch (SQLException e) { 115 | e.printStackTrace(); 116 | } 117 | return true; 118 | } 119 | 120 | // season deleter method 121 | public boolean delete(int hotel_id){ 122 | try{ 123 | String query = "DELETE FROM public.hotel_season WHERE id = ?"; 124 | PreparedStatement pr = connection.prepareStatement(query); 125 | // parameter assignment 126 | pr.setInt(1,hotel_id); 127 | // checks if return is not equals to -1. Thus, if it is not equals to -1, that means there is a 128 | //row affected with this action and row is deleted. 129 | return pr.executeUpdate() != -1; 130 | // if try block fails, an exception will be thrown 131 | }catch (SQLException e){ 132 | e.printStackTrace(); 133 | } 134 | return true; 135 | } 136 | } 137 | 138 | 139 | -------------------------------------------------------------------------------- /src/view/RoomView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import business.PensionManager; 5 | import business.RoomManager; 6 | import business.SeasonManager; 7 | import core.ComboItem; 8 | import core.Helper; 9 | import entity.Hotel; 10 | import entity.Pension; 11 | import entity.Room; 12 | import entity.Season; 13 | import javax.swing.*; 14 | import java.util.ArrayList; 15 | 16 | public class RoomView extends Layout { 17 | private JLabel lbl_title_add; 18 | private JComboBox cmb_room_add_hotel; 19 | private JComboBox cmb_season_add; 20 | private JComboBox cmb_room_type_add; 21 | private JTextField tf_adult_price; 22 | private JRadioButton rbut_projection; 23 | private JButton btn_save_add_room_menu; 24 | private JPanel wrapper; 25 | private JComboBox cmb_pension_add; 26 | private JTextField tf_child_price; 27 | private JTextField tf_bed_capacity; 28 | private JTextField tf_square_meter; 29 | private JRadioButton rbut_television; 30 | private JRadioButton rbut_minibar; 31 | private JRadioButton rbut_game_console; 32 | private JRadioButton rbut_cashbox; 33 | private JTextField tf_stock; 34 | private HotelManager hotelManager; 35 | private SeasonManager seasonManager; 36 | private PensionManager pensionManager; 37 | private ComboItem comboItem; 38 | private Hotel hotel; 39 | private Room room; 40 | private Season season; 41 | private RoomManager roomManager; 42 | 43 | //constructors 44 | public RoomView() { 45 | this.add(wrapper); 46 | this.visualInitialize(725, 425); 47 | this.comboItem = new ComboItem(); 48 | this.hotel = new Hotel(); 49 | this.room = new Room(); 50 | this.season = new Season(); 51 | this.pensionManager = new PensionManager(); 52 | this.seasonManager = new SeasonManager(); 53 | this.hotelManager = new HotelManager(); 54 | this.roomManager = new RoomManager(); 55 | 56 | // add all hotel names to combobox 57 | for (Hotel hotel : hotelManager.findAll()) { 58 | this.cmb_room_add_hotel.addItem(hotel.getComboItem()); 59 | } 60 | 61 | 62 | // adds listener to combo box 63 | cmb_room_add_hotel.addActionListener(e -> { 64 | // once the user picks a hotel, season and pension informations will be shown dynamically 65 | ComboItem selectedOtelItem = (ComboItem) cmb_room_add_hotel.getSelectedItem(); 66 | int selectedOtelId = selectedOtelItem.getKey(); 67 | ArrayList pensions = pensionManager.getPensionByOtelId(((ComboItem) cmb_room_add_hotel.getSelectedItem()).getKey()); 68 | cmb_pension_add.removeAllItems(); 69 | 70 | for(Pension pension:pensions){ 71 | cmb_pension_add.addItem(pension.getComboItem()); 72 | } 73 | 74 | ArrayList seasons = seasonManager.getSeasonsByOtelId(((ComboItem) cmb_room_add_hotel.getSelectedItem()).getKey()); 75 | 76 | cmb_season_add.removeAllItems(); 77 | for (Season season : seasons) { 78 | cmb_season_add.addItem(season.getComboItem()); 79 | 80 | } 81 | 82 | }); 83 | 84 | btn_save_add_room_menu.addActionListener(e -> { 85 | 86 | JTextField[] selectedRoomList = new JTextField[]{tf_adult_price, tf_child_price, tf_bed_capacity, tf_bed_capacity, tf_square_meter}; 87 | // checks if all fields are filled 88 | if (Helper.isFieldListEmpty(selectedRoomList)) { 89 | Helper.showMsg("fill"); 90 | } else { 91 | // boolean is for to check if the process is accomplished 92 | boolean result = false; 93 | // checks the combo box item and clicked value is being taken and rest of assignments 94 | ComboItem selectedHotel = (ComboItem) cmb_room_add_hotel.getSelectedItem(); 95 | ComboItem selectedPension = (ComboItem) cmb_pension_add.getSelectedItem(); 96 | ComboItem selectedSeason=(ComboItem) cmb_season_add.getSelectedItem(); 97 | room.setSeason_id(selectedSeason.getKey()); 98 | room.setPension_id(selectedPension.getKey()); 99 | room.setHotel_id(selectedHotel.getKey()); 100 | room.setType((String) cmb_room_type_add.getSelectedItem()); 101 | room.setStock(Integer.parseInt(tf_stock.getText())); 102 | room.setAdult_price(Double.parseDouble(tf_adult_price.getText())); 103 | room.setChild_price(Double.parseDouble(tf_child_price.getText())); 104 | room.setBed_capacity(Integer.parseInt(tf_bed_capacity.getText())); 105 | room.setSquare_meter(Integer.parseInt(tf_square_meter.getText())); 106 | room.setTelevision(rbut_television.isSelected()); 107 | room.setMinibar(rbut_minibar.isSelected()); 108 | room.setGame_console(rbut_game_console.isSelected()); 109 | room.setCash_box(rbut_cashbox.isSelected()); 110 | room.setProjection(rbut_projection.isSelected()); 111 | // checks and throws relevant message whether record process to db is successful or not 112 | if(room.getId()!=0){ 113 | result = roomManager.update(room); 114 | }else{ 115 | result=roomManager.save(room); 116 | } 117 | if(result){ 118 | Helper.showMsg("done"); 119 | 120 | dispose(); 121 | }else{ 122 | Helper.showMsg("error"); 123 | } 124 | } 125 | 126 | }); 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/view/RoomUpdateView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import business.PensionManager; 5 | import business.RoomManager; 6 | import business.SeasonManager; 7 | import core.ComboItem; 8 | import core.Helper; 9 | import entity.*; 10 | 11 | import javax.swing.*; 12 | import java.util.ArrayList; 13 | 14 | public class RoomUpdateView extends Layout { 15 | private JLabel lbl_title_add; 16 | private JComboBox cmb_room_add_hotel; 17 | private JComboBox cmb_season_add; 18 | private JComboBox cmb_room_type_add; 19 | private JTextField tf_adult_price; 20 | private JRadioButton rbut_projection; 21 | private JButton btn_save_add_room_menu; 22 | private JPanel wrapper; 23 | private JComboBox cmb_pension_add; 24 | private JTextField tf_child_price; 25 | private JTextField tf_bed_capacity; 26 | private JTextField tf_square_meter; 27 | private JRadioButton rbut_television; 28 | private JRadioButton rbut_minibar; 29 | private JRadioButton rbut_game_console; 30 | private JRadioButton rbut_cashbox; 31 | private JTextField tf_stock; 32 | private HotelManager hotelManager; 33 | private SeasonManager seasonManager; 34 | private PensionManager pensionManager; 35 | private ComboItem comboItem; 36 | private EmployeeView employeeView = new EmployeeView(); 37 | private Hotel hotel; 38 | private Room room; 39 | private Season season; 40 | private RoomManager roomManager; 41 | 42 | // constructor 43 | public RoomUpdateView(Room room) { 44 | this.add(wrapper); 45 | // visual interface initialization 46 | this.visualInitialize(725, 425); 47 | this.comboItem = new ComboItem(); 48 | this.hotel = new Hotel(); 49 | this.room = room; 50 | this.season = new Season(); 51 | this.pensionManager = new PensionManager(); 52 | this.seasonManager = new SeasonManager(); 53 | this.hotelManager = new HotelManager(); 54 | this.roomManager = new RoomManager(); 55 | 56 | // add all hotel names to combobox 57 | for (Hotel hotel : hotelManager.findAll()) { 58 | this.cmb_room_add_hotel.addItem(hotel.getComboItem()); 59 | } 60 | 61 | // save listener related button 62 | btn_save_add_room_menu.addActionListener(e -> { 63 | 64 | // checks if necessary fields are empty 65 | JTextField[] selectedRoomList = new JTextField[]{tf_adult_price, tf_child_price, tf_bed_capacity, tf_bed_capacity, tf_square_meter}; 66 | 67 | if (Helper.isFieldListEmpty(selectedRoomList)) { 68 | Helper.showMsg("fill"); 69 | } else { 70 | // dispose after 71 | dispose(); 72 | } 73 | 74 | // boolean is for to check if the process is accomplished 75 | boolean result; 76 | 77 | 78 | // checks thhe combo box item and clicked value is being taken 79 | ComboItem selectedHotel = (ComboItem) cmb_room_add_hotel.getSelectedItem(); 80 | ComboItem selectedPension = (ComboItem) cmb_pension_add.getSelectedItem(); 81 | ComboItem selectedSeason = (ComboItem) cmb_season_add.getSelectedItem(); 82 | 83 | // assignments 84 | this.room.setSeason_id(selectedSeason.getKey()); 85 | this.room.setPension_id(selectedPension.getKey()); 86 | this.room.setHotel_id(selectedHotel.getKey()); 87 | this.room.setType((String) cmb_room_type_add.getSelectedItem()); 88 | this.room.setStock(Integer.parseInt(tf_stock.getText())); 89 | this.room.setAdult_price(Double.parseDouble(tf_adult_price.getText())); 90 | this.room.setChild_price(Double.parseDouble(tf_child_price.getText())); 91 | this.room.setBed_capacity(Integer.parseInt(tf_bed_capacity.getText())); 92 | this.room.setSquare_meter(Integer.parseInt(tf_square_meter.getText())); 93 | this.room.setTelevision(rbut_television.isSelected()); 94 | this.room.setMinibar(rbut_minibar.isSelected()); 95 | this.room.setGame_console(rbut_game_console.isSelected()); 96 | this.room.setCash_box(rbut_cashbox.isSelected()); 97 | this.room.setProjection(rbut_projection.isSelected()); 98 | 99 | // checks and throws relevant message whether record process to db is successful or not 100 | System.out.println(room.getId()); 101 | if (room.getId() != 0) { 102 | result = roomManager.update(room); 103 | } else { 104 | result = roomManager.save(room); 105 | } 106 | if (result) { 107 | Helper.showMsg("done"); 108 | } else { 109 | Helper.showMsg("error"); 110 | } 111 | 112 | }); 113 | 114 | // listener for combo box 115 | cmb_room_add_hotel.addActionListener(e -> { 116 | 117 | // this block below, brings you the dynamic information of seasons and pensions 118 | ComboItem selectedOtelItem = (ComboItem) cmb_room_add_hotel.getSelectedItem(); 119 | int selectedOtelId = selectedOtelItem.getKey(); 120 | ArrayList pensions = pensionManager.getPensionByOtelId(((ComboItem) cmb_room_add_hotel.getSelectedItem()).getKey()); 121 | 122 | cmb_pension_add.removeAllItems(); 123 | 124 | for (Pension pension : pensions) { 125 | cmb_pension_add.addItem(pension.getComboItem()); 126 | } 127 | 128 | ArrayList seasons = seasonManager.getSeasonsByOtelId(((ComboItem) cmb_room_add_hotel.getSelectedItem()).getKey()); 129 | 130 | cmb_season_add.removeAllItems(); 131 | for (Season season : seasons) { 132 | cmb_season_add.addItem(season.getComboItem()); 133 | 134 | } 135 | 136 | }); 137 | 138 | 139 | 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /src/view/SeasonView.form: -------------------------------------------------------------------------------- 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 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /src/dao/PensionDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Database; 4 | import entity.Hotel; 5 | import entity.Pension; 6 | import entity.Season; 7 | import entity.User; 8 | 9 | import java.sql.Connection; 10 | import java.sql.PreparedStatement; 11 | import java.sql.ResultSet; 12 | import java.sql.SQLException; 13 | import java.util.ArrayList; 14 | 15 | 16 | public class PensionDao { 17 | 18 | private final Connection connection; 19 | 20 | // constructor for access to database 21 | public PensionDao() { 22 | this.connection = Database.getInstance(); 23 | } 24 | 25 | // function for bringing the pension information by a hotel id 26 | public ArrayList getPensionByOtelId(int id) { 27 | ArrayList pensions = new ArrayList<>(); 28 | String query = "SELECT * FROM public.hotel_pension WHERE hotel_id = ?"; 29 | 30 | try (PreparedStatement pr = connection.prepareStatement(query)) { 31 | // after query search, parameters are being assigned 32 | pr.setInt(1, id); 33 | ResultSet rs = pr.executeQuery(); 34 | // while rs has next, match method will be executed for pension object and pensions arraylist will be 35 | // added to pension 36 | while (rs.next()) { 37 | Pension pension = match(rs); 38 | pensions.add(pension); 39 | } 40 | } catch (SQLException e) { 41 | e.printStackTrace(); 42 | } 43 | 44 | return pensions; 45 | } 46 | 47 | // getter function for pension which has a specific id 48 | public Pension getByID(int id) { 49 | Pension obj = null; 50 | // query 51 | String query = "SELECT * FROM public.hotel_pension WHERE id = ? "; 52 | try { 53 | // parameter assignment 54 | PreparedStatement pr = this.connection.prepareStatement(query); 55 | pr.setInt(1, id); 56 | ResultSet rs = pr.executeQuery(); 57 | // while rs has next objects, match method will be executed 58 | if (rs.next()) { 59 | obj = this.match(rs); 60 | } 61 | // if there is a problem with try block, then an exception will be thrown. 62 | } catch (SQLException e) { 63 | e.printStackTrace(); 64 | } 65 | return obj; 66 | } 67 | 68 | // matcher function for matching resultset and pension obj 69 | //logic of match block is, the datas coming from result set, are being assigning to related objects 70 | public Pension match(ResultSet rs) throws SQLException { 71 | 72 | Pension obj = new Pension(); 73 | obj.setId(rs.getInt("id")); 74 | obj.setHotel_id(rs.getInt("hotel_id")); 75 | obj.setPension_type(rs.getString("pension_type")); 76 | 77 | 78 | return obj; 79 | } 80 | 81 | // function for pension update 82 | public boolean update(Pension pension) { 83 | try { 84 | String query = "UPDATE public.hotel_pension SET " + 85 | "hotel_id = ?," + 86 | "pension_type = ?" + 87 | "WHERE user_id = ?"; 88 | 89 | PreparedStatement pr = connection.prepareStatement(query); 90 | // parameter assignments 91 | pr.setInt(1,pension.getHotel_id()); 92 | pr.setString(2,pension.getPension_type()); 93 | // checks if return is not equasl to -1. Thus, if it is not equals to -1, that means there is a 94 | //row affected with this action and row is updatedd. 95 | return pr.executeUpdate() != -1; 96 | 97 | // if a problem occurs, sql exception will be thrown 98 | } catch (SQLException e) { 99 | e.printStackTrace(); 100 | } 101 | return true; 102 | } 103 | 104 | // function to bring all pensions 105 | public ArrayList findAll() { 106 | ArrayList pensionList = new ArrayList<>(); 107 | String sql = "SELECT * FROM public.hotel_pension"; 108 | try { 109 | ResultSet rs = this.connection.createStatement().executeQuery(sql); 110 | // once sql query returns as a result set, 111 | // whlile rs has next item, is being added to pension list through match method and returns to array list 112 | // through pensionlist return. 113 | while (rs.next()) { 114 | 115 | pensionList.add(this.match(rs)); 116 | } 117 | } catch (SQLException e) { 118 | e.printStackTrace(); 119 | } 120 | return pensionList; 121 | } 122 | 123 | // function to add pensions 124 | public boolean save(Pension pension){ 125 | String query = "INSERT INTO public.hotel_pension"+ 126 | "("+ 127 | "hotel_id,"+ 128 | "pension_type"+ 129 | ")"+ 130 | "VALUES (?,?)"; 131 | try { 132 | PreparedStatement pr = connection.prepareStatement(query); 133 | // parameters assignment 134 | pr.setInt(1,pension.getHotel_id()); 135 | pr.setString(2,pension.getPension_type()); 136 | // checks if return is not equasl to -1. Thus, if it is not equals to -1, that means there is a 137 | //row affected with this action and row is saved. 138 | return pr.executeUpdate() != -1; 139 | } catch (SQLException e) { 140 | e.printStackTrace(); 141 | } 142 | return true; 143 | } 144 | 145 | // function for pension deletion by id 146 | public boolean delete(int hotel_id){ 147 | try{ 148 | String query = "DELETE FROM public.hotel_pension WHERE id = ?"; 149 | PreparedStatement pr = connection.prepareStatement(query); 150 | pr.setInt(1,hotel_id); 151 | // checks if return is not equasl to -1. Thus, if it is not equals to -1, that means there is a 152 | //row affected with this action and row is deleted. 153 | return pr.executeUpdate() != -1; 154 | }catch (SQLException throwables){ 155 | throwables.printStackTrace(); 156 | } 157 | return true; 158 | } 159 | } -------------------------------------------------------------------------------- /src/entity/Room.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import business.HotelManager; 4 | import business.PensionManager; 5 | 6 | // variables 7 | public class Room { 8 | private int id; 9 | private int hotel_id; 10 | private int pension_id; 11 | private int season_id; 12 | private String type; 13 | private int stock; 14 | private double adult_price; 15 | private double child_price; 16 | private int bed_capacity; 17 | private int square_meter; 18 | private boolean television; 19 | private boolean minibar; 20 | private boolean game_console; 21 | private boolean cash_box; 22 | private boolean projection; 23 | private boolean gym; 24 | 25 | 26 | // default constructor method 27 | public Room() { 28 | } 29 | 30 | 31 | // constructor method with class variables 32 | public Room(int id, int hotel_id, int pension_id, int season_id, String type, int stock, double adult_price, double child_price, int bed_capacity, int square_meter, boolean television, boolean minibar, boolean game_console, boolean cash_box, boolean projection,boolean gym) { 33 | this.id = id; 34 | this.hotel_id = hotel_id; 35 | this.pension_id = pension_id; 36 | this.season_id = season_id; 37 | this.type = type; 38 | this.stock = stock; 39 | this.adult_price = adult_price; 40 | this.child_price = child_price; 41 | this.bed_capacity = bed_capacity; 42 | this.square_meter = square_meter; 43 | this.television = television; 44 | this.minibar = minibar; 45 | this.game_console = game_console; 46 | this.cash_box = cash_box; 47 | this.projection = projection; 48 | this.gym = gym; 49 | } 50 | 51 | 52 | // getter and setter methods 53 | public boolean isGym() { 54 | return gym; 55 | } 56 | 57 | public void setGym(boolean gym) { 58 | this.gym = gym; 59 | } 60 | 61 | public int getId() { 62 | return id; 63 | } 64 | 65 | public void setId(int id) { 66 | this.id = id; 67 | } 68 | 69 | public int getHotel_id() { 70 | return hotel_id; 71 | } 72 | 73 | public void setHotel_id(int hotel_id) { 74 | this.hotel_id = hotel_id; 75 | } 76 | 77 | public int getPension_id() { 78 | return pension_id; 79 | } 80 | 81 | public void setPension_id(int pension_id) { 82 | this.pension_id = pension_id; 83 | } 84 | 85 | public int getSeason_id() { 86 | return season_id; 87 | } 88 | 89 | public void setSeason_id(int season_id) { 90 | this.season_id = season_id; 91 | } 92 | 93 | public String getType() { 94 | return type; 95 | } 96 | 97 | public void setType(String type) { 98 | this.type = type; 99 | } 100 | 101 | public int getStock() { 102 | return stock; 103 | } 104 | 105 | public int setStock(int stock) { 106 | this.stock = stock; 107 | return stock; 108 | } 109 | 110 | public double getAdult_price() { 111 | return adult_price; 112 | } 113 | 114 | public void setAdult_price(double adult_price) { 115 | this.adult_price = adult_price; 116 | } 117 | 118 | public double getChild_price() { 119 | return child_price; 120 | } 121 | 122 | public void setChild_price(double child_price) { 123 | this.child_price = child_price; 124 | } 125 | 126 | public int getBed_capacity() { 127 | return bed_capacity; 128 | } 129 | 130 | public void setBed_capacity(int bed_capacity) { 131 | this.bed_capacity = bed_capacity; 132 | } 133 | 134 | public int getSquare_meter() { 135 | return square_meter; 136 | } 137 | 138 | public void setSquare_meter(int square_meter) { 139 | this.square_meter = square_meter; 140 | } 141 | 142 | public boolean isTelevision() { 143 | return television; 144 | } 145 | 146 | public void setTelevision(boolean television) { 147 | this.television = television; 148 | } 149 | 150 | public boolean isMinibar() { 151 | return minibar; 152 | } 153 | 154 | public void setMinibar(boolean minibar) { 155 | this.minibar = minibar; 156 | } 157 | 158 | public boolean isGame_console() { 159 | return game_console; 160 | } 161 | 162 | public void setGame_console(boolean game_console) { 163 | this.game_console = game_console; 164 | } 165 | 166 | public boolean isCash_box() { 167 | return cash_box; 168 | } 169 | 170 | public void setCash_box(boolean cash_box) { 171 | this.cash_box = cash_box; 172 | } 173 | 174 | public boolean isProjection() { 175 | return projection; 176 | } 177 | 178 | public void setProjection(boolean projection) { 179 | this.projection = projection; 180 | } 181 | 182 | 183 | // stringify method 184 | // logic of this method is for us to see the contents of an object as a string with a meaning. 185 | // generally, .toString() method provides you an unclear prints such as memory sector. 186 | // with the logic above, we need to see the print with a meaning. 187 | // that is why, we need do exclude .toString() method with @Override and add this method for a meaningful output instead. 188 | @Override 189 | public String toString() { 190 | return "Room{" + 191 | "id=" + id + 192 | ", hotel_id=" + hotel_id + 193 | ", pension_id=" + pension_id + 194 | ", season_id=" + season_id + 195 | ", type='" + type + '\'' + 196 | ", stock=" + stock + 197 | ", adult_price=" + adult_price + 198 | ", child_price=" + child_price + 199 | ", bed_capacity=" + bed_capacity + 200 | ", square_meter=" + square_meter + 201 | ", television=" + television + 202 | ", minibar=" + minibar + 203 | ", game_console=" + game_console + 204 | ", cash_box=" + cash_box + 205 | ", projection=" + projection + 206 | '}'; 207 | } 208 | 209 | // the methods are below for getting the id of hotel and pension that room bounded to 210 | public Hotel getHotel() { 211 | HotelManager hotelManager = new HotelManager(); 212 | return hotelManager.getById(hotel_id); 213 | } 214 | public Pension getPension() { 215 | PensionManager pensionManager=new PensionManager(); 216 | return pensionManager.getById(this.pension_id); 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /src/business/RoomManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.RoomDao; 5 | import entity.Room; 6 | 7 | import java.time.LocalDate; 8 | import java.time.format.DateTimeFormatter; 9 | import java.util.ArrayList; 10 | 11 | 12 | 13 | public class RoomManager { 14 | 15 | // new object for db connection 16 | RoomDao roomDao = new RoomDao(); 17 | 18 | // function that brings the room with specific id 19 | public Room getById(int id){return this.roomDao.getByID(id);} 20 | 21 | // function that brings all room records 22 | public ArrayList findAll(){return this.roomDao.findAll();} 23 | 24 | // the method that provides necessary information for table with generic data type as Object[] so, the array list may take 25 | // different type of objects 26 | public ArrayList getForTable(int size,ArrayList rooms){ 27 | ArrayList roomList = new ArrayList<>(); 28 | for (Room obj : rooms){ 29 | int i = 0; 30 | Object[] rowObject = new Object[size]; 31 | rowObject[i++] = obj.getId(); 32 | rowObject[i++] = obj.getHotel_id(); 33 | rowObject[i++] = obj.getPension_id(); 34 | rowObject[i++] = obj.getSeason_id(); 35 | rowObject[i++] = obj.getType(); 36 | rowObject[i++] = obj.getStock(); 37 | rowObject[i++] = obj.getAdult_price(); 38 | rowObject[i++] = obj.getChild_price(); 39 | rowObject[i++] = obj.getBed_capacity(); 40 | rowObject[i++] = obj.getSquare_meter(); 41 | rowObject[i++] = obj.isTelevision(); 42 | rowObject[i++] = obj.isMinibar(); 43 | rowObject[i++] = obj.isGame_console(); 44 | rowObject[i++] = obj.isCash_box(); 45 | rowObject[i++] = obj.isProjection(); 46 | roomList.add(rowObject); 47 | } 48 | return roomList; 49 | } 50 | 51 | // function that adds room record to database 52 | public boolean save(Room room){ 53 | if(room.getId()!=0){ 54 | Helper.showMsg("error"); 55 | } 56 | return this.roomDao.save(room); 57 | } 58 | 59 | // function that updates stock amount for room 60 | public boolean updateStock(Room room){ 61 | if(this.getById(room.getId())== null){ 62 | return false; 63 | } 64 | return this.roomDao.updateStock(room); 65 | } 66 | 67 | // function that deletes the room with an id 68 | public boolean delete(int id){ 69 | if(this.getById(id) == null){ 70 | Helper.showMsg(id + " id could not found"); 71 | return false; 72 | } 73 | return this.roomDao.delete(id); 74 | } 75 | 76 | // function that updates room records 77 | public boolean update(Room room) { 78 | if (this.getById(room.getId()) == null) { 79 | Helper.showMsg(room.getId()+ " id could not found"); 80 | return false; 81 | }else { 82 | return this.roomDao.update(room); 83 | ////////////////// dao'ya bak 84 | } 85 | 86 | 87 | 88 | } 89 | 90 | 91 | // filter method by search credentials 92 | 93 | // method below, returns an ArrayList of room objects and takes several parameters that specify search criteria for available rooms 94 | public ArrayList searchForTable(String hotelName, String cityAdress,String checkinDate,String checkoutDate, String adultNum, String childNum){ 95 | 96 | // all columns from public.room is being taken and left joins to public.hotel and public.hotel_season with sql aliases 97 | String query = "SELECT * from public.room r " + 98 | "LEFT JOIN public.hotel h ON r.hotel_id = h.id " + 99 | "LEFT JOIN public.hotel_season s ON r.season_id = s.id WHERE"; 100 | 101 | ArrayList whereList = new ArrayList<>(); 102 | // whereList is initialized to store the conditions for 'WHERE' clause of the query and since it is a number, checks if it is empty. 103 | whereList.add(" r.stock > " + 0); 104 | 105 | // check in and check out dates parsed to local date by using DateTimeFormatter then will be added to whereList. 106 | checkinDate = LocalDate.parse(checkinDate, DateTimeFormatter.ofPattern("dd/MM/yyyy")).toString(); 107 | checkoutDate = LocalDate.parse(checkoutDate, DateTimeFormatter.ofPattern("dd/MM/yyyy")).toString(); 108 | 109 | whereList.add(" AND s.start_date <= '" + checkinDate + "'"); 110 | whereList.add(" AND s.finish_date >='" + checkoutDate + "'"); 111 | // in case of not null situation, ILIKE sql operator creates a case insensitive pattern. 112 | if (hotelName != null){ 113 | whereList.add(" AND h.name ILIKE '%" + hotelName + "%'"); 114 | } 115 | // in case of not null situation, ILIKE sql operator creates a case insensitive pattern. 116 | if (cityAdress != null){ 117 | 118 | whereList.add(" AND h.address ILIKE '%" + cityAdress + "%'"); 119 | 120 | } 121 | 122 | 123 | // if adult amount and children amounts are valid and not null and not empty strings 124 | if ( adultNum != null && !adultNum.isEmpty() && childNum != null && !childNum.isEmpty()){ 125 | 126 | // since the numbers are being taken as strings, a parse operation is being applied to 127 | // convert string numbers into integer. 128 | // once the process is done, these converted values are being stored into adultnum and childnum 129 | try { 130 | int adultNumber = Integer.parseInt(adultNum); 131 | int childNumber = Integer.parseInt(childNum); 132 | int totalNumber = adultNumber + childNumber; 133 | 134 | // checks if a bed capacity of a room is greater or equal than total numbers of guests. 135 | whereList.add(" AND r.bed_capacity >= '" + (totalNumber) + "'"); 136 | 137 | // catches if anything goes wrong 138 | }catch (NumberFormatException e){ 139 | e.printStackTrace(); 140 | 141 | } 142 | // after conditions are added to the whereList, a concatenation process is being performed and query gets an 143 | // update with whereList 144 | query+= String.join("",whereList); 145 | 146 | } 147 | 148 | // we are taking the room information with selectbyquery method of roomdao. since return is expected as a list, 149 | // storing it in an arraylist. 150 | ArrayList queryResult = this.roomDao.selectByQuery(query); 151 | // and returning the result. 152 | return queryResult; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Database; 4 | 5 | import core.Helper; 6 | import entity.User; 7 | 8 | import java.sql.Connection; 9 | import java.sql.PreparedStatement; 10 | import java.sql.ResultSet; 11 | import java.sql.SQLException; 12 | import java.util.ArrayList; 13 | 14 | 15 | public class UserDao { 16 | private final Connection con; 17 | 18 | // constructor for access to database 19 | public UserDao() { 20 | this.con = Database.getInstance(); 21 | } 22 | 23 | // method that brings all users 24 | public ArrayList findAll() { 25 | ArrayList userList = new ArrayList<>(); 26 | String sql = "SELECT * FROM public.user"; 27 | try { 28 | ResultSet rs = this.con.createStatement().executeQuery(sql); 29 | while (rs.next()) { 30 | // while query result has a next item, object is being returned through match function. 31 | userList.add(this.match(rs)); 32 | } 33 | // if try block fails, an exception will be thrown 34 | } catch (SQLException e) { 35 | e.printStackTrace(); 36 | } 37 | return userList; 38 | } 39 | 40 | // method that finds user according to username and password 41 | public User findByLogin(String username, String password) { 42 | User obj = null; 43 | String query = "SELECT * FROM public.user WHERE user_name = ? AND user_pass = ?"; 44 | try { 45 | // parameter assignments 46 | PreparedStatement pr = this.con.prepareStatement(query); 47 | pr.setString(1, username); 48 | pr.setString(2, password); 49 | // executequery method lets you run the sql query over database. 50 | // below, query has been made and results are added to a result set. 51 | ResultSet rs = pr.executeQuery(); 52 | if (rs.next()) { 53 | // while query result has a next item, object is being returned through match function. 54 | obj = this.match(rs); 55 | } 56 | // if try block fails, an exception will be thrown 57 | } catch (SQLException e) { 58 | e.printStackTrace(); 59 | } 60 | return obj; 61 | } 62 | 63 | // matcher function for matching resultset and user obj 64 | //logic of match block is, the datas coming from result set, are being assigning to related objects 65 | public User match(ResultSet rs) throws SQLException { 66 | User obj = new User(); 67 | obj.setId(rs.getInt("user_id")); 68 | obj.setUsername(rs.getString("user_name")); 69 | obj.setPassword(rs.getString("user_pass")); 70 | obj.setRole(rs.getString("user_role")); 71 | return obj; 72 | } 73 | 74 | // user adder method 75 | public boolean save(User user) { 76 | String query = "INSERT INTO public.user (user_name , user_pass , user_role) VALUES (?,?, ?)"; 77 | try { 78 | PreparedStatement pr = con.prepareStatement(query); 79 | // parameter assignments 80 | pr.setString(1, user.getUsername()); 81 | pr.setString(2, user.getPassword()); 82 | pr.setString(3, user.getRole()); 83 | // checks if return is not equals to -1. Thus, if it is not equals to -1, that means there is a 84 | //row affected with this action and row is added. 85 | return pr.executeUpdate() != -1; 86 | // if try block fails, an exception will be thrown 87 | } catch (SQLException e) { 88 | e.printStackTrace(); 89 | } 90 | return true; 91 | } 92 | 93 | 94 | 95 | // user deleter 96 | public boolean delete(int model_id) { 97 | try { 98 | String query = "DELETE FROM public.user WHERE user_id = ?"; 99 | PreparedStatement pr = con.prepareStatement(query); 100 | // parameter assignment 101 | pr.setInt(1, model_id); 102 | // checks if return is not equals to -1. Thus, if it is not equals to -1, that means there is a 103 | //row affected with this action and row is deleted. 104 | return pr.executeUpdate() != -1; 105 | // if try block fails, an exception will be thrown 106 | } catch (SQLException e) { 107 | e.printStackTrace(); 108 | } 109 | return true; 110 | } 111 | 112 | // getter method with query 113 | public ArrayList selectByQuery(String query) { 114 | ArrayList userList = new ArrayList<>(); 115 | try { 116 | // while query result has a next item, object is being returned through match function. 117 | ResultSet rs = this.con.createStatement().executeQuery(query); 118 | while (rs.next()) { 119 | userList.add(this.match(rs)); 120 | 121 | } 122 | // if try block fails, an exception will be thrown 123 | } catch (SQLException e) { 124 | e.printStackTrace(); 125 | } 126 | return userList; 127 | } 128 | 129 | // user updater method 130 | public boolean update(User user) { 131 | try { 132 | String query = "UPDATE public.user SET " + 133 | "user_name = ?," + 134 | "user_pass = ?," + 135 | "user_role = ?" + 136 | "WHERE user_id = ?"; 137 | 138 | // parameter updated 139 | PreparedStatement pr = con.prepareStatement(query); 140 | pr.setString(1, user.getUsername()); 141 | pr.setString(2, user.getPassword().toString()); 142 | pr.setString(3, user.getRole()); 143 | pr.setInt(4, user.getId()); 144 | // checks if return is not equals to -1. Thus, if it is not equals to -1, that means there is a 145 | //row affected with this action and row is updated. 146 | return pr.executeUpdate() != -1; 147 | // if try block fails, an exception will be thrown 148 | } catch (SQLException e) { 149 | e.printStackTrace(); 150 | } 151 | return true; 152 | } 153 | 154 | // getter function of user with specifid id 155 | public User getByID(int id) { 156 | User obj = null; 157 | String query = "SELECT * FROM public.user WHERE user_id = ?"; 158 | try { 159 | // parameter assignments 160 | PreparedStatement pr = con.prepareStatement(query); 161 | pr.setInt(1, id); 162 | ResultSet rs = pr.executeQuery(); 163 | // checks if rs has next item, a user obj is being created through match method 164 | if (rs.next()) obj = this.match(rs); 165 | // if try block fails, an exception will be thrown 166 | } catch (SQLException e) { 167 | e.printStackTrace(); 168 | } 169 | return obj; 170 | } 171 | } 172 | 173 | 174 | -------------------------------------------------------------------------------- /src/dao/HotelDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Database; 4 | import entity.Hotel; 5 | import entity.User; 6 | 7 | import javax.xml.crypto.Data; 8 | import java.sql.Connection; 9 | import java.sql.PreparedStatement; 10 | import java.sql.ResultSet; 11 | import java.sql.SQLException; 12 | import java.util.ArrayList; 13 | 14 | 15 | public class HotelDao { 16 | private final Connection connection; 17 | 18 | // constructor for access to database 19 | public HotelDao() { 20 | 21 | this.connection = Database.getInstance(); 22 | } 23 | 24 | 25 | // brings the hotel with specific id 26 | public Hotel getByID(int id) { 27 | Hotel obj = null; 28 | String query = "SELECT * FROM public.hotel WHERE id = ? "; 29 | try { 30 | PreparedStatement pr = this.connection.prepareStatement(query); 31 | pr.setInt(1, id); 32 | ResultSet rs = pr.executeQuery(); 33 | if (rs.next()) { 34 | obj = this.match(rs); 35 | } 36 | } catch (SQLException e) { 37 | e.printStackTrace(); 38 | } 39 | return obj; 40 | } 41 | 42 | 43 | // match for hotel obj and resultset 44 | //logic of match block is, the datas coming from result set, are being assigning to related objects 45 | public Hotel match(ResultSet rs) throws SQLException { 46 | Hotel obj = new Hotel(); 47 | obj.setId(rs.getInt("id")); 48 | obj.setName(rs.getString("name")); 49 | obj.setAddress(rs.getString("address")); 50 | obj.setMail(rs.getString("mail")); 51 | obj.setPhone(rs.getString("phone")); 52 | obj.setStar(rs.getString("star")); 53 | obj.setCar_park(rs.getBoolean("car_park")); 54 | obj.setWifi(rs.getBoolean("wifi")); 55 | obj.setPool(rs.getBoolean("pool")); 56 | obj.setFitness(rs.getBoolean("fitness")); 57 | obj.setConcierge(rs.getBoolean("concierge")); 58 | obj.setSpa(rs.getBoolean("spa")); 59 | obj.setRoom_service(rs.getBoolean("room_service")); 60 | 61 | return obj; 62 | } 63 | 64 | // the function that brings all hotels 65 | public ArrayList findAll() { 66 | ArrayList hotelList = new ArrayList<>(); 67 | String sql = "SELECT * FROM public.hotel"; 68 | try { 69 | ResultSet rs = this.connection.createStatement().executeQuery(sql); 70 | while (rs.next()) { 71 | 72 | hotelList.add(this.match(rs)); 73 | } 74 | } catch (SQLException e) { 75 | e.printStackTrace(); 76 | } 77 | return hotelList; 78 | } 79 | 80 | 81 | // hotel save function. sends/inserts records to db 82 | public boolean save(Hotel hotel) { 83 | String query = "INSERT INTO public.hotel " + 84 | "(" + 85 | "name," + 86 | "mail," + 87 | "phone," + 88 | "address," + 89 | "star,"+ 90 | "car_park," + 91 | "wifi," + 92 | "pool," + 93 | "fitness," + 94 | "concierge," + 95 | "spa," + 96 | "room_service " + 97 | ")" + 98 | " VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"; 99 | try { 100 | // according to the query above, assignments for indexes and hotel parameters 101 | PreparedStatement pr = connection.prepareStatement(query); 102 | pr.setString(1, hotel.getName()); 103 | pr.setString(2, hotel.getMail()); 104 | pr.setString(3, hotel.getPhone()); 105 | pr.setString(4, hotel.getAddress()); 106 | pr.setString(5, hotel.getStar()); 107 | pr.setBoolean(6, hotel.isCar_park()); 108 | pr.setBoolean(7, hotel.isWifi()); 109 | pr.setBoolean(8, hotel.isPool()); 110 | pr.setBoolean(9, hotel.isFitness()); 111 | pr.setBoolean(10, hotel.isConcierge()); 112 | pr.setBoolean(11, hotel.isSpa()); 113 | pr.setBoolean(12, hotel.isRoom_service()); 114 | // checks if return is not equasl to -1. Thus, if it is not equals to -1, that means there is a 115 | //row affected with this action and row is saved. 116 | return pr.executeUpdate() != -1; 117 | } catch (SQLException e) { 118 | e.printStackTrace(); 119 | } 120 | return true; 121 | } 122 | 123 | // function for hotel deletion 124 | public boolean delete(int model_id){ 125 | try{ 126 | String query = "DELETE FROM public.hotel WHERE id = ?"; 127 | PreparedStatement pr = connection.prepareStatement(query); 128 | pr.setInt(1,model_id); 129 | 130 | // checks if return is not equasl to -1. Thus, if it is not equals to -1, that means there is a 131 | //row affected with this action and row is deleted. 132 | return pr.executeUpdate() != -1; 133 | }catch (SQLException e){ 134 | 135 | e.printStackTrace(); 136 | } 137 | return true; 138 | } 139 | 140 | // function for hotel update 141 | public boolean update(Hotel hotel) { 142 | try { 143 | String query = "UPDATE public.hotel SET " + 144 | "name," + 145 | "mail," + 146 | "phone," + 147 | "address," + 148 | "star,"+ 149 | "car_park," + 150 | "wifi," + 151 | "pool," + 152 | "fitness," + 153 | "concierge," + 154 | "spa," + 155 | "room_service " + 156 | "WHERE hotel = ?"; 157 | // according to the query above, assignments for indexes and hotel parameters 158 | PreparedStatement pr = connection.prepareStatement(query); 159 | pr.setString(1, hotel.getName()); 160 | pr.setString(2, hotel.getMail()); 161 | pr.setString(3, hotel.getPhone()); 162 | pr.setString(4, hotel.getAddress()); 163 | pr.setString(5, hotel.getStar()); 164 | pr.setBoolean(6, hotel.isCar_park()); 165 | pr.setBoolean(7, hotel.isWifi()); 166 | pr.setBoolean(8, hotel.isPool()); 167 | pr.setBoolean(9, hotel.isFitness()); 168 | pr.setBoolean(10, hotel.isConcierge()); 169 | pr.setBoolean(11, hotel.isSpa()); 170 | pr.setBoolean(12, hotel.isRoom_service()); 171 | 172 | // checks if return is not equasl to -1. Thus, if it is not equals to -1, that means there is a 173 | //row affected with this action and row is updated. 174 | return pr.executeUpdate() != -1; 175 | 176 | } catch (SQLException throwables) { 177 | throwables.printStackTrace(); 178 | } 179 | return false; 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /src/view/ReservationUpdateView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.ReservationManager; 4 | import business.RoomManager; 5 | import business.SeasonManager; 6 | import core.Helper; 7 | import entity.*; 8 | 9 | import javax.swing.*; 10 | import java.time.LocalDate; 11 | import java.time.format.DateTimeFormatter; 12 | import java.time.temporal.ChronoUnit; 13 | 14 | public class ReservationUpdateView extends Layout { 15 | private JPanel wrapper; 16 | private JTextField tf_res_hotel_name; 17 | private JTextField tf_res_city; 18 | private JTextField tf_res_star; 19 | private JRadioButton rbut_gym; 20 | private JButton btn_reservation_update; 21 | private JRadioButton rbut_carpark; 22 | private JRadioButton rbut_wifi; 23 | private JRadioButton rbut_swim_pool; 24 | private JRadioButton rbut_spa; 25 | private JRadioButton rbut_room_services; 26 | private JTextField tf_res_roomtype; 27 | private JTextField tf_res_room_field; 28 | private JTextField tf_res_bed_capacity; 29 | private JTextField tf_res_start_date; 30 | private JTextField tf_res_end_date; 31 | private JRadioButton rbut_television; 32 | private JRadioButton rbut_game_console; 33 | private JRadioButton rbut_cash_vault; 34 | private JRadioButton rbut_res_projection; 35 | private JRadioButton rbut_res_minibar; 36 | private JTextField tf_res_total_amount; 37 | private JTextField tf_res_total_guest_number; 38 | private JTextField tf_res_guess_mail; 39 | private JTextField tf_res_guess_name; 40 | private JTextField tf_phone_no; 41 | private JTextField tf_res_guess_id_no; 42 | private JTextField tf_res_pension; 43 | private ReservationManager reservationManager = new ReservationManager(); 44 | private Season season; 45 | private Pension pension; 46 | private Reservation reservation; 47 | private SeasonManager seasonManager; 48 | private RoomManager roomManager; 49 | 50 | private Room room; 51 | private String check_in_date; 52 | private String check_out_date; 53 | private Double adult_price; 54 | private Double child_price; 55 | 56 | 57 | // constructor with room class parameter. checks dates, reservation condition and guest numbers 58 | public ReservationUpdateView(Room room, String check_in_date, String check_out_date, int adult_numb, int child_numb, Reservation reservation) { 59 | 60 | 61 | this.add(wrapper); 62 | // visual interface initialization 63 | this.visualInitialize(1000, 800); 64 | this.wrapper = wrapper; 65 | this.room = room; 66 | this.adult_price = adult_price; 67 | this.child_price = child_price; 68 | this.check_in_date = check_in_date; 69 | this.check_out_date = check_out_date; 70 | 71 | // if reservation obj is null, reservation iformation is bringing from reservation manager class 72 | if (this.reservation == null) { 73 | this.reservation = this.reservationManager.getById(reservation.getId()); 74 | // and a new obj is being assigned 75 | this.roomManager = new RoomManager(); 76 | } 77 | 78 | 79 | /*if (this.reservation == null) ; 80 | { 81 | this.reservation=this.reservationManager.getById(reservation.getId()); 82 | this.roomManager = new RoomManager(); 83 | 84 | }*/ 85 | 86 | // variables for total price calculation 87 | int guest_count = adult_numb + child_numb; 88 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); 89 | LocalDate checkindate = LocalDate.parse(check_in_date, formatter); 90 | LocalDate checkoutdate = LocalDate.parse(check_out_date, formatter); 91 | long day_count = ChronoUnit.DAYS.between(checkindate, checkoutdate); 92 | 93 | // price calculation 94 | double total_price= (int) ((int) ((this.room.getAdult_price()*adult_numb+this.room.getChild_price()*child_numb))*day_count); 95 | 96 | 97 | // values for reservation update screen. 98 | // after getting suitable information for each row, a set method 99 | // will be applied. 100 | this.tf_res_hotel_name.setText(this.room.getHotel().getName()); 101 | this.tf_res_city.setText(this.room.getHotel().getAddress()); 102 | this.tf_res_star.setText(this.room.getHotel().getStar()); 103 | this.rbut_carpark.setSelected(this.room.getHotel().isCar_park()); 104 | this.rbut_wifi.setSelected(this.room.getHotel().isWifi()); 105 | this.rbut_swim_pool.setSelected(this.room.getHotel().isPool()); 106 | this.rbut_gym.setSelected(this.room.getHotel().isFitness()); 107 | this.rbut_spa.setSelected(this.room.getHotel().isSpa()); 108 | this.rbut_room_services.setSelected(this.room.getHotel().isRoom_service()); 109 | this.tf_res_roomtype.setText(this.room.getType()); 110 | this.tf_res_bed_capacity.setText(String.valueOf(this.room.getBed_capacity())); 111 | this.tf_res_pension.setText(this.room.getPension().getPension_type()); 112 | this.tf_res_room_field.setText(String.valueOf(this.room.getSquare_meter())); 113 | this.tf_res_start_date.setText(String.valueOf(this.check_in_date)); 114 | 115 | this.tf_res_end_date.setText(String.valueOf(this.check_out_date)); 116 | this.rbut_television.setSelected(this.room.isTelevision()); 117 | this.rbut_game_console.setSelected(this.room.isGame_console()); 118 | this.rbut_cash_vault.setSelected(this.room.isCash_box()); 119 | this.rbut_res_projection.setSelected(this.room.isProjection()); 120 | this.rbut_res_minibar.setSelected(this.room.isMinibar()); 121 | this.reservation.setGuess_phone(this.tf_phone_no.getText()); 122 | this.tf_res_total_amount.setText(String.valueOf(this.reservationManager.getById(reservation.getId()).getTotal_price())); 123 | this.tf_res_total_guest_number.setText(String.valueOf(this.reservationManager.getById(reservation.getId()).getGuest_count())); 124 | 125 | // if reservation has value, citizen id, guest name, mail and phone information is being asked 126 | if (reservation != null){ 127 | this.reservation.setGuess_citizen_id(this.tf_res_guess_id_no.getText()); 128 | this.reservation.setGuest_name(this.tf_res_guess_name.getText()); 129 | this.reservation.setGuess_mail(this.tf_res_guess_mail.getText()); 130 | this.reservation.setGuess_phone(this.tf_phone_no.getText()); 131 | } 132 | 133 | // reservation button listened 134 | btn_reservation_update.addActionListener(e -> { 135 | JTextField[] checkfieldEmpty = {this.tf_res_guess_name, this.tf_res_guess_id_no, this.tf_res_guess_mail, this.tf_phone_no}; 136 | if (Helper.isFieldListEmpty(checkfieldEmpty)) { 137 | Helper.showMsg("fill"); 138 | } else { 139 | boolean result; 140 | 141 | // reservation update for id, name, mail and phone no 142 | 143 | this.reservation.setGuess_citizen_id(this.tf_res_guess_id_no.getText()); 144 | this.reservation.setGuest_name(this.tf_res_guess_name.getText()); 145 | this.reservation.setGuess_mail(this.tf_res_guess_mail.getText()); 146 | this.reservation.setGuess_phone(this.tf_phone_no.getText()); 147 | 148 | // if reservation id is different from 0, update process passes 149 | if (this.reservation.getId() != 0) { 150 | result = this.reservationManager.update(this.reservation); 151 | 152 | } else { 153 | result = false; 154 | } 155 | if (result) { 156 | // if process is successful, a done message will be thrown 157 | Helper.showMsg("done"); 158 | dispose(); 159 | // if process fails, an error message will be thrown 160 | } else { 161 | Helper.showMsg("error"); 162 | } 163 | } 164 | }); 165 | } 166 | } -------------------------------------------------------------------------------- /src/view/ReservationView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.ReservationManager; 4 | import business.RoomManager; 5 | import business.SeasonManager; 6 | import core.Helper; 7 | import entity.*; 8 | 9 | import javax.swing.*; 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.ActionListener; 12 | import java.time.LocalDate; 13 | import java.time.format.DateTimeFormatter; 14 | import java.time.temporal.ChronoUnit; 15 | 16 | // variables 17 | 18 | public class ReservationView extends Layout { 19 | private JPanel wrapper; 20 | private JTextField tf_res_hotel_name; 21 | private JTextField tf_res_city; 22 | private JTextField tf_res_star; 23 | private JRadioButton rbut_gym; 24 | private JButton btn_reservation_add; 25 | private JRadioButton rbut_carpark; 26 | private JRadioButton rbut_wifi; 27 | private JRadioButton rbut_swim_pool; 28 | private JRadioButton rbut_spa; 29 | private JRadioButton rbut_room_services; 30 | private JTextField tf_res_roomtype; 31 | private JTextField tf_res_room_field; 32 | private JTextField tf_res_bed_capacity; 33 | private JTextField tf_res_start_date; 34 | private JTextField tf_res_end_date; 35 | private JRadioButton rbut_television; 36 | private JRadioButton rbut_game_console; 37 | private JRadioButton rbut_cash_vault; 38 | private JRadioButton rbut_res_projection; 39 | private JRadioButton rbut_res_minibar; 40 | private JTextField tf_res_total_amount; 41 | private JTextField tf_res_total_guest_number; 42 | private JTextField tf_res_guess_mail; 43 | private JTextField tf_res_guess_name; 44 | private JTextField tf_res_guess_tel_no; 45 | private JTextField tf_res_guess_id_no; 46 | private JTextField tf_res_pension; 47 | private JButton btn_calc_price; 48 | private ReservationManager reservationManager = new ReservationManager(); 49 | private Season season; 50 | private Pension pension; 51 | private Reservation reservation; 52 | private SeasonManager seasonManager; 53 | private RoomManager roomManager; 54 | 55 | private Room room; 56 | private String check_in_date; 57 | private String check_out_date; 58 | private Double adult_price; 59 | private Double child_price; 60 | 61 | private double total_price = 0; 62 | 63 | 64 | // constructor with room class parameter. checks dates, reservation condition and guest numbers 65 | public ReservationView(Room room, String check_in_date, String check_out_date, int adult_numb, int child_numb, Reservation reservation) { 66 | 67 | // visual interface initialization 68 | this.add(wrapper); 69 | this.visualInitialize(1000, 1000); 70 | this.wrapper = wrapper; 71 | 72 | 73 | this.room = room; 74 | this.adult_price = this.room.getAdult_price(); 75 | this.child_price = this.room.getChild_price(); 76 | this.check_in_date = check_in_date; 77 | this.check_out_date = check_out_date; 78 | 79 | // if reservation is null, new objects are being created for reservation and room manager 80 | if (this.reservation == null) ; 81 | { 82 | this.reservation = new Reservation(); 83 | this.roomManager = new RoomManager(); 84 | 85 | } 86 | // variables for total price calculation 87 | int guest_count = adult_numb + child_numb; 88 | if( check_in_date != null && check_out_date != null && !check_in_date.equals(" / / ") && !check_out_date.equals(" / / ")) { 89 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); 90 | LocalDate checkindate = LocalDate.parse(check_in_date, formatter); 91 | LocalDate checkoutdate = LocalDate.parse(check_out_date, formatter); 92 | long day_count = ChronoUnit.DAYS.between(checkindate,checkoutdate); 93 | System.out.println(day_count); 94 | 95 | 96 | 97 | 98 | 99 | 100 | // values for update screen. 101 | // after getting suitable information for each row, a set method 102 | // will be applied. 103 | this.tf_res_hotel_name.setText(this.room.getHotel().getName()); 104 | this.tf_res_city.setText(this.room.getHotel().getAddress()); 105 | this.tf_res_star.setText(this.room.getHotel().getStar()); 106 | this.rbut_carpark.setSelected(this.room.getHotel().isCar_park()); 107 | this.rbut_wifi.setSelected(this.room.getHotel().isWifi()); 108 | this.rbut_swim_pool.setSelected(this.room.getHotel().isPool()); 109 | this.rbut_gym.setSelected(this.room.getHotel().isFitness()); 110 | this.rbut_spa.setSelected(this.room.getHotel().isSpa()); 111 | this.rbut_room_services.setSelected(this.room.getHotel().isRoom_service()); 112 | this.tf_res_roomtype.setText(this.room.getType()); 113 | this.tf_res_bed_capacity.setText(String.valueOf(this.room.getBed_capacity())); 114 | this.tf_res_pension.setText(this.room.getPension().getPension_type()); 115 | this.tf_res_room_field.setText(String.valueOf(this.room.getSquare_meter())); 116 | this.tf_res_start_date.setText(String.valueOf(this.check_in_date)); 117 | this.tf_res_end_date.setText(String.valueOf(this.check_out_date)); 118 | this.rbut_television.setSelected(this.room.isTelevision()); 119 | this.rbut_game_console.setSelected(this.room.isGame_console()); 120 | this.rbut_cash_vault.setSelected(this.room.isCash_box()); 121 | this.rbut_res_projection.setSelected(this.room.isProjection()); 122 | this.rbut_res_minibar.setSelected(this.room.isMinibar()); 123 | this.tf_res_total_amount.setText(String.valueOf(total_price)); 124 | this.tf_res_total_guest_number.setText(String.valueOf(guest_count)); 125 | 126 | // adds listener for add button 127 | btn_reservation_add.addActionListener(e -> { 128 | JTextField[] checkfieldEmpty = {this.tf_res_guess_name,this.tf_res_guess_id_no,this.tf_res_guess_mail,this.tf_res_guess_tel_no}; 129 | // checks if necessary fields are empty 130 | if (Helper.isFieldListEmpty(checkfieldEmpty)){ 131 | Helper.showMsg("fill"); 132 | }else{ 133 | boolean result; 134 | 135 | // assigning reservation information 136 | this.reservation.setTotal_price(Double.parseDouble(this.tf_res_total_amount.getText())); 137 | this.reservation.setGuest_count(Integer.parseInt(this.tf_res_total_guest_number.getText())); 138 | this.reservation.setGuest_name(this.tf_res_guess_name.getText()); 139 | this.reservation.setGuess_citizen_id(this.tf_res_guess_id_no.getText()); 140 | this.reservation.setGuess_mail(this.tf_res_guess_mail.getText()); 141 | this.reservation.setGuess_phone(this.tf_res_guess_tel_no.getText()); 142 | this.reservation.setRoom_id(this.room.getId()); 143 | this.reservation.setCheck_in_date(LocalDate.parse(this.check_in_date,formatter)); 144 | this.reservation.setCheck_out_date(LocalDate.parse(this.check_out_date,formatter)); 145 | 146 | result = this.reservationManager.save(this.reservation); 147 | if (result){ 148 | Helper.showMsg("done"); 149 | 150 | this.roomManager.getById(this.room.setStock(this.room.getStock()-1)); 151 | this.roomManager.updateStock(this.room); 152 | dispose(); 153 | }else { 154 | Helper.showMsg("error"); 155 | } 156 | 157 | } 158 | }); 159 | 160 | btn_calc_price.addActionListener(new ActionListener() { 161 | @Override 162 | public void actionPerformed(ActionEvent e) { 163 | 164 | total_price = ((adult_price * adult_numb)+ child_price * child_numb) * day_count; 165 | tf_res_total_amount.setText(String.valueOf(total_price)); 166 | System.out.println(total_price); 167 | } 168 | });}else { 169 | dispose(); 170 | Helper.showMsg("Date section can not be empty"); 171 | } 172 | } 173 | } 174 | 175 | -------------------------------------------------------------------------------- /src/view/AdminView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.UserManager; 4 | import core.ComboItem; 5 | import core.Helper; 6 | import entity.User; 7 | 8 | 9 | import javax.swing.*; 10 | import javax.swing.table.DefaultTableModel; 11 | import java.awt.event.*; 12 | import java.util.ArrayList; 13 | 14 | // variables for admin view 15 | public class AdminView extends Layout { 16 | 17 | private JPanel wrapper; 18 | private JTabbedPane tabbedPane1; 19 | private JLabel lbl_welcome; 20 | private JButton LOGOUTButton; 21 | private JTable tbl_user; 22 | private JTextField tf_username; 23 | private JTextField tf_pass; 24 | private JComboBox cmb_user_role; 25 | private JButton btn_add; 26 | private JButton DELETEButton; 27 | private JComboBox cmb_users; 28 | private JButton btn_search_user; 29 | private JScrollPane scrl_user; 30 | private JButton btn_new_user; 31 | private JButton btn_clear_user; 32 | private JPanel w_top; 33 | private JPanel w_bot; 34 | private User user; 35 | private UserManager userManager; 36 | private DefaultTableModel tmdl_user = new DefaultTableModel(); 37 | private Object[] col_user ; 38 | private JPopupMenu user_menu; 39 | 40 | 41 | // constructor method 42 | public AdminView(User user) { 43 | // creating a new obj for popup menu 44 | this.user_menu = new JPopupMenu(); 45 | this.col_user = col_user; 46 | this.userManager = new UserManager(); 47 | this.add(wrapper); 48 | // visual interface loder with pixel values 49 | this.visualInitialize(1000, 500); 50 | this.user = user; 51 | 52 | // disposal upon user has no values. closes the window 53 | if (user == null) { 54 | dispose(); 55 | 56 | } 57 | 58 | // welcome label with username 59 | this.lbl_welcome.setText("Welcome : " + this.user.getUsername()); 60 | 61 | //user table loading and row selection added 62 | loadUserTable(null); 63 | tableRowSelect(tbl_user); 64 | 65 | // listener for log out button and window disposal 66 | LOGOUTButton.addActionListener(e -> { 67 | LoginView loginView = new LoginView(); 68 | dispose(); 69 | }); 70 | 71 | // listener for add button 72 | btn_add.addActionListener(e -> { 73 | // checks if field is empty. 74 | if (Helper.isFieldListEmpty(new JTextField[]{tf_username, tf_pass})) { 75 | // if it is, a fill message will be shown 76 | Helper.showMsg("fill"); 77 | } else { 78 | // if, if block fails and which means if the field is not empty, 79 | // a new user obj will be created. 80 | boolean result; 81 | User userr = new User(); 82 | // below we assign the value of userupdate's return to userr 83 | if (getUserUpdated() != null){ 84 | userr = getUserUpdated(); 85 | } 86 | 87 | // username and user password are being taken as string and user role value is being taken by combo box 88 | userr.setUsername(tf_username.getText()); 89 | userr.setPassword(tf_pass.getText()); 90 | userr.setRole((String) cmb_user_role.getSelectedItem()); 91 | 92 | // if block for update 93 | if (btn_add.getText().equals("UPDATE")){ 94 | result = userManager.update(userr); 95 | // else block for user save as it is 96 | }else{ 97 | result = userManager.save(userr); 98 | } 99 | 100 | // if user recorded, a done message will be shown 101 | // and user table will be cleared 102 | if (result) { 103 | Helper.showMsg("done"); 104 | loadUserTable(null); 105 | // if else block is being executed, an error message will be shown 106 | } else { 107 | Helper.showMsg("error"); 108 | 109 | } 110 | } 111 | }); 112 | 113 | // action listener for delete process 114 | DELETEButton.addActionListener(e -> { 115 | // a confirmation message will be shown to ask client whether he is sure or not. 116 | if(Helper.confirm("sure")){ 117 | // selected row will be assigned as selecteduserid 118 | int selectUserId = getTableSelectedRow(tbl_user,0); 119 | // selected id will be deletedand table will be cleared after shown of done message 120 | if (userManager.delete(selectUserId)){ 121 | Helper.showMsg("done"); 122 | loadUserTable(null); 123 | }else{ 124 | // if else block runs, an error message will be shown 125 | Helper.showMsg("error"); 126 | } 127 | } 128 | }); 129 | 130 | // listener for search button 131 | btn_search_user.addActionListener(e -> { 132 | // taking the values of clients choice 133 | String selectedUser= (String) this.cmb_users.getSelectedItem(); 134 | // user's choices are being recorded in an arraylist 135 | ArrayList userListBySearch=this.userManager.searchForTable(selectedUser); 136 | ArrayList userRowListBySearch=this.userManager.getForTable(col_user.length,userListBySearch); 137 | loadUserTable(userRowListBySearch); 138 | 139 | }); 140 | // calling tablerowselect in user table for a row selection 141 | tableRowSelect(tbl_user); 142 | 143 | // add listener to new user button 144 | this.btn_new_user.addActionListener(e -> { 145 | this.tf_username.setEnabled(true); 146 | this.tf_pass.setEnabled(true); 147 | this.cmb_user_role.setEnabled(true); 148 | this.btn_add.setEnabled(true); 149 | this.tf_username.setText(null); 150 | this.tf_pass.setText(null); 151 | this.cmb_user_role.setSelectedItem("ADMIN"); 152 | this.btn_add.setText("ADD"); 153 | // ıser clarification 154 | setUserUpdated(null); 155 | 156 | }); 157 | 158 | // update method for user update action 159 | this.user_menu.add("Update").addActionListener(e -> { 160 | this.tf_username.setEnabled(true); 161 | this.tf_pass.setEnabled(true); 162 | this.cmb_user_role.setEnabled(true); 163 | this.btn_add.setEnabled(true); 164 | int selectUserId = this.getTableSelectedRow(tbl_user,0); 165 | User userUpdate = this.userManager.getById(selectUserId); 166 | this.tf_username.setText(userUpdate.getUsername()); 167 | this.tf_pass.setText(userUpdate.getPassword()); 168 | this.cmb_user_role.setSelectedItem(userUpdate.getRole()); 169 | this.btn_add.setText("UPDATE"); 170 | setUserUpdated(userUpdate); 171 | }); 172 | // popup addition 173 | tbl_user.setComponentPopupMenu(user_menu); 174 | 175 | 176 | 177 | // action listeners for clear button 178 | btn_clear_user.addActionListener(e -> { 179 | cmb_users.setSelectedItem(null); 180 | loadUserTable(null); 181 | }); 182 | } 183 | 184 | // table initialization for user 185 | public void loadUserTable(ArrayList userList) { 186 | 187 | this.col_user = new Object[] {"ID", "Username", "Password", "Role"}; 188 | if(userList==null){ 189 | userList=this.userManager.getForTable(this.col_user.length,this.userManager.findAll()); 190 | } 191 | createTable(this.tmdl_user,this.tbl_user,col_user,userList); 192 | } 193 | 194 | // function enables row selection 195 | public void tableRowSelect(JTable table){ 196 | table.addMouseListener(new MouseAdapter() { 197 | 198 | 199 | @Override 200 | public void mouseReleased(MouseEvent e) { 201 | int selected_row = table.rowAtPoint(e.getPoint()); 202 | table.setRowSelectionInterval(selected_row,selected_row); 203 | } 204 | }); 205 | } 206 | 207 | 208 | private void createUIComponents() { 209 | } 210 | private User getUserUpdated (){ 211 | return user; 212 | 213 | } 214 | private void setUserUpdated (User user) { 215 | this.user = user; 216 | } 217 | 218 | } 219 | 220 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 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 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /src/dao/ReservationDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Database; 4 | import entity.Reservation; 5 | 6 | import java.sql.*; 7 | import java.time.LocalDate; 8 | import java.util.ArrayList; 9 | 10 | 11 | public class ReservationDao { 12 | 13 | private final Connection connection; 14 | 15 | // constructor for access to database 16 | public ReservationDao() { 17 | this.connection = Database.getInstance(); 18 | } 19 | 20 | // getter function of reservations by hotel id 21 | public ArrayList getReservationByOtelId(int otelId) { 22 | ArrayList reservations = new ArrayList<>(); 23 | String query = "SELECT * FROM public.reservation WHERE room_id = ?"; 24 | 25 | try (PreparedStatement pr = connection.prepareStatement(query)) { 26 | // parameter assignment 27 | pr.setInt(1, otelId); 28 | ResultSet rs = pr.executeQuery(); 29 | // once sql query returns as a result set 30 | // and while rs has next item, is being added to reservation list through match method and returns to array list 31 | // through reservations return. 32 | while (rs.next()) { 33 | Reservation reservation = match(rs); 34 | reservations.add(reservation); 35 | } 36 | // if try block fails, an exception will be thrown 37 | } catch (SQLException e) { 38 | e.printStackTrace(); 39 | } 40 | // reservations return 41 | return reservations; 42 | } 43 | 44 | // getter method by id 45 | public Reservation getByID(int id) { 46 | Reservation obj = null; 47 | String query = "SELECT * FROM public.reservation WHERE id = ?"; 48 | try { 49 | PreparedStatement pr = this.connection.prepareStatement(query); 50 | // parameter assignment 51 | pr.setInt(1, id); 52 | ResultSet rs = pr.executeQuery(); 53 | // while query result has a next item, object is being returned through match function. 54 | if (rs.next()) { 55 | obj = this.match(rs); 56 | } 57 | } catch (SQLException e) { 58 | e.printStackTrace(); 59 | } 60 | // obj return phase 61 | return obj; 62 | } 63 | 64 | 65 | // matcher function for matching resultset and reservation obj 66 | //logic of match block is, the datas coming from result set, are being assigning to related objects 67 | public Reservation match(ResultSet rs) throws SQLException { 68 | //logic of match block is, the datas coming from result set, are being assigning to related objects 69 | Reservation obj = new Reservation(); 70 | obj.setId(rs.getInt("id")); 71 | obj.setRoom_id(rs.getInt("room_id")); 72 | obj.setCheck_in_date(LocalDate.parse(rs.getString("check_in_date"))); 73 | obj.setTotal_price(rs.getDouble("total_price")); 74 | obj.setGuest_count(rs.getInt("guest_count")); 75 | obj.setGuest_name(rs.getString("guest_name")); 76 | obj.setGuess_citizen_id(rs.getString("guest_citizen_id")); 77 | obj.setGuess_mail(rs.getString("guest_mail")); 78 | obj.setGuess_phone(rs.getString("guest_phone")); 79 | obj.setCheck_out_date(LocalDate.parse(rs.getString("check_out_date"))); 80 | return obj; 81 | } 82 | 83 | // getter method for all reservations 84 | public ArrayList findAll() { 85 | ArrayList reservationList = new ArrayList<>(); 86 | String sql = "SELECT * FROM public.reservation"; 87 | try { 88 | // while resultset has next, values are being added to reservation listh through match method and 89 | ResultSet rs = this.connection.createStatement().executeQuery(sql); 90 | while (rs.next()) { 91 | 92 | reservationList.add(this.match(rs)); 93 | } 94 | } catch (SQLException e) { 95 | e.printStackTrace(); 96 | } 97 | // returns as reservation list into array list 98 | return reservationList; 99 | } 100 | 101 | // adder method for reservations 102 | public boolean save(Reservation reservation){ 103 | String query = "INSERT INTO public.reservation"+ 104 | "("+ 105 | "room_id,"+ 106 | "check_in_date," + 107 | "total_price,"+ 108 | "guest_count,"+ 109 | "guest_name,"+ 110 | "guest_citizen_id,"+ 111 | "guest_mail,"+ 112 | "guest_phone,"+ 113 | "check_out_date"+ 114 | ")"+ 115 | "VALUES (?,?,?,?,?,?,?,?,?)"; 116 | try { 117 | PreparedStatement pr = connection.prepareStatement(query); 118 | // parameters assignments 119 | pr.setInt(1,reservation.getRoom_id()); 120 | pr.setDate(2,Date.valueOf(reservation.getCheck_in_date())); 121 | pr.setDouble(3,reservation.getTotal_price()); 122 | pr.setInt(4,reservation.getGuest_count()); 123 | pr.setString(5,reservation.getGuest_name()); 124 | pr.setString(6,reservation.getGuest_citizen_id()); 125 | pr.setString(7,reservation.getGuest_mail()); 126 | pr.setString(8,reservation.getGuest_phone()); 127 | pr.setDate(9,Date.valueOf(reservation.getCheck_out_date())); 128 | // checks if return is not equals to -1. Thus, if it is not equals to -1, that means there is a 129 | //row affected with this action and row is saved. 130 | return pr.executeUpdate() != -1; 131 | } catch (SQLException throwables) { 132 | throwables.printStackTrace(); 133 | } 134 | return true; 135 | } 136 | 137 | // reservation deletion method 138 | public boolean delete(int hotel_id){ 139 | try{ 140 | String query = "DELETE FROM public.reservation WHERE id = ?"; 141 | PreparedStatement pr = connection.prepareStatement(query); 142 | // parameter assignment 143 | pr.setInt(1,hotel_id); 144 | // checks if return is not equasl to -1. Thus, if it is not equals to -1, that means there is a 145 | //row affected with this action and row is deleted. 146 | return pr.executeUpdate() != -1; 147 | }catch (SQLException e){ 148 | // if try block fails, an exception will be thrown 149 | e.printStackTrace(); 150 | } 151 | return true; 152 | } 153 | 154 | // getter for a specific reservation id 155 | public ArrayList getByReservationId(int id){ 156 | return this.selectByQuery("SELECT * FROM public.reservation WHERE id="+id); 157 | } 158 | 159 | // reservation getter by query 160 | public ArrayList selectByQuery(String query){ 161 | ArrayList resList=new ArrayList<>(); 162 | try { 163 | // while result set has next, reservation list will be added through match method 164 | ResultSet rs=this.connection.createStatement().executeQuery(query); 165 | while (rs.next()){ 166 | resList.add(this.match(rs)); 167 | 168 | } 169 | // if try block fails, exception will be thrown 170 | } catch (SQLException e) { 171 | e.printStackTrace(); 172 | } 173 | return resList; 174 | } 175 | 176 | 177 | // reservation updater function 178 | public boolean update (Reservation reservation){ 179 | try{ 180 | String query = "UPDATE public.reservation SET " + 181 | "room_id = ?,"+ 182 | "check_in_date = ?," + 183 | "total_price = ?,"+ 184 | "guest_count = ?,"+ 185 | "guest_name = ?,"+ 186 | "guest_citizen_id = ?,"+ 187 | "guest_mail = ?,"+ 188 | "guest_phone = ?,"+ 189 | "check_out_date = ? "+ 190 | "WHERE id = ?"; 191 | // parameter assignments 192 | PreparedStatement pr = connection.prepareStatement(query); 193 | pr.setInt(1,reservation.getRoom_id()); 194 | pr.setDate(2,Date.valueOf(reservation.getCheck_in_date())); 195 | pr.setDouble(3,reservation.getTotal_price()); 196 | pr.setInt(4,reservation.getGuest_count()); 197 | pr.setString(5,reservation.getGuest_name()); 198 | pr.setString(6,reservation.getGuest_citizen_id()); 199 | pr.setString(7,reservation.getGuest_mail()); 200 | pr.setString(8,reservation.getGuest_phone()); 201 | pr.setDate(9,Date.valueOf(reservation.getCheck_out_date())); 202 | pr.setInt(10,reservation.getId()); 203 | // checks if return is not equasl to -1. Thus, if it is not equals to -1, that means there is a 204 | //row affected with this action and row is updated. 205 | return pr.executeUpdate() != -1; 206 | }catch (SQLException throwables){ 207 | throwables.printStackTrace(); 208 | } 209 | return true; 210 | } 211 | 212 | } 213 | 214 | -------------------------------------------------------------------------------- /src/dao/RoomDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Database; 4 | import entity.Pension; 5 | import entity.Room; 6 | import entity.User; 7 | 8 | import javax.xml.crypto.Data; 9 | import java.sql.Connection; 10 | import java.sql.PreparedStatement; 11 | import java.sql.ResultSet; 12 | import java.sql.SQLException; 13 | import java.util.ArrayList; 14 | 15 | 16 | public class RoomDao { 17 | private final Connection connection; 18 | 19 | // constructor for access to database 20 | public RoomDao() { 21 | this.connection = Database.getInstance(); 22 | } 23 | 24 | // getter function of rooms with specifid id 25 | public Room getByID(int id) { 26 | Room obj = null; 27 | String query = "SELECT * FROM public.room WHERE id = ? "; 28 | try { 29 | PreparedStatement pr = this.connection.prepareStatement(query); 30 | // parameter assignment 31 | pr.setInt(1, id); 32 | ResultSet rs = pr.executeQuery(); 33 | if (rs.next()) { 34 | // while query result has a next item, object is being returned through match function. 35 | obj = this.match(rs); 36 | } 37 | // if try block fails an exception will be thrown 38 | } catch (SQLException e) { 39 | e.printStackTrace(); 40 | } 41 | return obj; 42 | } 43 | 44 | // matcher function for matching resultset and room obj 45 | //logic of match block is, the datas coming from result set, are being assigning to related objects 46 | public Room match(ResultSet rs) throws SQLException { 47 | Room obj = new Room(); 48 | obj.setId(rs.getInt("id")); 49 | obj.setHotel_id(rs.getInt("hotel_id")); 50 | obj.setPension_id(rs.getInt("pension_id")); 51 | obj.setSeason_id(rs.getInt("season_id")); 52 | obj.setType(rs.getString("type")); 53 | obj.setStock(rs.getInt("stock")); 54 | obj.setAdult_price(rs.getDouble("adult_price")); 55 | obj.setChild_price(rs.getDouble("child_price")); 56 | obj.setBed_capacity(rs.getInt("bed_capacity")); 57 | obj.setSquare_meter(rs.getInt("square_meter")); 58 | obj.setTelevision(rs.getBoolean("television")); 59 | obj.setMinibar(rs.getBoolean("minibar")); 60 | obj.setGame_console(rs.getBoolean("game_console")); 61 | obj.setProjection(rs.getBoolean("projection")); 62 | return obj; 63 | } 64 | 65 | 66 | // getter method for all rooms 67 | public ArrayList findAll() { 68 | ArrayList roomList = new ArrayList<>(); 69 | String sql = "SELECT * FROM public.room"; 70 | try { 71 | // while result set has next, values are being added to room list through match method and 72 | ResultSet rs = this.connection.createStatement().executeQuery(sql); 73 | while (rs.next()) { 74 | 75 | roomList.add(this.match(rs)); 76 | } 77 | } catch (SQLException e) { 78 | e.printStackTrace(); 79 | } 80 | // returns as roomlist list into array list 81 | return roomList; 82 | } 83 | 84 | // adder for room class 85 | public boolean save(Room room) { 86 | String query = "INSERT INTO public.room" + 87 | "(" + 88 | "hotel_id," + 89 | "pension_id," + 90 | "season_id," + 91 | "type," + 92 | "stock," + 93 | "adult_price," + 94 | "child_price," + 95 | "bed_capacity," + 96 | "square_meter," + 97 | "television," + 98 | "minibar," + 99 | "game_console," + 100 | "cash_box," + 101 | "projection" + 102 | ")" + 103 | "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; 104 | try { 105 | PreparedStatement pr = connection.prepareStatement(query); 106 | pr.setInt(1, room.getHotel_id()); 107 | pr.setInt(2, room.getPension_id()); 108 | pr.setInt(3, room.getSeason_id()); 109 | pr.setString(4, room.getType()); 110 | pr.setInt(5, room.getStock()); 111 | pr.setDouble(6, room.getAdult_price()); 112 | pr.setDouble(7, room.getChild_price()); 113 | pr.setInt(8, room.getBed_capacity()); 114 | pr.setInt(9, room.getSquare_meter()); 115 | pr.setBoolean(10, room.isTelevision()); 116 | pr.setBoolean(11, room.isMinibar()); 117 | pr.setBoolean(12, room.isGame_console()); 118 | pr.setBoolean(13, room.isCash_box()); 119 | pr.setBoolean(14, room.isProjection()); 120 | // checks if return is not equals to -1. Thus, if it is not equals to -1, that means there is a 121 | //row affected with this action and row is added. 122 | return pr.executeUpdate() != -1; 123 | } catch (SQLException throwables) { 124 | throwables.printStackTrace(); 125 | } 126 | return true; 127 | } 128 | 129 | // getter method with query 130 | public ArrayList selectByQuery(String query){ 131 | ArrayList roomList = new ArrayList<>(); 132 | try { 133 | ResultSet rs = this.connection.createStatement().executeQuery(query); 134 | // while result set has next, room list will be added through match method 135 | while (rs.next()){ 136 | roomList.add(this.match(rs)); 137 | } 138 | // if try block fails, an exception will be thrown 139 | } catch (SQLException e) { 140 | e.printStackTrace(); 141 | } 142 | return roomList; 143 | } 144 | 145 | // stock uptader method 146 | public boolean updateStock(Room room){ 147 | String query = "UPDATE public.room SET stock = ? WHERE id = ? "; 148 | try { 149 | // parameter assignments 150 | PreparedStatement pr = this.connection.prepareStatement(query); 151 | pr.setInt(1, room.getStock()); 152 | pr.setInt(2,room.getId()); 153 | // execute updater 154 | pr.executeUpdate(); 155 | // if try block fails an exception will be thrown 156 | }catch (SQLException e){ 157 | e.printStackTrace(); 158 | } 159 | return true; 160 | } 161 | 162 | // room deleter method 163 | public boolean delete(int hotel_id) { 164 | try { 165 | String query = "DELETE FROM public.room WHERE id = ?"; 166 | PreparedStatement pr = connection.prepareStatement(query); 167 | // parameter assignments 168 | pr.setInt(1, hotel_id); 169 | // checks if return is not equals to -1. Thus, if it is not equals to -1, that means there is a 170 | //row affected with this action and row is deleted. 171 | return pr.executeUpdate() != -1; 172 | } catch (SQLException exception) { 173 | exception.printStackTrace(); 174 | } 175 | return true; 176 | } 177 | 178 | 179 | // updater method for room 180 | public boolean update(Room room) { 181 | try { 182 | String query = "UPDATE public.room SET " + 183 | "hotel_id = ?," + 184 | "pension_id = ?," + 185 | "season_id= ?," + 186 | "type= ?," + 187 | "stock= ?," + 188 | "adult_price = ?," + 189 | "child_price = ?," + 190 | "bed_capacity = ?," + 191 | "square_meter = ?," + 192 | "television = ?," + 193 | "minibar = ?," + 194 | "game_console = ?," + 195 | "cash_box = ?," + 196 | "projection = ? " + 197 | "WHERE id = ? "; 198 | // parameter assignments 199 | PreparedStatement pr = connection.prepareStatement(query); 200 | pr.setInt(1, room.getHotel_id()); 201 | pr.setInt(2, room.getPension_id()); 202 | pr.setInt(3, room.getSeason_id()); 203 | pr.setString(4, room.getType()); 204 | pr.setInt(5, room.getStock()); 205 | pr.setDouble(6, room.getAdult_price()); 206 | pr.setDouble(7, room.getChild_price()); 207 | pr.setInt(8, room.getBed_capacity()); 208 | pr.setInt(9, room.getSquare_meter()); 209 | pr.setBoolean(10, room.isTelevision()); 210 | pr.setBoolean(11, room.isMinibar()); 211 | pr.setBoolean(12, room.isGame_console()); 212 | pr.setBoolean(13, room.isCash_box()); 213 | pr.setBoolean(14, room.isProjection()); 214 | pr.setInt(15, room.getId()); 215 | // checks if return is not equals to -1. Thus, if it is not equals to -1, that means there is a 216 | //row affected with this action and row is updated. 217 | return pr.executeUpdate() != -1; 218 | 219 | // if try block fails, an exception will be thrown 220 | } catch (SQLException e) { 221 | e.printStackTrace(); 222 | } 223 | return true; 224 | } 225 | 226 | 227 | 228 | } 229 | 230 | -------------------------------------------------------------------------------- /src/view/HotelView.form: -------------------------------------------------------------------------------- 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 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /src/view/RoomView.form: -------------------------------------------------------------------------------- 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 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | -------------------------------------------------------------------------------- /src/view/RoomUpdateView.form: -------------------------------------------------------------------------------- 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 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | -------------------------------------------------------------------------------- /src/view/AdminView.form: -------------------------------------------------------------------------------- 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 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | --------------------------------------------------------------------------------