├── images ├── .gitignore ├── .idea ├── .gitignore ├── misc.xml ├── libraries │ └── postgresql_42_7_3.xml ├── modules.xml └── uiDesigner.xml ├── TurizmAcente-master ├── .idea │ ├── .gitignore │ ├── vcs.xml │ ├── libraries │ │ └── postgresql_42_7_3.xml │ ├── misc.xml │ ├── modules.xml │ └── uiDesigner.xml ├── src │ ├── admin.png │ ├── patika.png │ ├── Main.java │ ├── core │ │ ├── ComboItem.java │ │ ├── Db.java │ │ └── Helper.java │ ├── entity │ │ ├── Types.java │ │ ├── User.java │ │ ├── Season.java │ │ ├── Hotel.java │ │ ├── Property.java │ │ ├── Room.java │ │ └── Reser.java │ ├── business │ │ ├── TypeManager.java │ │ ├── SeasonManager.java │ │ ├── HotelManager.java │ │ ├── RoomManager.java │ │ ├── UserManager.java │ │ ├── PropertyManager.java │ │ └── ReserManager.java │ ├── view │ │ ├── UserManagementView.java │ │ ├── LoginView.java │ │ ├── RevervationUpdateView.java │ │ ├── UserManagementView.form │ │ ├── Layout.java │ │ ├── AdminView.java │ │ ├── LoginView.form │ │ ├── AdminView.form │ │ ├── GuestInfoAddView.java │ │ ├── ReservationAdd.java │ │ ├── RevervationUpdateView.form │ │ └── HotelAddView.java │ └── dao │ │ ├── UserDao.java │ │ ├── RoomDao.java │ │ ├── TypeDao.java │ │ ├── HotelDao.java │ │ ├── ReserDao.java │ │ ├── SeasonDao.java │ │ └── PropertyDao.java ├── postgresql-42.7.3.jar ├── .gitignore ├── TurizmAcente.iml └── TurizmAcente-master.iml ├── tourismagencydb ├── taGirisEkranı.png ├── taOdaEklemeEkran.png ├── taOtelEklemeEkran.png ├── taOtelYönetimEkran.png ├── taYöeneticiPaneli.png ├── taOtelDuzenlemeEkranaı.png ├── taRezerGuncellemeEkranı.png ├── taRezervasonBilgiEkranı.png ├── taMisafirBilgiKayıtEkranı.png ├── taRezervasyonEklemeEkran.png ├── taOdaYönetimveOdaAramaEkranı.png ├── taKullanıcıEklemeDuzuenlemeEkrana.png ├── TurizmAcente-master.iml ├── README └── Requirements_and_Answers /images: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Project exclude paths 2 | /out/ -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /TurizmAcente-master/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /tourismagencydb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/tourismagencydb -------------------------------------------------------------------------------- /taGirisEkranı.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taGirisEkranı.png -------------------------------------------------------------------------------- /taOdaEklemeEkran.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taOdaEklemeEkran.png -------------------------------------------------------------------------------- /taOtelEklemeEkran.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taOtelEklemeEkran.png -------------------------------------------------------------------------------- /taOtelYönetimEkran.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taOtelYönetimEkran.png -------------------------------------------------------------------------------- /taYöeneticiPaneli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taYöeneticiPaneli.png -------------------------------------------------------------------------------- /taOtelDuzenlemeEkranaı.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taOtelDuzenlemeEkranaı.png -------------------------------------------------------------------------------- /taRezerGuncellemeEkranı.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taRezerGuncellemeEkranı.png -------------------------------------------------------------------------------- /taRezervasonBilgiEkranı.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taRezervasonBilgiEkranı.png -------------------------------------------------------------------------------- /taMisafirBilgiKayıtEkranı.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taMisafirBilgiKayıtEkranı.png -------------------------------------------------------------------------------- /taRezervasyonEklemeEkran.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taRezervasyonEklemeEkran.png -------------------------------------------------------------------------------- /taOdaYönetimveOdaAramaEkranı.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taOdaYönetimveOdaAramaEkranı.png -------------------------------------------------------------------------------- /TurizmAcente-master/src/admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/TurizmAcente-master/src/admin.png -------------------------------------------------------------------------------- /TurizmAcente-master/src/patika.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/TurizmAcente-master/src/patika.png -------------------------------------------------------------------------------- /taKullanıcıEklemeDuzuenlemeEkrana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/taKullanıcıEklemeDuzuenlemeEkrana.png -------------------------------------------------------------------------------- /TurizmAcente-master/postgresql-42.7.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokselgurluk/TurizmAcente-master/HEAD/TurizmAcente-master/postgresql-42.7.3.jar -------------------------------------------------------------------------------- /TurizmAcente-master/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/libraries/postgresql_42_7_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TurizmAcente-master/.idea/libraries/postgresql_42_7_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TurizmAcente-master/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /TurizmAcente-master/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TurizmAcente-master/.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 -------------------------------------------------------------------------------- /TurizmAcente-master/src/Main.java: -------------------------------------------------------------------------------- 1 | import business.UserManager; 2 | import core.Helper; 3 | import view.AdminView; 4 | import view.HotelView; 5 | import view.LoginView; 6 | 7 | public class Main { 8 | 9 | 10 | 11 | public static void main(String[] args) { 12 | Helper.setTheme(); 13 | LoginView loginView = new LoginView(); 14 | //UserManager userManager =new UserManager(); 15 | //HotelView employee = new HotelView(userManager.findByLogin("a","a")); 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /TurizmAcente-master/TurizmAcente.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /TurizmAcente-master.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /TurizmAcente-master/TurizmAcente-master.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/core/ComboItem.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | public class ComboItem { 4 | 5 | private int key; 6 | private String value; 7 | 8 | public ComboItem(int key, String value){ 9 | this.key = key; 10 | this.value = value; 11 | } 12 | 13 | public int getKey() { 14 | return key; 15 | } 16 | 17 | public void setKey(int key) { 18 | this.key = key; 19 | } 20 | 21 | public String getValue() { 22 | return value; 23 | } 24 | 25 | public void setValue(String value) { 26 | this.value = value; 27 | } 28 | 29 | public String toString(){ 30 | return this.value; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /TurizmAcente-master/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 | private static Db instance = null; 9 | private Connection connection = null; 10 | private final String DB_URL = "jdbc:postgresql://localhost/tourismagencydb"; 11 | private final String DB_USERNAME = "postgres"; 12 | private final String DB_PASS = "postgres"; 13 | 14 | 15 | private Db() { 16 | try { 17 | this.connection = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASS); 18 | } catch (SQLException e) { 19 | System.out.println(e.getMessage()); 20 | } 21 | 22 | 23 | } 24 | 25 | public Connection getConnection() { 26 | return connection; 27 | } 28 | 29 | public static Connection getInstance() { 30 | 31 | try { 32 | if (instance == null || instance.getConnection().isClosed()) { 33 | instance = new Db(); 34 | 35 | } 36 | } catch (SQLException e) { 37 | System.out.println(e.getMessage()); 38 | } 39 | return instance.getConnection(); 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/entity/Types.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class Types { 4 | private int typeId; 5 | private int hotel_id; 6 | private String typeName; 7 | 8 | 9 | public Types() { 10 | } 11 | 12 | public Types(int typeId,String typeName, int hotelId) { 13 | this.typeId = typeId; 14 | this.typeName = typeName; 15 | this.hotel_id = hotelId; 16 | } 17 | 18 | public int getTypeId() { 19 | return typeId; 20 | } 21 | 22 | public void setTypeId(int typeId) { 23 | this.typeId = typeId; 24 | } 25 | 26 | public int getHotel_id() { 27 | return hotel_id; 28 | } 29 | 30 | public void setHotel_id(int hotel_id) { 31 | this.hotel_id = hotel_id; 32 | } 33 | 34 | public String getTypeName() { 35 | return typeName; 36 | } 37 | 38 | public void setTypeName(String typeName) { 39 | this.typeName = typeName; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Types{" + 45 | "typeId=" + typeId + 46 | ", hotel_id=" + hotel_id + 47 | ", typeName='" + typeName + '\'' + 48 | '}'; 49 | } 50 | } -------------------------------------------------------------------------------- /TurizmAcente-master/src/entity/User.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class User { 4 | private int userId; 5 | private String username; 6 | private String password; 7 | private Role role; 8 | 9 | 10 | 11 | public enum Role { 12 | admin, 13 | employee 14 | } 15 | public User() { 16 | } 17 | public User(String username, String password, Role role) { 18 | this.username = username; 19 | this.password = password; 20 | this.role = role; 21 | } 22 | 23 | public User(int userId, String username, String password, Role role) { 24 | this.userId = userId; 25 | this.username = username; 26 | this.password = password; 27 | this.role = role; 28 | } 29 | 30 | public int getUserId() { 31 | return userId; 32 | } 33 | 34 | public void setUserId(int userId) { 35 | this.userId = userId; 36 | } 37 | 38 | public String getUsername() { 39 | return username; 40 | } 41 | 42 | public void setUsername(String username) { 43 | this.username = username; 44 | } 45 | 46 | public String getPassword() { 47 | return password; 48 | } 49 | 50 | public void setPassword(String password) { 51 | this.password = password; 52 | } 53 | 54 | public Role getRole() { 55 | return role; 56 | } 57 | 58 | public void setRole(Role role) { 59 | this.role = role; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "User{" + 65 | "id=" + userId + 66 | ", username='" + username + '\'' + 67 | ", password='" + password + '\'' + 68 | ", role='" + role + '\'' + 69 | '}'; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/business/TypeManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.TypeDao; 5 | import entity.Types; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class TypeManager { 11 | private TypeDao typeDao ; 12 | public TypeManager() { 13 | // this.con = Db.getInstance(); 14 | this.typeDao = new TypeDao(); 15 | 16 | } 17 | 18 | 19 | public ArrayList findAll(int id){ 20 | return this.typeDao.findAll(id); 21 | } 22 | 23 | 24 | public ArrayListgetForTable(int size,int id){ 25 | ArrayList brandRowList = new ArrayList<>(); 26 | for(Types obj : this.findAll(id)){ 27 | Object[] rowObject = new Object[size]; 28 | int i = 0; 29 | rowObject[i++] = obj.getHotel_id(); 30 | rowObject[i++] = obj.getTypeName(); 31 | brandRowList.add(rowObject); 32 | 33 | } 34 | return brandRowList; 35 | } 36 | 37 | public Types getById(int id) { 38 | return this.typeDao.getById(id); 39 | } 40 | public String getByTypeId(int id) { 41 | return this.typeDao.getByTypeId(id); 42 | } 43 | 44 | 45 | 46 | public boolean update (int hotelId, List rightList){ 47 | if(hotelId ==0 ){ 48 | Helper.showMsg(" ID bulunamadı"); 49 | return false; 50 | } 51 | return this.typeDao.update(hotelId,rightList); 52 | } 53 | public boolean save(int hotelId, List rightList){ 54 | return this.typeDao.save(hotelId,rightList); 55 | } 56 | public boolean deleteType(int hotelId,List typeNames ){ 57 | if(hotelId ==0 ){ 58 | Helper.showMsg(" ID bulunamadı"); 59 | return false; 60 | } 61 | return this.typeDao.deleteType(hotelId,typeNames); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 📹 Projenin videoya alınmış hali:https://www.youtube.com/watch?v=nC24uTr16Zs 2 | 3 | Turizm Acente Sistemi Projesi 4 | Bu proje, bir turizm acentesi için geliştirilmiş bir sistemdir. Projede acente çalışanlarının otel ve oda yönetimini sağlaması, rezervasyonları takip etmesi ve müşterilere hizmet vermesi amaçlanmıştır. 5 | 6 | Proje Amaçları 7 | Acenta çalışanlarının otel ve oda yönetimini sağlamak. 8 | Rezervasyonları kaydetmek, güncellemek, silmek ve takip etmek. 9 | Otel ve oda bilgilerini yönetmek. 10 | Müşterilere uygun otel ve oda seçenekleri sunmak. 11 | Proje Özellikleri 12 | Otel yönetimi: Otel ekleme, güncelleme, silme. 13 | Oda yönetimi: Oda ekleme, güncelleme, silme. 14 | Rezervasyon yönetimi: Rezervasyon ekleme, güncelleme, silme. 15 | Fiyatlandırma: Oda fiyatlarını belirleme ve rezervasyonlara göre fiyat hesaplama. 16 | Stoğu yönetme: Oda stoklarını dönem bazında takip etme. 17 | Kurulum 18 | Projenin çalışması için aşağıdaki adımları takip edin: 19 | 20 | Veritabanı Oluşturma: MySQL veya PostgreSQL veritabanı üzerinde projeye ait tabloları oluşturun. 21 | Veri Doldurma: Her tabloya en az 5 veri ekleyerek örnek veriler oluşturun. 22 | Bağlantı Ayarları: Veritabanı bağlantı bilgilerini db.properties dosyasına tanımlayın. 23 | Proje Derleme: Proje dosyalarını derleyin ve çalıştırın. 24 | Kullanım 25 | Projeyi çalıştırdıktan sonra aşağıdaki işlemleri gerçekleştirebilirsiniz: 26 | 27 | Acenta çalışanı girişi yapın. 28 | Otelleri listeleyin, yeni otel ekleyin veya mevcut otelleri güncelleyin/silin. 29 | Odaları listeleyin, yeni oda ekleyin veya mevcut odaları güncelleyin/silin. 30 | Rezervasyonları listeleyin, yeni rezervasyon ekleyin veya mevcut rezervasyonları güncelleyin/silin. 31 | Fiyatları belirleyin ve rezervasyonlara göre fiyat hesaplayın. 32 | Stoğu yönetin ve rezervasyonlarla ilişkilendirin. 33 | Proje değerlendirme kriterleri ve puanlama ölçütleri için Değerlendirme Kriterleri bölümünü inceleyin. 34 | 35 | Teknolojiler 36 | Java 37 | Swing GUI 38 | PostgreSQL veritabanı 39 | 40 | Katkıda Bulunanlar 41 | Rohat Doganer 42 | 43 | Lisans 44 | 45 | 46 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/business/SeasonManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.SeasonDao; 5 | import entity.Property; 6 | import entity.Season; 7 | 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class SeasonManager { 13 | private SeasonDao seasonDao ; 14 | public SeasonManager() { 15 | // this.con = Db.getInstance(); 16 | this.seasonDao = new SeasonDao(); 17 | 18 | } 19 | 20 | public Season getById(int id) { 21 | return this.seasonDao.getById(id); 22 | } 23 | public Season getSeasonDate(int seasonId) { 24 | return this.seasonDao.getSeasonDate(seasonId); 25 | } 26 | 27 | 28 | public List getBySeasonList(int id) { 29 | return this.seasonDao.getBySeasonList(id); 30 | } 31 | public ArrayList findAll(int id){ 32 | return this.seasonDao.findAll(id); 33 | } 34 | 35 | public ArrayListgetForTable(int size,int id){ 36 | ArrayList brandRowList = new ArrayList<>(); 37 | for(Season obj : this.findAll(id)){ 38 | Object[] rowObject = new Object[size]; 39 | int i = 0; 40 | 41 | rowObject[i++] = obj.getHotel_id(); 42 | rowObject[i++] = obj.getSeason_start(); 43 | rowObject[i++] = obj.getSeason_end(); 44 | rowObject[i++] = obj.getSeasonName(); 45 | 46 | brandRowList.add(rowObject); 47 | 48 | } 49 | return brandRowList; 50 | } 51 | public boolean save(List seasons, int hotelId){ 52 | return this.seasonDao.save(seasons,hotelId); 53 | } 54 | 55 | public boolean update (Season season){ 56 | if(season.getHotel_id()==0 ){ 57 | Helper.showMsg(" ID bulunamadı"); 58 | return false; 59 | } 60 | return this.seasonDao.update(season); 61 | } 62 | 63 | 64 | public Season getBySeason(int id) { 65 | return this.seasonDao.getBySeason(id); 66 | } 67 | /* public boolean deleteType(int hotelId,List typeNames ){ 68 | if(hotelId ==0 ){ 69 | Helper.showMsg(" ID bulunamadı"); 70 | return false; 71 | } 72 | return this.seasonDao.deleteType(hotelId,typeNames); 73 | }*/ 74 | } 75 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/business/HotelManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | 4 | import core.Helper; 5 | import dao.HotelDao; 6 | import entity.Hotel; 7 | 8 | import java.sql.ResultSet; 9 | import java.sql.SQLException; 10 | import java.sql.Statement; 11 | import java.util.ArrayList; 12 | 13 | public class HotelManager { 14 | private HotelDao hotelDao; 15 | public HotelManager(){ 16 | this.hotelDao = new HotelDao(); 17 | } 18 | public ArrayList findAll(){return this.hotelDao.findAll();} 19 | 20 | public ArrayList getHotelCity(String hotelName){return this.hotelDao.getHotelCity(hotelName);} 21 | 22 | public Hotel getById(int id) { 23 | return this.hotelDao.getById(id); 24 | } 25 | public int saveAndGetHotelId(Hotel hotel){ 26 | return this.hotelDao.saveAndGetHotelId(hotel); 27 | } 28 | 29 | public boolean update (Hotel hotel){ 30 | if(this.getById(hotel.getHotel_id())==null){ 31 | Helper.showMsg(hotel.getHotel_id()+" ID bulunamadı"); 32 | return false; 33 | } 34 | return this.hotelDao.update(hotel); 35 | } 36 | public boolean delete(int id ){ 37 | 38 | if(this.getById(id)==null){ 39 | Helper.showMsg(id+" ID kayıtlı model bulunamadı"); 40 | return false; 41 | } 42 | return this.hotelDao.delete(id); 43 | } 44 | 45 | 46 | //Otel ID", "Otel Adı", "Şehir", "Bölge", "Adres", "E-posta", "Telefon", "Yıldız Derecesi 47 | public ArrayList getForTable(int size,ArrayListhotelList){ 48 | ArrayList hotelArrayList = new ArrayList<>(); 49 | for(Hotel hotel : hotelList){ 50 | int i = 0; 51 | Object[] rowObject = new Object[size]; 52 | rowObject[i++] = hotel.getHotel_id(); 53 | rowObject[i++] = hotel.getHotel_name(); 54 | rowObject[i++] = hotel.getHotel_city(); 55 | rowObject[i++] = hotel.getHotel_district(); 56 | rowObject[i++] = hotel.getHotel_fllAdres(); 57 | rowObject[i++] = hotel.getHotel_email(); 58 | rowObject[i++] = hotel.getHotel_phone(); 59 | rowObject[i++] = hotel.getHotel_star(); 60 | hotelArrayList.add(rowObject); 61 | 62 | } 63 | return hotelArrayList; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/entity/Season.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import java.time.LocalDate; 4 | 5 | public class Season { 6 | 7 | private int seasonId; 8 | private LocalDate season_start; 9 | private LocalDate season_end; 10 | private int hotel_id; 11 | private String seasonName; 12 | 13 | /* // Sezon türlerine göre başlangıç ve bitiş tarihlerini tutacak ekstra alanlar 14 | private LocalDate summer_start; 15 | private LocalDate summer_end; 16 | private LocalDate winter_start; 17 | private LocalDate winter_end; 18 | 19 | // Getter ve Setter metotları...*/ 20 | 21 | public Season() { 22 | } 23 | 24 | public Season(int seasonId, LocalDate season_start, LocalDate season_end, String seasonName , int hotel_id) { 25 | this.seasonId = seasonId; 26 | this.season_start = season_start; 27 | this.season_end = season_end; 28 | this.seasonName = seasonName; 29 | this.hotel_id = hotel_id; 30 | } 31 | 32 | 33 | public String getSeasonName() { 34 | return seasonName; 35 | } 36 | 37 | public void setSeasonName(String seasonName) { 38 | this.seasonName = seasonName; 39 | } 40 | 41 | public int getSeasonId() { 42 | return seasonId; 43 | } 44 | 45 | public void setSeasonId(int seasonId) { 46 | this.seasonId = seasonId; 47 | } 48 | 49 | public LocalDate getSeason_start() { 50 | return season_start; 51 | } 52 | 53 | public void setSeason_start(LocalDate season_start) { 54 | this.season_start = season_start; 55 | } 56 | 57 | public int getHotel_id() { 58 | return hotel_id; 59 | } 60 | 61 | public void setHotel_id(int hotel_id) { 62 | this.hotel_id = hotel_id; 63 | } 64 | 65 | 66 | 67 | public LocalDate getSeason_end() { 68 | return season_end; 69 | } 70 | 71 | public void setSeason_end(LocalDate season_end) { 72 | this.season_end = season_end; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return "Season{" + 78 | "seasonId=" + seasonId + 79 | ", season_start=" + season_start + 80 | ", season_end=" + season_end + 81 | ", hotel_id=" + hotel_id + 82 | ", seasonName='" + seasonName + '\'' + 83 | 84 | '}'; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/UserManagementView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.RoomManager; 4 | import business.UserManager; 5 | import core.Helper; 6 | import entity.Room; 7 | import entity.User; 8 | 9 | import javax.swing.*; 10 | 11 | public class UserManagementView extends Layout{ 12 | private JPanel container; 13 | private JTextField fld_mng_name; 14 | private JTextField fld_mng_pass; 15 | private JComboBoxcmb_mng_role; 16 | private JButton btn_mng_save; 17 | // private JComboBox cmb_brand; 18 | 19 | private User user ; 20 | private UserManager userManager; 21 | 22 | 23 | public UserManagementView(User user) { 24 | this.userManager=new UserManager(); 25 | this.user=user; 26 | 27 | add(container); 28 | this.guiInitilaze(400,400); 29 | 30 | if(user != null){ 31 | fld_mng_name.setText(user.getUsername()); 32 | fld_mng_pass.setText(user.getPassword()); 33 | this.cmb_mng_role.setModel(new DefaultComboBoxModel<>(User.Role.values())); 34 | } 35 | this.cmb_mng_role.setModel(new DefaultComboBoxModel<>(User.Role.values())); 36 | btn_mng_save.addActionListener(e -> { 37 | if(Helper.isFieldListEmpty(new JTextField[]{this.fld_mng_name,this.fld_mng_pass,})){ 38 | Helper.showMsg("fill"); 39 | }else{ 40 | //ComboItem selectedBrand = (ComboItem) cmb_mng_role.getSelectedItem(); 41 | boolean result= false ; 42 | if (this.user != null){ 43 | this.user.setUsername(fld_mng_name.getText()); 44 | this.user.setPassword(fld_mng_pass.getText()); 45 | this.user.setRole((User.Role) cmb_mng_role.getSelectedItem()); 46 | result = this.userManager.update(this.user); 47 | System.out.println("update kısmına gırdi"); 48 | }else{ 49 | //result=this.userManager.save(this.user); 50 | User obj =new User(fld_mng_name.getText(),fld_mng_pass.getText(), (User.Role) cmb_mng_role.getSelectedItem()); 51 | result =this.userManager.save(obj); 52 | } 53 | if (result){ 54 | Helper.showMsg("done"); 55 | dispose(); 56 | }else{ 57 | Helper.showMsg("error"); 58 | } 59 | 60 | } 61 | 62 | 63 | }); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/business/RoomManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.RoomDao; 5 | import entity.Room; 6 | 7 | import java.util.ArrayList; 8 | 9 | 10 | public class RoomManager { 11 | private HotelManager hotelManager; 12 | private SeasonManager seasonManager ; 13 | private TypeManager typeManager; 14 | private final RoomDao roomDao ; 15 | public RoomManager() { 16 | // this.con = Db.getInstance(); 17 | this.roomDao = new RoomDao(); 18 | this.hotelManager =new HotelManager(); 19 | this.seasonManager = new SeasonManager(); 20 | this.typeManager = new TypeManager(); 21 | 22 | } 23 | public Room getById(int id) { 24 | return this.roomDao.getById(id); 25 | } 26 | 27 | 28 | public ArrayList findAll(){return this.roomDao.findAll();} 29 | 30 | public int save(Room room){ 31 | return this.roomDao.save(room); 32 | } 33 | 34 | public boolean stockUpdate(Room room,int num){ 35 | return this.roomDao.stockUpdate(room,num); 36 | } 37 | 38 | public boolean delete(int id ){ 39 | 40 | if(this.getById(id)==null){ 41 | Helper.showMsg(id+" ID kayıtlı model bulunamadı"); 42 | return false; 43 | } 44 | return this.roomDao.delete(id); 45 | } 46 | 47 | public ArrayList getForTable(int size, ArrayListroomList){ 48 | ArrayList hotelArrayList = new ArrayList<>(); 49 | for(Room room : roomList){ 50 | int i = 0; 51 | Object[] rowObject = new Object[size]; 52 | rowObject[i++] = room.getId(); 53 | rowObject[i++] = hotelManager.getById(room.getHotelId()).getHotel_name(); 54 | rowObject[i++] = hotelManager.getById(room.getHotelId()).getHotel_city(); 55 | rowObject[i++] = room.getRoomType(); 56 | rowObject[i++] = room.getStock(); 57 | rowObject[i++] = seasonManager.getSeasonDate(room.getSeasonId()).getSeason_start()+ " - " + seasonManager.getSeasonDate(room.getSeasonId()).getSeason_end(); 58 | rowObject[i++] = room.getAdultPrice(); 59 | rowObject[i++] = room.getChildPrice(); 60 | rowObject[i++] = typeManager.getByTypeId(room.getHotelTypeId()); 61 | hotelArrayList.add(rowObject); 62 | 63 | } 64 | return hotelArrayList; 65 | } 66 | 67 | public ArrayList searchForRooms(String strt_date, String fnsh_date,String searchCity,String hotelName, int adultNum,int childNum){ 68 | 69 | return this.roomDao.searchForRooms(strt_date,fnsh_date,searchCity,hotelName,adultNum,childNum);} 70 | } 71 | -------------------------------------------------------------------------------- /TurizmAcente-master/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.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | 11 | public class LoginView extends Layout { 12 | private JPanel container; 13 | private JTextField fld_user_name; 14 | private JPasswordField fld_password; 15 | private JButton btn_login; 16 | private JCheckBox chk_show_pass; 17 | 18 | private final UserManager userManager; 19 | 20 | private User user; 21 | 22 | 23 | public LoginView() { 24 | 25 | this.userManager=new UserManager(); 26 | 27 | 28 | add(container); 29 | this.guiInitilaze(550,300); 30 | this.setVisible(true); 31 | 32 | btn_login.addActionListener(e -> { 33 | 34 | JTextField[] checkFieldList ={this.fld_user_name,this.fld_password}; 35 | if(Helper.isFieldListEmpty(checkFieldList)){ 36 | Helper.showMsg("fill"); 37 | }else { 38 | User loginUser = this.userManager.findByLogin(this.fld_user_name.getText(),this.fld_password.getText()); 39 | System.out.println("kulanıcı bilgisi: "+loginUser); 40 | if(loginUser== null){ 41 | Helper.showMsg("notFound"); 42 | }else { 43 | if( loginUser.getRole().toString().equals("admin")) { 44 | AdminView adminView = new AdminView(loginUser); 45 | //this.setVisible(false); 46 | dispose(); 47 | 48 | } 49 | if( loginUser.getRole().toString().equals("employee")) { 50 | HotelView employee = new HotelView(loginUser); 51 | //this.setVisible(false); 52 | dispose(); 53 | } 54 | } 55 | } 56 | 57 | }); 58 | 59 | chk_show_pass.addActionListener(new ActionListener() { 60 | @Override 61 | public void actionPerformed(ActionEvent e) { 62 | // Checkbox durumuna göre şifre alanının görünürlüğünü ayarla 63 | JCheckBox checkbox = (JCheckBox) e.getSource(); 64 | if (checkbox.isSelected()) { 65 | fld_password.setEchoChar((char) 0); // Şifre gösterilsin 66 | chk_show_pass.setText("Gizle"); 67 | } else { 68 | fld_password.setEchoChar('*'); // Şifre gizlensin 69 | chk_show_pass.setText("Göster"); 70 | } 71 | } 72 | }); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/RevervationUpdateView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.ReserManager; 4 | import core.Helper; 5 | import entity.Reser; 6 | 7 | import javax.swing.*; 8 | 9 | 10 | public class RevervationUpdateView extends Layout{ 11 | 12 | private JPanel container; 13 | private JPanel pnl_reservation; 14 | private JTextField fld_client_name; 15 | private JTextField fld_check_start_date; 16 | private JTextField fld_check_end_date; 17 | private JTextField fld_client_phone; 18 | private JTextField fld_client_mail; 19 | private JTextArea txtArea_client_note; 20 | private JTextField fld_reser_price; 21 | private JTextField fld_adult_num; 22 | private JTextField fld_child_num; 23 | private JButton btn_reser_update; 24 | private JPanel pnl_titile; 25 | private JPanel pnl_update; 26 | private Reser reser; 27 | private ReserManager reserManager; 28 | 29 | RevervationUpdateView(Reser reserSelectId){ 30 | this.reser = reserSelectId; 31 | this.reserManager = new ReserManager(); 32 | 33 | this.guiInitilaze(600,350); 34 | add(container); 35 | 36 | 37 | fld_adult_num.setText(reser.getAdultNumb()); 38 | fld_child_num.setText(reser.getChildNumb()); 39 | fld_check_start_date.setText(reser.getReserCheckInDdate()); 40 | fld_check_end_date.setText(reser.getReserCheckOutDate()); 41 | fld_reser_price.setText(reser.getTotalPrice()); 42 | 43 | 44 | 45 | btn_reser_update.addActionListener(e -> { 46 | JTextField[] checkFieldList = { 47 | this.fld_client_name, 48 | this.fld_client_phone, 49 | this.fld_client_mail, 50 | }; 51 | 52 | if (Helper.isFieldListEmpty(checkFieldList) || Helper.isAreaEmpty(txtArea_client_note)) { 53 | Helper.showMsg("fill"); 54 | } else { 55 | this.reser.setReserFllName(fld_client_name.getText()); 56 | this.reser.setReserPhone(fld_client_phone.getText()); 57 | this.reser.setReserEmail(fld_client_mail.getText()); 58 | this.reser.setReserNote(txtArea_client_note.getText()); 59 | 60 | if(this.reser.getId() != 0) { 61 | boolean isUpdate = (this.reserManager.update(this.reser)); 62 | if (isUpdate) { 63 | Helper.showMsg("done"); 64 | dispose(); 65 | } 66 | else{Helper.showMsg("error");} 67 | }else{ 68 | Helper.showMsg("ID bulunamadı"); 69 | } 70 | } 71 | }); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/business/UserManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Db; 4 | import core.Helper; 5 | import dao.UserDao; 6 | import entity.User; 7 | 8 | import java.sql.Connection; 9 | import java.sql.PreparedStatement; 10 | import java.sql.SQLException; 11 | import java.util.ArrayList; 12 | 13 | public class UserManager { 14 | // private Connection con; 15 | private final UserDao userDao ; 16 | public UserManager() { 17 | // this.con = Db.getInstance(); 18 | this.userDao = new UserDao(); 19 | 20 | } 21 | 22 | public User findByLogin(String username , String password){ 23 | return this.userDao.findByLogin(username,password); 24 | 25 | } 26 | public ArrayList findAll(){ 27 | 28 | return this.userDao.findAll(); 29 | } 30 | 31 | public ArrayList getForTable(int size,ArrayListuserList){ 32 | ArrayList userRoleList = new ArrayList<>(); 33 | for(User user : userList){ 34 | int i = 0; 35 | Object[] rowObject = new Object[size]; 36 | rowObject[i++] = user.getUserId(); 37 | rowObject[i++] = user.getUsername(); 38 | rowObject[i++] = user.getPassword(); 39 | rowObject[i++] = user.getRole(); 40 | userRoleList.add(rowObject); 41 | 42 | } 43 | return userRoleList; 44 | } 45 | 46 | public User getById(int id) { 47 | return this.userDao.getById(id); 48 | } 49 | 50 | /* String select ="SELECT * FROM public.user "; 51 | ArrayList whereList = new ArrayList<>(); 52 | if (!role.toString().equals(" ")){ 53 | whereList.add("user_role = " +role.toString() ); 54 | 55 | } 56 | String whereStr = String.join(" AND ",whereList); 57 | String query=select; 58 | if(whereStr.length() > 0){ 59 | query += " WHERE "+whereStr; 60 | 61 | } 62 | 63 | System.out.println(query);*/ 64 | public ArrayList searcForTable(User.Role role){ 65 | String query ="SELECT * FROM public.user WHERE user_role = '"+ role.toString()+ "'"; 66 | return this.userDao.selectByQuery(query); 67 | 68 | } 69 | 70 | public boolean save(User user){ 71 | if(this.getById(user.getUserId())!=null){ 72 | Helper.showMsg("error"); 73 | return false ; 74 | } 75 | return this.userDao.save(user); 76 | } 77 | 78 | public boolean update (User user){ 79 | if(this.getById(user.getUserId())==null){ 80 | Helper.showMsg(user.getUserId()+" ID bulunamadı"); 81 | return false; 82 | } 83 | return this.userDao.update(user); 84 | } 85 | 86 | public boolean delete(int id ){ 87 | 88 | if(this.getById(id)==null){ 89 | Helper.showMsg(id+" ID bulunamadı"); 90 | return false; 91 | } 92 | return this.userDao.delete(id); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/business/PropertyManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.HotelDao; 5 | import dao.PropertyDao; 6 | import entity.*; 7 | 8 | import java.sql.PreparedStatement; 9 | import java.sql.SQLException; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class PropertyManager { 14 | 15 | private HotelDao hotelDao; 16 | private PropertyDao propertyDao; 17 | private RoomManager roomManager; 18 | private Room room; 19 | 20 | 21 | 22 | public PropertyManager() { 23 | 24 | this.propertyDao = new PropertyDao(); 25 | this.room= new Room(); 26 | this.roomManager = new RoomManager(); 27 | } 28 | 29 | public Property getById(int id) { 30 | return this.propertyDao.getById(id); 31 | } 32 | 33 | public ArrayList getListByRoomID(int id){ 34 | return this.propertyDao.getListByRoomID(id); 35 | } 36 | public Property getByBedNum(int id) { 37 | return this.propertyDao.getByBedNum(id); 38 | } 39 | 40 | /* public ArrayList getPropertyList(int id) { 41 | return this.propertyDao.getPropertyList(id); 42 | }*/ 43 | /* public ArrayList findAllRoomProperty(int id){ 44 | return this.propertyDao.getListByRoomID(id); 45 | }*/ 46 | 47 | public String getRoomPropertyName(int id) { 48 | return this.propertyDao.getRoomPropertyName(id); 49 | } 50 | public ArrayListgetForTableRoomProperty(int size,int id){ 51 | ArrayList brandRowList = new ArrayList<>(); 52 | for(Property obj : this.getListByRoomID(id)){ 53 | Object[] rowObject = new Object[size]; 54 | int i = 0; 55 | rowObject[i++] = roomManager.getById(id).getRoomPrice(); 56 | rowObject[i++] = obj.getRoomAdultBedNum(); 57 | rowObject[i++] = obj.getRoomChildBedNum(); 58 | rowObject[i++] = roomManager.getById(id).getAdultPrice(); 59 | rowObject[i++] = roomManager.getById(id).getChildPrice(); 60 | rowObject[i++] = obj.getRoomArea(); 61 | rowObject[i++] = obj.getRoomProperty(); 62 | brandRowList.add(rowObject); 63 | 64 | } 65 | return brandRowList; 66 | } 67 | 68 | public boolean update(Property property) { 69 | if (this.getById(property.getPropertyID()) == null) { 70 | Helper.showMsg(property.getPropertyID() + " ID bulunamadı"); 71 | return false; 72 | } 73 | return this.propertyDao.update(property); 74 | } 75 | 76 | public boolean save(Property property,int hotelId){ 77 | return this.propertyDao.save(property,hotelId); 78 | } 79 | public boolean saveRoomProperty(Property property){ 80 | return this.propertyDao.saveRoomProperty(property); 81 | } 82 | 83 | public List getPropertyList(int hotelId) { 84 | return this.propertyDao.getPropertyList(hotelId); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Requirements_and_Answers: -------------------------------------------------------------------------------- 1 | Projede veritabanı kullanılmış ve DB bağlantı konfigürasyonu doğru bir şekilde yapılmış 2 | core klasörü db sınıfı 3 | 4 | Admin kullanıcı tipine, projede bahsedilen employee listeleme, ekleme, güncelleme, silme gibi işlemleri yapabilecek şekilde kodlama yapılmış mı? 5 | 6 | View >Admin View 7 | Acente çalışanına (employee) projede bahsedilen otel, sezon, pansiyon, otel özelliği, oda, oda özelliği listeleme, ekleme ve rezervasyon ekleme, silme gibi işlemleri yapacak şekilde kodlama yapılmış mı? 8 | 9 | view > HotelView 10 | 11 | Login işleminde kullanıcının kaydı olup olmadığı kontrol ediliyor mu, kaydı yoksa ya da hatalı giriş yapıldıysa kullanıcıya hatalı giriş mesajı veriliyor mu? 12 | 13 | view > admin view 14 | 15 | Acente personeli anlaşmalı olduğu otelleri sisteme otel adı, adres, E-posta, telefon, yıldız, tesis özellikleri bilgilerini girerek kaydedebiliyor mu? 16 | 17 | view > hotelView 18 | view > hotelAddView 19 | view > hotelUpdateView 20 | 21 | Otellerin sisteme eklenmesinde dönem yönetimi yapılmış mı 22 | 23 | view > hotelAddView > 100. satırbaslangıcı 24 | 25 | Otellerin sisteme eklenmesinde pansiyon tipi yönetimi yapılmış mı? 26 | 27 | view > RoomAdd > 132. satır 28 | 29 | Acente personeli sisteme kayıtlı otellere oda ekleyebiliyor mu? Oda eklerken oda tipi (Single, Double, Junior Suite, Suite vb.), oda özellikleri (Yatak Sayısı, Televizyon, Minibar vb.) ve stok miktarı girişi dikkate alınmış mı? 30 | 31 | view > RoomAdd 32 | 33 | Sisteme yeni eklenen odaların fiyatları, sezon, pansiyon tipi ve konaklayanların yetişkin/çocuk olma durumuna göre belirleniyor mu? 34 | 35 | view > RoomAdd >265. satır roomPriceCalcul() metodu 36 | 37 | Acente çalışanı, tarih aralığına, otel ismine, şehire göre odaları başarılı bir şekilde arayabiliyor mu? (4 puan) 38 | 39 | view > HotelView > 154. satır 40 | 41 | Arama sonucuna uygun otellerin bilgileri (adres, yıldız, otel imkanları vb) ve odaların bilgileri (giriş, çıkış tarihi, yetişkin, çocuk sayısı, yatak sayısı, varsa, mini bar, TV vb) kullanıcıya gösteriliyor mu? 42 | 43 | view > HotelView > loadRoomTable() ve loadRoomPropertiesTable(); metotları 44 | 45 | Misafir bilgisi, kalınacak gece sayısı ve oda fiyatına göre konaklamaya ait fiyat başarılı bir şekilde hesaplanıyor mu? 46 | 47 | view > ReservationAdd > 136.satır > btn_reser_price 48 | 49 | Acenta çalışanı müşterinin talebine uygun odayı müşteri bilgilerini girerek başarılı şekilde rezervasyon yapabiliyor mu? 50 | 51 | view > ReservationAdd > 199.satır btn_add_reservation 52 | 53 | Rezervasyon yapılan odanın stoğu azalıyor mu?(4 puan) 54 | 55 | view > ReservationAdd > 236.satır stockUpdate 56 | 57 | Acente çalışanları, sistem üzerinden yapılan rezervasyonları başarılı bir şekilde listeleye biliyor mu? 58 | 59 | view > HotelView > loadReserTable() metotu 60 | 61 | Acente çalışanları, sistem üzerinden yapılan rezervasyonları başarılı bir şekilde güncelleyebiliyor mu? 62 | 63 | view > RevervationUpdateView 64 | 65 | Acente çalışanları, sistem üzerinden yapılan rezervasyonları başarılı bir şekilde silebiliyor mu? 66 | 67 | view > HotelView > 475. satır > reserMenuList() > sil 68 | 69 | Rezervasyon silme işleminden sonra ilgili odanın stoğu artıyor mu? 70 | 71 | view > HotelView > 484. satır > reserMenuList() > sil > stockUpdate 72 | 73 | 74 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/entity/Hotel.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class Hotel { 4 | private int hotel_id; 5 | private String hotel_name; 6 | private String hotel_city; 7 | private String hotel_district; 8 | private String hotel_fllAdres; 9 | private String hotel_phone; 10 | private String hotel_email; 11 | private int hotel_star; 12 | 13 | 14 | public Hotel() { 15 | } 16 | 17 | public Hotel(int hotel_id, String hotel_name, String hotel_city, String hotel_district, int hotel_star, String hotel_fllAdres, String hotel_phone, 18 | String hotel_email) { 19 | this.hotel_id = hotel_id; 20 | this.hotel_name = hotel_name; 21 | this.hotel_star = hotel_star; 22 | this.hotel_city = hotel_city; 23 | this.hotel_district = hotel_district; 24 | this.hotel_fllAdres = hotel_fllAdres; 25 | this.hotel_phone = hotel_phone; 26 | this.hotel_email = hotel_email; 27 | 28 | } 29 | 30 | 31 | public int getHotel_id() { 32 | return hotel_id; 33 | } 34 | 35 | public void setHotel_id(int hotel_id) { 36 | this.hotel_id = hotel_id; 37 | } 38 | 39 | public String getHotel_name() { 40 | return hotel_name; 41 | } 42 | 43 | public void setHotel_name(String hotel_name) { 44 | this.hotel_name = hotel_name; 45 | } 46 | public String getHotel_city() { 47 | return hotel_city; 48 | } 49 | 50 | public void setHotel_city(String hotel_city) { 51 | this.hotel_city = hotel_city; 52 | } 53 | 54 | public String getHotel_district() { 55 | return hotel_district; 56 | } 57 | 58 | public void setHotel_district(String hotel_district) { 59 | this.hotel_district = hotel_district; 60 | } 61 | 62 | public int getHotel_star() { 63 | return hotel_star; 64 | } 65 | 66 | public void setHotel_star(int hotel_star) { 67 | this.hotel_star = hotel_star; 68 | } 69 | 70 | /* public String getHotel_property() { 71 | return hotel_property; 72 | } 73 | 74 | public void setHotel_property(String hotel_property) { 75 | this.hotel_property = hotel_property; 76 | }*/ 77 | 78 | public String getHotel_fllAdres() { 79 | return hotel_fllAdres; 80 | } 81 | 82 | public void setHotel_fllAdres(String hotel_fllAdres) { 83 | this.hotel_fllAdres = hotel_fllAdres; 84 | } 85 | 86 | public String getHotel_phone() { 87 | return hotel_phone; 88 | } 89 | 90 | public void setHotel_phone(String hotel_phone) { 91 | this.hotel_phone = hotel_phone; 92 | } 93 | 94 | public String getHotel_email() { 95 | return hotel_email; 96 | } 97 | 98 | public void setHotel_email(String hotel_email) { 99 | this.hotel_email = hotel_email; 100 | } 101 | 102 | @Override 103 | public String toString() { 104 | return "Hotel{" + 105 | "hotel_id=" + hotel_id + 106 | ", hotel_name='" + hotel_name + '\'' + 107 | ", hotel_city='" + hotel_city + '\'' + 108 | ", hotel_district='" + hotel_district + '\'' + 109 | ", hotel_address='" + hotel_fllAdres + '\'' + 110 | ", hotel_phone='" + hotel_phone + '\'' + 111 | ", hotel_email='" + hotel_email + '\'' + 112 | ", hotel_star='" + hotel_star + '\'' + 113 | '}'; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/business/ReserManager.java: -------------------------------------------------------------------------------- 1 | package business; 2 | 3 | import core.Helper; 4 | import dao.HotelDao; 5 | import dao.ReserDao; 6 | import entity.Hotel; 7 | import entity.Property; 8 | import entity.Reser; 9 | import entity.Room; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class ReserManager { 15 | private ReserDao reserDao; 16 | private Room room; 17 | private HotelManager hotelManager; 18 | private RoomManager roomManager; 19 | public ReserManager(){ 20 | 21 | this.reserDao = new ReserDao(); 22 | this.hotelManager =new HotelManager(); 23 | this.roomManager = new RoomManager(); 24 | this.room=new Room(); 25 | } 26 | public Reser getById(int id) { 27 | return this.reserDao.getById(id); 28 | } 29 | public boolean update(Reser reser) { 30 | if (this.getById(reser.getId()) == null) { 31 | Helper.showMsg(reser.getId() + " ID bulunamadı"); 32 | return false; 33 | } 34 | return this.reserDao.update(reser); 35 | } 36 | public boolean delete(int id ){ 37 | 38 | if(this.getById(id)==null){ 39 | Helper.showMsg(id+" ID kayıtlı model bulunamadı"); 40 | return false; 41 | } 42 | return this.reserDao.delete(id); 43 | } 44 | 45 | public int saveAndGetReserlId(Reser reser){ 46 | return this.reserDao.saveAndGetReserlId(reser); 47 | } 48 | public boolean saveGuestInfoList(int reservationId){ 49 | return this.reserDao.saveGuestInfoList(reservationId); 50 | } 51 | public ArrayList findAll(){return this.reserDao.findAll();} 52 | public ArrayList getListByGuestInfo(int id){ 53 | return this.reserDao.getListByGuestInfo(id); 54 | } 55 | public ArrayListgetForTableGuestInfo(int size,int id){ 56 | ArrayList brandRowList = new ArrayList<>(); 57 | for(Reser obj : this.getListByGuestInfo(id)){ 58 | Object[] rowObject = new Object[size]; 59 | int i = 0; 60 | rowObject[i++] = obj.getId(); 61 | rowObject[i++] = obj.getGuestFllName(); 62 | rowObject[i++] = obj.getGuestnationalNumber(); 63 | rowObject[i++] = obj.getGuestCountry(); 64 | rowObject[i++] = obj.getGuestClass(); 65 | brandRowList.add(rowObject); 66 | 67 | } 68 | return brandRowList; 69 | } 70 | public ArrayList getForTable(int size, ArrayListresersList){ 71 | ArrayList reserArrayList = new ArrayList<>(); 72 | for(Reser reser : resersList){ 73 | int i = 0; 74 | Object[] rowObject = new Object[size]; 75 | rowObject[i++] = reser.getId(); 76 | rowObject[i++] = reser.getRoom_id(); 77 | rowObject[i++] = hotelManager.getById(roomManager.getById(reser.getRoom_id()).getHotelId()).getHotel_name(); 78 | rowObject[i++] = roomManager.getById(reser.getRoom_id()).getRoomType(); 79 | rowObject[i++] = reser.getReserFllName(); 80 | rowObject[i++] = reser.getReserPhone(); 81 | rowObject[i++] = reser.getReserEmail(); 82 | rowObject[i++] = reser.getReserNote(); 83 | rowObject[i++] = reser.getReserCheckInDdate(); 84 | rowObject[i++] = reser.getReserCheckOutDate(); 85 | rowObject[i++] = reser.getAdultNumb(); 86 | rowObject[i++] = reser.getChildNumb(); 87 | rowObject[i++] = reser.getTotalPrice(); 88 | reserArrayList.add(rowObject); 89 | 90 | } 91 | return reserArrayList; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/UserManagementView.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 | -------------------------------------------------------------------------------- /TurizmAcente-master/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.*; 8 | import java.awt.event.MouseAdapter; 9 | import java.awt.event.MouseEvent; 10 | import java.util.ArrayList; 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | public class Layout extends JFrame { 15 | 16 | public void createTableStringLines(JTextArea textArea, Object[] columns, int hotelId, List properties) { 17 | // JTextArea içeriğini temizle 18 | textArea.setText(""); 19 | 20 | // Tablo başlıklarını yazdır 21 | textArea.append(columns[0].toString() + "\t" + columns[1].toString() + "\n"); 22 | 23 | // Özellikleri alt alta yazdır 24 | for (String[] property : properties) { 25 | for (int i = 0; i < property.length; i++) { 26 | textArea.append(hotelId + "\t"); // Otel ID'sini yazdır 27 | textArea.append(property[i]); 28 | if (i < property.length - 1) { 29 | textArea.append("\n"); 30 | 31 | } 32 | } 33 | 34 | textArea.append("\n"); // Bir sonraki özellik için yeni satır ekle 35 | 36 | 37 | } 38 | 39 | // JTextArea'nın düzenlenemez hale getirilmesi (opsiyonel) 40 | textArea.setEditable(false); 41 | 42 | // JTextArea'nın boyutunu ayarla 43 | //textArea.setPreferredSize(new Dimension(200, 100)); 44 | } 45 | 46 | 47 | public void createTable(DefaultTableModel model, JTable table, Object[] columns, ArrayList rows) { 48 | model.setColumnIdentifiers(columns); 49 | table.setModel(model); 50 | table.getTableHeader().setReorderingAllowed(false); 51 | table.getColumnModel().getColumn(0).setMaxWidth(75); 52 | table.setEnabled(false); 53 | 54 | DefaultTableModel clearModel = (DefaultTableModel) table.getModel(); 55 | clearModel.setRowCount(0); 56 | 57 | if (rows == null) { 58 | rows = new ArrayList<>(); 59 | } 60 | for (Object[] row : rows) { 61 | model.addRow(row); 62 | } 63 | 64 | } 65 | 66 | public void guiInitilaze(int width, int height) { 67 | 68 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 69 | setTitle("Turizim Acente"); 70 | setSize(width, height); 71 | setLocation(Helper.getLocationPoint("x", this.getSize()), Helper.getLocationPoint("y", this.getSize())); 72 | setVisible(true); 73 | } 74 | 75 | /* public int getTableSelectedRow(JTable table,int index){ 76 | return Integer.parseInt(table.getValueAt(table.getSelectedRow(),index) .toString()); 77 | }*/ 78 | // JTable'dan belirli bir satırdaki veriyi elde etmek için metod 79 | public static int getTableSelectedRow(JTable table, int hotelIdColumnIndex) { 80 | int selectedRow = table.getSelectedRow(); 81 | 82 | if (selectedRow != -1) { // Eğer bir satır seçilmişse 83 | // Seçili satırdaki belirli sütunun değerini al 84 | Object hotelIdObj = table.getValueAt(selectedRow, hotelIdColumnIndex); 85 | 86 | if (hotelIdObj instanceof Integer) { 87 | return (Integer) hotelIdObj; // Hotel ID'sini integer olarak dön 88 | } 89 | } 90 | 91 | return -1; // Seçili bir satır yoksa veya hotel ID'si alınamazsa -1 dön 92 | } 93 | 94 | public void tableRowSelect(JTable table) { 95 | table.addMouseListener(new MouseAdapter() { 96 | @Override 97 | public void mousePressed(MouseEvent e) { 98 | int selected_row = table.rowAtPoint(e.getPoint()); 99 | table.setRowSelectionInterval(selected_row, selected_row); 100 | } 101 | }); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/entity/Property.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | import java.util.List; 4 | 5 | public class Property { 6 | 7 | private int propertyID; 8 | private List propertyNames; // Özellik isimlerini liste olarak tutmak için List kullanıyoruz 9 | private int hotel_id; // Otelin kimliğini (hotel_id) tutmak için daha genel bir isim olan hotelId kullanabiliriz 10 | 11 | 12 | private int roomPropertyId; 13 | private String roomProperty; 14 | private int roomId; 15 | private int roomAdultBedNum; 16 | private int roomChildBedNum; 17 | private int roomArea; 18 | 19 | private Room room; 20 | 21 | public Property() { 22 | } 23 | public Property(int roomPropertyId, String roomProperty, int roomId, int roomAdultBedNum,int roomChildBedNum, int roomArea) { 24 | this.roomPropertyId = roomPropertyId; 25 | this.roomProperty = roomProperty; 26 | this.roomId = roomId; 27 | this.roomAdultBedNum = roomAdultBedNum; 28 | this.roomChildBedNum = roomAdultBedNum; 29 | this.roomArea = roomArea; 30 | 31 | } 32 | public Property(List propertyNames) { 33 | this.propertyNames = propertyNames; 34 | } 35 | // Kurucu metod (constructor) 36 | public Property(int propertyID, List propertyNames, int hotel_id) { 37 | this.propertyID = propertyID; 38 | this.propertyNames = propertyNames; 39 | this.hotel_id = hotel_id; 40 | } 41 | 42 | 43 | public int getRoomPropertyId() { 44 | return roomPropertyId; 45 | } 46 | 47 | public void setRoomPropertyId(int roomPropertyId) { 48 | this.roomPropertyId = roomPropertyId; 49 | } 50 | 51 | public int getRoomArea() { 52 | return roomArea; 53 | } 54 | 55 | public void setRoomArea(int roomArea) { 56 | this.roomArea = roomArea; 57 | } 58 | 59 | public int getRoomAdultBedNum() { 60 | return roomAdultBedNum; 61 | } 62 | 63 | public void setRoomAdultBedNum(int roomAdultBedNum) { 64 | this.roomAdultBedNum = roomAdultBedNum; 65 | } 66 | 67 | public int getRoomChildBedNum() { 68 | return roomChildBedNum; 69 | } 70 | 71 | public void setRoomChildBedNum(int roomChildBedNum) { 72 | this.roomChildBedNum = roomChildBedNum; 73 | } 74 | 75 | public int getRoomId() { 76 | return roomId; 77 | } 78 | 79 | public void setRoomId(int roomId) { 80 | this.roomId = roomId; 81 | } 82 | 83 | public String getRoomProperty() { 84 | return roomProperty; 85 | } 86 | 87 | public void setRoomProperty(String roomProperty) { 88 | this.roomProperty = roomProperty; 89 | } 90 | 91 | // Getter ve setter metotları 92 | public int getPropertyID() { 93 | return propertyID; 94 | } 95 | 96 | public void setPropertyID(int propertyID) { 97 | this.propertyID = propertyID; 98 | } 99 | 100 | public List getPropertyNames() { 101 | return propertyNames; 102 | } 103 | 104 | public void setPropertyNames(List propertyNames) { 105 | this.propertyNames = propertyNames; 106 | } 107 | public int getHotel_id() { 108 | return hotel_id; 109 | } 110 | 111 | public void setHotel_id(int hotel_id) { 112 | this.hotel_id = hotel_id; 113 | } 114 | 115 | @Override 116 | public String toString() { 117 | return "Property{" + 118 | "propertyID=" + propertyID + 119 | ", propertyNames=" + propertyNames + 120 | ", hotel_id=" + hotel_id + 121 | ", roomPropertyId=" + roomPropertyId + 122 | ", roomProperty='" + roomProperty + '\'' + 123 | ", roomId=" + roomId + 124 | ", roomBed='" + roomAdultBedNum + '\'' + 125 | ", roomArea=" + roomArea + 126 | ", room=" + room + 127 | '}'; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/entity/Room.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class Room { 4 | private int id; 5 | private String roomType; 6 | private int stock; 7 | private int seasonId; 8 | private int adultPrice; 9 | private int childPrice; 10 | private int hotelTypeId; 11 | private int hotelId; 12 | private int roomPrice; 13 | 14 | 15 | public enum RoomType { 16 | SINGLE_ROOM("Single Room"), 17 | DOUBLE_ROOM("Double Room"), 18 | JUNIOR_SUITE_ROOM("Junior Suite Room"), 19 | SUITE_ROOM("Suite Room"); 20 | 21 | private final String displayName; 22 | 23 | RoomType(String displayName) { 24 | this.displayName = displayName; 25 | } 26 | 27 | public String getDisplayName() { 28 | return displayName; 29 | } 30 | } 31 | 32 | public Room() { 33 | } 34 | 35 | public Room(String roomType, int stock, int seasonId, int adultPrice, int childPrice, int hotelTypeId, int hotelId,int roomPrice) { 36 | 37 | this.roomType = roomType; 38 | this.stock = stock; 39 | this.seasonId = seasonId; 40 | this.adultPrice = adultPrice; 41 | this.childPrice = childPrice; 42 | this.hotelTypeId = hotelTypeId; 43 | this.hotelId = hotelId; 44 | this.roomPrice=roomPrice; 45 | } 46 | public Room(int id, String roomType, int stock, int seasonId, int adultPrice, int childPrice, int hotelTypeId, int hotelId) { 47 | this.id = id; 48 | this.roomType = roomType; 49 | this.stock = stock; 50 | this.seasonId = seasonId; 51 | this.adultPrice = adultPrice; 52 | this.childPrice = childPrice; 53 | this.hotelTypeId = hotelTypeId; 54 | this.hotelId = hotelId; 55 | } 56 | 57 | // Diğer getter ve setter metotları 58 | 59 | 60 | public int getRoomPrice() { 61 | return roomPrice; 62 | } 63 | 64 | public void setRoomPrice(int roomPrice) { 65 | this.roomPrice = roomPrice; 66 | } 67 | 68 | public int getId() { 69 | return id; 70 | } 71 | 72 | public void setId(int id) { 73 | this.id = id; 74 | } 75 | 76 | public String getRoomType() { 77 | return roomType; 78 | } 79 | 80 | public void setRoomType(String roomType) { 81 | this.roomType = roomType; 82 | } 83 | 84 | public int getStock() { 85 | return stock; 86 | } 87 | 88 | public void setStock(int stock) { 89 | this.stock = stock; 90 | } 91 | 92 | public int getSeasonId() { 93 | return seasonId; 94 | } 95 | 96 | public void setSeasonId(int seasonId) { 97 | this.seasonId = seasonId; 98 | } 99 | 100 | public int getAdultPrice() { 101 | return adultPrice; 102 | } 103 | 104 | public void setAdultPrice(int adultPrice) { 105 | this.adultPrice = adultPrice; 106 | } 107 | 108 | public int getChildPrice() { 109 | return childPrice; 110 | } 111 | 112 | public void setChildPrice(int childPrice) { 113 | this.childPrice = childPrice; 114 | } 115 | 116 | public int getHotelTypeId() { 117 | return hotelTypeId; 118 | } 119 | 120 | public void setHotelTypeId(int hotelTypeId) { 121 | this.hotelTypeId = hotelTypeId; 122 | } 123 | 124 | public int getHotelId() { 125 | return hotelId; 126 | } 127 | 128 | public void setHotelId(int hotelId) { 129 | this.hotelId = hotelId; 130 | } 131 | 132 | // toString metodu (isteğe bağlı) 133 | @Override 134 | public String toString() { 135 | return "Room{" + 136 | "id=" + id + 137 | ", roomType='" + roomType + '\'' + 138 | ", stock=" + stock + 139 | ", seasonId=" + seasonId + 140 | ", adultPrice=" + adultPrice + 141 | ", childPrice=" + childPrice + 142 | ", hotelTypeId=" + hotelTypeId + 143 | ", hotelId=" + hotelId + 144 | '}'; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.User; 5 | 6 | import java.sql.*; 7 | import java.util.ArrayList; 8 | 9 | public class UserDao { 10 | private final Connection con; 11 | 12 | public UserDao() { 13 | this.con = Db.getInstance(); 14 | } 15 | 16 | public User findByLogin(String username, String password) { 17 | User obj = null; 18 | String query = "SELECT * FROM public.user WHERE user_name = ? AND user_password = ? "; 19 | try { 20 | PreparedStatement pr = this.con.prepareStatement(query); 21 | pr.setString(1, username); 22 | pr.setString(2, password); 23 | 24 | ResultSet rs = pr.executeQuery(); 25 | if (rs.next()) { 26 | obj = this.match(rs); 27 | 28 | 29 | } 30 | } catch (SQLException e) { 31 | e.printStackTrace(); 32 | } 33 | return obj; 34 | } 35 | 36 | public ArrayList selectByQuery(String query) { 37 | // System.out.println(query); 38 | ArrayList userList = new ArrayList<>(); 39 | 40 | try { 41 | ResultSet rs = this.con.createStatement().executeQuery(query); 42 | while (rs.next()) { 43 | userList.add(this.match(rs)); 44 | 45 | } 46 | } catch (SQLException throwables) { 47 | throwables.printStackTrace(); 48 | } 49 | return userList; 50 | } 51 | 52 | public User match(ResultSet rs) throws SQLException { 53 | User obj = new User(); 54 | obj.setUserId(rs.getInt("user_id")); 55 | obj.setUsername(rs.getString("user_name")); 56 | obj.setPassword(rs.getString("user_password")); 57 | obj.setRole(User.Role.valueOf(rs.getString("user_role"))); 58 | 59 | 60 | return obj; 61 | } 62 | 63 | public ArrayList findAll() { 64 | ArrayList brandsList = new ArrayList<>(); 65 | String sql = "SELECT * FROM public.user ORDER BY user_id ASC"; 66 | try { 67 | Statement st = this.con.createStatement(); 68 | ResultSet rs = st.executeQuery(sql); 69 | 70 | while (rs.next()) { 71 | brandsList.add(this.match(rs)); 72 | } 73 | 74 | } catch (SQLException e) { 75 | e.printStackTrace(); 76 | } 77 | return brandsList; 78 | } 79 | 80 | public User getById(int id) { 81 | User obj = null; 82 | String query = "SELECT * FROM public.user WHERE user_id = ?"; 83 | try { 84 | PreparedStatement pr = con.prepareStatement(query); 85 | pr.setInt(1, id); 86 | ResultSet rs = pr.executeQuery(); 87 | if (rs.next()) { 88 | obj = this.match(rs); 89 | 90 | 91 | } 92 | } catch (SQLException e) { 93 | e.printStackTrace(); 94 | } 95 | return obj; 96 | 97 | } 98 | 99 | public boolean save(User user) { 100 | String query = "INSERT INTO public.user " + 101 | "(" + 102 | //"user_id," + 103 | "user_name," + 104 | "user_password," + 105 | "user_role" + 106 | ")" + 107 | " VALUES (?,?,?)"; 108 | try { 109 | PreparedStatement pr = con.prepareStatement(query); 110 | //pr.setInt(1, user.getUserId()); 111 | pr.setString(1, user.getUsername()); 112 | pr.setString(2, user.getPassword()); 113 | pr.setString(3, user.getRole().toString()); 114 | return pr.executeUpdate() != -1; 115 | } catch (SQLException throwables) { 116 | throwables.printStackTrace(); 117 | } 118 | return true; 119 | } 120 | 121 | public boolean update(User user) { 122 | String query = "UPDATE public.user SET " + 123 | "user_name = ?," + 124 | "user_password = ?," + 125 | "user_role = ? " + 126 | "WHERE user_id = ? "; 127 | try { 128 | PreparedStatement pr = con.prepareStatement(query); 129 | pr.setString(1, user.getUsername()); 130 | pr.setString(2, user.getPassword()); 131 | pr.setString(3, user.getRole().toString()); 132 | pr.setInt(4, user.getUserId()); 133 | return pr.executeUpdate() != -1; 134 | } catch (SQLException throwables) { 135 | throwables.printStackTrace(); 136 | } 137 | return true; 138 | } 139 | 140 | public boolean delete(int id) { 141 | String query = "DELETE FROM public.user WHERE user_id = ? "; 142 | try { 143 | PreparedStatement pr = con.prepareStatement(query); 144 | pr.setInt(1, id); 145 | return pr.executeUpdate() != -1; 146 | 147 | } catch (SQLException throwables) { 148 | throwables.printStackTrace(); 149 | } 150 | return true; 151 | 152 | } 153 | 154 | } 155 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/entity/Reser.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class Reser { 4 | private int id; 5 | private int room_id; 6 | private String reserFllName; 7 | private String reserPhone; 8 | private String reserEmail; 9 | private String reserNote; 10 | private String reserCheckInDdate; 11 | private String reserCheckOutDate; 12 | private String adultNumb; 13 | private String childNumb; 14 | private String totalPrice; 15 | 16 | private int guestId; 17 | private String guestFllName; 18 | 19 | private String guestnationalNumber; 20 | 21 | private String guestCountry; 22 | private String guestClass; 23 | 24 | public Reser() { 25 | } 26 | 27 | public Reser(int guestId,String guestCountry, String guestnationalNumber, String guestFllName,String guestClass) { 28 | this.guestId=guestId; 29 | this.guestCountry = guestCountry; 30 | this.guestnationalNumber = guestnationalNumber; 31 | this.guestFllName = guestFllName; 32 | this.guestClass = guestClass; 33 | } 34 | 35 | public Reser(int id, int room_id, String reserFllName, String reserPhone, String reserEmail, String reserNote, String reserCheckInDdate, String reserCheckOutDate, String adultNumb, String childNumb, String totalPrice) { 36 | this.id = id; 37 | this.room_id = room_id; 38 | this.reserFllName = reserFllName; 39 | this.reserPhone = reserPhone; 40 | this.reserEmail = reserEmail; 41 | this.reserNote = reserNote; 42 | this.reserCheckInDdate = reserCheckInDdate; 43 | this.reserCheckOutDate = reserCheckOutDate; 44 | this.adultNumb = adultNumb; 45 | this.childNumb = childNumb; 46 | this.totalPrice = totalPrice; 47 | } 48 | 49 | public int getGuestId() { 50 | return guestId; 51 | } 52 | 53 | public void setGuestId(int guestId) { 54 | this.guestId = guestId; 55 | } 56 | 57 | public String getGuestFllName() { 58 | return guestFllName; 59 | } 60 | 61 | public void setGuestFllName(String guestFllName) { 62 | this.guestFllName = guestFllName; 63 | } 64 | 65 | public String getGuestnationalNumber() { 66 | return guestnationalNumber; 67 | } 68 | 69 | public void setGuestnationalNumber(String guestnationalNumber) { 70 | this.guestnationalNumber = guestnationalNumber; 71 | } 72 | 73 | public String getGuestCountry() { 74 | return guestCountry; 75 | } 76 | 77 | public void setGuestCountry(String guestCountry) { 78 | this.guestCountry = guestCountry; 79 | } 80 | 81 | public String getGuestClass() { 82 | return guestClass; 83 | } 84 | 85 | public void setGuestClass(String guestClass) { 86 | this.guestClass = guestClass; 87 | } 88 | 89 | public int getId() { 90 | return id; 91 | } 92 | 93 | public void setId(int id) { 94 | this.id = id; 95 | } 96 | 97 | public int getRoom_id() { 98 | return room_id; 99 | } 100 | 101 | public void setRoom_id(int room_id) { 102 | this.room_id = room_id; 103 | } 104 | 105 | public String getReserFllName() { 106 | return reserFllName; 107 | } 108 | 109 | public void setReserFllName(String reserFllName) { 110 | this.reserFllName = reserFllName; 111 | } 112 | 113 | public String getReserPhone() { 114 | return reserPhone; 115 | } 116 | 117 | public void setReserPhone(String reserPhone) { 118 | this.reserPhone = reserPhone; 119 | } 120 | 121 | public String getReserEmail() { 122 | return reserEmail; 123 | } 124 | 125 | public void setReserEmail(String reserEmail) { 126 | this.reserEmail = reserEmail; 127 | } 128 | 129 | public String getReserNote() { 130 | return reserNote; 131 | } 132 | 133 | public void setReserNote(String reserNote) { 134 | this.reserNote = reserNote; 135 | } 136 | 137 | public String getReserCheckInDdate() { 138 | return reserCheckInDdate; 139 | } 140 | 141 | public void setReserCheckInDdate(String reserCheckInDdate) { 142 | this.reserCheckInDdate = reserCheckInDdate; 143 | } 144 | 145 | public String getReserCheckOutDate() { 146 | return reserCheckOutDate; 147 | } 148 | 149 | public void setReserCheckOutDate(String reserCheckOutDate) { 150 | this.reserCheckOutDate = reserCheckOutDate; 151 | } 152 | 153 | public String getAdultNumb() { 154 | return adultNumb; 155 | } 156 | 157 | public void setAdultNumb(String adultNumb) { 158 | this.adultNumb = adultNumb; 159 | } 160 | 161 | public String getChildNumb() { 162 | return childNumb; 163 | } 164 | 165 | public void setChildNumb(String childNumb) { 166 | this.childNumb = childNumb; 167 | } 168 | 169 | public String getTotalPrice() { 170 | return totalPrice; 171 | } 172 | 173 | public void setTotalPrice(String totalPrice) { 174 | this.totalPrice = totalPrice; 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /TurizmAcente-master/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.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | import java.awt.event.WindowAdapter; 12 | import java.awt.event.WindowEvent; 13 | import java.util.ArrayList; 14 | 15 | public class AdminView extends Layout { 16 | private JPanel pnl_top; 17 | private JTabbedPane tabbedPane1; 18 | private JPanel container; 19 | private JLabel lbl_welcome; 20 | private JButton btn_admin_logout; 21 | //private JComboBox cmb_role_list; 22 | private JComboBox cmb_role_list; 23 | private JButton btn_rol_search; 24 | private JButton btn_user_list_clear; 25 | private JTable tbl_user; 26 | private JPopupMenu user_Menu; 27 | private DefaultTableModel tmdl_user = new DefaultTableModel(); 28 | private UserManager userManager; 29 | private User user; 30 | 31 | private Object[] col_user; 32 | 33 | 34 | public AdminView(User user) { 35 | this.userManager = new UserManager(); 36 | add(container); 37 | this.guiInitilaze(1000, 500); 38 | this.user = user; 39 | if (this.user == null) { 40 | dispose(); 41 | }/*else if(!this.user.getRole().equals("admin")) { 42 | dispose(); 43 | }*/ 44 | btn_admin_logout.addActionListener(new ActionListener() { 45 | @Override 46 | public void actionPerformed(ActionEvent e) { 47 | dispose(); 48 | LoginView loginView = new LoginView(); 49 | 50 | } 51 | }); 52 | 53 | this.lbl_welcome.setText("Hoşgeldiniz : " + this.user.getRole()); 54 | loadAdminPanelComponent(); 55 | 56 | loadRoleFilter(); 57 | loadRoleTable(null); 58 | loadAdminPanelComponent(); 59 | 60 | } 61 | 62 | public void loadRoleFilter() { 63 | this.cmb_role_list.setModel(new DefaultComboBoxModel<>(User.Role.values())); 64 | this.cmb_role_list.setSelectedItem(null); 65 | 66 | } 67 | 68 | public void loadRoleTable(ArrayList userList) { 69 | this.col_user = new Object[]{"ID", "K.Adı", "K.Şifre", "K.Rol"}; 70 | if (userList == null) { 71 | userList = this.userManager.getForTable(col_user.length, userManager.findAll()); 72 | } 73 | this.createTable(this.tmdl_user, this.tbl_user, col_user, userList); 74 | } 75 | 76 | public void loadAdminPanelComponent() { 77 | 78 | 79 | btn_rol_search.addActionListener(e -> { 80 | 81 | /* ComboItem selectedBrand = (ComboItem) this.cmb_role_list.getSelectedItem(); 82 | int plateId = 0; 83 | if (selectedBrand != null) { 84 | plateId = selectedBrand.getKey(); 85 | }*/ 86 | if (this.cmb_role_list.getSelectedItem() != null) { 87 | ArrayList rolListBySearch = this.userManager.searcForTable((User.Role) cmb_role_list.getSelectedItem()); 88 | ArrayList modelRowListBySearch = this.userManager.getForTable(this.col_user.length, rolListBySearch); 89 | loadRoleTable(modelRowListBySearch); 90 | } 91 | }); 92 | this.btn_user_list_clear.addActionListener(e -> { 93 | this.cmb_role_list.setSelectedItem(null); 94 | loadRoleTable(null); 95 | }); 96 | 97 | this.tableRowSelect(this.tbl_user); 98 | this.user_Menu = new JPopupMenu(); 99 | this.user_Menu.add("Yeni").addActionListener(e -> { 100 | UserManagementView managementView = new UserManagementView(null); 101 | managementView.addWindowListener(new WindowAdapter() { 102 | @Override 103 | public void windowClosed(WindowEvent e) { 104 | /* loadBrandTable(); 105 | loadModelTable(null); 106 | loadModelFilterBrand(); 107 | loadCarTable(); 108 | loadRentalFilterPlate();*/ 109 | loadRoleTable(null); 110 | } 111 | }); 112 | }); 113 | this.user_Menu.add("Güncelle").addActionListener(e -> { 114 | int selectUserdId = this.getTableSelectedRow(tbl_user, 0); 115 | UserManagementView managementView = new UserManagementView(this.userManager.getById(selectUserdId)); 116 | managementView.addWindowListener(new WindowAdapter() { 117 | @Override 118 | public void windowClosed(WindowEvent e) { 119 | /* loadBrandTable(); 120 | loadModelTable(null); 121 | loadModelFilterBrand(); 122 | loadCarTable();*/ 123 | loadRoleTable(null); 124 | } 125 | }); 126 | }); 127 | this.user_Menu.add("Sil").addActionListener(e -> { 128 | if (Helper.confirm("sure")) { 129 | int selectBrandId = this.getTableSelectedRow(tbl_user, 0); 130 | if (this.userManager.delete(selectBrandId)) { 131 | Helper.showMsg("done"); 132 | /* loadBrandTable(); 133 | loadModelTable(null); 134 | loadModelFilterBrand(); 135 | loadCarTable();*/ 136 | loadRoleTable(null); 137 | } else { 138 | Helper.showMsg("error"); 139 | } 140 | } 141 | 142 | }); 143 | 144 | this.tbl_user.setComponentPopupMenu(this.user_Menu); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /TurizmAcente-master/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 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | 12 | public class Helper { 13 | public static void setTheme() { 14 | 15 | for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { 16 | if ("Nimbus".equals(info.getName())) { 17 | try { 18 | UIManager.setLookAndFeel(info.getClassName()); 19 | } catch (Exception e) { 20 | e.printStackTrace(); 21 | } 22 | break; 23 | } 24 | } 25 | 26 | } 27 | 28 | public static void showMsg(String str) { 29 | optionPayneTR(); 30 | String msg; 31 | String title; 32 | switch (str) { 33 | case "fill" -> { 34 | msg = "Lütfen tüm alanları doldurunuz !"; 35 | title = "Hata!"; 36 | } 37 | case "done" -> { 38 | msg = "İşlem Başarılı !"; 39 | title = "Sonuç"; 40 | } 41 | case "notFound" -> { 42 | msg = "Kayıt bulunamadı !"; 43 | title = "Bulunamadı"; 44 | } 45 | case "error" -> { 46 | msg = "Hatalı işlem yaptınız !"; 47 | title = "Hata!"; 48 | } 49 | default -> { 50 | msg = str; 51 | title = "Mesaj"; 52 | } 53 | } 54 | JOptionPane.showMessageDialog(null, msg, title, JOptionPane.INFORMATION_MESSAGE); 55 | } 56 | 57 | public static boolean confirm(String str) { 58 | optionPayneTR(); 59 | String msg; 60 | if (str.equals("sure")) { 61 | msg = "Bu işlemi yapmak istediginize eminmisiniz !!"; 62 | 63 | } else { 64 | msg = str; 65 | } 66 | return JOptionPane.showConfirmDialog(null, msg, "Eminmisiniz", JOptionPane.YES_NO_OPTION) == 0; 67 | 68 | } 69 | 70 | public static void optionPayneTR() { 71 | UIManager.put("OptionPane.okButtonText", "Tamam"); 72 | UIManager.put("OptionPane.yesButtonText", "Evet"); 73 | UIManager.put("OptionPane.noButtonText", "Hayır"); 74 | 75 | } 76 | 77 | //Jradio lara oda özellikleri metinleri için, oda ekleme ekranındaki 78 | public static String roomProperty(String number){ 79 | String property=""; 80 | switch (number){ 81 | case "1": 82 | property = "Televizyon "; 83 | break; 84 | case "2": 85 | property = "Minibar "; 86 | break; 87 | case "3": 88 | property = "Oyun Konsolu"; 89 | break; 90 | case "4": 91 | property = "Kasa"; 92 | break; 93 | case "5": 94 | property = "Projeksiyon"; 95 | break; 96 | } 97 | return property; 98 | } 99 | public static boolean isValidDate(String inputDate, String formatPattern) { 100 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern); 101 | 102 | try { 103 | LocalDate date = LocalDate.parse(inputDate, formatter); 104 | return true; // Geçerli tarih formatı 105 | } catch (DateTimeParseException e) { 106 | return false; // Geçersiz tarih formatı 107 | } 108 | } 109 | public static LocalDate parseDate(String inputDate, String formatPattern) { 110 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern); 111 | 112 | try { 113 | LocalDate date = LocalDate.parse(inputDate, formatter); 114 | return date; // Başarılı dönüşüm 115 | } catch (DateTimeParseException e) { 116 | return null; // Dönüşüm başarısız 117 | } 118 | } 119 | 120 | public static List getListFromJList(JList jList) { 121 | List list = new ArrayList<>(); 122 | for (int i = 0; i < jList.getModel().getSize(); i++) { 123 | list.add(jList.getModel().getElementAt(i)); 124 | } 125 | return list; 126 | } 127 | // Nesne listesini String listesine dönüştüren metot 128 | public static List convertObjectListToStringList(Object[] objectList) { 129 | List stringList = new ArrayList<>(); 130 | for (Object person : objectList) { 131 | // Her bir nesneyi String'e dönüştürerek listeye ekleyelim 132 | String str = person.toString(); // toString metodu çağrılır 133 | stringList.add(str); 134 | } 135 | return stringList; 136 | } 137 | public static boolean isList_J_Empty(JList list) { 138 | ListModel model = list.getModel(); 139 | return model.getSize() == 0; 140 | } 141 | 142 | public static boolean isFieldListEmpty(JTextField[] fieldList) { 143 | for (JTextField field : fieldList) { 144 | if (isFieldEmpty(field)) return true; 145 | } 146 | return false; 147 | } 148 | 149 | public static boolean isFieldEmpty(JTextField field) { 150 | return field.getText().trim().isEmpty(); 151 | 152 | } 153 | public static boolean isAreaEmpty(JTextArea field) { 154 | return field.getText().trim().isEmpty(); 155 | } 156 | 157 | public static int getLocationPoint(String type, Dimension size) { 158 | return switch (type) { 159 | case "x" -> (Toolkit.getDefaultToolkit().getScreenSize().width - size.width) / 2; 160 | case "y" -> (Toolkit.getDefaultToolkit().getScreenSize().height - size.height) / 2; 161 | default -> 0; 162 | }; 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /TurizmAcente-master/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 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 |
122 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/dao/RoomDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import core.Helper; 5 | import entity.Hotel; 6 | import entity.Reser; 7 | import entity.Room; 8 | 9 | import java.sql.*; 10 | import java.time.LocalDate; 11 | import java.time.format.DateTimeFormatter; 12 | import java.util.ArrayList; 13 | 14 | public class RoomDao { 15 | 16 | private Connection con; 17 | public RoomDao() { 18 | this.con = Db.getInstance(); 19 | 20 | } 21 | public Room getById(int id) { 22 | Room obj = null; 23 | String query = "SELECT * FROM room WHERE id = ?"; 24 | try { 25 | PreparedStatement pr = con.prepareStatement(query); 26 | pr.setInt(1, id); 27 | ResultSet rs = pr.executeQuery(); 28 | if (rs.next()) { 29 | obj = this.match(rs); 30 | } 31 | } catch (SQLException e) { 32 | e.printStackTrace(); 33 | } 34 | return obj; 35 | } 36 | public ArrayList findAll() { 37 | String sql = "SELECT * FROM public.room ORDER BY id ASC"; 38 | return this.selectByQuery(sql); 39 | } 40 | public ArrayList selectByQuery(String query) { 41 | ArrayList roomList = new ArrayList<>(); 42 | try { 43 | ResultSet rs = this.con.createStatement().executeQuery(query); 44 | while (rs.next()) { 45 | roomList.add(this.match(rs)); 46 | 47 | } 48 | } catch (SQLException throwables) { 49 | throwables.printStackTrace(); 50 | } 51 | return roomList; 52 | } 53 | 54 | 55 | public Room match(ResultSet rs) throws SQLException { 56 | Room room = new Room(); 57 | room.setId(rs.getInt("id")); 58 | room.setRoomType(rs.getString("room_type")); 59 | room.setStock(rs.getInt("stock")); 60 | room.setSeasonId(rs.getInt("season_id")); 61 | room.setAdultPrice(rs.getInt("adult_price")); 62 | room.setChildPrice(rs.getInt("child_price")); 63 | room.setHotelTypeId(rs.getInt("type_id")); 64 | room.setHotelId(rs.getInt("hotel_id")); 65 | room.setRoomPrice(rs.getInt("room_price")); 66 | return room; 67 | } 68 | public ArrayList searchForRooms(String strt_date, String fnsh_date,String searchCity,String hotelName, int adultNum,int childNum) { 69 | ArrayList searchedRooms = new ArrayList<>(); 70 | 71 | // SQL sorgusunu oluştur 72 | StringBuilder queryBuilder = new StringBuilder(); 73 | queryBuilder.append("SELECT r.* FROM room r "); 74 | queryBuilder.append("INNER JOIN hotels h ON r.hotel_id = h.hotel_id "); 75 | queryBuilder.append("INNER JOIN hotel_seasons s ON r.season_id = s.season_id "); 76 | queryBuilder.append("LEFT JOIN room_properties rp ON r.id = rp.room_id "); // room_properties tablosunu LEFT JOIN ile ekleyin 77 | queryBuilder.append("WHERE 1 = 1 "); // Başlangıç 78 | 79 | ArrayList where = new ArrayList<>(); 80 | 81 | if (searchCity != null && !searchCity.isEmpty()) { 82 | where.add("h.city = '" + searchCity + "'"); 83 | } 84 | 85 | if (hotelName != null && !hotelName.isEmpty()) { 86 | where.add("h.hotel_name = '" + hotelName + "'"); 87 | } 88 | 89 | if (strt_date != null && !strt_date.isEmpty() && fnsh_date != null && !fnsh_date.isEmpty()) { 90 | // Tarihleri LocalDate olarak dönüştür 91 | LocalDate startDate = LocalDate.parse(strt_date, DateTimeFormatter.ofPattern("dd-MM-yyyy")); 92 | LocalDate endDate = LocalDate.parse(fnsh_date, DateTimeFormatter.ofPattern("dd-MM-yyyy")); 93 | // Tarih aralığını WHERE koşuluna ekle 94 | where.add("s.start_date <= '" + startDate + "'"); 95 | where.add("s.end_date >= '" + endDate + "'"); 96 | } 97 | if ( adultNum > 0) { 98 | where.add("rp.adultd_bed_num = " + adultNum); 99 | } 100 | if ( childNum > 0) { 101 | where.add("rp.child_bed_num = " + childNum); 102 | } 103 | 104 | 105 | // WHERE koşullarını SQL sorgusuna ekle 106 | if (!where.isEmpty()) { 107 | queryBuilder.append(" AND "); 108 | queryBuilder.append(String.join(" AND ", where)); 109 | } 110 | 111 | // SQL sorgusunu tamamla 112 | String query = queryBuilder.toString(); 113 | 114 | // Oluşturulan sorguyu kullanarak odaları seç 115 | searchedRooms = selectByQuery(query); 116 | 117 | // Sonuçları döndür 118 | return searchedRooms; 119 | } 120 | 121 | public int save(Room room) { 122 | String query = "INSERT INTO room (room_type, stock, season_id, adult_price, child_price, type_id, hotel_id,room_price) VALUES (?,?,?,?,?,?,?,?)"; 123 | try { 124 | PreparedStatement pr = con.prepareStatement(query, Statement.RETURN_GENERATED_KEYS); 125 | pr.setString(1,room.getRoomType()); 126 | pr.setInt(2,room.getStock()); 127 | pr.setInt(3,room.getSeasonId()); 128 | pr.setInt(4,room.getAdultPrice()); 129 | pr.setInt(5,room.getChildPrice()); 130 | pr.setInt(6,room.getHotelTypeId()); 131 | pr.setInt(7,room.getHotelId()); 132 | pr.setInt(8,room.getRoomPrice()); 133 | 134 | int rowsAffected = pr.executeUpdate(); 135 | if (rowsAffected == 1) { 136 | ResultSet generatedKeys = pr.getGeneratedKeys(); 137 | if (generatedKeys.next()) { 138 | return generatedKeys.getInt(1); // Yeni otel ID'sini döndür 139 | } 140 | } 141 | } catch (SQLException throwables) { 142 | throwables.printStackTrace(); 143 | } 144 | return -1; // Hata durumunda veya başarısız eklemede -1 döndür 145 | } 146 | public boolean stockUpdate(Room room,int num){ 147 | String query = "UPDATE public.room SET " + 148 | "stock = ? " + 149 | "WHERE id = ?"; 150 | try{ 151 | PreparedStatement pr = this.con.prepareStatement(query); { 152 | pr.setInt(1,room.getStock()+num); 153 | pr.setInt(2,room.getId()); 154 | return pr.executeUpdate() != -1; 155 | } 156 | }catch (SQLException e){ 157 | e.printStackTrace(); 158 | return true; 159 | } 160 | 161 | } 162 | 163 | public boolean delete(int id) { 164 | String query = "DELETE FROM public.room WHERE id =?"; 165 | try { 166 | PreparedStatement pr = con.prepareStatement(query); 167 | pr.setInt(1, id); 168 | return pr.executeUpdate() != -1; 169 | 170 | } catch (SQLException throwables) { 171 | throwables.printStackTrace(); 172 | } 173 | return true; 174 | 175 | } 176 | 177 | } 178 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/dao/TypeDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.Hotel; 5 | import entity.Property; 6 | import entity.Types; 7 | import entity.User; 8 | 9 | import java.lang.reflect.Type; 10 | import java.sql.*; 11 | import java.util.ArrayList; 12 | import java.util.HashSet; 13 | import java.util.List; 14 | 15 | 16 | public class TypeDao { 17 | 18 | private Connection con; 19 | 20 | 21 | public TypeDao() { 22 | this.con = Db.getInstance(); 23 | } 24 | 25 | public Types getById(int id) { 26 | Types obj = null; 27 | String query = "SELECT * FROM public.type_hotel WHERE hotel_id = ?"; 28 | try { 29 | PreparedStatement pr = con.prepareStatement(query); 30 | pr.setInt(1, id); 31 | ResultSet rs = pr.executeQuery(); 32 | if (rs != null && !rs.isClosed() && rs.next()) { 33 | obj = this.match(rs); 34 | }/* else { 35 | // ResultSet boş ise veya rs.next() false dönerse, yeni bir Types objesi oluşturarak id'yi set edin 36 | obj = new Types(); 37 | obj.setHotel_id(id); // Dışarıdan gelen id'yi set et 38 | obj.setTypeName(null); 39 | }*/ 40 | } catch (SQLException e) { 41 | e.printStackTrace(); 42 | } 43 | return obj; 44 | 45 | } 46 | public String getByTypeId(int id) { 47 | String typeName = null; // Geri dönüş değeri için başlangıçta null 48 | 49 | String query = "SELECT type_name FROM public.type_hotel WHERE type_id = ?"; 50 | try (PreparedStatement pr = con.prepareStatement(query)) { 51 | pr.setInt(1, id); 52 | try (ResultSet rs = pr.executeQuery()) { 53 | if (rs.next()) { 54 | typeName = rs.getString("type_name"); 55 | 56 | } 57 | } 58 | } catch (SQLException e) { 59 | e.printStackTrace(); 60 | // Hata durumunda typeName zaten null olarak kalacak 61 | } 62 | 63 | return typeName; 64 | } 65 | 66 | public ArrayList findAll(int hotelId) { 67 | ArrayList typesList = new ArrayList<>(); 68 | 69 | String query = "SELECT type_id,hotel_id,type_name FROM public.type_hotel WHERE hotel_id = ?"; 70 | 71 | try { 72 | PreparedStatement pr = con.prepareStatement(query); 73 | pr.setInt(1, hotelId); 74 | ResultSet resultSet = pr.executeQuery(); 75 | while (resultSet.next()) { 76 | Types types = match(resultSet); 77 | typesList.add(types); 78 | } 79 | 80 | } catch (SQLException e) { 81 | e.printStackTrace(); 82 | } 83 | 84 | return typesList; 85 | } 86 | 87 | 88 | // Method to create Types object from ResultSet 89 | private Types match(ResultSet rs) throws SQLException { 90 | Types obj = new Types(); 91 | obj.setTypeId(rs.getInt("type_id")); 92 | obj.setHotel_id(rs.getInt("hotel_id")); 93 | obj.setTypeName(rs.getString("type_name")); 94 | return obj; 95 | } 96 | public boolean save(int hotelId, List rightList) { 97 | try { 98 | // Sağ listedeki özellikleri kontrol et ve ekle 99 | for (String feature : rightList) { 100 | // Özellik veritabanında bulunmuyorsa, ekle 101 | String insertQuery = "INSERT INTO type_hotel (hotel_id, type_name) VALUES (?, ?)"; 102 | PreparedStatement insertStatement = con.prepareStatement(insertQuery); 103 | insertStatement.setInt(1, hotelId); 104 | insertStatement.setString(2, feature); 105 | insertStatement.executeUpdate(); 106 | } 107 | } catch (SQLException e) { 108 | e.printStackTrace(); 109 | System.out.println("An error occurred while inserting new features: " + e.getMessage()); 110 | return false; // Ekleme işlemi başarısız olduğunda false döndür 111 | } 112 | return true; // Ekleme işlemi başarılıysa true döndür 113 | } 114 | 115 | public boolean update(int hotelId, List rightList) { 116 | try { 117 | // Var olan tüm özellikleri veritabanından al 118 | String selectQuery = "SELECT type_name FROM type_hotel WHERE hotel_id = ?"; 119 | PreparedStatement selectStatement = con.prepareStatement(selectQuery); 120 | selectStatement.setInt(1, hotelId); 121 | ResultSet resultSet = selectStatement.executeQuery(); 122 | 123 | HashSet existingFeatures = new HashSet<>(); 124 | while (resultSet.next()) { 125 | existingFeatures.add(resultSet.getString("type_name")); 126 | } 127 | 128 | // Sağ listedeki özellikleri kontrol et ve ekle 129 | for (String feature : rightList) { 130 | if (!existingFeatures.contains(feature)) { 131 | // Özellik veritabanında bulunmuyorsa, ekle 132 | String insertQuery = "INSERT INTO type_hotel (hotel_id, type_name) VALUES (?, ?)"; 133 | PreparedStatement insertStatement = con.prepareStatement(insertQuery); 134 | insertStatement.setInt(1, hotelId); 135 | insertStatement.setString(2, feature); 136 | insertStatement.executeUpdate(); 137 | } 138 | } 139 | } catch (SQLException e) { 140 | e.printStackTrace(); 141 | System.out.println("An error occurred while inserting new features: " + e.getMessage()); 142 | } 143 | return true; 144 | } 145 | 146 | public boolean deleteType(int hotelId, List rightList) { 147 | try { 148 | // Var olan tüm özellikleri veritabanından al 149 | String selectQuery = "SELECT type_name FROM type_hotel WHERE hotel_id = ?"; 150 | PreparedStatement selectStatement = con.prepareStatement(selectQuery); 151 | selectStatement.setInt(1, hotelId); 152 | ResultSet resultSet = selectStatement.executeQuery(); 153 | 154 | HashSet existingFeatures = new HashSet<>(); 155 | while (resultSet.next()) { 156 | existingFeatures.add(resultSet.getString("type_name")); 157 | } 158 | 159 | // Sağ listedeki özellikleri kontrol et ve sil 160 | for (String feature : rightList) { 161 | if (existingFeatures.contains(feature)) { 162 | // Özellik veritabanında bulunmuyorsa, sil 163 | String deleteQuery = "DELETE FROM type_hotel WHERE hotel_id = ? AND type_name = ?"; 164 | PreparedStatement insertStatement = con.prepareStatement(deleteQuery); 165 | insertStatement.setInt(1, hotelId); 166 | insertStatement.setString(2, feature); 167 | insertStatement.executeUpdate(); 168 | } 169 | } 170 | System.out.println("Records deleted successfully."); 171 | return true; 172 | } catch (SQLException e) { 173 | e.printStackTrace(); 174 | System.out.println("Error occurred while deleting records."); 175 | return false; 176 | } 177 | } 178 | } 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/AdminView.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 |
139 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/GuestInfoAddView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.ReserManager; 4 | import core.Helper; 5 | import entity.Reser; 6 | 7 | import javax.swing.*; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | import static core.Helper.isFieldListEmpty; 12 | 13 | public class GuestInfoAddView extends Layout{ 14 | private JPanel container; 15 | private JTextField fld_adult_name_1; 16 | private JTextField fld_adult_nationalNo_1; 17 | private JTextField fld_adult_country_1; 18 | private JPanel pnl_adult; 19 | private JPanel pnl_child; 20 | private JButton guest_save; 21 | private JTextField fld_adult_name_2; 22 | private JTextField fld_adult_name_3; 23 | private JTextField fld_adult_nationalNo_2; 24 | private JTextField fld_adult_nationalNo_3; 25 | private JTextField fld_adult_country_2; 26 | private JTextField fld_adult_country_3; 27 | private JTextField fld_child_name_1; 28 | private JTextField fld_child_name_2; 29 | private JTextField fld_child_name_3; 30 | private JTextField fld_child_nationalNo_1; 31 | private JTextField fld_child_nationalNo_2; 32 | private JTextField fld_child_nationalNo_3; 33 | private JTextField fld_child_country_1; 34 | private JTextField fld_child_country_2; 35 | private JTextField fld_child_country_3; 36 | private JLabel Child2; 37 | private JLabel Child1; 38 | private JLabel Child3; 39 | private JLabel Adult1; 40 | private JLabel Adult2; 41 | private JLabel Adultr3; 42 | 43 | private Reser reser ; 44 | 45 | private ReserManager reserManager; 46 | private int adultNum = 0; 47 | private int childNum = 0; 48 | public static List reservations =new ArrayList<>(); 49 | /* private List reservations; 50 | 51 | public GuestInfoAddView(List reservations) { 52 | this.reservations = reservations; 53 | }*/ 54 | GuestInfoAddView(int adultNum,int childNum){ 55 | add(container); 56 | this.guiInitilaze(600, 450); 57 | 58 | this.reser= new Reser(); 59 | this.reserManager = new ReserManager(); 60 | 61 | this.adultNum = adultNum; 62 | this.childNum = childNum; 63 | 64 | 65 | for(int i =0 ; i<= this.adultNum ;i++){ 66 | if(i==1){ 67 | fld_adult_name_1.setEnabled(true); 68 | fld_adult_nationalNo_1.setEnabled(true); 69 | fld_adult_country_1.setEnabled(true); 70 | }else if(i==2){ 71 | fld_adult_name_2.setEnabled(true); 72 | fld_adult_nationalNo_2.setEnabled(true); 73 | fld_adult_country_2.setEnabled(true); 74 | }else if(i==3){ 75 | fld_adult_name_3.setEnabled(true); 76 | fld_adult_nationalNo_3.setEnabled(true); 77 | fld_adult_country_3.setEnabled(true); 78 | } 79 | } 80 | for(int i =0 ; i<= this.childNum ;i++){ 81 | if(i==1){ 82 | fld_child_name_1.setEnabled(true); 83 | fld_child_nationalNo_1.setEnabled(true); 84 | fld_child_country_1.setEnabled(true); 85 | }else if(i==2){ 86 | fld_child_name_2.setEnabled(true); 87 | fld_child_nationalNo_2.setEnabled(true); 88 | fld_child_country_2.setEnabled(true); 89 | }else if(i==3){ 90 | fld_child_name_3.setEnabled(true); 91 | fld_child_nationalNo_3.setEnabled(true); 92 | fld_child_country_3.setEnabled(true); 93 | } 94 | } 95 | 96 | guest_save.addActionListener(e -> { 97 | 98 | // Her bir grup için JTextField dizilerini tanımlayalım 99 | JTextField[] groupA1 = {fld_adult_name_1, fld_adult_nationalNo_1, fld_adult_country_1}; 100 | JTextField[] groupA2 = {fld_adult_name_2, fld_adult_nationalNo_2, fld_adult_country_2}; 101 | JTextField[] groupA3 = {fld_adult_name_3, fld_adult_nationalNo_3, fld_adult_country_3}; 102 | JTextField[] groupC1 = {fld_child_name_1, fld_child_nationalNo_1, fld_child_country_1}; 103 | JTextField[] groupC2 = {fld_child_name_2, fld_child_nationalNo_2, fld_child_country_2}; 104 | JTextField[] groupC3 = {fld_child_name_3, fld_child_nationalNo_3, fld_child_country_3}; 105 | 106 | boolean groupA1Valid = checkFields(groupA1); 107 | boolean groupA2Valid = checkFields(groupA2); 108 | boolean groupA3Valid = checkFields(groupA3); 109 | boolean group1Valid = checkFields(groupC1); 110 | boolean group2Valid = checkFields(groupC2); 111 | boolean group3Valid = checkFields(groupC3); 112 | 113 | if (groupA1Valid && groupA2Valid && groupA3Valid &&group1Valid && group2Valid &&group3Valid) { 114 | Helper.showMsg("Kontroller Başarılı"); 115 | 116 | // Her bir grup için JTextField dizilerini tanımlayalım 117 | JTextField[][] groups = { 118 | {fld_adult_name_1, fld_adult_nationalNo_1, fld_adult_country_1}, 119 | {fld_adult_name_2, fld_adult_nationalNo_2, fld_adult_country_2}, 120 | {fld_adult_name_3, fld_adult_nationalNo_3, fld_adult_country_3}, 121 | {fld_child_name_1, fld_child_nationalNo_1, fld_child_country_1}, 122 | {fld_child_name_2, fld_child_nationalNo_2, fld_child_country_2}, 123 | {fld_child_name_3, fld_child_nationalNo_3, fld_child_country_3} 124 | }; 125 | 126 | // Reser nesnelerini tutacak bir liste oluşturalım 127 | //List resers = new ArrayList<>(); 128 | 129 | // Her bir grup için döngüyü kullanarak kontrol yapalım 130 | for (int i = 0; i < groups.length; i++) { 131 | JTextField[] group = groups[i]; 132 | if (isFieldListEmpty(group)) { 133 | continue; // Grup boş ise atla 134 | } 135 | 136 | // Grup dolu ise Reser nesnesi oluşturup bilgileri ekleyelim 137 | Reser reser = new Reser(); 138 | reser.setGuestFllName(group[0].getText()); 139 | reser.setGuestnationalNumber(group[1].getText()); 140 | reser.setGuestCountry(group[2].getText()); 141 | 142 | // Diğer özelliklerini de burada ayarlayabilirsiniz (örn. setGuestClass) 143 | if (i < 3) { 144 | reser.setGuestClass("Adult"); // İlk üç grup için Adult olarak ayarla 145 | } else { 146 | reser.setGuestClass("Child"); // Son üç grup için Child olarak ayarla 147 | } 148 | 149 | // Oluşturulan Reser nesnesini listeye ekleyelim 150 | reservations.add(reser); 151 | } 152 | 153 | // Listede en az bir eleman varsa kontroller başarılıdır 154 | if (!reservations.isEmpty()) { 155 | Helper.showMsg("Liste ekleme Başarılı"); 156 | 157 | // Daha sonra bu listeyi istediğiniz şekilde kullanabilirsiniz 158 | // Örneğin, veritabanına eklemek için saveAndGetReserId fonksiyonunu kullanabilirsiniz 159 | } else { 160 | Helper.showMsg("Lütfen en az bir alanı doldurun."); 161 | } 162 | 163 | } else { 164 | Helper.showMsg("Lütfen tüm alanları doldurun."); 165 | } 166 | 167 | }); 168 | } 169 | private boolean checkFields(JTextField[] fields) { 170 | for (JTextField field : fields) { 171 | if (field.isEnabled()) { 172 | String text = field.getText().trim(); 173 | if (text.isEmpty()) { 174 | return false; 175 | } 176 | } 177 | } 178 | return true; 179 | } 180 | 181 | } -------------------------------------------------------------------------------- /TurizmAcente-master/src/dao/HotelDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import core.Helper; 5 | import entity.Hotel; 6 | import entity.Property; 7 | 8 | import java.sql.*; 9 | 10 | import java.sql.Connection; 11 | import java.sql.ResultSet; 12 | import java.sql.SQLException; 13 | 14 | import java.util.ArrayList; 15 | 16 | public class HotelDao { 17 | 18 | private final Connection con; 19 | 20 | public HotelDao() { 21 | this.con = Db.getInstance(); 22 | } 23 | 24 | public Hotel getById(int id) { 25 | Hotel obj = null; 26 | String query = "SELECT * FROM public.hotels WHERE hotel_id = ?"; 27 | try { 28 | PreparedStatement pr = con.prepareStatement(query); 29 | pr.setInt(1, id); 30 | ResultSet rs = pr.executeQuery(); 31 | if (rs.next()) { 32 | obj = this.match(rs); 33 | 34 | 35 | } 36 | } catch (SQLException e) { 37 | e.printStackTrace(); 38 | } 39 | return obj; 40 | 41 | } 42 | 43 | public ArrayList findAll() { 44 | String sql = "SELECT * FROM public.hotels ORDER BY hotel_id ASC"; 45 | return this.selectByQuery(sql); 46 | } 47 | 48 | // Metot, otel bilgilerini güncellemek için kullanılır 49 | public boolean update(Hotel hotel) { 50 | String updateQuery = "UPDATE public.hotels " + 51 | "SET hotel_name = ?, " + 52 | "city = ?, " + 53 | "district = ?, " + 54 | "full_address = ?, " + 55 | "email = ?, " + 56 | "phone_number = ?, " + 57 | "star = ? " + 58 | "WHERE hotel_id = ?"; 59 | try { 60 | PreparedStatement pr = con.prepareStatement(updateQuery); 61 | // PreparedStatement'e parametreleri set et 62 | pr.setString(1, hotel.getHotel_name()); 63 | pr.setString(2, hotel.getHotel_city()); 64 | pr.setString(3, hotel.getHotel_district()); 65 | pr.setString(4, hotel.getHotel_fllAdres()); 66 | pr.setString(5, hotel.getHotel_email()); 67 | pr.setString(6, hotel.getHotel_phone()); 68 | pr.setInt(7, hotel.getHotel_star()); 69 | pr.setInt(8, hotel.getHotel_id()); 70 | 71 | return pr.executeUpdate() != -1; 72 | } catch (SQLException throwables) { 73 | throwables.printStackTrace(); 74 | } 75 | return true; 76 | } 77 | 78 | 79 | /* public boolean save(Hotel hotel) { 80 | String insertQuery = "INSERT INTO public.hotels (" + 81 | "hotel_name, city, district, full_address, email, phone_number, star) " + 82 | "VALUES (?, ?, ?, ?, ?, ?, ?)"; 83 | 84 | try { 85 | PreparedStatement pr = con.prepareStatement(insertQuery); 86 | pr.setString(1, hotel.getHotel_name()); 87 | pr.setString(2, hotel.getHotel_city()); 88 | pr.setString(3, hotel.getHotel_district()); 89 | pr.setString(4, hotel.getHotel_fllAdres()); 90 | pr.setString(5, hotel.getHotel_email()); 91 | pr.setString(6, hotel.getHotel_phone()); 92 | pr.setInt(7, hotel.getHotel_star()); 93 | return pr.executeUpdate() != -1; 94 | } catch (SQLException throwables) { 95 | throwables.printStackTrace(); 96 | } 97 | return true; 98 | }*/ 99 | 100 | public int saveAndGetHotelId(Hotel hotel) { 101 | String insertQuery = "INSERT INTO public.hotels (" + 102 | "hotel_name, city, district, full_address, email, phone_number, star) " + 103 | "VALUES (?, ?, ?, ?, ?, ?, ?)"; 104 | 105 | try { 106 | // Önce veritabanında aynı e-posta adresiyle kayıt olup olmadığını kontrol et 107 | if (!isEmailExists(hotel.getHotel_email())) { 108 | PreparedStatement pr = con.prepareStatement(insertQuery, Statement.RETURN_GENERATED_KEYS); 109 | pr.setString(1, hotel.getHotel_name()); 110 | pr.setString(2, hotel.getHotel_city()); 111 | pr.setString(3, hotel.getHotel_district()); 112 | pr.setString(4, hotel.getHotel_fllAdres()); 113 | pr.setString(5, hotel.getHotel_email()); 114 | pr.setString(6, hotel.getHotel_phone()); 115 | pr.setInt(7, hotel.getHotel_star()); 116 | 117 | int rowsAffected = pr.executeUpdate(); 118 | if (rowsAffected == 1) { 119 | ResultSet generatedKeys = pr.getGeneratedKeys(); 120 | if (generatedKeys.next()) { 121 | return generatedKeys.getInt(1); // Yeni otel ID'sini döndür 122 | } 123 | } 124 | } else { 125 | Helper.showMsg("Bu e-posta ile daha önce kayıt yapılmış"); 126 | } 127 | } catch (SQLException throwables) { 128 | throwables.printStackTrace(); 129 | } 130 | return -1; // Hata durumunda veya başarısız eklemede -1 döndür 131 | } 132 | 133 | // Veritabanında verilen e-posta adresiyle kayıtlı otel var mı diye kontrol eden metod 134 | private boolean isEmailExists(String email) throws SQLException { 135 | String query = "SELECT COUNT(*) FROM public.hotels WHERE email = ?"; 136 | try (PreparedStatement pr = con.prepareStatement(query)) { 137 | pr.setString(1, email); 138 | ResultSet rs = pr.executeQuery(); 139 | if (rs.next()) { 140 | int count = rs.getInt(1); 141 | return count > 0; // Eğer count 0'dan büyükse e-posta adresiyle kayıtlı otel var demektir 142 | } 143 | } 144 | return false; 145 | } 146 | 147 | 148 | public ArrayList selectByQuery(String query) { 149 | ArrayList modelList = new ArrayList<>(); 150 | try { 151 | ResultSet rs = this.con.createStatement().executeQuery(query); 152 | while (rs.next()) { 153 | modelList.add(this.match(rs)); 154 | 155 | } 156 | } catch (SQLException throwables) { 157 | throwables.printStackTrace(); 158 | } 159 | return modelList; 160 | } 161 | 162 | public Hotel match(ResultSet rs) throws SQLException { 163 | Hotel obj = new Hotel(); 164 | obj.setHotel_id(rs.getInt("hotel_id")); 165 | obj.setHotel_name(rs.getString("hotel_name")); 166 | obj.setHotel_city(rs.getString("city")); 167 | obj.setHotel_district((rs.getString("district"))); 168 | obj.setHotel_fllAdres((rs.getString("full_address"))); 169 | obj.setHotel_email((rs.getString("email"))); 170 | obj.setHotel_phone((rs.getString("phone_number"))); 171 | obj.setHotel_star((rs.getInt("star"))); 172 | return obj; 173 | } 174 | public ArrayList getHotelCity(String hotelName){ 175 | ArrayList roomPropertiesList = new ArrayList<>(); 176 | Hotel obj; 177 | String query = "SELECT hotel_id,city FROM public.hotels WHERE hotel_name = ?"; 178 | try { 179 | PreparedStatement pr = con.prepareStatement(query); 180 | pr.setString(1, hotelName); 181 | ResultSet rs = pr.executeQuery(); 182 | while (rs.next()){ 183 | obj = new Hotel(); 184 | obj.setHotel_id(rs.getInt("hotel_id")); 185 | obj.setHotel_city(rs.getString("city")); 186 | 187 | roomPropertiesList.add(obj); 188 | } 189 | } catch (SQLException e) { 190 | e.printStackTrace(); 191 | } 192 | 193 | return roomPropertiesList; 194 | } 195 | 196 | public boolean delete(int id) { 197 | String query = "DELETE FROM public.hotels WHERE hotel_id =?"; 198 | try { 199 | PreparedStatement pr = con.prepareStatement(query); 200 | pr.setInt(1, id); 201 | return pr.executeUpdate() != -1; 202 | 203 | } catch (SQLException throwables) { 204 | throwables.printStackTrace(); 205 | } 206 | return true; 207 | 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/dao/ReserDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import core.Helper; 5 | import entity.Property; 6 | import entity.Reser; 7 | import entity.Room; 8 | import view.GuestInfoAddView; 9 | 10 | import java.sql.*; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class ReserDao { 15 | private Connection con; 16 | public ReserDao() { 17 | this.con = Db.getInstance(); 18 | } 19 | 20 | public Reser getById(int id) { 21 | Reser obj = null; 22 | String query = "SELECT * FROM public.reservations WHERE id = ?"; 23 | try { 24 | PreparedStatement pr = con.prepareStatement(query); 25 | pr.setInt(1, id); 26 | ResultSet rs = pr.executeQuery(); 27 | if (rs.next()) { 28 | obj = this.match(rs); 29 | } 30 | } catch (SQLException e) { 31 | e.printStackTrace(); 32 | } 33 | return obj; 34 | } 35 | 36 | 37 | 38 | 39 | public ArrayList findAll() { 40 | String sql = "SELECT * FROM public.reservations ORDER BY id ASC"; 41 | return this.selectByQuery(sql); 42 | } 43 | public ArrayList selectByQuery(String query) { 44 | ArrayList modelList = new ArrayList<>(); 45 | try { 46 | ResultSet rs = this.con.createStatement().executeQuery(query); 47 | while (rs.next()) { 48 | modelList.add(this.match(rs)); 49 | } 50 | } catch (SQLException throwables) { 51 | throwables.printStackTrace(); 52 | } 53 | return modelList; 54 | } 55 | // public Reser(int id, int room_id, String reserFllName, String reserPhone, String reserEmail, String reserNote, String reserCheckInDdate, String reserCheckOutDate, String adultNumb, String childNumb, String totalPrice) { 56 | public Reser match(ResultSet rs) throws SQLException { 57 | Reser reser = new Reser(); 58 | reser.setId(rs.getInt("id")); 59 | reser.setRoom_id(rs.getInt("room_id")); 60 | reser.setReserFllName(rs.getString("reser_fll_name")); 61 | reser.setReserPhone(rs.getString("reser_phone")); 62 | reser.setReserEmail(rs.getString("reser_email")); 63 | reser.setReserNote(rs.getString("reser_note")); 64 | reser.setReserCheckInDdate(rs.getString("reser_check_in_date")); 65 | reser.setReserCheckOutDate(rs.getString("reser_check_out_date")); 66 | reser.setAdultNumb(rs.getString("adult_numb")); 67 | reser.setChildNumb(rs.getString("child_numb")); 68 | reser.setTotalPrice(rs.getString("total_price")); 69 | return reser; 70 | } 71 | 72 | 73 | 74 | 75 | 76 | //int roomID, String fllName, String phone, String email, String notes, String checkIn,String checkOut, String adultNnumb, String childNumb, String totalPrice 77 | public int saveAndGetReserlId(Reser reser) { 78 | String insertQuery = "INSERT INTO public.reservations (room_id, reser_fll_name, reser_phone, reser_email, reser_note, reser_check_in_date, reser_check_out_date, adult_numb, child_numb, total_price) VALUES (?,?,?,?,?,?,?,?,?,?)"; 79 | try { 80 | 81 | PreparedStatement pr = con.prepareStatement(insertQuery, Statement.RETURN_GENERATED_KEYS); 82 | pr.setInt(1, reser.getRoom_id()); 83 | pr.setString(2, reser.getReserFllName()); 84 | pr.setString(3, reser.getReserPhone()); 85 | pr.setString(4, reser.getReserEmail()); 86 | pr.setString(5, reser.getReserNote()); 87 | pr.setString(6, reser.getReserCheckInDdate()); 88 | pr.setString(7, reser.getReserCheckOutDate()); 89 | pr.setString(8, reser.getAdultNumb()); 90 | pr.setString(9, reser.getChildNumb()); 91 | pr.setString(10, reser.getTotalPrice()); 92 | 93 | int rowsAffected = pr.executeUpdate(); 94 | if (rowsAffected == 1) { 95 | ResultSet generatedKeys = pr.getGeneratedKeys(); 96 | if (generatedKeys.next()) { 97 | return generatedKeys.getInt(1); // Yeni rezervasyon ID'sini döndür 98 | } 99 | } else { 100 | Helper.showMsg("Reservation could not be added."); // Ekleme başarısız olduğunda hata mesajı 101 | } 102 | } catch (SQLException throwables) { 103 | throwables.printStackTrace(); // Hata durumunda istisna işleniyor 104 | } 105 | return -1; // Hata durumunda veya başarısız eklemede -1 döndürülüyor 106 | } 107 | 108 | public boolean update(Reser reser){ 109 | String query = "UPDATE public.reservations SET " + 110 | "reser_fll_name = ?, " + 111 | "reser_phone = ?, " + 112 | "reser_email = ?, " + 113 | "reser_note = ? " + 114 | "WHERE id = ?"; 115 | try{ 116 | PreparedStatement pr = this.con.prepareStatement(query); { 117 | pr.setString(1,reser.getReserFllName()); 118 | pr.setString(2,reser.getReserPhone()); 119 | pr.setString(3,reser.getReserEmail()); 120 | pr.setString(4,reser.getReserNote()); 121 | pr.setInt(5,reser.getId()); 122 | return pr.executeUpdate() != -1; 123 | } 124 | }catch (SQLException e){ 125 | e.printStackTrace(); 126 | return true; 127 | } 128 | 129 | } 130 | 131 | public boolean delete(int id) { 132 | String query = "DELETE FROM public.reservations WHERE id =?"; 133 | try { 134 | PreparedStatement pr = con.prepareStatement(query); 135 | pr.setInt(1, id); 136 | return pr.executeUpdate() != -1; 137 | 138 | } catch (SQLException throwables) { 139 | throwables.printStackTrace(); 140 | } 141 | return true; 142 | 143 | } 144 | 145 | 146 | // Örnek: reservations listesini veritabanına eklemek 147 | public boolean saveGuestInfoList(int reservationId) { 148 | try { 149 | // reservations listesini GuestInfoAddView sınıfından al 150 | List guestInfoList = GuestInfoAddView.reservations; 151 | 152 | // Her bir Reser nesnesi için guest_info tablosuna ekleme yap 153 | for (Reser reser : guestInfoList) { 154 | String insertQuery = "INSERT INTO public.guest_info (reservations_id, full_name, national_number, country, guest_class) VALUES (?, ?, ?, ?, ?)"; 155 | PreparedStatement insertStatement = con.prepareStatement(insertQuery); 156 | insertStatement.setInt(1, reservationId); 157 | insertStatement.setString(2, reser.getGuestFllName()); 158 | insertStatement.setString(3, reser.getGuestnationalNumber()); 159 | insertStatement.setString(4, reser.getGuestCountry()); 160 | insertStatement.setString(5, reser.getGuestClass()); 161 | insertStatement.executeUpdate(); 162 | } 163 | } catch (SQLException e) { 164 | e.printStackTrace(); 165 | System.out.println("An error occurred while inserting new guest information: " + e.getMessage()); 166 | return false; // Ekleme işlemi başarısız olduğunda false döndür 167 | } 168 | return true; // Ekleme işlemi başarılıysa true döndür 169 | } 170 | 171 | 172 | 173 | 174 | public ArrayList getListByGuestInfo(int id){ 175 | ArrayList reserGuestInfoList = new ArrayList<>(); 176 | String query = "SELECT * FROM guest_info WHERE reservations_id = ?"; 177 | 178 | try { 179 | PreparedStatement pr = con.prepareStatement(query); 180 | pr.setInt(1, id); 181 | ResultSet rs = pr.executeQuery(); 182 | while (rs.next()){ 183 | Reser resers =new Reser(); 184 | resers.setGuestId(rs.getInt("guest_id")); 185 | resers.setId(rs.getInt("reservations_id")); 186 | resers.setGuestFllName(rs.getString("full_name")); 187 | resers.setGuestnationalNumber(rs.getString("national_number")); 188 | resers.setGuestCountry(rs.getString("country")); 189 | resers.setGuestClass(rs.getString("guest_class")); 190 | 191 | reserGuestInfoList.add(resers); 192 | } 193 | } catch (SQLException e) { 194 | e.printStackTrace(); 195 | } 196 | 197 | return reserGuestInfoList; 198 | } 199 | 200 | } 201 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /TurizmAcente-master/.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 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/dao/SeasonDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.Hotel; 5 | import entity.Property; 6 | import entity.Season; 7 | import entity.User; 8 | 9 | import java.sql.*; 10 | import java.time.LocalDate; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class SeasonDao { 15 | private Connection con; 16 | 17 | public SeasonDao() { 18 | this.con = Db.getInstance(); 19 | } 20 | 21 | /* public ArrayList findAll(int hotelId) { 22 | ArrayList seasonArrayList = new ArrayList<>(); 23 | 24 | String query = "SELECT season_id, start_date, end_date, hotel_id, season_type FROM hotel_seasons WHERE hotel_id = ? ORDER BY season_id ASC"; 25 | 26 | try (PreparedStatement statement = con.prepareStatement(query)) { 27 | statement.setInt(1, hotelId); 28 | ResultSet resultSet = statement.executeQuery(); 29 | 30 | while (resultSet.next()) { 31 | Season season = match(resultSet); 32 | seasonArrayList.add(season); 33 | } 34 | } catch (SQLException e) { 35 | e.printStackTrace(); 36 | } 37 | 38 | return seasonArrayList; 39 | }*/ 40 | 41 | public Season getById(int hotelId) { 42 | Season season = null; 43 | String query = "SELECT season_id, hotel_id, start_date, end_date, season_type FROM hotel_seasons WHERE hotel_id = ?"; 44 | 45 | try (PreparedStatement pr = con.prepareStatement(query)) { 46 | pr.setInt(1, hotelId); 47 | ResultSet rs = pr.executeQuery(); 48 | 49 | if (rs.next()) { 50 | season = match(rs); 51 | } 52 | } catch (SQLException e) { 53 | e.printStackTrace(); 54 | } 55 | 56 | return season; 57 | } 58 | public Season getSeasonDate(int seasonId) { 59 | Season season = null; 60 | String query = "SELECT season_id, hotel_id,start_date, end_date, season_type FROM hotel_seasons WHERE season_id = ?"; 61 | 62 | try (PreparedStatement pr = con.prepareStatement(query)) { 63 | pr.setInt(1, seasonId); 64 | ResultSet rs = pr.executeQuery(); 65 | 66 | if (rs.next()) { 67 | season = match(rs); 68 | } 69 | } catch (SQLException e) { 70 | e.printStackTrace(); 71 | } 72 | 73 | return season; 74 | } 75 | 76 | 77 | public ArrayList findAll(int hotelId) { 78 | ArrayList seasonArrayList = new ArrayList<>(); 79 | 80 | String query = "SELECT season_id,hotel_id, start_date, end_date ,season_type FROM hotel_seasons WHERE hotel_id = ? ORDER BY season_id ASC"; 81 | 82 | try { 83 | PreparedStatement statement = con.prepareStatement(query); 84 | statement.setInt(1, hotelId); 85 | ResultSet resultSet = statement.executeQuery(); 86 | 87 | while (resultSet.next()) { 88 | Season season = match(resultSet); 89 | // Sezon türüne göre başlangıç ve bitiş tarihlerini ayarla 90 | 91 | seasonArrayList.add(season); 92 | } 93 | 94 | } catch (SQLException e) { 95 | e.printStackTrace(); 96 | } 97 | 98 | return seasonArrayList; 99 | } 100 | public List getBySeasonList(int hotelId) { 101 | List seasons = new ArrayList<>(); 102 | String query = "SELECT * FROM hotel_seasons WHERE hotel_id = ?"; 103 | 104 | try (PreparedStatement pr = con.prepareStatement(query)) { 105 | pr.setInt(1, hotelId); 106 | ResultSet rs = pr.executeQuery(); 107 | 108 | while (rs.next()) { 109 | Season season = match(rs); 110 | seasons.add(season); // Her sezonu listeye ekle 111 | } 112 | } catch (SQLException e) { 113 | e.printStackTrace(); 114 | } 115 | 116 | return seasons; 117 | } 118 | 119 | // Method to create Season object from ResultSet 120 | /* private Season match(ResultSet rs) throws SQLException { 121 | Season season = new Season(); 122 | season.setSeasonId(rs.getInt("season_id")); 123 | season.setHotel_id(rs.getInt("hotel_id")); 124 | season.setSeason_start(rs.getObject("start_date", LocalDate.class)); 125 | season.setSeason_end(rs.getObject("end_date", LocalDate.class)); 126 | season.setSeasonName(rs.getString("season_type")); 127 | return season; 128 | }*/ 129 | 130 | private Season match(ResultSet rs) throws SQLException { 131 | Season season = new Season(); 132 | season.setSeasonId(rs.getInt("season_id")); 133 | season.setHotel_id(rs.getInt("hotel_id")); 134 | season.setSeason_start(LocalDate.parse(rs.getString("start_date"))); 135 | season.setSeason_end(LocalDate.parse(rs.getString("end_date"))); 136 | season.setSeasonName(rs.getString("season_type")); 137 | String seasonType = season.getSeasonName(); 138 | 139 | return season; 140 | } 141 | 142 | 143 | /* public boolean save( Season season, int hotelId) { 144 | String insertQuery = "INSERT INTO hotel_seasons (hotel_id, start_date, end_date, season_type) VALUES (?, ?, ?, ?)"; 145 | try (PreparedStatement pr = con.prepareStatement(insertQuery)) { 146 | pr.setInt(1, hotelId); // hotel_id parametresi olarak gelen değeri kullan 147 | pr.setDate(2, Date.valueOf(season.getSeason_start())); 148 | pr.setDate(3, Date.valueOf(season.getSeason_end())); 149 | pr.setString(4, season.getSeasonName()); 150 | 151 | int rowsAffected = pr.executeUpdate(); 152 | return rowsAffected == 1; // Ekleme işlemi başarılıysa true döndür 153 | } catch (SQLException e) { 154 | e.printStackTrace(); 155 | System.out.println("An error occurred while inserting new season: " + e.getMessage()); 156 | return false; // Ekleme işlemi başarısız olduysa false döndür 157 | } 158 | 159 | }*/ 160 | public boolean save(List seasons, int hotelId) { 161 | String insertQuery = "INSERT INTO hotel_seasons (hotel_id, start_date, end_date, season_type) VALUES (?, ?, ?, ?)"; 162 | boolean success = true; 163 | 164 | try (PreparedStatement pr = con.prepareStatement(insertQuery)) { 165 | for (Season season : seasons) { 166 | pr.setInt(1, hotelId); 167 | pr.setDate(2, Date.valueOf(season.getSeason_start())); 168 | pr.setDate(3, Date.valueOf(season.getSeason_end())); 169 | pr.setString(4, season.getSeasonName()); 170 | 171 | int rowsAffected = pr.executeUpdate(); 172 | if (rowsAffected != 1) { 173 | success = false; 174 | break; 175 | } 176 | } 177 | } catch (SQLException e) { 178 | e.printStackTrace(); 179 | System.out.println("An error occurred while inserting new seasons: " + e.getMessage()); 180 | success = false; 181 | } 182 | 183 | return success; 184 | } 185 | 186 | 187 | public boolean update(Season season) { 188 | String updateQuery = "UPDATE hotel_seasons " 189 | + "SET start_date = ?, end_date = ? " 190 | + "WHERE hotel_id = ? AND season_type = ?"; 191 | try (PreparedStatement pr = con.prepareStatement(updateQuery)) { 192 | pr.setDate(1, Date.valueOf(season.getSeason_start())); 193 | pr.setDate(2, Date.valueOf(season.getSeason_end())); 194 | pr.setInt(3, season.getHotel_id()); 195 | pr.setString(4, season.getSeasonName()); 196 | 197 | int rowsAffected = pr.executeUpdate(); 198 | return rowsAffected > 0; // Güncelleme başarılı ise true döndür 199 | 200 | } catch (SQLException e) { 201 | e.printStackTrace(); // Hata durumunda hatayı yazdır 202 | return false; // Güncelleme başarısız ise false döndür 203 | } 204 | } 205 | 206 | public ArrayList selectByQuery(String query) { 207 | ArrayList seasonArrayList = new ArrayList<>(); 208 | 209 | try (ResultSet rs = con.createStatement().executeQuery(query)) { 210 | while (rs.next()) { 211 | Season season = match(rs); 212 | seasonArrayList.add(season); 213 | } 214 | } catch (SQLException e) { 215 | e.printStackTrace(); 216 | } 217 | 218 | return seasonArrayList; 219 | } 220 | 221 | public Season getBySeason(int id) { 222 | Season obj = new Season(); 223 | String query ="SELECT * FROM hotel_seasons WHERE season_id = ?"; 224 | try { 225 | PreparedStatement pr = con.prepareStatement(query); 226 | pr.setInt(1, id); 227 | ResultSet rs = pr.executeQuery(); 228 | if (rs.next()) { 229 | //obj.setSeasonId(rs.getInt("season_id")); 230 | // obj.setHotel_id(rs.getInt("hotel_id")); 231 | obj.setSeason_start(LocalDate.parse(rs.getString("start_date"))); 232 | obj.setSeason_end(LocalDate.parse(rs.getString("end_date"))); 233 | obj.setSeasonName(rs.getString("season_type")); 234 | } 235 | 236 | } catch (SQLException e) { 237 | e.printStackTrace(); 238 | } 239 | return obj; 240 | 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/dao/PropertyDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import core.Db; 4 | import entity.Property; 5 | import org.postgresql.jdbc.PgArray; 6 | 7 | import java.sql.*; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | public class PropertyDao { 12 | private Connection con; 13 | 14 | private final HotelDao hotelDao = new HotelDao(); 15 | 16 | public PropertyDao() { 17 | this.con = Db.getInstance(); 18 | 19 | } 20 | public Property getById(int id) { 21 | Property obj = null; 22 | String query = "SELECT * FROM public.hotel_property WHERE hotel_id = ?"; 23 | try { 24 | PreparedStatement pr = con.prepareStatement(query); 25 | pr.setInt(1, id); 26 | ResultSet rs = pr.executeQuery(); 27 | if (rs.next()) { 28 | obj = this.match(rs); 29 | } else { 30 | // ResultSet boş ise veya rs.next() false dönerse, yeni bir Types objesi oluşturarak id'yi set edin 31 | obj = new Property(); 32 | obj.setHotel_id(id); // Dışarıdan gelen id'yi set et 33 | obj.setPropertyNames(List.of(new String[] {"Ücretsiz Otopark", 34 | "Ücretsiz WiFi", 35 | "Yüzme Havuzu", 36 | "Fitness Center", 37 | "Hotel Concierge", 38 | "SPA", 39 | "7/24 Oda Servisi"})); 40 | } 41 | 42 | } catch (SQLException e) { 43 | e.printStackTrace(); 44 | } 45 | return obj; 46 | 47 | } 48 | 49 | 50 | /* public ArrayList getPropertyList(int id) { 51 | ArrayList resultList = new ArrayList<>(); 52 | 53 | String query = "SELECT * FROM public.hotel_property WHERE hotel_id = ? ORDER BY property_id ASC"; 54 | try (PreparedStatement pr = con.prepareStatement(query)) { 55 | pr.setInt(1, id); 56 | ResultSet rs = pr.executeQuery(); 57 | 58 | while (rs.next()) { 59 | // Her satır için Object[] dizisi oluşturup verileri ekleyelim 60 | Object[] row = new Object[rs.getMetaData().getColumnCount()]; 61 | for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { 62 | row[i - 1] = rs.getObject(i); // Sütun değerlerini diziye ekle 63 | } 64 | resultList.add(row); // Listeye ekleyelim 65 | } 66 | } catch (SQLException e) { 67 | e.printStackTrace(); 68 | } 69 | 70 | return resultList; 71 | }*/ 72 | public List getPropertyList(int hotelId) { 73 | List propertyList = new ArrayList<>(); 74 | 75 | String query = "SELECT * FROM public.hotel_property WHERE hotel_id = ?"; 76 | try (PreparedStatement ps = con.prepareStatement(query)) { 77 | ps.setInt(1, hotelId); 78 | ResultSet rs = ps.executeQuery(); 79 | 80 | while (rs.next()) { 81 | Array propertyNamesArray = rs.getArray("property_names"); 82 | if (propertyNamesArray != null) { 83 | // PostgreSQL array'i PgArray olarak elde et 84 | PgArray pgArray = (PgArray) propertyNamesArray; 85 | 86 | // PgArray'den Java dizisine dönüşüm 87 | Object[] pgElements = (Object[]) pgArray.getArray(); 88 | 89 | // Java dizisini String dizisine dönüştür 90 | String[] propertyNames = new String[pgElements.length]; 91 | for (int i = 0; i < pgElements.length; i++) { 92 | propertyNames[i] = (String) pgElements[i]; 93 | } 94 | 95 | // Listeye ekle 96 | propertyList.add(propertyNames); 97 | } 98 | } 99 | } catch (SQLException e) { 100 | throw new RuntimeException(e); 101 | } 102 | 103 | return propertyList; 104 | } 105 | 106 | public Property match(ResultSet rs) throws SQLException { 107 | Property property = new Property(); 108 | property.setPropertyID(rs.getInt("property_id")); 109 | property.setHotel_id(rs.getInt("hotel_id")); 110 | 111 | // Get the java.sql.Array from the ResultSet 112 | Array propertyNamesArray = rs.getArray("property_names"); 113 | 114 | if (propertyNamesArray != null) { 115 | // Convert java.sql.Array to Object array 116 | Object[] propertyNamesData = (Object[]) propertyNamesArray.getArray(); 117 | 118 | // Convert Object array to List 119 | List propertyNamesList = new ArrayList<>(); 120 | for (Object element : propertyNamesData) { 121 | if (element != null) { 122 | propertyNamesList.add(element.toString()); 123 | } 124 | } // Set the propertyNames list in the Property object 125 | property.setPropertyNames(propertyNamesList); 126 | } 127 | 128 | return property; 129 | } 130 | 131 | public ArrayList findAll() { 132 | String sql = "SELECT * FROM public.hotel_property ORDER BY property_id ASC"; 133 | return this.selectByQuery(sql); 134 | 135 | } 136 | 137 | public ArrayList selectByQuery(String query) { 138 | ArrayList modelList = new ArrayList<>(); 139 | try { 140 | ResultSet rs = this.con.createStatement().executeQuery(query); 141 | while (rs.next()) { 142 | modelList.add(this.match(rs)); 143 | 144 | } 145 | } catch (SQLException throwables) { 146 | throwables.printStackTrace(); 147 | } 148 | return modelList; 149 | } 150 | 151 | 152 | public boolean save(Property property, int hotelId) { 153 | String insertQuery = "INSERT INTO public.hotel_property (property_names, hotel_id) VALUES (?, ?)"; 154 | 155 | try { 156 | PreparedStatement pr = con.prepareStatement(insertQuery); 157 | Array propertyNamesArray = con.createArrayOf("text", property.getPropertyNames().toArray()); 158 | pr.setArray(1, propertyNamesArray); 159 | pr.setInt(2, hotelId); 160 | 161 | int rowsAffected = pr.executeUpdate(); 162 | return rowsAffected > 0; // Ekleme başarılıysa true döndür 163 | } catch (SQLException throwables) { 164 | throwables.printStackTrace(); 165 | } 166 | return false; // Hata durumunda veya başarısız eklemede false döndür 167 | } 168 | 169 | 170 | public boolean update(Property property) { 171 | String query = "UPDATE public.hotel_property SET " + 172 | "property_id = ?," + 173 | "property_names = ? " + // Düzeltme: Virgül gereksizdi 174 | "WHERE hotel_id = ?"; 175 | 176 | 177 | try { 178 | PreparedStatement pr = con.prepareStatement(query); 179 | pr.setInt(1, property.getPropertyID()); 180 | if (!property.getPropertyNames().contains("Otel Özellikleri")) { 181 | Array propertyNamesArray = con.createArrayOf("text", property.getPropertyNames().toArray()); 182 | pr.setArray(2, propertyNamesArray); 183 | } 184 | pr.setInt(3, property.getHotel_id()); 185 | return pr.executeUpdate() != -1; 186 | } catch (SQLException throwables) { 187 | throwables.printStackTrace(); 188 | } 189 | return true; 190 | } 191 | 192 | 193 | public boolean saveRoomProperty(Property property){ 194 | String query = "INSERT INTO room_properties (property, room_id, adultd_bed_num, child_bed_num, area ) VALUES (?,?,?,?,?)"; 195 | try { 196 | PreparedStatement pr = con.prepareStatement(query); 197 | pr.setString(1,property.getRoomProperty()); 198 | pr.setInt(2,property.getRoomId()); 199 | pr.setInt(3, property.getRoomAdultBedNum()); 200 | pr.setInt(4, property.getRoomChildBedNum()); 201 | pr.setInt(5, property.getRoomArea()); 202 | return pr.executeUpdate() != -1; 203 | } catch (SQLException e) { 204 | e.printStackTrace(); 205 | } 206 | return true; 207 | } 208 | 209 | public boolean delete(int id) { 210 | String query = "DELETE FROM public.hotel_property WHERE hotel_id =?"; 211 | try { 212 | PreparedStatement pr = con.prepareStatement(query); 213 | pr.setInt(1, id); 214 | return pr.executeUpdate() != -1; 215 | 216 | } catch (SQLException throwables) { 217 | throwables.printStackTrace(); 218 | } 219 | return true; 220 | 221 | } 222 | public ArrayList getListByRoomID( int id){ 223 | ArrayList roomPropertiesList = new ArrayList<>(); 224 | Property obj; 225 | // Property property =new Property(); 226 | String query = "SELECT * FROM room_properties WHERE room_id = ?"; 227 | try { 228 | PreparedStatement pr = con.prepareStatement(query); 229 | pr.setInt(1, id); 230 | ResultSet rs = pr.executeQuery(); 231 | while (rs.next()){ 232 | obj = new Property(); 233 | obj.setRoomProperty(rs.getString("property")); 234 | obj.setRoomAdultBedNum(rs.getInt("adultd_bed_num")); 235 | obj.setRoomChildBedNum(rs.getInt("child_bed_num")); 236 | obj.setRoomArea(rs.getInt("area")); 237 | roomPropertiesList.add(obj); 238 | 239 | } 240 | } catch (SQLException e) { 241 | e.printStackTrace(); 242 | } 243 | 244 | return roomPropertiesList; 245 | } 246 | public String getRoomPropertyName(int id) { 247 | String obj = null; 248 | String query = "SELECT * FROM public.room_properties WHERE room_id = ?"; 249 | try { 250 | PreparedStatement pr = con.prepareStatement(query); 251 | pr.setInt(1, id); 252 | ResultSet rs = pr.executeQuery(); 253 | if (rs.next()) { 254 | obj =(rs.getString("property")); 255 | } 256 | } catch (SQLException e) { 257 | e.printStackTrace(); 258 | } 259 | return obj; 260 | } 261 | public Property getByBedNum(int id) { 262 | Property obj = new Property(); 263 | String query = "SELECT adultd_bed_num,child_bed_num FROM public.room_properties WHERE room_id = ?"; 264 | try { 265 | PreparedStatement pr = con.prepareStatement(query); 266 | pr.setInt(1, id); 267 | ResultSet rs = pr.executeQuery(); 268 | if (rs.next()) { 269 | obj.setRoomAdultBedNum(rs.getInt("adultd_bed_num")); 270 | obj.setRoomChildBedNum(rs.getInt("child_bed_num")); 271 | } 272 | 273 | } catch (SQLException e) { 274 | e.printStackTrace(); 275 | } 276 | return obj; 277 | 278 | } 279 | 280 | } 281 | 282 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/ReservationAdd.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.*; 4 | import core.Helper; 5 | import entity.*; 6 | 7 | import javax.swing.*; 8 | import java.awt.event.KeyAdapter; 9 | import java.awt.event.KeyEvent; 10 | import java.text.DecimalFormat; 11 | import java.time.LocalDate; 12 | import java.time.format.DateTimeFormatter; 13 | import java.time.temporal.ChronoUnit; 14 | import java.util.List; 15 | 16 | public class ReservationAdd extends Layout { 17 | private JPanel wrapper; 18 | private JPanel pnl_reservation; 19 | private JTextField fld_hotel_name; 20 | private JTextArea txtArea_hotel_address; 21 | private JTextField fld_hotel_phone; 22 | private JTextArea txtArea_hotel_property; 23 | private JTextField fld_pansiyon_type; 24 | private JTextArea txtArea_room_property; 25 | private JTextField fld_adult_numb; 26 | private JTextField fld_child_numb; 27 | private JTextField fld_check_start_date; 28 | private JTextField fld_check_end_date; 29 | private JTextField fld_Night_Price; 30 | private JTextField fld_reser_price; 31 | private JPanel pnl_top; 32 | private JTextField fld_client_name; 33 | private JTextField fld_client_phone; 34 | private JTextField fld_client_mail; 35 | private JTextArea txtArea_client_note; 36 | private JButton btn_add_reservation; 37 | private JPanel container; 38 | private JButton btn_reser_price; 39 | private JLabel lbl_season_name; 40 | private JLabel lbl_season_date; 41 | private JButton misafirBilgileriButton; 42 | private JComboBox cmb_AdultBedNums; 43 | private JComboBox cmb_ChildBedNum; 44 | private JTextField fld_room_type; 45 | private JLabel lbl_adult_price; 46 | private JLabel lbl_child_price; 47 | private Room room; 48 | private HotelManager hotelManager; 49 | private Hotel hotel; 50 | private PropertyManager propertyManager; 51 | private Property property; 52 | private TypeManager typeManager; 53 | private Types types; 54 | private SeasonManager seasonManager; 55 | private Season season; 56 | private ReserManager reserManager; 57 | private Reser reser; 58 | private RoomManager roomManager; 59 | LocalDate reservationStartDate; 60 | LocalDate reservationEndDate; 61 | LocalDate seasonStartDate; 62 | LocalDate seasonEndDate; 63 | int daysBetween; 64 | 65 | int adultBedNum=0; 66 | int childBedNum=0; 67 | public ReservationAdd(Room selectroom,Property selectProperty) { 68 | this.hotelManager = new HotelManager(); 69 | this.propertyManager = new PropertyManager(); 70 | this.typeManager = new TypeManager(); 71 | this.seasonManager = new SeasonManager(); 72 | this.roomManager = new RoomManager(); 73 | this.reserManager = new ReserManager(); 74 | 75 | this.reser = new Reser(); 76 | this.property = selectProperty; 77 | this.room = selectroom; 78 | add(container); 79 | this.guiInitilaze(800, 650); 80 | 81 | 82 | String hotelName = this.hotelManager.getById(this.room.getHotelId()).getHotel_name(); 83 | fld_hotel_name.setText(hotelName); 84 | String hotelAdres =this.hotelManager.getById(this.room.getHotelId()).getHotel_fllAdres(); 85 | txtArea_hotel_address.setText(hotelAdres); 86 | String hotelPhone =this.hotelManager.getById(this.room.getHotelId()).getHotel_phone(); 87 | fld_hotel_phone.setText(hotelPhone); 88 | 89 | propertyManager.getByBedNum(this.room.getId()).getRoomAdultBedNum(); 90 | // Yetişkin sayısını al ve JTextField'e yaz 91 | adultBedNum = propertyManager.getByBedNum(this.room.getId()).getRoomAdultBedNum(); 92 | fld_adult_numb.setText(String.valueOf(adultBedNum)); 93 | 94 | // Çocuk sayısını al ve JTextField'e yaz 95 | childBedNum = propertyManager.getByBedNum(this.room.getId()).getRoomChildBedNum(); 96 | fld_child_numb.setText(String.valueOf(childBedNum)); 97 | 98 | List hotelPropertyList = property.getPropertyNames(); 99 | // JTextArea içeriğini temizle 100 | txtArea_hotel_property.setText(""); 101 | // Listede bulunan tüm özellikleri JTextArea'ya ekleyin 102 | for (String property : hotelPropertyList) { 103 | txtArea_hotel_property.append(property+"\n"); // Her özelliği yeni satıra ekleyin 104 | } 105 | //yetıskın cocuk yatak sayısı kapasıte verısını belırleme 106 | loadCmbBedNumsList(); 107 | 108 | 109 | 110 | lbl_adult_price.setText("Yetişkin Ücreti : "+room.getAdultPrice()); 111 | lbl_child_price.setText("Cocuk Ücreti : "+room.getChildPrice()); 112 | 113 | txtArea_room_property.setText(propertyManager.getRoomPropertyName(room.getId())); 114 | 115 | String hotelPansType = typeManager.getByTypeId(this.room.getHotelTypeId()); 116 | fld_pansiyon_type.setText(hotelPansType); 117 | 118 | String roomType =this.room.getRoomType(); 119 | fld_room_type.setText(roomType); 120 | 121 | 122 | String roomNightPrince = String.valueOf(this.room.getRoomPrice()); 123 | fld_Night_Price.setText(roomNightPrince); 124 | 125 | seasonStartDate=seasonManager.getSeasonDate(this.room.getSeasonId()).getSeason_start(); 126 | seasonEndDate=seasonManager.getSeasonDate(this.room.getSeasonId()).getSeason_end(); 127 | 128 | String formattedStartDate=seasonStartDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy")); 129 | String formattedEndDate =seasonEndDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy")); 130 | lbl_season_date.setText(formattedStartDate+" - "+formattedEndDate); 131 | 132 | String seasonName=seasonManager.getSeasonDate(this.room.getSeasonId()).getSeasonName(); 133 | lbl_season_name.setText(seasonName); 134 | 135 | 136 | btn_reser_price.addActionListener(e -> { 137 | 138 | if(Helper.isValidDate(fld_check_start_date.getText(),("dd-MM-yyyy")) && Helper.isValidDate(fld_check_end_date.getText(),("dd-MM-yyyy") )) 139 | { 140 | reservationStartDate=(LocalDate.parse(fld_check_start_date.getText(), DateTimeFormatter.ofPattern("dd-MM-yyyy"))); 141 | reservationEndDate=(LocalDate.parse(fld_check_end_date.getText(), DateTimeFormatter.ofPattern("dd-MM-yyyy"))); 142 | daysBetween = (int) ChronoUnit.DAYS.between(reservationStartDate, reservationEndDate); 143 | 144 | }else{ 145 | Helper.showMsg("Geçersiz tarih girildi"); 146 | } 147 | if(!fld_check_start_date.getText().isEmpty() && !fld_check_end_date.getText().isEmpty()) { 148 | int comparison = reservationStartDate.compareTo(reservationEndDate); 149 | int comparisonSeasonStart = seasonStartDate.compareTo(reservationStartDate); 150 | int comparisonSeasonEnd = reservationEndDate.compareTo(seasonEndDate); 151 | if (comparisonSeasonStart < 0 && comparisonSeasonEnd < 0) { 152 | if ((comparison < 0)) { 153 | int roomPrince = this.room.getRoomPrice(); 154 | int adultPrice = this.room.getAdultPrice(); 155 | int childPrice = this.room.getChildPrice(); 156 | 157 | int reservationPrice = ((daysBetween * roomPrince) + (adultPrice * (int) cmb_AdultBedNums.getSelectedItem()) + (childPrice * (int) cmb_ChildBedNum.getSelectedItem())); 158 | 159 | fld_reser_price.setText(String.valueOf(reservationPrice)); 160 | // Biçimlendirici oluştur (Virgülden sonra iki ondalık basamak kullan) 161 | DecimalFormat decimalFormat = new DecimalFormat("#,##0.00"); 162 | // Sayıyı belirli bir biçimde formatla 163 | String formattedText = decimalFormat.format(reservationPrice); 164 | fld_reser_price.setText(formattedText + " TL "); 165 | 166 | } else { 167 | Helper.showMsg(reservationStartDate + " tarihi " + reservationEndDate + " tarihinden geride olamaz."); 168 | } 169 | } else { 170 | Helper.showMsg(formattedStartDate + " - " + formattedEndDate + " sezon tarihileri arsında olmalı."); 171 | } 172 | }else{ 173 | Helper.showMsg("Rezervasyon Tarihleri Boş olamaz"); 174 | } 175 | }); 176 | fld_check_start_date.addKeyListener(new KeyAdapter() { 177 | @Override 178 | public void keyReleased(KeyEvent e) { 179 | fld_reser_price.setText(null); 180 | } 181 | }); 182 | fld_check_end_date.addKeyListener(new KeyAdapter() { 183 | @Override 184 | public void keyReleased(KeyEvent e) { 185 | fld_reser_price.setText(null); 186 | } 187 | }); 188 | 189 | cmb_AdultBedNums.addActionListener(e -> { 190 | fld_reser_price.setText(null); 191 | GuestInfoAddView.reservations.clear(); 192 | }); 193 | cmb_ChildBedNum.addActionListener(e -> { 194 | fld_reser_price.setText(null); 195 | GuestInfoAddView.reservations.clear(); 196 | }); 197 | 198 | 199 | btn_add_reservation.addActionListener(e -> { 200 | 201 | List guestInfoList = GuestInfoAddView.reservations; 202 | 203 | if ((guestInfoList == null) || !guestInfoList.isEmpty()) { 204 | 205 | if (Helper.isFieldEmpty(fld_client_name) || Helper.isFieldEmpty(fld_client_phone)|| 206 | Helper.isFieldEmpty(fld_client_mail)||Helper.isAreaEmpty(txtArea_client_note)||Helper.isFieldEmpty(fld_reser_price)|| 207 | cmb_AdultBedNums.getSelectedItem() ==null ||(Integer) cmb_AdultBedNums.getSelectedItem() == 0 || 208 | cmb_ChildBedNum.getSelectedItem() ==null ) 209 | { 210 | Helper.showMsg("fill"); 211 | } else if (!Helper.isValidDate(fld_check_start_date.getText(),("dd-MM-yyyy")) || !Helper.isValidDate(fld_check_end_date.getText(),("dd-MM-yyyy"))) 212 | { 213 | Helper.showMsg("Geçersiz tarih girildi"); 214 | } else { 215 | String fldAdultBedNum = cmb_AdultBedNums.getSelectedItem().toString(); 216 | String fldChildBedNum = cmb_ChildBedNum.getSelectedItem().toString(); 217 | 218 | this.reser.setRoom_id(this.room.getId()); 219 | this.reser.setReserFllName(fld_client_name.getText()); 220 | this.reser.setReserPhone(fld_client_phone.getText()); 221 | this.reser.setReserEmail(fld_client_mail.getText()); 222 | this.reser.setReserNote(txtArea_client_note.getText()); 223 | this.reser.setReserCheckInDdate(fld_check_start_date.getText()); 224 | this.reser.setReserCheckOutDate(fld_check_end_date.getText()); 225 | this.reser.setAdultNumb(fldAdultBedNum); 226 | this.reser.setChildNumb(fldChildBedNum); 227 | this.reser.setTotalPrice(fld_reser_price.getText()); 228 | 229 | // if(this.room.getStock()>0){ 230 | int reservationId = this.reserManager.saveAndGetReserlId(this.reser); 231 | if (reservationId > 0) { 232 | this.reser.setId(reservationId); 233 | if(this.reserManager.saveGuestInfoList(reservationId)) { 234 | Helper.showMsg("done"); 235 | dispose(); 236 | if(this.roomManager.stockUpdate(this.room,-1)){ 237 | Helper.showMsg("Stok Azaltıldı"); 238 | } 239 | 240 | } 241 | else { 242 | Helper.showMsg("error"); 243 | } 244 | } else { 245 | Helper.showMsg("error"); 246 | } 247 | /* }else{ 248 | Helper.showMsg("Oda stok 0 rezervasyon yapılamaz"); 249 | }*/ 250 | } 251 | }else { 252 | Helper.showMsg("Misafir Bilgileri Boş Olamaz"); 253 | } 254 | }); 255 | misafirBilgileriButton.addActionListener(e -> { 256 | int fldAdultBedNum=0; 257 | if(cmb_AdultBedNums.getSelectedItem()!=null){ 258 | fldAdultBedNum= (int) cmb_AdultBedNums.getSelectedItem(); 259 | } 260 | // int fldAdultBedNum= (int) cmb_AdultBedNums.getSelectedItem(); 261 | int fldChildBedNum = (int)cmb_ChildBedNum.getSelectedItem(); 262 | GuestInfoAddView guestInfoAddView = new GuestInfoAddView(fldAdultBedNum,fldChildBedNum); 263 | 264 | }); 265 | } 266 | 267 | 268 | public void loadCmbBedNumsList(){ 269 | // Integer dizisi oluşturalım 270 | Integer[] itemAdult = new Integer[adultBedNum + 1]; 271 | for (int i = 0; i <= adultBedNum; i++) { 272 | itemAdult[i] = i; 273 | } 274 | DefaultComboBoxModel cmbAdultModel = new DefaultComboBoxModel<>(itemAdult); 275 | cmb_AdultBedNums.setModel(cmbAdultModel); 276 | cmb_AdultBedNums.setSelectedIndex(0); 277 | 278 | // Integer dizisi oluşturalım 279 | Integer[] itemChild = new Integer[childBedNum + 1]; 280 | for (int i = 0; i <= childBedNum; i++) { 281 | itemChild[i] = i; 282 | } 283 | DefaultComboBoxModel cmbChildModel = new DefaultComboBoxModel<>(itemChild); 284 | cmb_ChildBedNum.setModel(cmbChildModel); 285 | cmb_ChildBedNum.setSelectedIndex(0); 286 | 287 | } 288 | 289 | 290 | } 291 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/RevervationUpdateView.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 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/HotelAddView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.HotelManager; 4 | import business.PropertyManager; 5 | import business.SeasonManager; 6 | import business.TypeManager; 7 | import core.Helper; 8 | import entity.Hotel; 9 | import entity.Property; 10 | import entity.Season; 11 | import entity.Types; 12 | 13 | 14 | import javax.swing.*; 15 | import java.awt.*; 16 | import java.awt.event.ActionEvent; 17 | import java.awt.event.ActionListener; 18 | import java.time.LocalDate; 19 | import java.time.format.DateTimeFormatter; 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | public class HotelAddView extends Layout { 24 | private JPanel container; 25 | private JList lst_left_pro; 26 | private JList lst_right_pro; 27 | private JList lst_left_type; 28 | private JList lst_right_type; 29 | private JButton btn_single_right; 30 | private JButton btn_multi_right; 31 | private JButton btn_multi_left; 32 | private JButton btn_single_left; 33 | private JTextField fld_hotel_name; 34 | private JTextField fld_hotel_city; 35 | private JTextField fld_hotel_district; 36 | private JTextField fld_hoteml_fllAdres; 37 | private JTextField fld_hotel_mail; 38 | private JTextField fld_hotel_phone; 39 | private JComboBox cmb_hotel_star; 40 | private JButton btn_hotel_save; 41 | private JButton btn_single_right_type; 42 | private JButton btn_multi_right_type; 43 | private JButton btn_single_left_type; 44 | private JButton btn_multi_left_type; 45 | private JRadioButton rd_btn_sum; 46 | private JRadioButton rd_btn_win; 47 | private JFormattedTextField fld_season_start; 48 | private JFormattedTextField fld_season_end; 49 | private JPanel pnl_hotel; 50 | private JPanel pntl_top; 51 | private JPanel pnl_season; 52 | private JPanel pnl_property; 53 | private JPanel pnl_type; 54 | 55 | private DefaultListModel leftListPropertyModel; 56 | private DefaultListModel rightListPropertyModel; 57 | 58 | private DefaultListModel leftListTypeModel; 59 | private DefaultListModel rightListTypeModel; 60 | 61 | private HotelManager hotelManager; 62 | private Hotel hotel; 63 | private PropertyManager propertyManager; 64 | private Property property; 65 | private TypeManager typeManager; 66 | private Types types; 67 | private SeasonManager seasonManager; 68 | private Season season; 69 | 70 | List listRightType; 71 | 72 | // HotelManegementGUI yapıcı metodu 73 | public HotelAddView(Hotel hotel,Property property, Types types ,Season season) { 74 | this.hotelManager = new HotelManager(); 75 | this.hotel = hotel; 76 | this.propertyManager = new PropertyManager(); 77 | this.property = property; 78 | this.typeManager = new TypeManager(); 79 | this.types = types; 80 | this.seasonManager = new SeasonManager(); 81 | this.season = season; 82 | add(container); 83 | this.guiInitilaze(700, 650); 84 | rightListTypeModel = new DefaultListModel<>(); 85 | rightListPropertyModel = new DefaultListModel<>(); 86 | 87 | Integer[] integers = {1, 2, 3, 4, 5}; 88 | // DefaultComboBoxModel oluşturun ve tam sayıları modele ekleyin 89 | DefaultComboBoxModel model = new DefaultComboBoxModel<>(integers); 90 | cmb_hotel_star.setModel(model); 91 | 92 | // GUI bileşenlerini oluşturma işlemleri 93 | hotelPropertyListComponent(); 94 | hotelTypeListComponent(); 95 | 96 | 97 | 98 | 99 | // Kaydetme butonuna ActionListener ekleme 100 | btn_hotel_save.addActionListener(e -> { 101 | boolean isProper = false; 102 | boolean isType = false; 103 | boolean isSeason = false; 104 | 105 | // Yeni bir Property nesnesi oluşturarak propertyNames listesini set etme 106 | 107 | JTextField[] checkFieldList = { 108 | this.fld_hotel_name, 109 | this.fld_hotel_city, 110 | this.fld_hotel_district, 111 | this.fld_hoteml_fllAdres, 112 | this.fld_hotel_mail, 113 | this.fld_hotel_phone, 114 | this.fld_season_start, 115 | this.fld_season_end, 116 | }; 117 | if (Helper.isFieldListEmpty(checkFieldList) || 118 | Helper.isList_J_Empty(lst_right_pro) || 119 | Helper.isList_J_Empty(lst_right_type) || 120 | (!rd_btn_sum.isSelected() || !rd_btn_win.isSelected())){ 121 | Helper.showMsg("Zorunlu Kısımlar Eksik"); 122 | } 123 | else if (!Helper.isValidDate(fld_season_start.getText(),("dd-MM-yyyy")) || !Helper.isValidDate(fld_season_end.getText(),("dd-MM-yyyy"))) { 124 | Helper.showMsg("Geçersiz tarih girildi"); 125 | }else{ 126 | //this.hotel.setHotel_id(tempHotelID); 127 | this.hotel.setHotel_name(fld_hotel_name.getText()); 128 | this.hotel.setHotel_city(fld_hotel_city.getText()); 129 | this.hotel.setHotel_district(fld_hotel_district.getText()); 130 | this.hotel.setHotel_fllAdres(fld_hoteml_fllAdres.getText()); 131 | this.hotel.setHotel_email(fld_hotel_mail.getText()); 132 | this.hotel.setHotel_phone(fld_hotel_phone.getText()); 133 | this.hotel.setHotel_star((Integer)cmb_hotel_star.getSelectedItem()); 134 | 135 | 136 | List seasons = new ArrayList<>(); 137 | Season summerSeason = new Season(); 138 | summerSeason.setSeasonName("Summer"); 139 | summerSeason.setSeason_start(LocalDate.parse(fld_season_start.getText(), DateTimeFormatter.ofPattern("dd-MM-yyyy"))); 140 | summerSeason.setSeason_end(LocalDate.parse(fld_season_end.getText(), DateTimeFormatter.ofPattern("dd-MM-yyyy"))); 141 | seasons.add(summerSeason); 142 | 143 | // Winter sezonunu oluşturup listeye ekleme 144 | Season winterSeason = new Season(); 145 | winterSeason.setSeasonName("Winter"); 146 | winterSeason.setSeason_start(LocalDate.parse(fld_season_start.getText(), DateTimeFormatter.ofPattern("dd-MM-yyyy"))); 147 | winterSeason.setSeason_end(LocalDate.parse(fld_season_end.getText(), DateTimeFormatter.ofPattern("dd-MM-yyyy"))); 148 | seasons.add(winterSeason); 149 | 150 | 151 | int hotelId = this.hotelManager.saveAndGetHotelId(this.hotel); 152 | 153 | if(hotelId !=0) { 154 | List propertyNames = Helper.getListFromJList(lst_right_pro); 155 | this.property.setPropertyNames(propertyNames); 156 | isProper = propertyManager.save(this.property,hotelId); 157 | 158 | 159 | List listRightType = Helper.getListFromJList(lst_right_type); 160 | isType = this.typeManager.save(hotelId, listRightType); 161 | 162 | 163 | isSeason = this.seasonManager.save(seasons, hotelId); 164 | 165 | if (isProper) { 166 | Helper.showMsg("Ozellık kayıt başarılı"); 167 | } else { 168 | Helper.showMsg("Ozellilk kayıt başarısız"); 169 | } 170 | if (isType) { 171 | Helper.showMsg("Type kayıt başarılı"); 172 | } else { 173 | Helper.showMsg("Type kayıt başarısız"); 174 | } 175 | if (isSeason) { 176 | Helper.showMsg("Season kayıt başarılı"); 177 | } else { 178 | Helper.showMsg("Season kayıt başarısız"); 179 | } 180 | Helper.showMsg("Hotel bilgi kayıt başarılı"); 181 | }else { 182 | Helper.showMsg("Hotel bilgi kayıt başarısız"); 183 | } 184 | } 185 | }); 186 | 187 | } 188 | public void hotelPropertyListComponent() { 189 | leftListPropertyModel = new DefaultListModel<>(); 190 | String[] propertyArray = {"Ücretsiz Otopark", 191 | "Ücretsiz WiFi", 192 | "Yüzme Havuzu", 193 | "Fitness Center", 194 | "Hotel Concierge", 195 | "SPA", 196 | "7/24 Oda Servisi"}; 197 | 198 | for (int i = 0; i < propertyArray.length; i++) { 199 | leftListPropertyModel.addElement(propertyArray[i]); 200 | } 201 | lst_left_pro.setModel(leftListPropertyModel); 202 | 203 | btn_single_right.addActionListener(new ActionListener() { 204 | @Override 205 | public void actionPerformed(ActionEvent e) { 206 | String getLeftListValue = lst_left_pro.getSelectedValue(); 207 | int value = lst_left_pro.getSelectedIndex(); 208 | // getLeftListValue != null 209 | if (value >= 0 && !rightListPropertyModel.contains(getLeftListValue)) { 210 | rightListPropertyModel.addElement(getLeftListValue); 211 | lst_right_pro.setModel(rightListPropertyModel); 212 | } else if (getLeftListValue == null) { 213 | Helper.showMsg("Özellik Seçiniz"); 214 | } else { 215 | Helper.showMsg("Listede Mevcut"); 216 | } 217 | } 218 | }); 219 | 220 | 221 | 222 | btn_single_left.addActionListener(e -> { 223 | if (lst_right_pro.getSelectedValue() != null) { 224 | 225 | rightListPropertyModel.removeElement(lst_right_pro.getSelectedValue()); 226 | 227 | } else { 228 | Helper.showMsg("Özellik Seçiniz"); 229 | } 230 | }); 231 | btn_multi_right.addActionListener(new ActionListener() { 232 | @Override 233 | public void actionPerformed(ActionEvent e) { 234 | if (leftListPropertyModel.getSize() == rightListPropertyModel.getSize()) { 235 | Helper.showMsg("Listenin tümü mevcut"); 236 | } else { 237 | // Sol listedeki tüm öğeleri al 238 | List allItems = new ArrayList<>(); 239 | for (int i = 0; i < leftListPropertyModel.getSize(); i++) { 240 | allItems.add(leftListPropertyModel.getElementAt(i)); 241 | } 242 | // Sağ listedeki mevcut öğeleri bir List'e al 243 | List existingItems = new ArrayList<>(); 244 | for (int i = 0; i < rightListPropertyModel.getSize(); i++) { 245 | existingItems.add(rightListPropertyModel.getElementAt(i)); 246 | 247 | } 248 | // Sol listedeki tüm öğeleri sağ listeye ekle (ancak sağ listede olmayanları) 249 | for (String item : allItems) { 250 | if (!existingItems.contains(item)) { 251 | rightListPropertyModel.addElement(item); 252 | lst_right_pro.setModel(rightListPropertyModel); 253 | 254 | } 255 | } 256 | } 257 | } 258 | }); 259 | btn_multi_left.addActionListener(new ActionListener() { 260 | @Override 261 | public void actionPerformed(ActionEvent e) { 262 | rightListPropertyModel.removeAllElements(); 263 | 264 | } 265 | }); 266 | } 267 | public void hotelTypeListComponent() { 268 | 269 | leftListTypeModel = new DefaultListModel<>(); 270 | 271 | String[] typeArray = { 272 | "Ultra Her şey Dahil", 273 | "Her şey Dahil", 274 | "Oda Kahvaltı", 275 | "Tam Pansiyon", 276 | "Yarım Pansiyon", 277 | "Sadece Yatak", 278 | "Alkol Hariç" 279 | }; 280 | 281 | for (int i = 0; i < typeArray.length; i++) { 282 | leftListTypeModel.addElement(typeArray[i]); 283 | } 284 | lst_left_type.setModel(leftListTypeModel); 285 | 286 | btn_single_right_type.addActionListener(new ActionListener() { 287 | @Override 288 | public void actionPerformed(ActionEvent e) { 289 | String getLeftListValue = lst_left_type.getSelectedValue(); 290 | int value = lst_left_type.getSelectedIndex(); 291 | // getLeftListValue != null 292 | if (value >= 0 && !rightListTypeModel.contains(getLeftListValue)) { 293 | rightListTypeModel.addElement(getLeftListValue); 294 | lst_right_type.setModel(rightListTypeModel); 295 | } else if (getLeftListValue == null) { 296 | Helper.showMsg("Özellik Seçiniz"); 297 | } else { 298 | Helper.showMsg("Listede Mevcut"); 299 | } 300 | } 301 | }); 302 | btn_single_left_type.addActionListener(e -> { 303 | // String getLeftListValue = lst_right.getSelectedValue(); 304 | //int value=lst_right.getSelectedIndex(); 305 | if (lst_right_type.getSelectedValue() != null) { 306 | rightListTypeModel.removeElement(lst_right_type.getSelectedValue()); 307 | } else { 308 | Helper.showMsg("Özellik Seçiniz"); 309 | } 310 | }); 311 | btn_multi_right_type.addActionListener(new ActionListener() { 312 | @Override 313 | public void actionPerformed(ActionEvent e) { 314 | if (leftListTypeModel.getSize() == rightListTypeModel.getSize()) { 315 | Helper.showMsg("Listenin tümü mevcut"); 316 | } else { 317 | // Sol listedeki tüm öğeleri al 318 | List allItems = new ArrayList<>(); 319 | for (int i = 0; i < leftListTypeModel.getSize(); i++) { 320 | allItems.add(leftListTypeModel.getElementAt(i)); 321 | } 322 | 323 | // Sağ listedeki mevcut öğeleri bir List'e al 324 | List existingItems = new ArrayList<>(); 325 | for (int i = 0; i < rightListTypeModel.getSize(); i++) { 326 | existingItems.add(rightListTypeModel.getElementAt(i)); 327 | } 328 | 329 | // Sol listedeki tüm öğeleri sağ listeye ekle (ancak sağ listede olmayanları) 330 | for (String item : allItems) { 331 | if (!existingItems.contains(item)) { 332 | rightListTypeModel.addElement(item); 333 | lst_right_type.setModel(rightListTypeModel); 334 | } 335 | } 336 | } 337 | 338 | 339 | } 340 | }); 341 | btn_multi_left_type.addActionListener(new ActionListener() { 342 | @Override 343 | public void actionPerformed(ActionEvent e) { 344 | 345 | rightListTypeModel.removeAllElements(); 346 | } 347 | }); 348 | } 349 | 350 | 351 | 352 | 353 | } 354 | --------------------------------------------------------------------------------