├── .idea ├── .gitignore ├── vcs.xml ├── modules.xml ├── libraries │ ├── TourismAgency.xml │ └── TourismAgency1.xml ├── misc.xml └── uiDesigner.xml ├── tourism.sql ├── postgresql-42.7.0.jar ├── .gitignore ├── TourismAgency.iml ├── src ├── App.java ├── core │ ├── ComboItem.java │ ├── Db.java │ └── Helper.java ├── entity │ ├── Pension.java │ ├── Season.java │ ├── User.java │ ├── Hotel.java │ ├── Reservation.java │ └── Room.java ├── view │ ├── PensionView.java │ ├── SeasonView.java │ ├── LoginView.java │ ├── Layout.java │ ├── PensionView.form │ ├── UserView.java │ ├── SeasonView.form │ ├── HotelAddView.java │ ├── UserView.form │ ├── LoginView.form │ ├── AdminView.form │ ├── AdminView.java │ ├── RoomAddView.java │ ├── ReservationAddView.java │ ├── HotelAddView.form │ ├── RoomAddView.form │ ├── EmployeeView.form │ └── ReservationAddView.form ├── business │ ├── SeasonManager.java │ ├── PensionManager.java │ ├── HotelManager.java │ ├── UserManager.java │ ├── ReservationManager.java │ └── RoomManager.java └── dao │ ├── PensionDao.java │ ├── SeasonDao.java │ ├── HotelDao.java │ ├── UserDao.java │ ├── ReservationDao.java │ └── RoomDao.java └── README.md /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /tourism.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yldrmceyy/TourismManagmentSystem/HEAD/tourism.sql -------------------------------------------------------------------------------- /postgresql-42.7.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yldrmceyy/TourismManagmentSystem/HEAD/postgresql-42.7.0.jar -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/libraries/TourismAgency.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/TourismAgency1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.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 -------------------------------------------------------------------------------- /TourismAgency.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/App.java: -------------------------------------------------------------------------------- 1 | import business.UserManager; 2 | import core.Db; 3 | import core.Helper; 4 | import entity.User; 5 | import view.AdminView; 6 | import view.EmployeeView; 7 | import view.LoginView; 8 | import view.UserView; 9 | 10 | import java.sql.Connection; 11 | import java.sql.DriverManager; 12 | 13 | public class App { 14 | public static void main(String[] args) { 15 | // Uygulama temasını ayarlamak için Helper.setTheme() fonksiyonu kullanılır. 16 | Helper.setTheme(); 17 | 18 | // LoginView sınıfından bir örnek oluşturulur. 19 | LoginView loginView = new LoginView(); 20 | 21 | // Kullıcı girişi için kullanlır 22 | //EmployeeView employeeView = new EmployeeView(new User()); 23 | 24 | 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/core/ComboItem.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | // Constructor: Öğenin anahtar ve değerini alarak bir ComboItem oluşturur 4 | public class ComboItem { 5 | private int key ; 6 | private String value; 7 | 8 | public ComboItem(int key, String value) { 9 | // Öğenin anahtar değeri 10 | this.key = key; 11 | 12 | // Öğenin görünen değeri 13 | this.value = value; 14 | } 15 | 16 | public int getKey() { 17 | return key; 18 | } 19 | 20 | public void setKey(int key) { 21 | this.key = key; 22 | } 23 | 24 | public String getValue() { 25 | return value; 26 | } 27 | 28 | public void setValue(String value) { 29 | this.value = value; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return this.value; 35 | } 36 | } -------------------------------------------------------------------------------- /src/entity/Pension.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import core.ComboItem; 4 | 5 | //Pansiyon tanımlamaları 6 | public class Pension { 7 | private int pencion_id; 8 | private int hotel_id; 9 | private String pencion_type; 10 | 11 | // Pansiyon parametresiz metodu 12 | public Pension() { 13 | 14 | } 15 | 16 | //getter setterlar 17 | public int getPencionId() { 18 | return pencion_id; 19 | } 20 | 21 | public void setPencionId(int pencion_id) { 22 | this.pencion_id = pencion_id; 23 | } 24 | 25 | public int getHotelId() { 26 | return hotel_id; 27 | } 28 | 29 | public void setHotelId(int hotel_id) { 30 | this.hotel_id = hotel_id; 31 | } 32 | 33 | public String getPencionType() { 34 | return pencion_type; 35 | } 36 | 37 | public void setPencionType(String pencion_type) { 38 | this.pencion_type = pencion_type; 39 | } 40 | 41 | //toString metodu 42 | @Override 43 | public String toString() { 44 | return "Pencion{" + 45 | "pencion_id=" + pencion_id + 46 | ", hotel_id=" + hotel_id + 47 | ", pencion_type='" + pencion_type + '\'' + 48 | '}'; 49 | } 50 | 51 | public ComboItem getComboItem() { 52 | return new ComboItem(this.getPencionId(), this.getPencionType()); 53 | } 54 | } -------------------------------------------------------------------------------- /src/core/Db.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | public class Db { 8 | // Singleton tasarım deseni kullanılarak oluşturulmuş olan instance 9 | private static Db instance = null; 10 | // Veritabanı bağlantısı için kullanılan Connection nesnesi 11 | private Connection connection = null; 12 | // Veritabanı URL'si 13 | private final String DB_URL = "jdbc:postgresql://localhost:5432/tourism"; 14 | // Veritabanı kullanıcı adı 15 | private final String DB_USERNAME = "postgres"; 16 | // Veritabanı şifresi 17 | private final String DB_PASS = "postgres"; 18 | 19 | //Database connection 20 | private Db() { 21 | try { 22 | this.connection = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASS); 23 | } catch (SQLException e) { 24 | System.out.println(e.getMessage()); 25 | } 26 | } 27 | // Veritabanı bağlantısını döndüren metod 28 | public Connection getConnection() { 29 | return this.connection; 30 | } 31 | 32 | // Singleton tasarım deseni gereği oluşturulmuş olan veya mevcut instance'ı döndüren metod 33 | public static Connection getInstance() { 34 | try { 35 | // Eğer instance null ise veya bağlantı kapalı ise yeni bir instance oluşturulur 36 | if (instance == null || instance.getConnection().isClosed()) { 37 | instance = new Db(); 38 | } 39 | 40 | } catch (SQLException e) { 41 | // Bağlantı durumu kontrolünde hata olması durumunda hata mesajı yazdırılır 42 | System.out.println(e.getMessage()); 43 | } 44 | return instance.getConnection(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/view/PensionView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import business.PensionManager; 5 | import entity.Hotel; 6 | 7 | import javax.swing.*; 8 | 9 | // PencionView sınıfı, pansiyon eklemek için kullanılan arayüzü temsil eder ve Layout sınıfından türetilmiştir. 10 | public class PensionView extends Layout { 11 | 12 | // Arayüzdeki bileşenlerin tanımlandığı değişkenler. 13 | private JPanel container; 14 | private JComboBox cmb_pencion; 15 | private JButton btn_pencion_save; 16 | private JLabel lbl_hotel_id; 17 | private Hotel hotel; 18 | private HotelManager hotelManager; 19 | private PensionManager pencionManager; 20 | 21 | // PencionView sınıfının constructor'ı. Arayüz bileşenleri, otel yöneticisi ve pansiyon yöneticisi başlatılır. 22 | public PensionView(Hotel hotel) { 23 | this.pencionManager = new PensionManager(hotel); 24 | this.hotelManager = new HotelManager(); 25 | this.hotel = hotel; 26 | this.add(container); 27 | this.guiInitilaze(400, 350); 28 | this.lbl_hotel_id.setText(String.valueOf(this.hotel.getId())); 29 | lbl_hotel_id.setText("OTEL ID : " + hotel.getId()); 30 | 31 | 32 | // "btn_pencion_save" butonuna ActionListener ekleniyor. 33 | btn_pencion_save.addActionListener(e -> { 34 | 35 | // Seçilen pansiyon tipi alınıp ekrana yazdırılıyor. 36 | this.cmb_pencion.getSelectedItem().toString(); 37 | System.out.println(this.cmb_pencion.getSelectedItem().toString()); 38 | 39 | // Pansiyon yöneticisi aracılığıyla pansiyon kaydediliyor ve pencere kapatılıyor. 40 | pencionManager.savePencion(hotel, String.valueOf(cmb_pencion.getSelectedItem())); 41 | dispose(); 42 | }); 43 | } 44 | } -------------------------------------------------------------------------------- /src/entity/Season.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import core.ComboItem; 4 | 5 | import java.time.LocalDate; 6 | 7 | public class Season { 8 | private int season_id; 9 | private int hotel_id; 10 | private LocalDate season_strt_date; 11 | private LocalDate season_fnsh_date; 12 | 13 | 14 | public Season() { 15 | } 16 | 17 | public int getSeason_id() { 18 | return season_id; 19 | } 20 | 21 | public void setSeason_id(int season_id) { 22 | this.season_id = season_id; 23 | } 24 | 25 | public int getHotel_id() { 26 | return hotel_id; 27 | } 28 | 29 | public void setHotel_id(int hotel_id) { 30 | this.hotel_id = hotel_id; 31 | } 32 | 33 | public LocalDate getSeason_strt_date() { 34 | return season_strt_date; 35 | } 36 | 37 | public void setSeason_strt_date(LocalDate season_strt_date) { 38 | this.season_strt_date = season_strt_date; 39 | } 40 | 41 | public LocalDate getSeason_fnsh_date() { 42 | return season_fnsh_date; 43 | } 44 | 45 | public void setSeason_fnsh_date(LocalDate season_fnsh_date) { 46 | this.season_fnsh_date = season_fnsh_date; 47 | } 48 | 49 | //Sezon nesnesinin toString metodu 50 | @Override 51 | public String toString() { 52 | return "Season{" + 53 | "season_id=" + season_id + 54 | ", hotel_id=" + hotel_id + 55 | ", season_strt_date='" + season_strt_date + '\'' + 56 | ", season_fnsh_date='" + season_fnsh_date + '\'' + 57 | '}'; 58 | } 59 | 60 | //ComboItem döndüren metot 61 | public ComboItem getComboItem() { 62 | return new ComboItem(this.getSeason_id(), this.getSeason_strt_date() + " - " + this.getSeason_fnsh_date()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/business/SeasonManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import dao.SeasonDao; 4 | import core.Helper; 5 | import entity.Hotel; 6 | import entity.Season; 7 | 8 | import java.time.LocalDate; 9 | import java.util.ArrayList; 10 | 11 | public class SeasonManager { 12 | private final SeasonDao seasonDao; 13 | private Hotel hotel; 14 | 15 | // Constructor: Otel ve SeasonDao nesnelerini başlatır 16 | public SeasonManager(Hotel hotel) { 17 | this.hotel = hotel; 18 | this.seasonDao = new SeasonDao(); 19 | } 20 | 21 | // Belirli bir otel için sezon kaydını yapar 22 | public boolean saveSeason(Hotel hotel, LocalDate strDate, LocalDate endDate) { 23 | if (hotel.getId() != 0) { 24 | Helper.showMsg("done"); 25 | } 26 | return this.seasonDao.saveSeason(hotel, strDate, endDate); 27 | } 28 | 29 | // Tablo için uygun veri yapısını oluşturan metod 30 | public ArrayList getForTable(int size, ArrayList seasons) { 31 | ArrayList seasonList = new ArrayList<>(); 32 | for (Season obj : seasons) { 33 | int i = 0; 34 | Object[] rowObject = new Object[size]; 35 | rowObject[i++] = obj.getSeason_id(); 36 | rowObject[i++] = obj.getHotel_id(); 37 | rowObject[i++] = obj.getSeason_strt_date(); 38 | rowObject[i++] = obj.getSeason_fnsh_date(); 39 | 40 | seasonList.add(rowObject); 41 | } 42 | return seasonList; 43 | } 44 | 45 | // Tüm sezonları getiren metod 46 | public ArrayList findAll() { 47 | return this.seasonDao.findAll(); 48 | } 49 | 50 | // Belirli bir otel için sezonları getiren metod 51 | public ArrayList findByHotelId(int hotel_id) { 52 | return this.seasonDao.findByHotelId(hotel_id); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/entity/User.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import javax.swing.*; 4 | 5 | public class User { 6 | private int Role; 7 | private int id; 8 | private String username; 9 | private String password; 10 | private String role; 11 | 12 | public User(String text, String text1, Object selectedItem) { 13 | } 14 | 15 | public enum Role { 16 | admin, 17 | employee 18 | } 19 | 20 | public User() { 21 | } 22 | 23 | //User(Kullanıcı) oluşturmak için kullanılan parametre verdiğim kurucu metot 24 | public User(int id, String username, String password, String role) { 25 | this.id = id; 26 | this.username = username; 27 | this.password = password; 28 | this.role = role; 29 | } 30 | 31 | //Kullanıcı getter setterları get eden ve set eden metotlar 32 | public int getId() { 33 | return id; 34 | } 35 | 36 | public void setId(int id) { 37 | this.id = id; 38 | } 39 | 40 | public String getUsername() { 41 | return username; 42 | } 43 | 44 | public void setUsername(String username) { 45 | this.username = username; 46 | } 47 | 48 | public String getPassword() { 49 | return password; 50 | } 51 | 52 | public void setPassword(String password) { 53 | this.password = password; 54 | } 55 | 56 | public String getRole() { 57 | return role; 58 | } 59 | 60 | public void setRole(String role) { 61 | this.role = role; 62 | } 63 | 64 | //String olarak gösteren metot 65 | @Override 66 | public String toString() { 67 | return "User{" + 68 | "id=" + id + 69 | ", username='" + username + '\'' + 70 | ", password='" + password + '\'' + 71 | ", role='" + role + '\'' + 72 | '}'; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/view/SeasonView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import business.SeasonManager; 5 | import core.Helper; 6 | import entity.Hotel; 7 | 8 | import javax.swing.*; 9 | import javax.swing.text.MaskFormatter; 10 | import java.text.ParseException; 11 | import java.time.LocalDate; 12 | import java.time.format.DateTimeFormatter; 13 | 14 | public class SeasonView extends Layout { 15 | 16 | // SeasonView sınıfının constructor'ı. 17 | private JPanel container; 18 | private JLabel lbl_season_id; 19 | private JLabel lbl_season_strt; 20 | private JLabel lbl_season_fnsh; 21 | private JButton btn_season_save; 22 | private JFormattedTextField ftxt_season_strt; 23 | private JFormattedTextField ftxt_season_fnsh; 24 | private Hotel hotel; 25 | private HotelManager hotelManager; 26 | private SeasonManager seasonManager; 27 | 28 | 29 | public SeasonView(Hotel hotel) { 30 | this.seasonManager = new SeasonManager(null); 31 | //this.pencionManager = new PencionManager(hotel); 32 | this.hotelManager = new HotelManager(); 33 | this.hotel = hotel; 34 | this.add(container); 35 | this.guiInitilaze(400, 350); 36 | 37 | // "btn_season_save" butonuna ActionListener eklenir. 38 | lbl_season_id.setText("OTEL ID : " + hotel.getId()); 39 | 40 | // Otele ait sezon bilgileri kaydedilir. 41 | btn_season_save.addActionListener(e -> { 42 | LocalDate convertedSeaonStrtDate = LocalDate.parse(this.ftxt_season_strt.getText(), DateTimeFormatter.ofPattern("dd/MM/yyyy")); 43 | LocalDate convertedSeaonFnshDate = LocalDate.parse(this.ftxt_season_fnsh.getText(), DateTimeFormatter.ofPattern("dd/MM/yyyy")); 44 | 45 | seasonManager.saveSeason(hotel, convertedSeaonStrtDate, convertedSeaonFnshDate); 46 | dispose(); 47 | }); 48 | } 49 | 50 | // UI bileşenleri oluşturulurken formatlı metin alanları için MaskFormatter kullanılır. 51 | private void createUIComponents() throws ParseException { 52 | this.ftxt_season_strt = new JFormattedTextField(new MaskFormatter("##/##/####")); 53 | this.ftxt_season_fnsh = new JFormattedTextField(new MaskFormatter("##/##/####")); 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /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 | 8 | import java.util.ArrayList; 9 | 10 | //Pansiyonları yöneten sınıf. 11 | public class PensionManager { 12 | private final PensionDao pensionDao; 13 | private Hotel hotel; 14 | 15 | //PencionManager sınıfının yapıcı metodu. 16 | public PensionManager(Hotel hotel) { 17 | this.hotel = hotel; 18 | this.pensionDao = new PensionDao(); 19 | } 20 | 21 | /* 22 | Yeni bir pansiyon kaydı oluşturur. 23 | * @param hotel Otel nesnesi 24 | * @param val Pansiyon tipi 25 | * @return Kayıt işlemi başarılıysa true, aksi takdirde false 26 | */ 27 | public boolean savePencion(Hotel hotel, String val) { 28 | if (hotel.getId() != 0) { 29 | // Otel ID'si 0 olmayan bir pansiyon kaydı oluşturulduğunda başarılı mesajı gösterilir. 30 | Helper.showMsg("done"); 31 | 32 | } 33 | return this.pensionDao.savePencion(hotel, val); 34 | } 35 | 36 | 37 | /* 38 | * Pansiyon listesini belirtilen boyutta bir nesne dizisi olarak getirir. 39 | * @param size Nesne dizisinin boyutu 40 | * @param pencions -->Pansiyon listesi 41 | * @return Belirtilen boyutta bir nesne dizisi 42 | */ 43 | public ArrayList getForTable(int size, ArrayList pencions) { 44 | ArrayList pencionList = new ArrayList<>(); 45 | for (Pension obj : pencions) { 46 | int i = 0; 47 | Object[] rowObject = new Object[size]; 48 | rowObject[i++] = obj.getPencionId(); 49 | rowObject[i++] = obj.getHotelId(); 50 | rowObject[i++] = obj.getPencionType(); 51 | 52 | pencionList.add(rowObject); 53 | } 54 | return pencionList; 55 | } 56 | 57 | 58 | /* 59 | * Tüm pansiyonları getirir. 60 | * @return Tüm pansiyonlar 61 | */ 62 | public ArrayList findAll() { 63 | return this.pensionDao.findAll(); 64 | } 65 | 66 | 67 | /* 68 | * Belirtilen otel ID'sine ait pansiyonları getirir. 69 | * @param hotel_id Otel ID'si 70 | * @return Belirtilen otel ID'sine ait pansiyonlar 71 | */ 72 | public ArrayList findByHotelId(int hotel_id) { 73 | return this.pensionDao.findByHotelId(hotel_id); 74 | } 75 | } -------------------------------------------------------------------------------- /src/business/HotelManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import dao.HotelDao; 4 | import core.Helper; 5 | import entity.Hotel; 6 | 7 | import java.util.ArrayList; 8 | 9 | //Otelleri yöneten sınıf. 10 | public class HotelManager { 11 | private final HotelDao hotelDao; 12 | 13 | //HotelManager sınıfının yapıcı metodu. 14 | public HotelManager() { 15 | this.hotelDao = new HotelDao(); 16 | } 17 | 18 | //Tüm otelleri getirir. 19 | public ArrayList findAll() { 20 | return this.hotelDao.findAll(); 21 | } 22 | 23 | //Belirtilen otel ID'sine ait oteli getirir. 24 | public Hotel getById(int id) { 25 | return this.hotelDao.getById(id); 26 | } 27 | 28 | /* 29 | * Otelleri belirtilen boyutta bir nesne dizisi olarak getirir. 30 | * @param size Nesne dizisinin boyutu 31 | * @param hotels Otel listesi 32 | * @return Belirtilen boyutta bir nesne dizisi 33 | */ 34 | public ArrayList getForTable(int size, ArrayList hotels) { 35 | ArrayList hotelList = new ArrayList<>(); 36 | for (Hotel obj : hotels) { 37 | int i = 0; 38 | Object[] rowObject = new Object[size]; 39 | rowObject[i++] = obj.getId(); 40 | rowObject[i++] = obj.getName(); 41 | rowObject[i++] = obj.getAddress(); 42 | rowObject[i++] = obj.getMail(); 43 | rowObject[i++] = obj.getPhone(); 44 | rowObject[i++] = obj.getStar(); 45 | rowObject[i++] = obj.isCar_park(); 46 | rowObject[i++] = obj.isWifi(); 47 | rowObject[i++] = obj.isPool(); 48 | rowObject[i++] = obj.isFitness(); 49 | rowObject[i++] = obj.isConcierge(); 50 | rowObject[i++] = obj.isSpa(); 51 | rowObject[i++] = obj.isRoom_service(); 52 | 53 | hotelList.add(rowObject); 54 | } 55 | return hotelList; 56 | } 57 | 58 | /* 59 | * Yeni bir otel kaydı oluşturur. 60 | * @param hotel Otel nesnesi 61 | * @return Kayıt işlemi başarılıysa true, aksi takdirde false 62 | */ 63 | 64 | 65 | public boolean save(Hotel hotel) { 66 | if (hotel.getId() != 0) { 67 | Helper.showMsg("error"); 68 | 69 | } 70 | return this.hotelDao.save(hotel); 71 | } 72 | 73 | // Belirli bir ID'ye sahip kullanıcıyı silen metod 74 | public boolean delete(int id) { 75 | if (this.getById(id) == null) { 76 | // Eğer kullanıcı ID'si bulunamazsa, silme işlemi yapılmaz 77 | return false; 78 | } 79 | return this.hotelDao.delete(id); 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /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 | import java.awt.*; 9 | import java.awt.event.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | 12 | public class LoginView extends Layout { 13 | private JPanel container; 14 | private JPanel w_top; 15 | private JLabel lbl_welcome; 16 | private JLabel lbl_welcome2; 17 | private JPanel w_bottom; 18 | private JTextField fld_username; 19 | private JPasswordField fld_pass; 20 | private JButton btn_login; 21 | private JLabel lbl_username; 22 | private JLabel lbl_pass; 23 | private final UserManager userManager; 24 | 25 | // login kayot ekranı 26 | public LoginView() { 27 | this.userManager = new UserManager(); 28 | this.add(container); 29 | this.guiInitilaze(400, 400); 30 | 31 | // "btn_login" butonuna ActionListener ekleniyor. 32 | btn_login.addActionListener(e -> { 33 | 34 | // Kontrol edilecek text alanları bir diziye ekleniyor. 35 | JTextField[] checkFieldList = {this.fld_username, this.fld_pass}; 36 | 37 | // Eğer kontrol edilecek alanlardan biri boşsa, kullanıcıya bir uyarı mesajı gösterilir. 38 | if (Helper.isFieldListEmpty(checkFieldList)) { 39 | Helper.showMsg("fill"); 40 | } else { 41 | 42 | // Girilen kullanıcı adı ve şifre ile kullanıcıyı bulan bir metot çağrılır. 43 | User loginUser = this.userManager.findByLogin(this.fld_username.getText(), this.fld_pass.getText()); 44 | 45 | // Eğer kullanıcı bulunamazsa, kullanıcıya bir uyarı mesajı gösterilir. 46 | if (loginUser == null) { 47 | Helper.showMsg("notFound"); 48 | 49 | // Eğer kullanıcı admin ise, admin ekranını oluşturup, mevcut pencereyi kapat. 50 | } else if (loginUser.getRole().equals("admin")) { 51 | System.out.println(loginUser.toString()); 52 | dispose(); 53 | 54 | // Yeni bir AdminView penceresi oluşturulur ve kullanıcı bilgisi ile başlatılır. 55 | AdminView adminView = new AdminView(loginUser); 56 | 57 | } else if (loginUser.getRole().equals("employee")) { 58 | 59 | // Eğer kullanıcı employee ise, employee ekranını oluşturup, mevcut pencereyi kapat. 60 | 61 | EmployeeView employeeView = new EmployeeView(loginUser); 62 | dispose(); 63 | System.out.println(loginUser.toString()); 64 | } 65 | } 66 | }); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /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 | // Gui oluşturma 13 | public void guiInitilaze(int width, int height) { 14 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 15 | this.setTitle("Turizm Acentası"); 16 | this.setSize(width, height); 17 | 18 | // Pencereyi ekranın ortasına yerleştirme 19 | this.setLocation(Helper.getLocationPoint("x", this.getSize()), Helper.getLocationPoint("y", this.getSize())); 20 | this.setVisible(true); 21 | } 22 | 23 | // JTable için tablo oluşturan metot 24 | public void createTable(DefaultTableModel model, JTable table, Object[] columns, ArrayList rows) { 25 | 26 | // Sütun başlıklarını ayarla 27 | model.setColumnIdentifiers(columns); 28 | 29 | // Modeli tabloya ekle 30 | table.setModel(model); 31 | 32 | // Sütunların yer değiştirmesini engelle 33 | table.getTableHeader().setReorderingAllowed(false); 34 | 35 | // İlk sütunun genişliğini maksimuma ayarla (örneğin, ID sütunu) 36 | table.getColumnModel().getColumn(0).setMaxWidth(75); 37 | 38 | // Tabloyu düzenlenemez hale getir 39 | table.setEnabled(false); 40 | 41 | // Modeli temizle ve yeni satırları ekle, tabloya yeni veriler ekleneceği veya tablonun güncelleneceği durumlarda 42 | DefaultTableModel clearModel = (DefaultTableModel) table.getModel(); 43 | clearModel.setRowCount(0); 44 | 45 | // Eğer satır listesi null ise, boş bir liste oluştur 46 | if (rows == null) { 47 | rows = new ArrayList<>(); 48 | } 49 | 50 | // Satırları modeldeki tabloya ekle 51 | for (Object[] row : rows) { 52 | model.addRow(row); 53 | } 54 | } 55 | 56 | // Tablodan seçilen satırın belirli bir indeksteki değerini getiren metot 57 | public int getTableSelectedRow(JTable table, int index) { 58 | //return Integer.parseInt(table.getValueAt(table.getSelectedRow(), index).toString()); 59 | return (int) table.getValueAt(table.getSelectedRow(), index); 60 | 61 | } 62 | 63 | // Tabloya tıklandığında satırı seçen metot 64 | public void tableRowSelect(JTable table) { 65 | table.addMouseListener(new MouseAdapter() { 66 | @Override 67 | public void mousePressed(MouseEvent e) { 68 | int selected_row = table.rowAtPoint(e.getPoint()); 69 | table.setRowSelectionInterval(selected_row, selected_row); 70 | } 71 | }); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/view/UserView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import business.UserManager; 5 | import core.Helper; 6 | import entity.Hotel; 7 | import entity.User; 8 | 9 | import javax.swing.*; 10 | import javax.swing.table.DefaultTableModel; 11 | import java.util.ArrayList; 12 | 13 | public class UserView extends Layout { 14 | private JPanel container; 15 | private JLabel lbl_user; 16 | private JLabel lbl_user_name; 17 | private JTextField fld_user_name; 18 | private JPasswordField fld_user_pass; 19 | private JComboBox cmb_user_role; 20 | private JButton btn_userSave; 21 | private User user; 22 | private UserManager userManager; 23 | private DefaultTableModel tmdl_user; 24 | 25 | // UserView sınıfının constructor'ı. 26 | public UserView(User user) { 27 | this.user = user; 28 | this.userManager = new UserManager(); 29 | this.add(container); 30 | this.guiInitilaze(300, 300); 31 | 32 | // Eğer user null ise, yeni bir User oluşturulur. 33 | if (user == null) { 34 | this.user = new User(); 35 | } else { 36 | this.user = user; 37 | } 38 | 39 | // Eğer user varsa, mevcut kullanıcı bilgileri görüntülenir. 40 | if (user != null) { 41 | this.fld_user_name.setText(user.getUsername()); 42 | this.fld_user_pass.setText(user.getPassword()); 43 | this.cmb_user_role.setSelectedItem(user.getRole()); 44 | } 45 | 46 | // ComboBox'a kullanıcı rollerini ekler. 47 | this.cmb_user_role.setModel(new DefaultComboBoxModel<>(User.Role.values())); 48 | 49 | // "btn_userSave" butonuna ActionListener eklenir. 50 | btn_userSave.addActionListener(e -> { 51 | 52 | // Kullanıcı adı veya şifre alanı boş ise uyarı mesajı gösterilir. 53 | if (Helper.isFieldEmpty(this.fld_user_name) || (Helper.isFieldEmpty(this.fld_user_pass))) { 54 | Helper.showMsg("fill"); 55 | } else { 56 | boolean result = true; 57 | 58 | // Kullanıcı bilgileri alınır. 59 | this.user.setUsername(fld_user_name.getText()); 60 | this.user.setPassword(fld_user_pass.getText()); 61 | this.user.setRole(String.valueOf(cmb_user_role.getSelectedItem())); 62 | 63 | if (this.user.getId() != 0) { 64 | // Kullanıcı daha önce kaydedilmişse güncellenir, değilse yeni kayıt yapılır. 65 | result = this.userManager.update(this.user); 66 | } else { 67 | result = this.userManager.save(this.user); 68 | } 69 | if (result) { 70 | 71 | // İşlem sonucuna göre mesaj gösterilir ve pencere kapatılır. 72 | Helper.showMsg("done"); 73 | dispose(); 74 | } else { 75 | Helper.showMsg("error"); 76 | } 77 | } 78 | }); 79 | } 80 | } -------------------------------------------------------------------------------- /src/business/UserManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import dao.UserDao; 4 | import entity.User; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class UserManager { 9 | private final UserDao userDao; 10 | 11 | // Constructor: UserDao nesnesini başlatır 12 | public UserManager() { 13 | this.userDao = new UserDao(); 14 | } 15 | 16 | // Kullanıcı girişi yapılırken kullanılan metod 17 | public User findByLogin(String username, String password) { 18 | // farklı işlemler yapabiliriz 19 | return this.userDao.findByLogin(username, password); 20 | } 21 | 22 | // Tüm kullanıcıları getiren metod 23 | public ArrayList findAll() { 24 | return this.userDao.findAll(); 25 | } 26 | 27 | // Tablo için gerekli veri yapısını oluşturan metod 28 | public ArrayList getForTable(int size, ArrayList userList) { 29 | ArrayList userObjList = new ArrayList<>(); 30 | for (User obj : userList) { 31 | Object[] rowObject = new Object[size]; 32 | int i = 0; 33 | rowObject[i++] = obj.getId(); 34 | rowObject[i++] = obj.getUsername(); 35 | rowObject[i++] = obj.getPassword(); 36 | rowObject[i++] = obj.getRole(); 37 | userObjList.add(rowObject); 38 | } 39 | return userObjList; 40 | } 41 | 42 | // Kullanıcı ekleyen veya güncelleyen metod 43 | public boolean save(User user) { 44 | if (user.getId() != 0) { 45 | // Eğer kullanıcının ID'si varsa (0'dan farklı), güncelleme işlemi yapılır 46 | } 47 | return this.userDao.save(user); 48 | } 49 | 50 | // Belirli bir ID'ye sahip kullanıcıyı getiren metod 51 | public User getById(int id) { 52 | return this.userDao.getById(id); 53 | } 54 | 55 | // Kullanıcı güncelleyen metod 56 | public boolean update(User user) { 57 | // Eğer kullanıcı ID'si bulunamazsa, güncelleme yapılmaz 58 | if (this.getById(user.getId()) == null) { 59 | } 60 | return this.userDao.update(user); 61 | } 62 | 63 | // Belirli bir ID'ye sahip kullanıcıyı silen metod 64 | public boolean delete(int id) { 65 | if (this.getById(id) == null) { 66 | // Eğer kullanıcı ID'si bulunamazsa, silme işlemi yapılmaz 67 | return false; 68 | } 69 | return this.userDao.delete(id); 70 | } 71 | 72 | // Belirli bir role sahip kullanıcıları getiren metod 73 | public ArrayList searchForTable(User.Role role) { 74 | String select = "SELECT * FROM public.user"; 75 | ArrayList whereList = new ArrayList<>(); 76 | 77 | if (role != null) { 78 | whereList.add("user_role = '" + role.toString() + "'"); 79 | } 80 | String whereStr = String.join(" AND ", whereList); 81 | String query = select; 82 | if (whereStr.length() > 0) { 83 | query += " WHERE " + whereStr; 84 | } 85 | return this.userDao.selectByQuery(query); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/business/ReservationManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import dao.ReservationDao; 4 | import dao.RoomDao; 5 | import core.Db; 6 | import core.Helper; 7 | import entity.*; 8 | 9 | import java.sql.Connection; 10 | import java.util.ArrayList; 11 | 12 | //Rezervasyon yönetim sınıfı. 13 | public class ReservationManager { 14 | private Connection con; 15 | private final RoomDao roomDao; 16 | private Hotel hotel; 17 | private HotelManager hotelManager; 18 | private Room room; 19 | private final ReservationDao reservationDao; 20 | private RoomManager roomManager; 21 | 22 | //ReservationManager sınıfının metodu 23 | public ReservationManager(){ 24 | reservationDao = new ReservationDao(); 25 | this.con = Db.getInstance(); 26 | this.roomDao = new RoomDao(); 27 | this.hotel = new Hotel(); 28 | this.room = room; 29 | this.hotelManager = new HotelManager(); 30 | this.roomManager = new RoomManager(); 31 | } 32 | 33 | //Belirli bir rezervasyonun bilgilerini getirir. 34 | public Reservation getById(int id) { 35 | return this.reservationDao.getById(id); 36 | } 37 | 38 | //Belirtilen ID'ye sahip rezervasyonu siler. 39 | public boolean delete(int id) { 40 | if (this.getById(id) == null) { 41 | return false; 42 | } 43 | return this.reservationDao.delete(id); 44 | } 45 | 46 | //Rezervasyon bilgilerini günceller. 47 | public boolean update(Reservation reservation) { 48 | if (this.getById(reservation.getId()) == null) { 49 | } 50 | return this.reservationDao.update(reservation); 51 | } 52 | 53 | //Rezervasyon listesini belirtilen boyutta bir nesne dizisi olarak getirir. 54 | public ArrayList getForTable(int size, ArrayList reservations) { 55 | ArrayList reservationList = new ArrayList<>(); 56 | for (Reservation obj : reservations) { 57 | int i = 0; 58 | Object[] rowObject = new Object[size]; 59 | rowObject[i++] = obj.getId(); 60 | rowObject[i++] = obj.getReservation_room_id(); 61 | rowObject[i++] = obj.getReservation_start_date(); 62 | rowObject[i++] = obj.getReservation_end_date(); 63 | rowObject[i++] = obj.getReservation_total_price(); 64 | rowObject[i++] = obj.getReservation_guest_number(); 65 | rowObject[i++] = obj.getReservation_guest_name(); 66 | rowObject[i++] = obj.getReservation_guest_id(); 67 | rowObject[i++] = obj.getReservation_mail(); 68 | rowObject[i++] = obj.getReservation_phone(); 69 | reservationList.add(rowObject); 70 | } 71 | return reservationList; 72 | } 73 | 74 | //Tüm rezervasyonları getirir. 75 | public ArrayList findAll() { 76 | return this.reservationDao.findAll(); 77 | } 78 | 79 | //Yeni bir rezervasyon kaydı oluşturur. 80 | public boolean save(Reservation reservation, int totalGuests) { 81 | if (reservation.getId() != 0) { 82 | // ID değeri 0 olmayan bir rezervasyonun kaydedilmeye çalışılması hatası. 83 | Helper.showMsg("error"); 84 | 85 | } 86 | return this.reservationDao.save(reservation); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/dao/PensionDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.Hotel; 5 | import entity.Pension; 6 | 7 | import java.sql.Connection; 8 | import java.sql.PreparedStatement; 9 | import java.sql.ResultSet; 10 | import java.sql.SQLException; 11 | import java.util.ArrayList; 12 | 13 | public class PensionDao { 14 | 15 | // Veritabanı bağlantısını temsil eden nesne 16 | private final Connection con; 17 | 18 | // Kurucu metod: Veritabanı bağlantısını kur 19 | public PensionDao() { 20 | this.con = Db.getInstance(); 21 | } 22 | 23 | // Belirli bir otel için yeni bir pansiyon tipi ekleyen metot 24 | public boolean savePencion(Hotel hotel, String val) { 25 | String query = "INSERT INTO public.hotel_pension" + 26 | " (hotel_id, pension_type)" + 27 | " VALUES ( ?, ? )"; 28 | try { 29 | PreparedStatement pr = con.prepareStatement(query); 30 | pr.setInt(1, hotel.getId()); 31 | pr.setString(2, val); 32 | 33 | return pr.executeUpdate() != -1; 34 | } catch (SQLException throwables) { 35 | throwables.printStackTrace(); 36 | } 37 | return true; 38 | } 39 | 40 | // Tüm pansiyon tiplerini getiren metot 41 | public ArrayList findAll() { 42 | ArrayList pencionList = new ArrayList<>(); 43 | String sql = "SELECT * FROM public.hotel_pension"; 44 | try { 45 | ResultSet rs = this.con.createStatement().executeQuery(sql); 46 | while (rs.next()) { 47 | pencionList.add(this.match(rs)); 48 | } 49 | } catch (SQLException e) { 50 | e.printStackTrace(); 51 | } 52 | return pencionList; 53 | } 54 | 55 | 56 | // Belirli bir otel için pansiyon tiplerini getiren metot 57 | public ArrayList findByHotelId(int hotelId) { 58 | ArrayList pencionList = new ArrayList<>(); 59 | String sql = "SELECT * FROM public.hotel_pension WHERE hotel_id = ?"; 60 | try { 61 | PreparedStatement pr = con.prepareStatement(sql); 62 | pr.setInt(1, hotelId); 63 | ResultSet rs = pr.executeQuery(); 64 | while (rs.next()) { 65 | pencionList.add(this.match(rs)); 66 | } 67 | } catch (SQLException e) { 68 | e.printStackTrace(); 69 | } 70 | return pencionList; 71 | } 72 | 73 | // ResultSet'ten alınan verileri bir Pencion nesnesine eşleyen metot 74 | public Pension match(ResultSet rs) throws SQLException { 75 | Pension obj = new Pension(); 76 | obj.setPencionId(rs.getInt("id")); 77 | obj.setHotelId(rs.getInt("hotel_id")); 78 | obj.setPencionType(rs.getString("pension_type")); 79 | return obj; 80 | } 81 | 82 | // Belirli bir panisyon tipi ID'si ile yemek tipini getiren metot 83 | public Pension getById(int id) { 84 | Pension obj = null; 85 | String query = "SELECT * FROM public.hotel_pension WHERE id = ?"; 86 | try { 87 | PreparedStatement pr = this.con.prepareStatement(query); 88 | pr.setInt(1, id); 89 | ResultSet rs = pr.executeQuery(); 90 | if (rs.next()) { 91 | obj = this.match(rs); 92 | } 93 | } catch (SQLException e) { 94 | e.printStackTrace(); 95 | } 96 | return obj; 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /src/dao/SeasonDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.Hotel; 5 | import entity.Season; 6 | 7 | import java.sql.Date; 8 | 9 | import java.sql.*; 10 | import java.time.LocalDate; 11 | import java.util.ArrayList; 12 | 13 | public class SeasonDao { 14 | // Veritabanı bağlantısını temsil eden nesne 15 | private final Connection con; 16 | 17 | // Veritabanı bağlantısını kurucu metod aracılığıyla oluşturma 18 | public SeasonDao() { 19 | this.con = Db.getInstance(); 20 | } 21 | 22 | // Tüm sezonları getiren metot 23 | public ArrayList findAll() { 24 | ArrayList seasonList = new ArrayList<>(); 25 | String sql = "SELECT * FROM public.hotel_season"; 26 | try { 27 | ResultSet rs = this.con.createStatement().executeQuery(sql); 28 | while (rs.next()) { 29 | seasonList.add(this.match(rs)); 30 | } 31 | } catch (SQLException e) { 32 | e.printStackTrace(); 33 | } 34 | return seasonList; 35 | } 36 | 37 | // Belirli bir otel için sezonları getiren metot 38 | public ArrayList findByHotelId(int hotelId) { 39 | ArrayList seasonList = new ArrayList<>(); 40 | String sql = "SELECT * FROM public.hotel_season WHERE hotel_id = ?"; 41 | try { 42 | PreparedStatement pr = con.prepareStatement(sql); 43 | pr.setInt(1, hotelId); 44 | ResultSet rs = pr.executeQuery(); 45 | while (rs.next()) { 46 | seasonList.add(this.match(rs)); 47 | } 48 | } catch (SQLException e) { 49 | e.printStackTrace(); 50 | } 51 | return seasonList; 52 | } 53 | 54 | // ResultSet'ten alınan verileri bir Season nesnesine eşleyen metot 55 | public Season match(ResultSet rs) throws SQLException { 56 | Season obj = new Season(); 57 | obj.setSeason_id(rs.getInt("id")); 58 | obj.setHotel_id(rs.getInt("hotel_id")); 59 | obj.setSeason_strt_date(LocalDate.parse(rs.getString("start_date"))); 60 | obj.setSeason_fnsh_date(LocalDate.parse(rs.getString("finish_date"))); 61 | return obj; 62 | } 63 | 64 | // Belirli bir otel için yeni bir sezon ekleyen metot 65 | public boolean saveSeason(Hotel hotel, LocalDate strDate, LocalDate endDate) { 66 | String query = "INSERT INTO public.hotel_season" + 67 | "(hotel_id, start_date, finish_date)" + 68 | " VALUES ( ?, ?, ?)"; 69 | try { 70 | PreparedStatement pr = con.prepareStatement(query); 71 | pr.setInt(1, hotel.getId()); 72 | pr.setDate(2, Date.valueOf(strDate)); 73 | pr.setDate(3, Date.valueOf(endDate)); 74 | 75 | return pr.executeUpdate() != -1; 76 | } catch (SQLException throwables) { 77 | throwables.printStackTrace(); 78 | } 79 | return true; 80 | } 81 | 82 | // Belirli bir sezonu ID ile getiren metot 83 | public Season getById(int id) { 84 | Season obj = null; 85 | String query = "SELECT * FROM public.hotel_season WHERE id = ?"; 86 | try { 87 | PreparedStatement pr = this.con.prepareStatement(query); 88 | pr.setInt(1, id); 89 | ResultSet rs = pr.executeQuery(); 90 | if (rs.next()) { 91 | obj = this.match(rs); 92 | } 93 | } catch (SQLException e) { 94 | e.printStackTrace(); 95 | } 96 | return obj; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/entity/Hotel.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | 4 | import core.ComboItem; 5 | 6 | public class Hotel { 7 | 8 | //Otel ile ilişkili tanımlamalar 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 car_park; 16 | private boolean wifi; 17 | private boolean pool; 18 | private boolean fitness; 19 | private boolean concierge; 20 | private boolean spa; 21 | private boolean room_service; 22 | 23 | public Hotel() { 24 | } 25 | 26 | //Parametreli otel kurucu metodu 27 | public Hotel(int id, String name, String address, String mail, String phone, String star, boolean car_park, boolean wifi, boolean pool, boolean fitness, boolean concierge, boolean spa, boolean room_service) { 28 | 29 | this.id = id; 30 | this.name = name; 31 | this.address = address; 32 | this.mail = mail; 33 | this.phone = phone; 34 | this.star = star; 35 | this.car_park = car_park; 36 | this.wifi = wifi; 37 | this.pool = pool; 38 | this.fitness = fitness; 39 | this.concierge = concierge; 40 | this.spa = spa; 41 | this.room_service = room_service; 42 | } 43 | 44 | 45 | //Hotel getter setterlarının metotları 46 | public int getId() { 47 | return id; 48 | } 49 | 50 | public void setId(int id) { 51 | this.id = id; 52 | } 53 | 54 | public String getName() { 55 | return name; 56 | } 57 | 58 | public void setName(String name) { 59 | this.name = name; 60 | } 61 | 62 | public String getAddress() { 63 | return address; 64 | } 65 | 66 | public void setAddress(String address) { 67 | this.address = address; 68 | } 69 | 70 | public String getMail() { 71 | return mail; 72 | } 73 | 74 | public void setMail(String mail) { 75 | this.mail = mail; 76 | } 77 | 78 | public String getPhone() { 79 | return phone; 80 | } 81 | 82 | public void setPhone(String phone) { 83 | this.phone = phone; 84 | } 85 | 86 | public String getStar() { 87 | return star; 88 | } 89 | 90 | public void setStar(String star) { 91 | this.star = star; 92 | } 93 | 94 | public boolean isCar_park() { 95 | return car_park; 96 | } 97 | 98 | public void setCar_park(boolean car_park) { 99 | this.car_park = car_park; 100 | } 101 | 102 | public boolean isWifi() { 103 | return wifi; 104 | } 105 | 106 | public void setWifi(boolean wifi) { 107 | this.wifi = wifi; 108 | } 109 | 110 | public boolean isPool() { 111 | return pool; 112 | } 113 | 114 | public void setPool(boolean pool) { 115 | this.pool = pool; 116 | } 117 | 118 | public boolean isFitness() { 119 | return fitness; 120 | } 121 | 122 | public void setFitness(boolean fitness) { 123 | this.fitness = fitness; 124 | } 125 | 126 | public boolean isConcierge() { 127 | return concierge; 128 | } 129 | 130 | public void setConcierge(boolean concierge) { 131 | this.concierge = concierge; 132 | } 133 | 134 | public boolean isSpa() { 135 | return spa; 136 | } 137 | 138 | public void setSpa(boolean spa) { 139 | this.spa = spa; 140 | } 141 | 142 | public boolean isRoom_service() { 143 | return room_service; 144 | } 145 | 146 | public void setRoom_service(boolean room_service) { 147 | this.room_service = room_service; 148 | } 149 | 150 | public ComboItem getComboItem() { 151 | return new ComboItem(this.getId(), this.getName() + " - " + this.getAddress()); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/view/HotelAddView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import core.Helper; 5 | import entity.Hotel; 6 | 7 | import javax.swing.*; 8 | 9 | // HotelAddView sınıfı, otel ekleme arayüzünü temsil eder ve Layout sınıfından türetilmiştir. 10 | public class HotelAddView extends Layout { 11 | 12 | // Arayüzdeki bileşenlerin tanımlandığı değişkenler. 13 | private JPanel container; 14 | private JTextField fld_hotel_name; 15 | private JTextField fld_mail; 16 | private JTextField fld_phone; 17 | private JComboBox cmb_star; 18 | private JRadioButton rb_pool; 19 | private JRadioButton rp_fitness; 20 | private JRadioButton rb_car_park; 21 | private JRadioButton rb_concierge; 22 | private JRadioButton rb_spa; 23 | private JRadioButton rb_room_service; 24 | private JButton btn_hotel_save; 25 | private JRadioButton rb_wifi; 26 | private JLabel lbl_star; 27 | private JLabel lbl_phone; 28 | private JLabel lbl_mail; 29 | private JLabel lbl_hotel_name; 30 | private JLabel lbl_hote_add; 31 | private JLabel lbl_address; 32 | private JTextField fld_address; 33 | private HotelManager hotelManager; 34 | private Hotel hotel; 35 | 36 | 37 | // HotelAddView sınıfının constructor'ı. Arayüz bileşenleri ve yönetici sınıfların başlatılması için kullanılır. 38 | public HotelAddView(Object o) { 39 | this.hotel = hotel; 40 | this.hotelManager = new HotelManager(); 41 | this.add(container); 42 | this.guiInitilaze(300, 500); 43 | loadHotelAddComponent(); 44 | 45 | } 46 | 47 | // Otel ekleme bileşenlerini yükleyen metod. 48 | public void loadHotelAddComponent() { 49 | 50 | // "btn_hotel_save" butonuna ActionListener ekleniyor. 51 | btn_hotel_save.addActionListener(e -> { 52 | 53 | // Kontrol edilecek text alanları bir diziye ekleniyor. 54 | JTextField[] checkFieldList = {this.fld_hotel_name, this.fld_mail, this.fld_phone, this.fld_address}; 55 | 56 | // Eğer kontrol edilecek alanlardan biri boşsa, kullanıcıya bir uyarı mesajı gösterilir. 57 | if (Helper.isFieldListEmpty(checkFieldList)) { 58 | Helper.showMsg("fill"); 59 | } else { 60 | 61 | // Eğer tüm alanlar dolu ise, yeni bir otel nesnesi oluşturulur ve bilgileri alınır. 62 | boolean result = true; 63 | Hotel hotelNew = new Hotel(); 64 | hotelNew.setName(fld_hotel_name.getText()); 65 | hotelNew.setMail(fld_mail.getText()); 66 | hotelNew.setPhone(fld_phone.getText()); 67 | hotelNew.setAddress(fld_address.getText()); 68 | hotelNew.setStar(String.valueOf(cmb_star.getSelectedItem())); 69 | hotelNew.setCar_park(rb_car_park.isSelected()); 70 | hotelNew.setPool(rb_pool.isSelected()); 71 | hotelNew.setFitness(rp_fitness.isSelected()); 72 | hotelNew.setConcierge(rb_concierge.isSelected()); 73 | hotelNew.setSpa(rb_spa.isSelected()); 74 | hotelNew.setRoom_service(rb_room_service.isSelected()); 75 | 76 | // Eğer otel ID'si 0 ise (yani yeni bir otel ekleniyorsa), oteli kaydet ve pencereyi kapat. 77 | if (hotelNew.getId() == 0) { 78 | result = this.hotelManager.save(hotelNew); 79 | dispose(); // Pencereyi kapat 80 | 81 | } else { 82 | 83 | // Eğer otel ID'si 0 değilse (yani mevcut bir otel güncelleniyorsa), bu kısım kullanılabilir. 84 | // Ancak burada bir işlem yapılması gerekiyorsa eklenmelidir. 85 | } 86 | 87 | // Sonuca göre bir mesaj gösterilir. 88 | if (result) { 89 | Helper.showMsg("done"); 90 | 91 | 92 | } else { 93 | Helper.showMsg("error"); 94 | } 95 | } 96 | }); 97 | 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /src/view/UserView.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 | -------------------------------------------------------------------------------- /src/entity/Reservation.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Date; 5 | 6 | //Rezervasyon ile ilişkili tanımlamalar 7 | public class Reservation { 8 | private int id; 9 | private int reservation_room_id; 10 | private LocalDate reservation_start_date; 11 | private LocalDate reservation_end_date; 12 | private int reservation_total_price; 13 | private int reservation_guest_number; 14 | private String reservation_guest_name; 15 | private int reservation_guest_id; 16 | private String reservation_mail; 17 | private int reservation_phone; 18 | private Room room; 19 | 20 | //Rezervasyon parametresiz kurucu metodu 21 | public Reservation() { 22 | } 23 | 24 | //getter setterlar 25 | public Room getRoom() { 26 | return room; 27 | } 28 | 29 | public void setRoom(Room room) { 30 | this.room = room; 31 | } 32 | 33 | public int getId() { 34 | return id; 35 | } 36 | 37 | public void setId(int id) { 38 | this.id = id; 39 | } 40 | 41 | public int getReservation_room_id() { 42 | return reservation_room_id; 43 | } 44 | 45 | public void setReservation_room_id(int reservation_room_id) { 46 | this.reservation_room_id = reservation_room_id; 47 | } 48 | 49 | public LocalDate getReservation_start_date() { 50 | return reservation_start_date; 51 | } 52 | 53 | public void setReservation_start_date(LocalDate reservation_start_date) { 54 | this.reservation_start_date = reservation_start_date; 55 | } 56 | 57 | public LocalDate getReservation_end_date() { 58 | return reservation_end_date; 59 | } 60 | 61 | public void setReservation_end_date(LocalDate reservation_end_date) { 62 | this.reservation_end_date = reservation_end_date; 63 | } 64 | 65 | public int getReservation_total_price() { 66 | return reservation_total_price; 67 | } 68 | 69 | public void setReservation_total_price(int reservation_total_price) { 70 | this.reservation_total_price = reservation_total_price; 71 | } 72 | 73 | public int getReservation_guest_number() { 74 | return reservation_guest_number; 75 | } 76 | 77 | public void setReservation_guest_number(int reservation_guest_number) { 78 | this.reservation_guest_number = reservation_guest_number; 79 | } 80 | 81 | public String getReservation_guest_name() { 82 | return reservation_guest_name; 83 | } 84 | 85 | public void setReservation_guest_name(String reservation_guest_name) { 86 | this.reservation_guest_name = reservation_guest_name; 87 | } 88 | 89 | public int getReservation_guest_id() { 90 | return reservation_guest_id; 91 | } 92 | 93 | public void setReservation_guest_id(int reservation_guest_id) { 94 | this.reservation_guest_id = reservation_guest_id; 95 | } 96 | 97 | public String getReservation_mail() { 98 | return reservation_mail; 99 | } 100 | 101 | public void setReservation_mail(String reservation_mail) { 102 | this.reservation_mail = reservation_mail; 103 | } 104 | 105 | public int getReservation_phone() { 106 | return reservation_phone; 107 | } 108 | 109 | public void setReservation_phone(int reservation_phone) { 110 | this.reservation_phone = reservation_phone; 111 | } 112 | 113 | @Override 114 | public String toString() { 115 | return "Reservation{" + 116 | "id=" + id + 117 | ", reservation_room_id=" + reservation_room_id + 118 | ", reservation_start_date=" + reservation_start_date + 119 | ", reservation_end_date=" + reservation_end_date + 120 | ", reservation_total_price=" + reservation_total_price + 121 | ", reservation_guest_number=" + reservation_guest_number + 122 | ", reservation_guest_name='" + reservation_guest_name + '\'' + 123 | ", reservation_guest_id=" + reservation_guest_id + 124 | ", reservation_mail='" + reservation_mail + '\'' + 125 | ", reservation_phone=" + reservation_phone + 126 | '}'; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/core/Helper.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | import java.time.LocalDate; 6 | import java.time.format.DateTimeFormatter; 7 | import java.time.format.DateTimeParseException; 8 | 9 | public class Helper { 10 | 11 | /*Açıklama: Kullanıcı arayüzü temasını ayarlayan metod. 12 | Detaylar: Nimbus temasını kullanmaktadır.*/ 13 | public static void setTheme() { 14 | for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { 15 | if ("Nimbus".equals(info.getName())) { 16 | try { 17 | UIManager.setLookAndFeel(info.getClassName()); 18 | } catch (Exception e) { 19 | System.out.println(e.getMessage()); 20 | } 21 | break; 22 | } 23 | } 24 | } 25 | 26 | 27 | 28 | // Kullanıcıya bilgi mesajları gösteren metod 29 | public static void showMsg(String str) { 30 | optionPaneTR(); 31 | String msg; 32 | String title; 33 | switch (str) { 34 | // Tüm alanları doldurması gerektiğini belirten hata mesajı 35 | case "fill" -> { 36 | msg = "Lütfen tüm alanları doldurunuz."; 37 | title = "HATA!"; 38 | } 39 | case "done" -> { 40 | // İşlemin başarıyla tamamlandığını belirten başarı mesajı 41 | msg = "İşlem Başarılı !"; 42 | title = "Sonuç"; 43 | } 44 | case "notFound" -> { 45 | // Kullanıcının bulunamadığını belirten hata mesajı 46 | msg = "Kullanıcı Bulunamadı !"; 47 | title = "Bulunamadı"; 48 | } 49 | case "error" -> { 50 | // Hatalı işlem yapıldığını belirten hata mesajı 51 | msg = "Hatalı İşlem Yaptınız!"; 52 | title = "Hata!"; 53 | } 54 | default -> { 55 | // Diğer durumlar: Verilen dizeyi içeren bir genel mesaj 56 | msg = str; 57 | title = "Mesaj"; 58 | } 59 | } 60 | JOptionPane.showMessageDialog(null, msg, title, JOptionPane.INFORMATION_MESSAGE); 61 | } 62 | 63 | // Kullanıcıya onay almak için bir iletişim kutusu gösteren metod 64 | public static boolean confirm(String str) { 65 | optionPaneTR(); 66 | String msg; 67 | if (str.equals("sure")) { 68 | msg = "Bu işlemi yapmak istediğine emin misin ? "; 69 | } else { 70 | msg = str; 71 | } 72 | return JOptionPane.showConfirmDialog(null, msg, "Emin misin ?", JOptionPane.YES_NO_OPTION) == 0; 73 | } 74 | 75 | // Verilen JTextField'in boş olup olmadığını kontrol eden metod 76 | public static boolean isFieldEmpty(JTextField field) { 77 | return field.getText().trim().isEmpty(); 78 | } 79 | 80 | // Verilen JTextField dizisinin herhangi bir elemanının boş olup olmadığını kontrol eden metod 81 | public static boolean isFieldListEmpty(JTextField[] fieldList) { 82 | for (JTextField field : fieldList) { 83 | if (isFieldEmpty(field)) { 84 | return true; 85 | } 86 | } 87 | return false; 88 | } 89 | 90 | // Ekranın belirli bir boyutta pencere için merkez konumunu belirleyen metod 91 | public static int getLocationPoint(String type, Dimension size) { 92 | return switch (type) { 93 | case "x" -> (Toolkit.getDefaultToolkit().getScreenSize().width - size.width) / 2; 94 | case "y" -> (Toolkit.getDefaultToolkit().getScreenSize().height - size.height) / 2; 95 | default -> 0; 96 | }; 97 | } 98 | 99 | // İletişim kutusu düğmelerinin Türkçeleştirilmiş metinlerini ayarlayan metod 100 | public static void optionPaneTR() { 101 | UIManager.put("OptionPane.okButtonText", "Tamam"); 102 | UIManager.put("OptionPane.yesButtonText", "Evet"); 103 | UIManager.put("OptionPane.noButtonText", "Hayır"); 104 | } 105 | 106 | 107 | public static boolean isValidDate(String inputDate, String formatPattern) { 108 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern); 109 | 110 | try { 111 | LocalDate date = LocalDate.parse(inputDate, formatter); 112 | return true; // Geçerli tarih formatı 113 | } catch (DateTimeParseException e) { 114 | return false; // Geçersiz tarih formatı 115 | } 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/dao/HotelDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.Hotel; 5 | 6 | import java.sql.Connection; 7 | import java.sql.PreparedStatement; 8 | import java.sql.ResultSet; 9 | import java.sql.SQLException; 10 | import java.util.ArrayList; 11 | 12 | public class HotelDao { 13 | // Veritabanı bağlantısını temsil eden nesne 14 | private final Connection con; 15 | 16 | 17 | private HotelDao hotelDao; 18 | 19 | // Kurucu metod: Veritabanı bağlantısını kurma 20 | public HotelDao() { 21 | this.con = Db.getInstance(); 22 | } 23 | 24 | // Tüm otelleri getiren metot 25 | public ArrayList findAll() { 26 | ArrayList hotelList = new ArrayList<>(); 27 | String sql = "SELECT * FROM public.hotel"; 28 | try { 29 | ResultSet rs = this.con.createStatement().executeQuery(sql); 30 | while (rs.next()) { 31 | hotelList.add(this.match(rs)); 32 | } 33 | } catch (SQLException e) { 34 | e.printStackTrace(); 35 | } 36 | return hotelList; 37 | } 38 | 39 | // ResultSet'ten alınan verileri bir Hotel nesnesine eşleyen metot 40 | public Hotel match(ResultSet rs) throws SQLException { 41 | Hotel obj = new Hotel(); 42 | obj.setId(rs.getInt("id")); 43 | obj.setName(rs.getString("name")); 44 | obj.setAddress(rs.getString("address")); 45 | obj.setMail(rs.getString("mail")); 46 | obj.setPhone(rs.getString("phone")); 47 | obj.setStar(rs.getString("star")); 48 | obj.setCar_park(rs.getBoolean("car_park")); 49 | obj.setWifi(rs.getBoolean("wifi")); 50 | obj.setPool(rs.getBoolean("pool")); 51 | obj.setFitness(rs.getBoolean("fitness")); 52 | obj.setConcierge(rs.getBoolean("concierge")); 53 | obj.setSpa(rs.getBoolean("spa")); 54 | obj.setRoom_service(rs.getBoolean("room_service")); 55 | return obj; 56 | } 57 | 58 | // Yeni bir otel ekleyen metot 59 | public boolean save(Hotel hotel) { 60 | String query = "INSERT INTO public.hotel" + 61 | "(" + 62 | "name," + 63 | "mail," + 64 | "phone," + 65 | "address," + 66 | "star," + 67 | "car_park," + 68 | "wifi," + 69 | "pool," + 70 | "fitness," + 71 | "concierge," + 72 | "spa," + 73 | "room_service" + 74 | ")" + 75 | " VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"; 76 | try { 77 | PreparedStatement pr = con.prepareStatement(query); 78 | pr.setString(1, hotel.getName()); 79 | pr.setString(2, hotel.getMail()); 80 | pr.setString(3, hotel.getPhone()); 81 | pr.setString(4, hotel.getAddress()); 82 | pr.setString(5, hotel.getStar()); 83 | pr.setBoolean(6, hotel.isCar_park()); 84 | pr.setBoolean(7, hotel.isWifi()); 85 | pr.setBoolean(8, hotel.isPool()); 86 | pr.setBoolean(9, hotel.isFitness()); 87 | pr.setBoolean(10, hotel.isConcierge()); 88 | pr.setBoolean(11, hotel.isSpa()); 89 | pr.setBoolean(12, hotel.isRoom_service()); 90 | 91 | return pr.executeUpdate() != -1; 92 | } catch (SQLException throwables) { 93 | throwables.printStackTrace(); 94 | } 95 | return true; 96 | } 97 | 98 | // Belirli bir otel ID'si ile oteli getiren metot 99 | public Hotel getById(int id) { 100 | Hotel obj = null; 101 | String query = "SELECT * FROM public.hotel WHERE id = ?"; 102 | try { 103 | PreparedStatement pr = this.con.prepareStatement(query); 104 | pr.setInt(1, id); 105 | ResultSet rs = pr.executeQuery(); 106 | if (rs.next()) { 107 | obj = this.match(rs); 108 | } 109 | } catch (SQLException e) { 110 | e.printStackTrace(); 111 | } 112 | return obj; 113 | 114 | } 115 | 116 | // Belirli bir oteli ID ile silen metot// 117 | public boolean delete(int id) { 118 | String query = "DELETE FROM public.hotel WHERE id = ?"; 119 | try { 120 | PreparedStatement pr = this.con.prepareStatement(query); 121 | pr.setInt(1, id); 122 | return pr.executeUpdate() != -1; 123 | } catch (SQLException e) { 124 | e.printStackTrace(); 125 | } 126 | return true; 127 | } 128 | } 129 | 130 | -------------------------------------------------------------------------------- /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 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /src/entity/Room.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class Room { 4 | //Oda ile ilişkilendirilmiş tanımlamalar 5 | private int room_id; 6 | private int hotel_id; 7 | private int pencion_id; 8 | private int season_id; 9 | private String room_type; 10 | private int room_stock; 11 | private int room_adult_price; 12 | private int room_child_price; 13 | private int room_bed_capacity; 14 | private int room_square_meter; 15 | private boolean room_television; 16 | private boolean room_minibar; 17 | private boolean room_case_box;////////// 18 | private boolean room_game_console; 19 | private boolean room_projection; 20 | private Hotel hotel; 21 | private Season season; 22 | private Pension pencion; 23 | 24 | //Oda tiplerinin enum tanımlayan metot 25 | public enum RoomType { 26 | Single_room, 27 | Double_room, 28 | junior_suite_room, 29 | suite_room 30 | } 31 | 32 | //Parametresiz kurucu metot 33 | public Room() { 34 | } 35 | 36 | //Hotel getter ve setterlarının olduğu metotlar 37 | public Hotel getHotel() { 38 | return hotel; 39 | } 40 | 41 | public void setHotel(Hotel hotel) { 42 | this.hotel = hotel; 43 | } 44 | 45 | public Season getSeason() { 46 | return season; 47 | } 48 | 49 | public void setSeason(Season season) { 50 | this.season = season; 51 | } 52 | 53 | public Pension getPencion() { 54 | return pencion; 55 | } 56 | 57 | public void setPencion(Pension pencion) { 58 | this.pencion = pencion; 59 | } 60 | 61 | public int getRoom_id() { 62 | return room_id; 63 | } 64 | 65 | public void setRoom_id(int room_id) { 66 | this.room_id = room_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 getPencion_id() { 78 | return pencion_id; 79 | } 80 | 81 | public void setPencion_id(int pencion_id) { 82 | this.pencion_id = pencion_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 getRoom_type() { 94 | return room_type; 95 | } 96 | 97 | public void setRoom_type(String room_type) { 98 | this.room_type = room_type; 99 | } 100 | 101 | public int getRoom_stock() { 102 | return room_stock; 103 | } 104 | 105 | public void setRoom_stock(int room_stock) { 106 | this.room_stock = room_stock; 107 | } 108 | 109 | public int getRoom_adult_price() { 110 | return room_adult_price; 111 | } 112 | 113 | public void setRoom_adult_price(int r_adult_price) { 114 | this.room_adult_price = r_adult_price; 115 | } 116 | 117 | public int getRoom_child_price() { 118 | return room_child_price; 119 | } 120 | 121 | public void setRoom_child_price(int r_child_price) { 122 | this.room_child_price = r_child_price; 123 | } 124 | 125 | public int getRoom_bed_capacity() { 126 | return room_bed_capacity; 127 | } 128 | 129 | public void setRoom_bed_capacity(int room_bed_capacity) { 130 | this.room_bed_capacity = room_bed_capacity; 131 | } 132 | 133 | public int getRoom_square_meter() { 134 | return room_square_meter; 135 | } 136 | 137 | public void setRoom_square_meter(int room_square_meter) { 138 | this.room_square_meter = room_square_meter; 139 | } 140 | 141 | public boolean isRoom_television() { 142 | return room_television; 143 | } 144 | 145 | public void setRoom_television(boolean room_television) { 146 | this.room_television = room_television; 147 | } 148 | 149 | public boolean isRoom_minibar() { 150 | return room_minibar; 151 | } 152 | 153 | public void setRoom_minibar(boolean room_minibar) { 154 | this.room_minibar = room_minibar; 155 | } 156 | 157 | public boolean isRoom_game_console() { 158 | return room_game_console; 159 | } 160 | 161 | public void setRoom_game_console(boolean room_game_console) { 162 | this.room_game_console = room_game_console; 163 | } 164 | 165 | public boolean isRoom_case_box() { 166 | return room_case_box; 167 | } 168 | 169 | public void setRoom_case_box(boolean room_case_box) { 170 | this.room_case_box = room_case_box; 171 | } 172 | 173 | public boolean isRoom_projection() { 174 | return room_projection; 175 | } 176 | 177 | public void setRoom_projection(boolean room_projection) { 178 | this.room_projection = room_projection; 179 | } 180 | 181 | @Override 182 | public String toString() { 183 | return "Room{" + 184 | "room_id=" + room_id + 185 | ", hotel_id=" + hotel_id + 186 | ", pencion_id=" + pencion_id + 187 | ", season_id=" + season_id + 188 | ", room_type='" + room_type + '\'' + 189 | ", room_stock=" + room_stock + 190 | ", room_adult_price=" + room_adult_price + 191 | ", room_child_price=" + room_child_price + 192 | ", room_bed_capacity=" + room_bed_capacity + 193 | ", room_square_meter=" + room_square_meter + 194 | ", room_television=" + room_television + 195 | ", room_minibar=" + room_minibar + 196 | ", room_game_console=" + room_game_console + 197 | ", room_projection=" + room_projection + 198 | ", room_case_box=" + room_case_box + 199 | '}'; 200 | 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /src/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.User; 5 | 6 | import java.sql.Connection; 7 | import java.sql.PreparedStatement; 8 | import java.sql.ResultSet; 9 | import java.sql.SQLException; 10 | import java.util.ArrayList; 11 | 12 | public class UserDao { 13 | //Veri tabanı bağlantısını yapan nesne 14 | private final Connection con; 15 | 16 | //Kullanıcı özellikleri 17 | private int id; 18 | private String name; 19 | 20 | //Veritabanı bağlantısını kurucu metod aracılığıyla oluşturma 21 | public UserDao() { 22 | this.con = Db.getInstance(); 23 | } 24 | 25 | // Tüm kullanıcıları getiren metot 26 | public ArrayList findAll() { 27 | 28 | // Boş bir User listesi oluşturuluyor. 29 | ArrayList userList = new ArrayList<>(); 30 | // SQL sorgusu 31 | String sql = "SELECT * FROM public.user"; 32 | try { 33 | // Veritabanı bağlantısından bir Statement nesnesi alınıyor ve SQL sorgusu çalıştırılıyor. 34 | ResultSet rs = this.con.createStatement().executeQuery(sql); 35 | 36 | // ResultSet üzerinde döngü ile sonuçlar okunuyor 37 | while (rs.next()) { 38 | 39 | // Her bir satır için "match" metodunu kullanarak bir User nesnesi oluşturulup userList'e ekleniyor. 40 | userList.add(this.match(rs)); 41 | } 42 | // SQL isteği sırasında oluşan herhangi bir hata durumunda hata detayları yazdırılıyor. 43 | } catch (SQLException e) { 44 | e.printStackTrace(); 45 | } 46 | // Sonuç olarak, tüm kullanıcıları içeren User listesi döndürülüyor. 47 | return userList; 48 | } 49 | 50 | // DB user function 51 | // Veri tabanına bağlanıp kullanıcı var mı sorgusu ve daha sonrasında objeye atayıp döndürme 52 | public User findByLogin(String username, String password) { 53 | User obj = null; 54 | String query = "SELECT * FROM public.user WHERE user_name =? AND user_pass =?"; 55 | try { 56 | PreparedStatement pr = this.con.prepareStatement(query); 57 | pr.setString(1, username); 58 | pr.setString(2, password); 59 | ResultSet rs = pr.executeQuery(); 60 | if (rs.next()) { 61 | obj = this.match(rs); 62 | } 63 | } catch (SQLException e) { 64 | e.printStackTrace(); 65 | } 66 | return obj; 67 | } 68 | 69 | // seçilen id ile query oluşturan function 70 | public User getById(int id) { 71 | User obj = null; 72 | String query = "SELECT * FROM public.user WHERE user_id = ?"; 73 | try { 74 | PreparedStatement pr = this.con.prepareStatement(query); 75 | pr.setInt(1, id); 76 | ResultSet rs = pr.executeQuery(); 77 | if (rs.next()) { 78 | obj = this.match(rs); 79 | } 80 | } catch (SQLException e) { 81 | e.printStackTrace(); 82 | } 83 | return obj; 84 | } 85 | 86 | // veriyi modele çevirme 87 | public User match(ResultSet rs) throws SQLException { 88 | User obj = new User(); 89 | obj.setId(rs.getInt("user_id")); 90 | obj.setUsername(rs.getString("user_name")); 91 | obj.setPassword(rs.getString("user_pass")); 92 | obj.setRole(rs.getString("user_role")); 93 | return obj; 94 | } 95 | 96 | // Yeni bir kullanıcıyı veritabanına ekleyen metot 97 | public boolean save(User user) { 98 | String query = "INSERT INTO public.user (user_name, user_pass,user_role) VALUES(?,?,?)"; 99 | try { 100 | PreparedStatement pr = this.con.prepareStatement(query); 101 | pr.setString(1, user.getUsername()); 102 | pr.setString(2, user.getPassword()); 103 | pr.setString(3, user.getRole()); 104 | return pr.executeUpdate() != -1; 105 | 106 | } catch (SQLException e) { 107 | e.printStackTrace(); 108 | } 109 | return true; 110 | } 111 | 112 | // Var olan bir kullanıcıyı güncelleyen metot 113 | public boolean update(User user) { 114 | String query = "UPDATE public.user SET " + 115 | "user_name= ? , " + 116 | "user_pass = ? , " + 117 | "user_role = ? " + 118 | "WHERE user_id = ? "; 119 | try { 120 | PreparedStatement pr = con.prepareStatement(query); 121 | pr.setString(1, user.getUsername()); 122 | pr.setString(2, user.getPassword()); 123 | pr.setString(3, user.getRole()); 124 | pr.setInt(4, user.getId()); 125 | return pr.executeUpdate() != -1; 126 | } catch (SQLException throwables) { 127 | throwables.printStackTrace(); 128 | } 129 | return true; 130 | } 131 | 132 | // Belirli bir kullanıcıyı ID ile silen metot 133 | public boolean delete(int id) { 134 | String query = "DELETE FROM public.user WHERE user_id = ?"; 135 | try { 136 | PreparedStatement pr = this.con.prepareStatement(query); 137 | pr.setInt(1, id); 138 | return pr.executeUpdate() != -1; 139 | } catch (SQLException e) { 140 | e.printStackTrace(); 141 | } 142 | return true; 143 | } 144 | 145 | // Belirli bir sorguya göre kullanıcıları seçen metot 146 | public ArrayList selectByQuery(String query) { 147 | ArrayList userList = new ArrayList<>(); 148 | 149 | try { 150 | ResultSet rs = this.con.createStatement().executeQuery(query); 151 | while (rs.next()) { 152 | userList.add(this.match(rs)); 153 | } 154 | } catch (SQLException throwable) { 155 | throwable.printStackTrace(); 156 | } 157 | return userList; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /src/business/RoomManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import dao.RoomDao; 4 | import core.Db; 5 | import core.Helper; 6 | import entity.Hotel; 7 | import entity.Room; 8 | 9 | import java.sql.Connection; 10 | import java.time.LocalDate; 11 | import java.time.format.DateTimeFormatter; 12 | import java.util.ArrayList; 13 | 14 | public class RoomManager { 15 | private Connection con; 16 | private final RoomDao roomDao; 17 | private Hotel hotel; 18 | private HotelManager hotelManager; 19 | private Room room; 20 | 21 | // Constructor: Bağlantıyı başlatır ve diğer nesneleri oluşturur 22 | public RoomManager() { 23 | this.con = Db.getInstance(); 24 | this.roomDao = new RoomDao(); 25 | this.hotel = new Hotel(); 26 | this.room = room; 27 | this.hotelManager = new HotelManager(); 28 | } 29 | 30 | // Tablo için uygun veri yapısını oluşturan metod 31 | public ArrayList getForTable(int size, ArrayList rooms) { 32 | ArrayList roomObjList = new ArrayList<>(); 33 | for (Room obj : rooms) { 34 | Object[] rowObject = new Object[size]; 35 | int i = 0; 36 | // Oda özellikleri tablo için bir satır oluşturulur 37 | rowObject[i++] = obj.getRoom_id(); 38 | rowObject[i++] = obj.getHotel().getName(); 39 | rowObject[i++] = obj.getPencion().getPencionType(); 40 | rowObject[i++] = obj.getRoom_type(); 41 | rowObject[i++] = obj.getRoom_stock(); 42 | rowObject[i++] = obj.getRoom_adult_price(); 43 | rowObject[i++] = obj.getRoom_child_price(); 44 | rowObject[i++] = obj.getRoom_bed_capacity(); 45 | rowObject[i++] = obj.getRoom_square_meter(); 46 | rowObject[i++] = obj.isRoom_television(); 47 | rowObject[i++] = obj.isRoom_minibar(); 48 | rowObject[i++] = obj.isRoom_game_console(); 49 | rowObject[i++] = obj.isRoom_projection(); 50 | rowObject[i++] = obj.isRoom_case_box(); 51 | roomObjList.add(rowObject); 52 | } 53 | return roomObjList; 54 | } 55 | 56 | // Tüm odaları getiren metod 57 | public ArrayList findAll() { 58 | return this.roomDao.findAll(); 59 | } 60 | 61 | // Oda kaydı yapma metod 62 | public boolean save(Room room) { 63 | if (room.getRoom_id() != 0) { 64 | Helper.showMsg("error"); 65 | 66 | } 67 | return this.roomDao.save(room); 68 | } 69 | 70 | // Oda arama metod 71 | public ArrayList searchForRoom(String hotel_name, String hotel_address, String start_date, String finish_date, String adult_num, String child_num) { 72 | 73 | // SQL sorgusunu oluştur 74 | String query = "SELECT * FROM room r " + 75 | "JOIN hotel h ON r.hotel_id = h.id " + 76 | "LEFT JOIN hotel_season s ON r.season_id = s.id"; 77 | 78 | // WHERE ve JOIN ON şartlarını tutacak ArrayList'ler 79 | ArrayList where = new ArrayList<>(); 80 | ArrayList joinWhere = new ArrayList<>(); 81 | 82 | 83 | 84 | // Otel adı şartı ekle 85 | if (hotel_name != null) { 86 | where.add("h.name ILIKE '%" + hotel_name + "%'"); 87 | } 88 | 89 | // Otelin şehirlerini şartı ekle 90 | if (hotel_address != null) { 91 | where.add("h.address ILIKE '%" + hotel_address + "%'"); 92 | } 93 | 94 | // Yetişkin ve çocuk sayısına göre şartları ekle 95 | if (adult_num != null && !adult_num.isEmpty() && child_num != null && !child_num.isEmpty()) { 96 | try { 97 | int adultNum = Integer.parseInt(adult_num); 98 | int childNum = Integer.parseInt(child_num); 99 | int total_person = adultNum + childNum; 100 | where.add("r.bed_capacity >= '" + (total_person) + "'"); 101 | } catch (NumberFormatException e) { 102 | e.printStackTrace(); 103 | } 104 | } 105 | 106 | // Tarih formatını uygun formata çevir 107 | 108 | 109 | if (start_date != null && !start_date.isEmpty() && !start_date.equals(" / / ") && finish_date != null && !finish_date.isEmpty() && !finish_date.equals(" / / ")) { 110 | 111 | // Tarihleri LocalDate olarak dönüştür 112 | start_date = LocalDate.parse(start_date, DateTimeFormatter.ofPattern("dd/MM/yyyy")).toString(); 113 | finish_date = LocalDate.parse(finish_date, DateTimeFormatter.ofPattern("dd/MM/yyyy")).toString(); 114 | 115 | // Tarih aralığını WHERE koşuluna ekle 116 | where.add("s.start_date <= '" + start_date + "'"); 117 | where.add("s.finish_date >= '" + finish_date + "'"); 118 | } 119 | 120 | 121 | 122 | // Oda stoğu kontrolü şartını ekle 123 | where.add("r.stock > 0"); 124 | 125 | // WHERE şartlarını birleştir 126 | String whereStr = String.join(" AND ", where); 127 | String joinStr = String.join(" AND ", joinWhere); 128 | 129 | // JOIN ON şartını sorguya ekle 130 | if (joinStr.length() > 0) { 131 | query += " ON " + joinStr; 132 | } 133 | 134 | // WHERE şartını sorguya ekle 135 | if (whereStr.length() > 0) { 136 | query += " WHERE " + whereStr; 137 | } 138 | 139 | // Oluşturulan sorguyu ekrana yazdır (opsiyonel, sorguyu kontrol etmek için) 140 | System.out.println(query); 141 | 142 | // Oluşturulan sorguya göre odaları getir 143 | return this.roomDao.selectByQuery(query); 144 | } 145 | 146 | // Belirli bir oda ID'si ile odayı getiren metod 147 | public Room getById(int id) { 148 | return roomDao.getById(id); 149 | } 150 | 151 | // Oda stok güncelleme metod 152 | public boolean updateStock(Room room) { 153 | return this.roomDao.updateStock(room); 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/dao/ReservationDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.Reservation; 5 | 6 | import java.sql.Connection; 7 | import java.sql.PreparedStatement; 8 | import java.sql.ResultSet; 9 | import java.sql.SQLException; 10 | import java.time.LocalDate; 11 | import java.util.ArrayList; 12 | import java.sql.Date; 13 | 14 | public class ReservationDao { 15 | 16 | // Veritabanı bağlantısını temsil eden nesne 17 | private final Connection con; 18 | 19 | // İlişkili DAO sınıfı 20 | private final RoomDao roomDao = new RoomDao(); 21 | 22 | // Kurucu metod: Veritabanı bağlantısını kurma 23 | public ReservationDao() { 24 | this.con = Db.getInstance(); 25 | } 26 | 27 | // Tüm rezervasyonları getiren metot 28 | public ArrayList findAll() { 29 | ArrayList reservationList = new ArrayList<>(); 30 | String sql = "SELECT * FROM public.reservation"; 31 | try { 32 | ResultSet rs = this.con.createStatement().executeQuery(sql); 33 | while (rs.next()) { 34 | reservationList.add(this.match(rs)); 35 | } 36 | } catch (SQLException e) { 37 | e.printStackTrace(); 38 | } 39 | return reservationList; 40 | } 41 | 42 | // ResultSet'ten alınan verileri bir Reservation nesnesine eşleyen metot 43 | public Reservation match(ResultSet rs) throws SQLException { 44 | Reservation obj = new Reservation(); 45 | obj.setId(rs.getInt("id")); 46 | obj.setReservation_room_id(rs.getInt("room_id")); 47 | obj.setReservation_start_date(LocalDate.parse(rs.getString("check_in_date"))); 48 | obj.setReservation_end_date(LocalDate.parse(rs.getString("check_out_date"))); 49 | obj.setReservation_total_price(rs.getInt("total_price")); 50 | obj.setReservation_guest_number(rs.getInt("guest_count")); 51 | obj.setReservation_guest_name(rs.getString("guest_name")); 52 | obj.setReservation_guest_id(rs.getInt("guest_citizen_id")); 53 | obj.setReservation_mail(rs.getString("guest_mail")); 54 | obj.setReservation_phone(rs.getInt("guest_phone")); 55 | return obj; 56 | } 57 | 58 | // Belirli bir rezervasyon ID'si ile rezervasyonu getiren metot 59 | public Reservation getById(int id) { 60 | Reservation obj = null; 61 | String query = "SELECT * FROM public.reservation WHERE id = ?"; 62 | try { 63 | PreparedStatement pr = this.con.prepareStatement(query); 64 | pr.setInt(1, id); 65 | ResultSet rs = pr.executeQuery(); 66 | if (rs.next()) { 67 | obj = this.match(rs); 68 | } 69 | } catch (SQLException e) { 70 | e.printStackTrace(); 71 | } 72 | return obj; 73 | 74 | } 75 | 76 | // Yeni bir rezervasyon ekleyen metot 77 | public boolean save(Reservation reservation) { 78 | String query = "INSERT INTO public.reservation" + 79 | "(" + 80 | "room_id," + 81 | "check_in_date," + 82 | "check_out_date," + 83 | "total_price," + 84 | "guest_count," + 85 | "guest_name," + 86 | "guest_citizen_id," + 87 | "guest_mail," + 88 | "guest_phone" + 89 | ")" + 90 | "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"; 91 | try { 92 | PreparedStatement pr = con.prepareStatement(query); 93 | pr.setInt(1, reservation.getReservation_room_id()); 94 | pr.setDate(2, Date.valueOf(reservation.getReservation_start_date())); 95 | pr.setDate(3, Date.valueOf(reservation.getReservation_end_date())); 96 | pr.setInt(4, reservation.getReservation_total_price()); 97 | pr.setInt(5, reservation.getReservation_guest_number()); 98 | pr.setString(6, reservation.getReservation_guest_name()); 99 | pr.setInt(7, reservation.getReservation_guest_id()); 100 | pr.setString(8, reservation.getReservation_mail()); 101 | pr.setInt(9, reservation.getReservation_phone()); 102 | 103 | return pr.executeUpdate() != -1; 104 | } catch (SQLException throwables) { 105 | throwables.printStackTrace(); 106 | } 107 | return true; 108 | } 109 | 110 | // Belirli bir rezervasyonu güncelleyen metot 111 | public boolean update(Reservation reservation) { 112 | String query = "UPDATE public.reservation SET " + 113 | "guest_count= ? , " + 114 | "guest_name= ? , " + 115 | "guest_citizen_id= ? , " + 116 | "guest_mail= ? , " + 117 | "guest_phone= ? " + 118 | "WHERE id = ? "; 119 | try { 120 | PreparedStatement pr = con.prepareStatement(query); 121 | pr.setInt(1, reservation.getReservation_guest_number()); 122 | pr.setString(2, reservation.getReservation_guest_name()); 123 | pr.setInt(3, reservation.getReservation_guest_id()); 124 | pr.setString(4, reservation.getReservation_mail()); 125 | pr.setInt(5, reservation.getReservation_phone()); 126 | pr.setInt(6,reservation.getId()); 127 | return pr.executeUpdate() != -1; 128 | } catch (SQLException throwables) { 129 | throwables.printStackTrace(); 130 | } 131 | return true; 132 | } 133 | 134 | // Belirli bir rezervasyonu silen metot 135 | public boolean delete(int id) { 136 | String query = "DELETE FROM public.reservation WHERE id = ?"; 137 | try { 138 | PreparedStatement pr = this.con.prepareStatement(query); 139 | pr.setInt(1, id); 140 | return pr.executeUpdate() != -1; 141 | } catch (SQLException e) { 142 | e.printStackTrace(); 143 | } 144 | return true; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/view/AdminView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.UserManager; 4 | import core.Helper; 5 | import entity.User; 6 | 7 | import javax.swing.*; 8 | import javax.swing.table.DefaultTableModel; 9 | import java.awt.event.*; 10 | import java.util.ArrayList; 11 | 12 | public class AdminView extends Layout { 13 | private User user; 14 | private JPanel container; 15 | private JButton btn_logout; 16 | private JComboBox cmb_user_search; 17 | private JButton btn_save; 18 | private JButton btn_search; 19 | private JLabel lbl_welcome; 20 | private JTable tbl_user; 21 | private JButton btn_clear; 22 | private DefaultTableModel tmdl_user = new DefaultTableModel(); 23 | private UserManager userManager; 24 | private JPopupMenu userMenu; 25 | private Object[] col_user; 26 | 27 | // AdminView sınıfının constructor metodu 28 | public AdminView(User loggedInUser) { 29 | this.userManager = new UserManager(); 30 | this.add(container); 31 | this.guiInitilaze(700, 500); 32 | this.user = loggedInUser; 33 | if (loggedInUser == null) { 34 | dispose(); // Pencereyi kapatma 35 | } 36 | this.lbl_welcome.setText("HOŞ GELDİNİZ : " + this.user.getUsername().toUpperCase()); 37 | 38 | /* 39 | Kullanıcı tablosunu yükleme 40 | Kullanıcı bileşenlerini yükleme 41 | Kullanıcı filtresini yükleme 42 | */ 43 | 44 | loadUserTable(null); 45 | loadUserComponent(); 46 | loadUserFilter(); 47 | 48 | this.tbl_user.setComponentPopupMenu(userMenu); 49 | 50 | btn_logout.addActionListener(new ActionListener() { 51 | @Override 52 | public void actionPerformed(ActionEvent e) { 53 | //System.exit(0); 54 | dispose(); 55 | LoginView loginView=new LoginView(); 56 | } 57 | }); 58 | 59 | // Kullanıcı temizle butonu için ActionListener ekleme 60 | btn_clear.addActionListener(new ActionListener() { 61 | @Override 62 | public void actionPerformed(ActionEvent e) { 63 | cmb_user_search.setSelectedItem(null); 64 | loadUserTable(null); 65 | } 66 | }); 67 | 68 | 69 | // Kullanıcı arama butonu için ActionListener ekleme 70 | this.btn_search.addActionListener(e -> { 71 | ArrayList userListBySearch = this.userManager.searchForTable((User.Role) cmb_user_search.getSelectedItem()); 72 | ArrayList userRowListBySearch = this.userManager.getForTable(col_user.length, userListBySearch); 73 | loadUserTable(userRowListBySearch); 74 | }); 75 | 76 | } 77 | 78 | 79 | 80 | // Kullanıcı tablosunu yükleme metodu 81 | public void loadUserTable(ArrayList usersList) { 82 | this.col_user = new Object[]{"Kullanıcı ID", "Kullanıcı Adı", "Parola", "Kullanıcı Rolü"}; 83 | if (usersList == null) { 84 | usersList = this.userManager.getForTable(col_user.length, userManager.findAll()); 85 | } 86 | this.createTable(this.tmdl_user, tbl_user, col_user, usersList); 87 | } 88 | 89 | 90 | 91 | 92 | // Kullanıcı bileşenlerini yükleme metodu 93 | public void loadUserComponent() { 94 | //Tabloda tıklanan satırın seçilmesi 95 | this.tbl_user.addMouseListener(new MouseAdapter() { 96 | @Override 97 | public void mousePressed(MouseEvent e) { 98 | //int selected_row = tbl_user.rowAtPoint(e.getPoint()); 99 | //tbl_user.setRowSelectionInterval(selected_row, selected_row); 100 | tableRowSelect(tbl_user); 101 | } 102 | }); 103 | 104 | // ekleme,güncelle,sil butonları ekleme 105 | this.userMenu = new JPopupMenu(); 106 | 107 | // ekleme 108 | this.userMenu.add("Yeni").addActionListener(e -> { 109 | UserView userView = new UserView(null); 110 | userView.addWindowListener(new WindowAdapter() { 111 | @Override 112 | public void windowClosed(WindowEvent e) { 113 | loadUserTable(null); 114 | } 115 | }); 116 | }); 117 | 118 | // seçili olan userid yi databaseden alıp buraya gönderme 119 | userMenu.add("Güncelle").addActionListener(e -> { 120 | int selectUserId = this.getTableSelectedRow(tbl_user, 0); 121 | UserView userView = new UserView(this.userManager.getById(selectUserId)); 122 | userView.addWindowListener(new WindowAdapter() { 123 | @Override 124 | public void windowClosed(WindowEvent e) { 125 | loadUserTable(null); 126 | } 127 | }); 128 | }); 129 | 130 | 131 | // "Sil" işlevini içeren bir ActionListener eklenir. 132 | userMenu.add("Sil").addActionListener(e -> { 133 | 134 | // Kullanıcıya emin olup olmadığını soran bir onay penceresi gösterilir. 135 | if (Helper.confirm("sure")) { 136 | 137 | // Seçilen kullanıcının ID'si alınır. 138 | int selectUserId = this.getTableSelectedRow(tbl_user, 0); 139 | 140 | // Kullanıcı ID'sine göre kullanıcı silinir. 141 | if (this.userManager.delete(selectUserId)) { 142 | 143 | // Başarılı bir şekilde silindiğinde kullanıcıya mesaj gösterilir. 144 | Helper.showMsg("done"); 145 | loadUserTable(null); 146 | } else { 147 | 148 | // Silme işlemi başarısızsa kullanıcıya hata mesajı gösterilir. 149 | Helper.showMsg("error"); 150 | } 151 | } 152 | }); 153 | 154 | 155 | } 156 | 157 | // Kullanıcı filtresini yükleme metodu 158 | public void loadUserFilter() { 159 | this.cmb_user_search.setModel(new DefaultComboBoxModel<>(User.Role.values())); 160 | this.cmb_user_search.setSelectedItem(null); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /src/dao/RoomDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.Room; 5 | 6 | import java.sql.Connection; 7 | import java.sql.PreparedStatement; 8 | import java.sql.ResultSet; 9 | import java.sql.SQLException; 10 | import java.util.ArrayList; 11 | 12 | public class RoomDao { 13 | // Veritabanı bağlantısını temsil eden nesne 14 | private final Connection con; 15 | 16 | // İlişkili DAO sınıfları 17 | private PensionDao pencionDao; 18 | private SeasonDao seasonDao; 19 | private HotelDao hotelDao; 20 | 21 | 22 | public RoomDao() { 23 | // Kurucu metod: DAO sınıflarını oluştur ve veritabanı bağlantısını kur 24 | this.hotelDao = new HotelDao(); 25 | this.pencionDao = new PensionDao(); 26 | this.seasonDao = new SeasonDao(); 27 | this.con = Db.getInstance(); 28 | } 29 | 30 | 31 | // ResultSet'ten alınan verileri bir Room nesnesine eşleyen metot 32 | public Room match(ResultSet rs) throws SQLException { 33 | Room obj = new Room(); 34 | obj.setRoom_id(rs.getInt("id")); 35 | obj.setHotel_id(rs.getInt("hotel_id")); 36 | obj.setPencion_id(rs.getInt("pension_id")); 37 | obj.setSeason_id(rs.getInt("season_id")); 38 | obj.setRoom_type(rs.getString("type")); 39 | obj.setRoom_stock(rs.getInt("stock")); 40 | obj.setRoom_adult_price(rs.getInt("adult_price")); 41 | obj.setRoom_child_price(rs.getInt("child_price")); 42 | obj.setRoom_bed_capacity(rs.getInt("bed_capacity")); 43 | obj.setRoom_square_meter(rs.getInt("square_meter")); 44 | obj.setRoom_television(rs.getBoolean("television")); 45 | obj.setRoom_minibar(rs.getBoolean("minibar")); 46 | obj.setRoom_game_console(rs.getBoolean("game_console")); 47 | 48 | obj.setRoom_projection(rs.getBoolean("projection")); 49 | obj.setRoom_case_box(rs.getBoolean("safe"));/////// 50 | 51 | // İlişkili DAO sınıflarını kullanarak ilgili nesneleri set et 52 | obj.setPencion(this.pencionDao.getById(rs.getInt("pension_id"))); 53 | obj.setSeason(this.seasonDao.getById(rs.getInt("season_id"))); 54 | obj.setHotel(this.hotelDao.getById(rs.getInt("hotel_id"))); 55 | return obj; 56 | } 57 | 58 | // Yeni bir oda ekleyen metot 59 | public boolean save(Room room) { 60 | String query = "INSERT INTO public.room" + 61 | "(" + 62 | "hotel_id, " + 63 | "pension_id, " + 64 | "season_id, " + 65 | "type, " + 66 | "stock, " + 67 | "adult_price, " + 68 | "child_price, " + 69 | "bed_capacity, " + 70 | "square_meter, " + 71 | "television, " + 72 | "minibar, " + 73 | "game_console, " + 74 | "projection, " + 75 | "safe" + 76 | ")" + 77 | "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; 78 | 79 | try { 80 | PreparedStatement pr = this.con.prepareStatement(query); 81 | pr.setInt(1, room.getHotel_id()); 82 | pr.setInt(2, room.getPencion_id()); 83 | pr.setInt(3, room.getSeason_id()); 84 | pr.setString(4, room.getRoom_type()); 85 | pr.setInt(5, room.getRoom_stock()); 86 | pr.setInt(6, room.getRoom_adult_price()); 87 | pr.setInt(7, room.getRoom_child_price()); 88 | pr.setInt(8, room.getRoom_bed_capacity()); 89 | pr.setInt(9, room.getRoom_square_meter()); 90 | pr.setBoolean(10, room.isRoom_television()); 91 | pr.setBoolean(11, room.isRoom_minibar()); 92 | pr.setBoolean(12, room.isRoom_game_console()); 93 | pr.setBoolean(13, room.isRoom_projection()); 94 | pr.setBoolean(14, room.isRoom_case_box()); 95 | return pr.executeUpdate() != -1; 96 | } catch (SQLException e) { 97 | e.printStackTrace(); 98 | } 99 | return true; 100 | } 101 | 102 | // Tüm odaları getiren metot 103 | public ArrayList findAll() { 104 | ArrayList roomList = new ArrayList<>(); 105 | String sql = "SELECT * FROM public.room"; 106 | try { 107 | ResultSet rs = this.con.createStatement().executeQuery(sql); 108 | while (rs.next()) { 109 | roomList.add(this.match(rs)); 110 | } 111 | } catch (SQLException e) { 112 | e.printStackTrace(); 113 | } 114 | return roomList; 115 | } 116 | 117 | // Belirli bir sorguya göre odaları getiren metot 118 | public ArrayList selectByQuery(String query) { 119 | ArrayList roomList = new ArrayList<>(); 120 | try { 121 | ResultSet rs = this.con.createStatement().executeQuery(query); 122 | while (rs.next()) { 123 | roomList.add(this.match(rs)); 124 | } 125 | } catch (SQLException throwable) { 126 | throwable.printStackTrace(); 127 | } 128 | return roomList; 129 | } 130 | 131 | // Belirli bir oda ID'si ile odayı getiren metot 132 | public Room getById(int id) { 133 | Room obj = null; 134 | String query = "SELECT * FROM public.room WHERE id = ?"; 135 | try { 136 | PreparedStatement pr = this.con.prepareStatement(query); 137 | pr.setInt(1, id); 138 | ResultSet rs = pr.executeQuery(); 139 | if (rs.next()) { 140 | obj = this.match(rs); 141 | } 142 | } catch (SQLException e) { 143 | e.printStackTrace(); 144 | } 145 | return obj; 146 | } 147 | 148 | // Oda stok miktarını güncelleyen metot 149 | public boolean updateStock(Room room){ 150 | String query = "UPDATE public.room SET stock = ? WHERE id = ?"; 151 | try {PreparedStatement pr = this.con.prepareStatement(query); 152 | pr.setInt(1,room.getRoom_stock()); 153 | pr.setInt(2,room.getRoom_id()); 154 | return pr.executeUpdate() != -1; 155 | }catch (SQLException e){ 156 | e.printStackTrace(); 157 | } 158 | return true; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/view/RoomAddView.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 | 14 | import javax.swing.*; 15 | 16 | // RoomAddView sınıfı, yeni bir oda eklemek için kullanılan arayüzü temsil eder ve Layout sınıfından türetilmiştir. 17 | public class RoomAddView extends Layout { 18 | 19 | // Arayüzdeki bileşenlerin tanımlandığı değişkenler. 20 | private JPanel container; 21 | private JButton btn_room_add; 22 | private JComboBox cmb_hotel_add; 23 | private JComboBox cmb_pencion_add; 24 | private JComboBox cmb_season_add; 25 | private JComboBox cmb_room_type_add; 26 | private JTextField fld_stock_add; 27 | private JTextField fld_square_meter_add; 28 | private JTextField fld_bed_capacity_add; 29 | private JRadioButton rdb_tv_add; 30 | private JRadioButton rdb_minibar_add; 31 | private JRadioButton rdb_game_console_add; 32 | private JRadioButton rdb_projection_add; 33 | private JRadioButton rdb_case_box_add; 34 | private JLabel fld_oda; 35 | private JTextField fld_adult_add; 36 | private JTextField fld_child_add; 37 | private JPanel pnl_room_add; 38 | private JPanel pnl_add_room_right; 39 | private JPanel pnl_add_room_left; 40 | private RoomAddView roomAddView; 41 | private RoomManager roomManager; 42 | private Room room; 43 | private HotelManager hotelManager; 44 | private SeasonManager seasonManager; 45 | private PensionManager pencionManager; 46 | 47 | // RoomAddView sınıfının constructor'ı. 48 | public RoomAddView(Object o) { 49 | this.roomManager = new RoomManager(); 50 | this.seasonManager = new SeasonManager(null); 51 | this.pencionManager = new PensionManager(null); 52 | this.hotelManager = new HotelManager(); 53 | this.room = room; 54 | this.add(container); 55 | this.guiInitilaze(1000, 600); 56 | this.cmb_room_type_add.setModel(new DefaultComboBoxModel<>(Room.RoomType.values())); 57 | 58 | // Otel ComboBox'ı için otel bilgilerini doldur. 59 | int counter = 0; 60 | for (Hotel hotel : this.hotelManager.findAll()) { 61 | if (counter == 0) { 62 | getPencionByHotel(hotel.getId()); 63 | getSeasonByHotel(hotel.getId()); 64 | } 65 | cmb_hotel_add.addItem(hotel.getComboItem()); 66 | counter++; 67 | } 68 | 69 | // "btn_room_add" butonuna ActionListener eklenir. 70 | btn_room_add.addActionListener(e -> { 71 | 72 | // Gerekli text alanları kontrol edilir ve gerekli işlemler yapılır. 73 | JTextField[] checkFieldList = {this.fld_stock_add, this.fld_adult_add, this.fld_child_add, this.fld_bed_capacity_add, this.fld_square_meter_add}; 74 | if (Helper.isFieldListEmpty(checkFieldList)) { 75 | Helper.showMsg("fill"); 76 | } else { 77 | boolean result = true; 78 | Room roomNew = new Room(); 79 | 80 | // Seçilen otel bilgisi alınır. 81 | ComboItem selectedOtelInfo = (ComboItem) cmb_hotel_add.getSelectedItem(); 82 | roomNew.setHotel_id(selectedOtelInfo.getKey()); 83 | 84 | // Seçilen sezon bilgisi alınır. 85 | ComboItem selectedSeasonInfo = (ComboItem) cmb_season_add.getSelectedItem(); 86 | roomNew.setSeason_id(selectedSeasonInfo.getKey()); 87 | 88 | // Seçilen pansiyon bilgisi alınır. 89 | ComboItem selectedPensionInfo = (ComboItem) cmb_pencion_add.getSelectedItem(); 90 | roomNew.setPencion_id(selectedPensionInfo.getKey()); 91 | 92 | // Diğer bilgiler alınır ve setlemeler 93 | roomNew.setRoom_stock(Integer.parseInt(fld_stock_add.getText())); 94 | roomNew.setRoom_adult_price(Integer.parseInt(fld_adult_add.getText())); 95 | roomNew.setRoom_child_price(Integer.parseInt(fld_child_add.getText())); 96 | roomNew.setRoom_bed_capacity(Integer.parseInt(fld_bed_capacity_add.getText())); 97 | roomNew.setRoom_square_meter(Integer.parseInt(fld_square_meter_add.getText())); 98 | roomNew.setRoom_type(String.valueOf((Room.RoomType) cmb_room_type_add.getSelectedItem())); 99 | roomNew.setRoom_television(rdb_tv_add.isSelected()); 100 | roomNew.setRoom_minibar(rdb_minibar_add.isSelected()); 101 | roomNew.setRoom_game_console(rdb_game_console_add.isSelected()); 102 | roomNew.setRoom_case_box(rdb_case_box_add.isSelected());//////// 103 | roomNew.setRoom_projection(rdb_projection_add.isSelected()); 104 | 105 | 106 | 107 | // Yeni bir oda ekleniyorsa, odanın bilgileri kaydedilir. 108 | if (roomNew.getRoom_id() == 0) { 109 | result = this.roomManager.save(roomNew); 110 | dispose(); 111 | 112 | } else { 113 | 114 | } 115 | if (result) { 116 | Helper.showMsg("done"); 117 | 118 | 119 | } else { 120 | Helper.showMsg("error"); 121 | } 122 | 123 | } 124 | 125 | 126 | }); 127 | 128 | 129 | // Otel ComboBox'ında bir değişiklik olduğunda çalışacak ActionListener. 130 | cmb_hotel_add.addActionListener(e -> { 131 | ComboItem item = (ComboItem) cmb_hotel_add.getSelectedItem(); 132 | 133 | // Seçilen otel bilgisine göre pansiyon ve sezon bilgileri güncellenir. 134 | getPencionByHotel(item.getKey()); 135 | getSeasonByHotel(item.getKey()); 136 | 137 | }); 138 | } 139 | 140 | // Seçilen otel bilgisine göre pansiyonları ComboBox'a ekler. 141 | private void getPencionByHotel(int hotel_id) { 142 | for (Pension pencion : this.pencionManager.findByHotelId(hotel_id)) { 143 | cmb_pencion_add.addItem((pencion.getComboItem())); 144 | } 145 | } 146 | 147 | // Seçilen otel bilgisine göre sezonları ComboBox'a ekler. 148 | private void getSeasonByHotel(int hotel_id) { 149 | for (Season season : this.seasonManager.findByHotelId(hotel_id)) { 150 | cmb_season_add.addItem((season.getComboItem())); 151 | } 152 | } 153 | 154 | } 155 | 156 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tourism Managament System 2 | This project encompasses a Java application developed to manage tourism agency operations. The project consists of five main packages: DAO (Data Access Object), Business, Entity, Core, and View. 3 | 4 | 5 | ## About the project 6 | The tourism agency project is a comprehensive application that offers a wide range of services, including hotel management, room reservations, customer information, and user management. This project involves adding hotels, managing rooms, making reservations, and updating customer information. Additionally, it allows the creation of users in different roles (admin and employee), enabling more effective management of business processes. As a result, the tourism agency project facilitates travel and accommodation processes, providing services in accordance with industry standards. 7 | 8 | 9 | ## Used Technologies 10 | 11 | - __Java JDK 19__ : 12 | Development of the project has been carried out using the Java programming language. Java was chosen for its platform independence and powerful object-oriented programming features. 13 | 14 | - __Swing (UI Library)__ : 15 | Java Swing framework has been utilized for developing the user interface (UI). Swing offers a wide range of components for Java-based desktop applications. 16 | 17 | - __PostgreSQL__ : 18 | PostgreSQL has been chosen as the database management system. PostgreSQL provides a reliable, open-source, and scalable relational database management system. The project stores customer information, hotel, and reservation data in a PostgreSQL database. 19 | 20 | - __JDBC (Java Database Connectivity)__ : 21 | JDBC, a standard API for accessing databases in Java applications, has been employed. Through this API, the project connects to the PostgreSQL database and performs operations. 22 | 23 | - __IntelliJ IDEA__ : 24 | IntelliJ IDEA has been used for the development and management of the project. IntelliJ IDEA is an integrated development environment that facilitates Java development and enhances productivity. 25 | 26 | ## Project Structure 27 | The project is comprised of five main packages: 28 | 29 | 30 | 31 | ## Project File Directory 32 | ```sh 33 | TourismAgency/ 34 | | 35 | ├── business/ ---> Classes containing business logic operations. 36 | │ └── 37 | │ 38 | ├── core/ ---> Fundamental helper classes and tools. 39 | │ └── (...) 40 | │ 41 | ├── dao/ ---> Data Access Objects managing database operations. 42 | │ └── (...) 43 | │ 44 | ├── entity/ ---> Entity classes representing database tables. 45 | | └── (...) 46 | | 47 | ├── view/ ---> Classes containing User Interface (UI) components 48 | | └── (...) 49 | | 50 | ├── App 51 | | 52 | └── README.md 53 | ```` 54 | 55 | __*DAO (Data Access Object) package:*__
This package handles database operations. It contains code that directly interacts with the database and abstracts data access. This way, database operations are isolated from other layers, making changes easier. 56 | 57 | __*Business package:*__
This is the layer where business logic operations are performed. Data retrieved from the database is processed, business rules are applied, and results are generated. For example, operations like customer reservations, tour planning, etc., are carried out in this layer. 58 | 59 | __*Entity package:*__
It contains data models that map to database tables. These models are used to represent data in the database. For instance, classes representing a customer or a tour reservation can be found in this package. 60 | 61 | __*Core package:*__
This package includes general utility functions and code intended for general use across different layers of the application. 62 | 63 | __*View package:*__
This package includes code related to the user interface (UI). It provides data presentation to the user and manages user interaction with the application. For example, screens where users can view tour reservations or make new tour reservations can be found in this package. 64 | 65 | 66 | # Features 67 | 68 | ## Hotel Management 69 | - Create, view, edit, and delete hotel entries. 70 | - Manage hotel information including updates and deletions. 71 | 72 | ## Room Management 73 | - Add, view, edit, and delete room entries within hotels. 74 | - Control room details such as availability, pricing, and features. 75 | 76 | ## Reservation Management 77 | - Make, view, update, and cancel reservations seamlessly. 78 | - Efficiently manage reservation information and status updates. 79 | 80 | ## User Management 81 | - Add, view, update, and delete user profiles. 82 | - Assign roles such as "admin" and "employee" to users for access control and privileges. 83 | 84 | 85 | 86 | ## Example Use Cases 87 | ### Adding a New Hotel: 88 | **1.** Navigate to the main screen and click on the "Add Hotel" button.
89 | **2.** Fill in the required details for the new hotel.
90 | **3.** Save the information, and the new hotel will be added to the system.
91 | **4.** Visit the "Hotel List" tab to view the newly added hotels.
92 | 93 | ### Adding a New Room: 94 | **1.** Access the "Add Room" tab within the application.
95 | **2.** Select the desired hotel to add the room to.
96 | **3.** Enter the relevant details for the new room, such as room type, availability, and pricing.
97 | **4.** Save the changes, and the new room will be added to the selected hotel.
98 | 99 | ### Making a Reservation: 100 | **1.** Go to the "Make Reservation" tab in the application.
101 | **2.** Choose the hotel where you want to make the reservation.
102 | **3.** Select the desired room type and specify the reservation details such as check-in and check-out dates.
103 | **4.** Confirm the reservation, and it will be successfully made in the system.
104 | 105 | ### User Creation: 106 | **1.** Access the "Users" tab within the application.
107 | **2.** Click on the option to create a new user profile.
108 | **3.** Enter the user's details and assign an appropriate role, either "admin" or "employee".
109 | **4.** Save the changes, and the new user will be added to the system with the assigned role.
110 | 111 | ### Reservation Update/Delete: 112 | **1.** Navigate to the "Reservations" tab to view existing reservations.
113 | **2.** Select the reservation you want to update or delete.
114 | **3.** Make the necessary modifications to the reservation details or choose to delete it entirely.
115 | **4.** Save the changes, and the reservation will be updated or removed from the system.
116 | 117 | 118 | ## Project Promotional Video 119 | [https://www.youtube.com/watch?v=MCWyehN0A_E](https://youtu.be/EmSsMbuue9A) 120 | 121 | 122 | ## Requirements 123 | - Java JDK 19 124 | - PostgreSQL database 125 | -------------------------------------------------------------------------------- /src/view/ReservationAddView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.ReservationManager; 4 | import business.RoomManager; 5 | import core.Helper; 6 | import entity.Reservation; 7 | import entity.Room; 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 | // ReservationAddView sınıfı, rezervasyon ekleme ve güncelleme arayüzünü temsil eder ve Layout sınıfından türetilmiştir. 17 | public class ReservationAddView extends Layout { 18 | 19 | // Arayüzdeki bileşenlerin tanımlandığı değişkenler. 20 | private JPanel container; 21 | private JTextField fld_reservation_hotel_name; 22 | private JTextField fld_reservation_address; 23 | private JTextField fld_reservation_star; 24 | private JRadioButton radio_carpark; 25 | private JRadioButton radio_concierge; 26 | private JRadioButton radio_wifi; 27 | private JRadioButton radio_spa; 28 | private JRadioButton radio_pool; 29 | private JRadioButton radio_room_service; 30 | private JRadioButton radio_fitness; 31 | private JTextField fld_roomType; 32 | private JTextField fld_pansiyonType; 33 | private JTextField fld_startDate; 34 | private JTextField fld_endDate; 35 | private JTextField fld_totalPrice; 36 | private JTextField fld_bedCapacity; 37 | private JTextField fld_meter; 38 | private JRadioButton radio_tv; 39 | private JRadioButton radio_gameConsole; 40 | private JRadioButton radio_projection; 41 | private JRadioButton radio_cashBox; 42 | private JRadioButton radio_minibar; 43 | private JTextField fld_guestName; 44 | private JTextField fld_guestPhone; 45 | private JTextField fld_guest_total_person; 46 | private JTextField fld_guestMail; 47 | private JButton btn_reservationSve; 48 | private JTextField fld_guestID; 49 | private JTextField fld_hotel_adult; 50 | private JTextField fld_hotel_child; 51 | private Reservation reservation; 52 | private ReservationManager reservationManager; 53 | private RoomManager roomManager; 54 | private Room room; 55 | private EmployeeView employeeView; 56 | 57 | // ReservationAddView sınıfının constructor'ı. Rezervasyon ve oda bilgileri ile başlatılır. 58 | public ReservationAddView(Reservation reservation, Room room, JFormattedTextField startDate, JFormattedTextField endDate, JTextField adult, JTextField child) { 59 | this.room = room; 60 | this.reservation = reservation; 61 | this.reservationManager = new ReservationManager(); 62 | this.add(container); 63 | this.guiInitilaze(1000, 700); 64 | this.roomManager = new RoomManager(); 65 | String strGuestNumber; 66 | LocalDate from; 67 | LocalDate to; 68 | double totalPrice; 69 | 70 | if (this.reservation.getId() != 0) { 71 | from = this.reservation.getReservation_start_date(); 72 | to = this.reservation.getReservation_end_date(); 73 | strGuestNumber = String.valueOf(this.reservation.getReservation_guest_number()); 74 | this.fld_guest_total_person.setText(strGuestNumber); 75 | this.fld_guestName.setText(this.reservation.getReservation_guest_name()); 76 | this.fld_guestID.setText(String.valueOf(this.reservation.getReservation_guest_id())); 77 | this.fld_guestMail.setText(this.reservation.getReservation_mail()); 78 | this.fld_guestPhone.setText(String.valueOf(this.reservation.getReservation_phone())); 79 | totalPrice = this.reservation.getReservation_total_price(); 80 | } else { 81 | from = LocalDate.parse(startDate.getText(), DateTimeFormatter.ofPattern("dd/MM/yyyy")); 82 | to = LocalDate.parse(endDate.getText(), DateTimeFormatter.ofPattern("dd/MM/yyyy")); 83 | if (child.getText().isEmpty()) { 84 | child.setText("0"); 85 | } 86 | if (adult.getText().isEmpty()) { 87 | adult.setText("0"); 88 | } 89 | int adultCount = Integer.parseInt(adult.getText()); 90 | int childCount = Integer.parseInt(child.getText()); 91 | int totalGuestNumber = adultCount + childCount; 92 | strGuestNumber = String.valueOf(totalGuestNumber); 93 | this.fld_guest_total_person.setText(strGuestNumber); 94 | long daysBetween = ChronoUnit.DAYS.between(from, to); 95 | double adultPrice = room.getRoom_adult_price(); 96 | double childPrice = room.getRoom_child_price(); 97 | totalPrice = (adultPrice * adultCount + childPrice * childCount) * daysBetween; 98 | } 99 | 100 | this.fld_reservation_hotel_name.setText(room.getHotel().getName()); 101 | this.fld_reservation_address.setText(room.getHotel().getAddress()); 102 | this.fld_reservation_star.setText(room.getHotel().getStar()); 103 | this.fld_roomType.setText(room.getRoom_type()); 104 | this.fld_pansiyonType.setText(room.getPencion().getPencionType()); 105 | this.fld_startDate.setText(from.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))); 106 | this.fld_endDate.setText(to.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))); 107 | this.fld_totalPrice.setText(String.valueOf(totalPrice)); 108 | this.fld_meter.setText(String.valueOf(room.getRoom_square_meter())); 109 | this.fld_bedCapacity.setText(String.valueOf(room.getRoom_bed_capacity())); 110 | 111 | this.radio_concierge.setSelected(room.getHotel().isConcierge()); 112 | this.radio_carpark.setSelected(room.getHotel().isCar_park()); 113 | this.radio_fitness.setSelected(room.getHotel().isFitness()); 114 | this.radio_wifi.setSelected(room.getHotel().isWifi()); 115 | this.radio_spa.setSelected(room.getHotel().isSpa()); 116 | this.radio_pool.setSelected(room.getHotel().isPool()); 117 | this.radio_room_service.setSelected(room.getHotel().isRoom_service()); 118 | this.radio_tv.setSelected(room.isRoom_television()); 119 | this.radio_gameConsole.setSelected(room.isRoom_game_console()); 120 | this.radio_projection.setSelected(room.isRoom_projection()); 121 | this.radio_minibar.setSelected(room.isRoom_minibar()); 122 | 123 | btn_reservationSve.addActionListener(new ActionListener() { 124 | @Override 125 | public void actionPerformed(ActionEvent e) { 126 | JTextField[] checkFieldList = {fld_guestName, fld_guestID, fld_guestMail, fld_guestPhone, fld_startDate, fld_endDate}; 127 | if (Helper.isFieldListEmpty(checkFieldList)) { 128 | Helper.showMsg("fill"); 129 | } else { 130 | int totalGuests = Integer.parseInt(fld_guest_total_person.getText()); 131 | if (totalGuests == 0) { 132 | Helper.showMsg("Misafir sayısı en az 1 olmalıdır."); 133 | } else { 134 | reservation.setReservation_room_id(room.getRoom_id()); 135 | reservation.setReservation_guest_name(fld_guestName.getText()); 136 | reservation.setReservation_guest_id(Integer.parseInt(fld_guestID.getText())); 137 | reservation.setReservation_mail(fld_guestMail.getText()); 138 | reservation.setReservation_phone(Integer.parseInt(fld_guestPhone.getText())); 139 | reservation.setReservation_start_date(LocalDate.parse(startDate.getText(), DateTimeFormatter.ofPattern("dd/MM/yyyy"))); 140 | reservation.setReservation_end_date(LocalDate.parse(endDate.getText(), DateTimeFormatter.ofPattern("dd/MM/yyyy"))); 141 | reservation.setReservation_total_price((int) totalPrice); 142 | reservation.setReservation_guest_number(Integer.parseInt(strGuestNumber)); 143 | boolean result; 144 | if (reservation.getId() != 0) { 145 | result = reservationManager.update(reservation); 146 | dispose(); 147 | } else { 148 | result = reservationManager.save(reservation, totalGuests); 149 | room.setRoom_stock(room.getRoom_stock() - 1); 150 | roomManager.updateStock(room); 151 | dispose(); 152 | } 153 | if (result) { 154 | Helper.showMsg("done"); 155 | } else { 156 | Helper.showMsg("error"); 157 | } 158 | } 159 | } 160 | } 161 | }); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /src/view/HotelAddView.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 | -------------------------------------------------------------------------------- /.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/view/RoomAddView.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 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | -------------------------------------------------------------------------------- /src/view/EmployeeView.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 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | -------------------------------------------------------------------------------- /src/view/ReservationAddView.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 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 |
455 | --------------------------------------------------------------------------------