├── TurizmAcente-master ├── .idea │ ├── .name │ ├── .gitignore │ ├── vcs.xml │ ├── libraries │ │ ├── postgresql_42_7_3.xml │ │ └── postgresql_42_7_31.xml │ ├── misc.xml │ ├── modules.xml │ └── uiDesigner.xml ├── img.png ├── img_1.png ├── img_2.png ├── img_3.png ├── img_4.png ├── img_5.png ├── img_6.png ├── img_7.png ├── 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 │ │ ├── PropertyManager.java │ │ ├── UserManager.java │ │ └── ReserManager.java │ ├── view │ │ ├── LoginView.java │ │ ├── RevervationUpdateView.java │ │ ├── UserManagementView.java │ │ ├── Layout.java │ │ ├── UserManagementView.form │ │ ├── AdminView.java │ │ ├── LoginView.form │ │ ├── AdminView.form │ │ ├── GuestInfoAddView.java │ │ ├── RevervationUpdateView.form │ │ ├── ReservationAdd.java │ │ └── RoomAdd.form │ └── dao │ │ ├── UserDao.java │ │ ├── TypeDao.java │ │ ├── RoomDao.java │ │ ├── SeasonDao.java │ │ ├── HotelDao.java │ │ ├── ReserDao.java │ │ └── PropertyDao.java ├── postgresql-42.7.3.jar ├── turizmacentesistemi.sql ├── .gitignore ├── TurizmAcente-master.iml ├── TurizmAcente.iml └── README.md ├── img.png ├── img_1.png ├── img_2.png ├── img_3.png ├── img_4.png ├── img_5.png ├── img_6.png ├── img_7.png ├── rohat.png ├── rohatt.jpg ├── rohatt.png ├── rohattt.jpg ├── turizm.jpg ├── LICENSE └── README.md /TurizmAcente-master/.idea/.name: -------------------------------------------------------------------------------- 1 | Main.java -------------------------------------------------------------------------------- /img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/img.png -------------------------------------------------------------------------------- /img_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/img_1.png -------------------------------------------------------------------------------- /img_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/img_2.png -------------------------------------------------------------------------------- /img_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/img_3.png -------------------------------------------------------------------------------- /img_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/img_4.png -------------------------------------------------------------------------------- /img_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/img_5.png -------------------------------------------------------------------------------- /img_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/img_6.png -------------------------------------------------------------------------------- /img_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/img_7.png -------------------------------------------------------------------------------- /rohat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/rohat.png -------------------------------------------------------------------------------- /rohatt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/rohatt.jpg -------------------------------------------------------------------------------- /rohatt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/rohatt.png -------------------------------------------------------------------------------- /rohattt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/rohattt.jpg -------------------------------------------------------------------------------- /turizm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/turizm.jpg -------------------------------------------------------------------------------- /TurizmAcente-master/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /TurizmAcente-master/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/img.png -------------------------------------------------------------------------------- /TurizmAcente-master/img_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/img_1.png -------------------------------------------------------------------------------- /TurizmAcente-master/img_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/img_2.png -------------------------------------------------------------------------------- /TurizmAcente-master/img_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/img_3.png -------------------------------------------------------------------------------- /TurizmAcente-master/img_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/img_4.png -------------------------------------------------------------------------------- /TurizmAcente-master/img_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/img_5.png -------------------------------------------------------------------------------- /TurizmAcente-master/img_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/img_6.png -------------------------------------------------------------------------------- /TurizmAcente-master/img_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/img_7.png -------------------------------------------------------------------------------- /TurizmAcente-master/src/admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/src/admin.png -------------------------------------------------------------------------------- /TurizmAcente-master/src/patika.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/src/patika.png -------------------------------------------------------------------------------- /TurizmAcente-master/postgresql-42.7.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/postgresql-42.7.3.jar -------------------------------------------------------------------------------- /TurizmAcente-master/turizmacentesistemi.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohatdgnr/TourismAgency/HEAD/TurizmAcente-master/turizmacentesistemi.sql -------------------------------------------------------------------------------- /TurizmAcente-master/src/Main.java: -------------------------------------------------------------------------------- 1 | import core.Helper; 2 | import view.LoginView; 3 | 4 | public class Main { 5 | 6 | public static void main(String[] args) { 7 | Helper.setTheme(); 8 | LoginView loginView = new LoginView(); 9 | 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /TurizmAcente-master/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /TurizmAcente-master/.idea/libraries/postgresql_42_7_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TurizmAcente-master/.idea/libraries/postgresql_42_7_31.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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/TurizmAcente-master.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /TurizmAcente-master/TurizmAcente.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Rohat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /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/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 | // Değerlendirme Formu 6 Projede veritabanı kullanılmış ve DB bağlantı konfigürasyonu doğru bir şekilde yapılmış 9 | private static Db instance = null; 10 | private Connection connection = null; 11 | private final String DB_URL = "jdbc:postgresql://localhost:5432/turizmacentesistemi"; 12 | private final String DB_USERNAME = "postgres"; 13 | private final String DB_PASS = "1234"; 14 | 15 | 16 | private Db() { 17 | try { 18 | this.connection = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASS); 19 | } catch (SQLException e) { 20 | System.out.println(e.getMessage()); 21 | } 22 | 23 | 24 | } 25 | 26 | public Connection getConnection() { 27 | return connection; 28 | } 29 | 30 | public static Connection getInstance() { 31 | 32 | try { 33 | if (instance == null || instance.getConnection().isClosed()) { 34 | instance = new Db(); 35 | 36 | } 37 | } catch (SQLException e) { 38 | System.out.println(e.getMessage()); 39 | } 40 | return instance.getConnection(); 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /TurizmAcente-master/README.md: -------------------------------------------------------------------------------- 1 | #Patika Turizm Acentesi Turizm Acente Sistemi 2 | Bu proje, Patika Turizm Acentesi'nin günlük operasyonlarını dijital bir platforma taşımak için geliştirilmiş bir 3 | yazılım çözümüdür. Bu yazılım, otel yönetimi, oda yönetimi, dönem yönetimi, fiyat yönetimi, oda arama ve rezervasyon 4 | işlemleri gibi bir dizi özelliği içermektedir. 5 | 6 | Kullanılan Teknolojiler 7 | - Java 8 | - Java Swing (GUI) 9 | - PostgreSQL 10 | 11 | Kurulum 12 | - Bu projeyi klonlayın. 13 | - PostgreSQL veritabanında turizmacentesistemi adında bir veritabanı oluşturun. 14 | - turizmacentesistemi.sql dosyasını kullanarak veritabanı tablolarını oluşturun. 15 | Veritabanı bağlantısını yapılandırmak için DatabaseConnection.java dosyasını düzenleyin. 16 | 17 | Proje Yapısı 18 | 19 | - business: İş mantığını gerçekleştiren servis sınıfları 20 | 21 | - core: Dizini altında veritabanı oluşturma dosyası, bulunmaktadır. 22 | 23 | - dao: Veritabanı işlemlerini gerçekleştiren DAO (Data Access Object) sınıfları 24 | 25 | - entity: Veritabanı tablolarını temsil eden model sınıfları 26 | 27 | - views: Kullanıcı arayüzünü oluşturan Swing GUI sınıfları 28 | 29 | Projenin videoya alınmış hali aşağıdaki linkte mevcuttur. 30 | 31 | https://www.youtube.com/watch?v=RrVL1pAHLcM&t=4s 32 | 33 | Proje ile ilgili görseller : 34 | 35 | Giriş Ekranı 36 | 37 | ![img.png](img.png) 38 | 39 | Admin Kullanıcısının Ekranı : 40 | 41 | ![img_1.png](img_1.png) 42 | 43 | Employee(Çalışan) Kullanıcısın Ekranları : 44 | 45 | ![img_2.png](img_2.png) 46 | 47 | ![img_3.png](img_3.png) 48 | 49 | ![img_4.png](img_4.png) 50 | 51 | ![img_5.png](img_5.png) 52 | 53 | ![img_6.png](img_6.png) 54 | 55 | ![img_7.png](img_7.png) 56 | 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | # Patika Turizm Acentesi Turizm Acente Sistemi 6 | 7 | Bu proje, Patika Turizm Acentesi'nin günlük operasyonlarını dijital bir platforma taşımak için geliştirilmiş bir yazılım çözümüdür. Bu yazılım, otel yönetimi, oda yönetimi, dönem yönetimi, fiyat yönetimi, oda arama ve rezervasyon işlemleri gibi bir dizi özelliği içermektedir. 8 | 9 | # Kullanılan Teknolojiler 10 | 11 | - Java 12 | - Java Swing (GUI) 13 | - PostgreSQL 14 | 15 | 16 | # Kurulum 17 | 18 | - Bu projeyi klonlayın. 19 | - PostgreSQL veritabanında turizmacentesistemi adında bir veritabanı oluşturun. 20 | - turizmacentesistemi.sql dosyasını kullanarak veritabanı tablolarını oluşturun. Veritabanı bağlantısını yapılandırmak için DatabaseConnection.java dosyasını düzenleyin. 21 | 22 | 23 | # Proje Yapısı 24 | 25 | - business: İş mantığını gerçekleştiren servis sınıfları 26 | 27 | - core: Dizini altında veritabanı oluşturma dosyası, bulunmaktadır. 28 | 29 | - dao: Veritabanı işlemlerini gerçekleştiren DAO (Data Access Object) sınıfları 30 | 31 | - entity: Veritabanı tablolarını temsil eden model sınıfları 32 | 33 | - views: Kullanıcı arayüzünü oluşturan Swing GUI sınıfları 34 | 35 | 36 | # Projenin videoya alınmış hali aşağıdaki linkte mevcuttur. 37 | 38 | - https://www.youtube.com/watch?v=RrVL1pAHLcM&t=4s 39 | 40 | 41 | # Proje ile ilgili görseller : 42 | 43 | - Giriş Ekranı 44 | 45 | 46 | 47 | - Admin Kullanıcısının Ekranı : 48 | 49 | 50 | 51 | - Employee(Çalışan) Kullanıcısın Ekranları : 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /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/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 | 14 | 15 | public Season() { 16 | } 17 | 18 | public Season(int seasonId, LocalDate season_start, LocalDate season_end, String seasonName , int hotel_id) { 19 | this.seasonId = seasonId; 20 | this.season_start = season_start; 21 | this.season_end = season_end; 22 | this.seasonName = seasonName; 23 | this.hotel_id = hotel_id; 24 | } 25 | 26 | 27 | public String getSeasonName() { 28 | return seasonName; 29 | } 30 | 31 | public void setSeasonName(String seasonName) { 32 | this.seasonName = seasonName; 33 | } 34 | 35 | public int getSeasonId() { 36 | return seasonId; 37 | } 38 | 39 | public void setSeasonId(int seasonId) { 40 | this.seasonId = seasonId; 41 | } 42 | 43 | public LocalDate getSeason_start() { 44 | return season_start; 45 | } 46 | 47 | public void setSeason_start(LocalDate season_start) { 48 | this.season_start = season_start; 49 | } 50 | 51 | public int getHotel_id() { 52 | return hotel_id; 53 | } 54 | 55 | public void setHotel_id(int hotel_id) { 56 | this.hotel_id = hotel_id; 57 | } 58 | 59 | 60 | 61 | public LocalDate getSeason_end() { 62 | return season_end; 63 | } 64 | 65 | public void setSeason_end(LocalDate season_end) { 66 | this.season_end = season_end; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return "Season{" + 72 | "seasonId=" + seasonId + 73 | ", season_start=" + season_start + 74 | ", season_end=" + season_end + 75 | ", hotel_id=" + hotel_id + 76 | ", seasonName='" + seasonName + '\'' + 77 | 78 | '}'; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /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 | 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ı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 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ı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 59 | return false; 60 | } 61 | return this.typeDao.deleteType(hotelId,typeNames); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /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ı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 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 | 68 | } 69 | -------------------------------------------------------------------------------- /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 | 9 | public class LoginView extends Layout { 10 | private JPanel container; 11 | private JTextField fld_user_name; 12 | private JPasswordField fld_password; 13 | private JButton btn_login; 14 | 15 | private final UserManager userManager; 16 | 17 | 18 | public LoginView() { 19 | 20 | this.userManager = new UserManager(); 21 | 22 | 23 | add(container); 24 | this.guiInitilaze(550, 300); 25 | this.setVisible(true); 26 | 27 | btn_login.addActionListener(e -> { 28 | 29 | JTextField[] checkFieldList = {this.fld_user_name, this.fld_password}; 30 | if (Helper.isFieldListEmpty(checkFieldList)) { 31 | Helper.showMsg("fill"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 32 | } else { 33 | User loginUser = this.userManager.findByLogin(this.fld_user_name.getText(), this.fld_password.getText()); 34 | System.out.println("kulanıcı bilgisi: " + loginUser); 35 | if (loginUser == null) { 36 | Helper.showMsg("notFound"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 37 | } else { 38 | if (loginUser.getRole().toString().equals("admin")) { //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 39 | AdminView adminView = new AdminView(loginUser); 40 | 41 | dispose(); 42 | 43 | } 44 | if (loginUser.getRole().toString().equals("employee")) { //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 45 | HotelView employee = new HotelView(loginUser); 46 | 47 | dispose(); 48 | } 49 | } 50 | } 51 | 52 | }); 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /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ı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 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ı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 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/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 final RoomDao roomDao ; 14 | public RoomManager() { 15 | // this.con = Db.getInstance(); 16 | this.roomDao = new RoomDao(); 17 | this.hotelManager =new HotelManager(); 18 | this.seasonManager = new SeasonManager(); 19 | 20 | } 21 | public Room getById(int id) { 22 | return this.roomDao.getById(id); 23 | } 24 | 25 | 26 | public ArrayList findAll(){return this.roomDao.findAll();} 27 | 28 | public int save(Room room){ 29 | return this.roomDao.save(room); 30 | } 31 | 32 | public boolean stockUpdate(Room room,int num){ 33 | return this.roomDao.stockUpdate(room,num); 34 | } 35 | 36 | public boolean delete(int id ){ 37 | 38 | if(this.getById(id)==null){ 39 | Helper.showMsg(id+" ID kayıtlı model bulunamadı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 40 | return false; 41 | } 42 | return this.roomDao.delete(id); 43 | } 44 | 45 | public ArrayList getForTable(int size, ArrayListroomList){ 46 | ArrayList hotelArrayList = new ArrayList<>(); 47 | for(Room room : roomList){ 48 | int i = 0; 49 | Object[] rowObject = new Object[size]; 50 | rowObject[i++] = room.getId(); 51 | rowObject[i++] = hotelManager.getById(room.getHotelId()).getHotel_name(); 52 | rowObject[i++] = hotelManager.getById(room.getHotelId()).getHotel_city(); 53 | rowObject[i++] = room.getRoomType(); 54 | rowObject[i++] = room.getStock(); 55 | rowObject[i++] = seasonManager.getSeasonDate(room.getSeasonId()).getSeason_start()+ " - " + seasonManager.getSeasonDate(room.getSeasonId()).getSeason_end(); 56 | rowObject[i++] = room.getAdultPrice(); 57 | rowObject[i++] = room.getChildPrice(); 58 | rowObject[i++] = room.getHotelTypeId(); 59 | hotelArrayList.add(rowObject); 60 | 61 | } 62 | return hotelArrayList; 63 | } 64 | 65 | public ArrayList searchForRooms(String strt_date, String fnsh_date,String searchCity,String hotelName, int adultNum,int childNum){ 66 | 67 | return this.roomDao.searchForRooms(strt_date,fnsh_date,searchCity,hotelName,adultNum,childNum);} 68 | } 69 | -------------------------------------------------------------------------------- /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 | 41 | 42 | 43 | public ArrayListgetForTableRoomProperty(int size,int id){ 44 | ArrayList brandRowList = new ArrayList<>(); 45 | for(Property obj : this.getListByRoomID(id)){ 46 | Object[] rowObject = new Object[size]; 47 | int i = 0; 48 | rowObject[i++] = obj.getRoomProperty(); 49 | rowObject[i++] = obj.getRoomAdultBedNum(); 50 | rowObject[i++] = obj.getRoomChildBedNum(); 51 | rowObject[i++] = roomManager.getById(id).getAdultPrice(); 52 | rowObject[i++] = roomManager.getById(id).getChildPrice(); 53 | rowObject[i++] = obj.getRoomArea(); 54 | rowObject[i++] = roomManager.getById(id).getRoomPrice(); 55 | 56 | brandRowList.add(rowObject); 57 | 58 | } 59 | return brandRowList; 60 | } 61 | 62 | public boolean update(Property property) { 63 | if (this.getById(property.getPropertyID()) == null) { 64 | Helper.showMsg(property.getPropertyID() + " ID bulunamadı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 65 | return false; 66 | } 67 | return this.propertyDao.update(property); 68 | } 69 | 70 | public boolean save(Property property,int hotelId){ 71 | return this.propertyDao.save(property,hotelId); 72 | } 73 | public boolean saveRoomProperty(Property property){ 74 | return this.propertyDao.saveRoomProperty(property); 75 | } 76 | 77 | public List getPropertyList(int hotelId) { 78 | return this.propertyDao.getPropertyList(hotelId); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /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 | 17 | public UserManager() { 18 | 19 | this.userDao = new UserDao(); 20 | 21 | } 22 | 23 | public User findByLogin(String username, String password) { 24 | return this.userDao.findByLogin(username, password); 25 | 26 | } 27 | 28 | public ArrayList findAll() { 29 | 30 | return this.userDao.findAll(); 31 | } 32 | 33 | public ArrayList getForTable(int size, ArrayList userList) { 34 | ArrayList userRoleList = new ArrayList<>(); 35 | for (User user : userList) { 36 | int i = 0; 37 | Object[] rowObject = new Object[size]; 38 | rowObject[i++] = user.getUserId(); 39 | rowObject[i++] = user.getUsername(); 40 | rowObject[i++] = user.getPassword(); 41 | rowObject[i++] = user.getRole(); 42 | userRoleList.add(rowObject); 43 | 44 | } 45 | return userRoleList; 46 | } 47 | 48 | public User getById(int id) { 49 | return this.userDao.getById(id); 50 | } 51 | 52 | 53 | public ArrayList searcForTable(User.Role role) { 54 | String query = "SELECT * FROM public.user WHERE user_role = '" + role.toString() + "'"; 55 | return this.userDao.selectByQuery(query); 56 | 57 | } 58 | 59 | public boolean save(User user) { 60 | if (this.getById(user.getUserId()) != null) { 61 | Helper.showMsg("error"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 62 | return false; 63 | } 64 | return this.userDao.save(user); 65 | } 66 | 67 | public boolean update(User user) { 68 | if (this.getById(user.getUserId()) == null) { 69 | Helper.showMsg(user.getUserId() + " ID bulunamadı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 70 | return false; 71 | } 72 | return this.userDao.update(user); 73 | } 74 | 75 | public boolean delete(int id) { 76 | 77 | if (this.getById(id) == null) { 78 | Helper.showMsg(id + " ID bulunamadı"); 79 | return false; 80 | } 81 | return this.userDao.delete(id); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /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"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 64 | dispose(); 65 | } 66 | else{Helper.showMsg("error");} //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 67 | }else{ 68 | Helper.showMsg("ID bulunamadı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 69 | } 70 | } 71 | }); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/UserManagementView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | 4 | import business.UserManager; 5 | import core.Helper; 6 | import entity.User; 7 | import javax.swing.*; 8 | 9 | 10 | public class UserManagementView extends Layout { 11 | private JPanel container; 12 | private JTextField fld_mng_name; 13 | private JTextField fld_mng_pass; 14 | private JComboBox cmb_mng_role; 15 | private JButton btn_mng_save; 16 | 17 | private User user; 18 | private UserManager userManager; 19 | 20 | /** 21 | * Yapılandırıcı metot. 22 | * Constructor method. 23 | * @param user Giriş yapan kullanıcı bilgisi 24 | * Information of the logged-in user 25 | */ 26 | public UserManagementView(User user) { 27 | this.userManager = new UserManager(); 28 | this.user = user; 29 | 30 | add(container); 31 | this.guiInitilaze(400, 400); 32 | 33 | // Eğer kullanıcı varsa, bilgileri doldur 34 | // If there is a user, fill the information 35 | if (user != null) { 36 | fld_mng_name.setText(user.getUsername()); 37 | fld_mng_pass.setText(user.getPassword()); 38 | this.cmb_mng_role.setModel(new DefaultComboBoxModel<>(User.Role.values())); 39 | } 40 | // Kullanıcı rollerini açılır menüye ekle 41 | // Add user roles to the combo box 42 | this.cmb_mng_role.setModel(new DefaultComboBoxModel<>(User.Role.values())); 43 | // Kaydet butonuna tıklandığında 44 | // When the save button is clicked 45 | btn_mng_save.addActionListener(e -> { 46 | // Alanlar boş mu diye kontrol et 47 | // Check if the fields are empty 48 | if (Helper.isFieldListEmpty(new JTextField[]{this.fld_mng_name, this.fld_mng_pass})) { 49 | Helper.showMsg("fill"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 50 | } else { 51 | boolean result = false; 52 | if (this.user != null) { 53 | this.user.setUsername(fld_mng_name.getText()); 54 | this.user.setPassword(fld_mng_pass.getText()); 55 | this.user.setRole((User.Role) cmb_mng_role.getSelectedItem()); 56 | result = this.userManager.update(this.user); 57 | } else { 58 | //result=this.userManager.save(this.user); 59 | User obj = new User(fld_mng_name.getText(), fld_mng_pass.getText(), (User.Role) cmb_mng_role.getSelectedItem()); 60 | result = this.userManager.save(obj); 61 | } 62 | if (result) { 63 | Helper.showMsg("done"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 64 | dispose(); 65 | } else { 66 | Helper.showMsg("error"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 67 | } 68 | } 69 | }); 70 | } 71 | } -------------------------------------------------------------------------------- /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 | 71 | 72 | public String getHotel_fllAdres() { 73 | return hotel_fllAdres; 74 | } 75 | 76 | public void setHotel_fllAdres(String hotel_fllAdres) { 77 | this.hotel_fllAdres = hotel_fllAdres; 78 | } 79 | 80 | public String getHotel_phone() { 81 | return hotel_phone; 82 | } 83 | 84 | public void setHotel_phone(String hotel_phone) { 85 | this.hotel_phone = hotel_phone; 86 | } 87 | 88 | public String getHotel_email() { 89 | return hotel_email; 90 | } 91 | 92 | public void setHotel_email(String hotel_email) { 93 | this.hotel_email = hotel_email; 94 | } 95 | 96 | @Override 97 | public String toString() { 98 | return "Hotel{" + 99 | "hotel_id=" + hotel_id + 100 | ", hotel_name='" + hotel_name + '\'' + 101 | ", hotel_city='" + hotel_city + '\'' + 102 | ", hotel_district='" + hotel_district + '\'' + 103 | ", hotel_address='" + hotel_fllAdres + '\'' + 104 | ", hotel_phone='" + hotel_phone + '\'' + 105 | ", hotel_email='" + hotel_email + '\'' + 106 | ", hotel_star='" + hotel_star + '\'' + 107 | '}'; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /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 | 76 | // JTable'dan belirli bir satırdaki veriyi elde etmek için metod 77 | public static int getTableSelectedRow(JTable table, int hotelIdColumnIndex) { 78 | int selectedRow = table.getSelectedRow(); 79 | 80 | if (selectedRow != -1) { // Eğer bir satır seçilmişse 81 | // Seçili satırdaki belirli sütunun değerini al 82 | Object hotelIdObj = table.getValueAt(selectedRow, hotelIdColumnIndex); 83 | 84 | if (hotelIdObj instanceof Integer) { 85 | return (Integer) hotelIdObj; // Hotel ID'sini integer olarak dön 86 | } 87 | } 88 | 89 | return -1; // Seçili bir satır yoksa veya hotel ID'si alınamazsa -1 dön 90 | } 91 | 92 | public void tableRowSelect(JTable table) { 93 | table.addMouseListener(new MouseAdapter() { 94 | @Override 95 | public void mousePressed(MouseEvent e) { 96 | int selected_row = table.rowAtPoint(e.getPoint()); 97 | table.setRowSelectionInterval(selected_row, selected_row); 98 | } 99 | }); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /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/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ı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 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ı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 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/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 | public enum RoomType { 14 | SINGLE_ROOM("Single Room"), 15 | DOUBLE_ROOM("Double Room"), 16 | JUNIOR_SUITE_ROOM("Junior Suite Room"), 17 | SUITE_ROOM("Suite Room"); 18 | 19 | private final String displayName; 20 | 21 | RoomType(String displayName) { 22 | this.displayName = displayName; 23 | } 24 | 25 | public String getDisplayName() { 26 | return displayName; 27 | } 28 | } 29 | 30 | public Room() { 31 | } 32 | 33 | public Room(String roomType, int stock, int seasonId, int adultPrice, int childPrice, int hotelTypeId, int hotelId,int roomPrice) { 34 | 35 | this.roomType = roomType; 36 | this.stock = stock; 37 | this.seasonId = seasonId; 38 | this.adultPrice = adultPrice; 39 | this.childPrice = childPrice; 40 | this.hotelTypeId = hotelTypeId; 41 | this.hotelId = hotelId; 42 | this.roomPrice=roomPrice; 43 | } 44 | public Room(int id, String roomType, int stock, int seasonId, int adultPrice, int childPrice, int hotelTypeId, int hotelId) { 45 | this.id = id; 46 | this.roomType = roomType; 47 | this.stock = stock; 48 | this.seasonId = seasonId; 49 | this.adultPrice = adultPrice; 50 | this.childPrice = childPrice; 51 | this.hotelTypeId = hotelTypeId; 52 | this.hotelId = hotelId; 53 | } 54 | 55 | // Diğer getter ve setter metotları 56 | 57 | 58 | public int getRoomPrice() { 59 | return roomPrice; 60 | } 61 | 62 | public void setRoomPrice(int roomPrice) { 63 | this.roomPrice = roomPrice; 64 | } 65 | 66 | public int getId() { 67 | return id; 68 | } 69 | 70 | public void setId(int id) { 71 | this.id = id; 72 | } 73 | 74 | public String getRoomType() { 75 | return roomType; 76 | } 77 | 78 | public void setRoomType(String roomType) { 79 | this.roomType = roomType; 80 | } 81 | 82 | public int getStock() { 83 | return stock; 84 | } 85 | 86 | public void setStock(int stock) { 87 | this.stock = stock; 88 | } 89 | 90 | public int getSeasonId() { 91 | return seasonId; 92 | } 93 | 94 | public void setSeasonId(int seasonId) { 95 | this.seasonId = seasonId; 96 | } 97 | 98 | public int getAdultPrice() { 99 | return adultPrice; 100 | } 101 | 102 | public void setAdultPrice(int adultPrice) { 103 | this.adultPrice = adultPrice; 104 | } 105 | 106 | public int getChildPrice() { 107 | return childPrice; 108 | } 109 | 110 | public void setChildPrice(int childPrice) { 111 | this.childPrice = childPrice; 112 | } 113 | 114 | public int getHotelTypeId() { 115 | return hotelTypeId; 116 | } 117 | 118 | public void setHotelTypeId(int hotelTypeId) { 119 | this.hotelTypeId = hotelTypeId; 120 | } 121 | 122 | public int getHotelId() { 123 | return hotelId; 124 | } 125 | 126 | public void setHotelId(int hotelId) { 127 | this.hotelId = hotelId; 128 | } 129 | 130 | // toString metodu (isteğe bağlı) 131 | @Override 132 | public String toString() { 133 | return "Room{" + 134 | "id=" + id + 135 | ", roomType='" + roomType + '\'' + 136 | ", stock=" + stock + 137 | ", seasonId=" + seasonId + 138 | ", adultPrice=" + adultPrice + 139 | ", childPrice=" + childPrice + 140 | ", hotelTypeId=" + hotelTypeId + 141 | ", hotelId=" + hotelId + 142 | '}'; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /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 | } 42 | btn_admin_logout.addActionListener(new ActionListener() { 43 | @Override 44 | public void actionPerformed(ActionEvent e) { 45 | dispose(); 46 | LoginView loginView = new LoginView(); 47 | 48 | } 49 | }); 50 | 51 | this.lbl_welcome.setText("Hoşgeldiniz : " + this.user.getRole()); 52 | loadAdminPanelComponent(); 53 | 54 | loadRoleFilter(); 55 | loadRoleTable(null); 56 | loadAdminPanelComponent(); 57 | 58 | } 59 | 60 | public void loadRoleFilter() { 61 | this.cmb_role_list.setModel(new DefaultComboBoxModel<>(User.Role.values())); 62 | this.cmb_role_list.setSelectedItem(null); 63 | 64 | } 65 | 66 | public void loadRoleTable(ArrayList userList) { 67 | this.col_user = new Object[]{"ID", "K.Adı", "K.Şifre", "K.Rol"}; 68 | if (userList == null) { 69 | userList = this.userManager.getForTable(col_user.length, userManager.findAll()); 70 | } 71 | this.createTable(this.tmdl_user, this.tbl_user, col_user, userList); 72 | } 73 | 74 | public void loadAdminPanelComponent() { 75 | 76 | 77 | btn_rol_search.addActionListener(e -> { 78 | 79 | 80 | if (this.cmb_role_list.getSelectedItem() != null) { 81 | ArrayList rolListBySearch = this.userManager.searcForTable((User.Role) cmb_role_list.getSelectedItem()); 82 | ArrayList modelRowListBySearch = this.userManager.getForTable(this.col_user.length, rolListBySearch); 83 | loadRoleTable(modelRowListBySearch); 84 | } 85 | }); 86 | this.btn_user_list_clear.addActionListener(e -> { 87 | this.cmb_role_list.setSelectedItem(null); 88 | loadRoleTable(null); 89 | }); 90 | 91 | this.tableRowSelect(this.tbl_user); 92 | this.user_Menu = new JPopupMenu(); 93 | this.user_Menu.add("Yeni").addActionListener(e -> { 94 | UserManagementView managementView = new UserManagementView(null); 95 | managementView.addWindowListener(new WindowAdapter() { 96 | @Override 97 | public void windowClosed(WindowEvent e) { 98 | 99 | loadRoleTable(null); 100 | } 101 | }); 102 | }); 103 | this.user_Menu.add("Güncelle").addActionListener(e -> { 104 | int selectUserdId = this.getTableSelectedRow(tbl_user, 0); 105 | UserManagementView managementView = new UserManagementView(this.userManager.getById(selectUserdId)); 106 | managementView.addWindowListener(new WindowAdapter() { 107 | @Override 108 | public void windowClosed(WindowEvent e) { 109 | 110 | loadRoleTable(null); 111 | } 112 | }); 113 | }); 114 | this.user_Menu.add("Sil").addActionListener(e -> { 115 | if (Helper.confirm("sure")) { //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 116 | int selectBrandId = this.getTableSelectedRow(tbl_user, 0); 117 | if (this.userManager.delete(selectBrandId)) { 118 | Helper.showMsg("done"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 119 | 120 | loadRoleTable(null); 121 | } else { 122 | Helper.showMsg("error"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 123 | } 124 | } 125 | 126 | }); 127 | 128 | this.tbl_user.setComponentPopupMenu(this.user_Menu); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 34 | case "fill" -> { 35 | msg = "Lütfen tüm alanları doldurunuz !"; 36 | title = "Hata!"; 37 | } 38 | case "done" -> { 39 | msg = "İşlem Başarılı !"; 40 | title = "Sonuç"; 41 | } 42 | case "notFound" -> { 43 | msg = "Kayıt bulunamadı !"; 44 | title = "Bulunamadı"; 45 | } 46 | case "error" -> { 47 | msg = "Hatalı işlem yaptınız !"; 48 | title = "Hata!"; 49 | } 50 | default -> { 51 | msg = str; 52 | title = "Mesaj"; 53 | } 54 | } 55 | JOptionPane.showMessageDialog(null, msg, title, JOptionPane.INFORMATION_MESSAGE); 56 | } 57 | 58 | public static boolean confirm(String str) { 59 | optionPayneTR(); 60 | String msg; 61 | if (str.equals("sure")) { 62 | msg = "Bu işlemi yapmak istediginize eminmisiniz !!"; 63 | 64 | } else { 65 | msg = str; 66 | } 67 | return JOptionPane.showConfirmDialog(null, msg, "Eminmisiniz", JOptionPane.YES_NO_OPTION) == 0; 68 | 69 | } 70 | 71 | public static void optionPayneTR() { 72 | UIManager.put("OptionPane.okButtonText", "Tamam"); 73 | UIManager.put("OptionPane.yesButtonText", "Evet"); 74 | UIManager.put("OptionPane.noButtonText", "Hayır"); 75 | 76 | } 77 | 78 | //Jradio lara oda özellikleri metinleri için, oda ekleme ekranındaki 79 | public static String roomProperty(String number){ 80 | String property=""; 81 | switch (number){ 82 | case "1": 83 | property = "Televizyon "; 84 | break; 85 | case "2": 86 | property = "Minibar "; 87 | break; 88 | case "3": 89 | property = "Oyun Konsolu"; 90 | break; 91 | case "4": 92 | property = "Kasa"; 93 | break; 94 | case "5": 95 | property = "Projeksiyon"; 96 | break; 97 | } 98 | return property; 99 | } 100 | public static boolean isValidDate(String inputDate, String formatPattern) { 101 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern); 102 | 103 | try { 104 | LocalDate date = LocalDate.parse(inputDate, formatter); 105 | return true; // Geçerli tarih formatı 106 | } catch (DateTimeParseException e) { 107 | return false; // Geçersiz tarih formatı 108 | } 109 | } 110 | public static LocalDate parseDate(String inputDate, String formatPattern) { 111 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern); 112 | 113 | try { 114 | LocalDate date = LocalDate.parse(inputDate, formatter); 115 | return date; // Başarılı dönüşüm 116 | } catch (DateTimeParseException e) { 117 | return null; // Dönüşüm başarısız 118 | } 119 | } 120 | 121 | public static List getListFromJList(JList jList) { 122 | List list = new ArrayList<>(); 123 | for (int i = 0; i < jList.getModel().getSize(); i++) { 124 | list.add(jList.getModel().getElementAt(i)); 125 | } 126 | return list; 127 | } 128 | // Nesne listesini String listesine dönüştüren metot 129 | public static List convertObjectListToStringList(Object[] objectList) { 130 | List stringList = new ArrayList<>(); 131 | for (Object person : objectList) { 132 | // Her bir nesneyi String'e dönüştürerek listeye ekleyelim 133 | String str = person.toString(); // toString metodu çağrılır 134 | stringList.add(str); 135 | } 136 | return stringList; 137 | } 138 | public static boolean isList_J_Empty(JList list) { 139 | ListModel model = list.getModel(); 140 | return model.getSize() == 0; 141 | } 142 | 143 | public static boolean isFieldListEmpty(JTextField[] fieldList) { 144 | for (JTextField field : fieldList) { 145 | if (isFieldEmpty(field)) return true; 146 | } 147 | return false; 148 | } 149 | 150 | public static boolean isFieldEmpty(JTextField field) { 151 | return field.getText().trim().isEmpty(); 152 | 153 | } 154 | public static boolean isAreaEmpty(JTextArea field) { 155 | return field.getText().trim().isEmpty(); 156 | } 157 | 158 | public static int getLocationPoint(String type, Dimension size) { 159 | return switch (type) { 160 | case "x" -> (Toolkit.getDefaultToolkit().getScreenSize().width - size.width) / 2; 161 | case "y" -> (Toolkit.getDefaultToolkit().getScreenSize().height - size.height) / 2; 162 | default -> 0; 163 | }; 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /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 | } 35 | } catch (SQLException e) { 36 | e.printStackTrace(); 37 | } 38 | return obj; 39 | 40 | } 41 | public String getByTypeId(int id) { 42 | String typeName = null; // Geri dönüş değeri için başlangıçta null 43 | 44 | String query = "SELECT type_name FROM public.type_hotel WHERE type_id = ?"; 45 | try (PreparedStatement pr = con.prepareStatement(query)) { 46 | pr.setInt(1, id); 47 | try (ResultSet rs = pr.executeQuery()) { 48 | if (rs.next()) { 49 | typeName = rs.getString("type_name"); 50 | 51 | } 52 | } 53 | } catch (SQLException e) { 54 | e.printStackTrace(); 55 | // Hata durumunda typeName zaten null olarak kalacak 56 | } 57 | 58 | return typeName; 59 | } 60 | 61 | public ArrayList findAll(int hotelId) { 62 | ArrayList typesList = new ArrayList<>(); 63 | 64 | String query = "SELECT type_id,hotel_id,type_name FROM public.type_hotel WHERE hotel_id = ?"; 65 | 66 | try { 67 | PreparedStatement pr = con.prepareStatement(query); 68 | pr.setInt(1, hotelId); 69 | ResultSet resultSet = pr.executeQuery(); 70 | while (resultSet.next()) { 71 | Types types = match(resultSet); 72 | typesList.add(types); 73 | } 74 | 75 | } catch (SQLException e) { 76 | e.printStackTrace(); 77 | } 78 | 79 | return typesList; 80 | } 81 | 82 | 83 | // Method to create Types object from ResultSet 84 | private Types match(ResultSet rs) throws SQLException { 85 | Types obj = new Types(); 86 | obj.setTypeId(rs.getInt("type_id")); 87 | obj.setHotel_id(rs.getInt("hotel_id")); 88 | obj.setTypeName(rs.getString("type_name")); 89 | return obj; 90 | } 91 | public boolean save(int hotelId, List rightList) { 92 | try { 93 | // Sağ listedeki özellikleri kontrol et ve ekle 94 | for (String feature : rightList) { 95 | // Özellik veritabanında bulunmuyorsa, ekle 96 | String insertQuery = "INSERT INTO type_hotel (hotel_id, type_name) VALUES (?, ?)"; 97 | PreparedStatement insertStatement = con.prepareStatement(insertQuery); 98 | insertStatement.setInt(1, hotelId); 99 | insertStatement.setString(2, feature); 100 | insertStatement.executeUpdate(); 101 | } 102 | } catch (SQLException e) { 103 | e.printStackTrace(); 104 | return false; // Ekleme işlemi başarısız olduğunda false döndür 105 | } 106 | return true; // Ekleme işlemi başarılıysa true döndür 107 | } 108 | 109 | public boolean update(int hotelId, List rightList) { 110 | try { 111 | // Var olan tüm özellikleri veritabanından al 112 | String selectQuery = "SELECT type_name FROM type_hotel WHERE hotel_id = ?"; 113 | PreparedStatement selectStatement = con.prepareStatement(selectQuery); 114 | selectStatement.setInt(1, hotelId); 115 | ResultSet resultSet = selectStatement.executeQuery(); 116 | 117 | HashSet existingFeatures = new HashSet<>(); 118 | while (resultSet.next()) { 119 | existingFeatures.add(resultSet.getString("type_name")); 120 | } 121 | 122 | // Sağ listedeki özellikleri kontrol et ve ekle 123 | for (String feature : rightList) { 124 | if (!existingFeatures.contains(feature)) { 125 | // Özellik veritabanında bulunmuyorsa, ekle 126 | String insertQuery = "INSERT INTO type_hotel (hotel_id, type_name) VALUES (?, ?)"; 127 | PreparedStatement insertStatement = con.prepareStatement(insertQuery); 128 | insertStatement.setInt(1, hotelId); 129 | insertStatement.setString(2, feature); 130 | insertStatement.executeUpdate(); 131 | } 132 | } 133 | } catch (SQLException e) { 134 | e.printStackTrace(); 135 | 136 | } 137 | return true; 138 | } 139 | 140 | public boolean deleteType(int hotelId, List rightList) { 141 | try { 142 | // Var olan tüm özellikleri veritabanından al 143 | String selectQuery = "SELECT type_name FROM type_hotel WHERE hotel_id = ?"; 144 | PreparedStatement selectStatement = con.prepareStatement(selectQuery); 145 | selectStatement.setInt(1, hotelId); 146 | ResultSet resultSet = selectStatement.executeQuery(); 147 | 148 | HashSet existingFeatures = new HashSet<>(); 149 | while (resultSet.next()) { 150 | existingFeatures.add(resultSet.getString("type_name")); 151 | } 152 | 153 | // Sağ listedeki özellikleri kontrol et ve sil 154 | for (String feature : rightList) { 155 | if (existingFeatures.contains(feature)) { 156 | // Özellik veritabanında bulunmuyorsa, sil 157 | String deleteQuery = "DELETE FROM type_hotel WHERE hotel_id = ? AND type_name = ?"; 158 | PreparedStatement insertStatement = con.prepareStatement(deleteQuery); 159 | insertStatement.setInt(1, hotelId); 160 | insertStatement.setString(2, feature); 161 | insertStatement.executeUpdate(); 162 | } 163 | } 164 | return true; 165 | } catch (SQLException e) { 166 | e.printStackTrace(); 167 | return false; 168 | } 169 | } 170 | } 171 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /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 modelList = new ArrayList<>(); 42 | try { 43 | ResultSet rs = this.con.createStatement().executeQuery(query); 44 | while (rs.next()) { 45 | modelList.add(this.match(rs)); 46 | 47 | } 48 | } catch (SQLException throwables) { 49 | throwables.printStackTrace(); 50 | } 51 | return modelList; 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 <= '" + endDate + "'"); 95 | where.add("s.end_date >= '" + startDate + "'"); 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/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 | 22 | public Season getById(int hotelId) { 23 | Season season = null; 24 | String query = "SELECT season_id, hotel_id, start_date, end_date, season_type FROM hotel_seasons WHERE hotel_id = ?"; 25 | 26 | try (PreparedStatement pr = con.prepareStatement(query)) { 27 | pr.setInt(1, hotelId); 28 | ResultSet rs = pr.executeQuery(); 29 | 30 | if (rs.next()) { 31 | season = match(rs); 32 | } 33 | } catch (SQLException e) { 34 | e.printStackTrace(); 35 | } 36 | 37 | return season; 38 | } 39 | public Season getSeasonDate(int seasonId) { 40 | Season season = null; 41 | String query = "SELECT season_id, hotel_id,start_date, end_date, season_type FROM hotel_seasons WHERE season_id = ?"; 42 | 43 | try (PreparedStatement pr = con.prepareStatement(query)) { 44 | pr.setInt(1, seasonId); 45 | ResultSet rs = pr.executeQuery(); 46 | 47 | if (rs.next()) { 48 | season = match(rs); 49 | } 50 | } catch (SQLException e) { 51 | e.printStackTrace(); 52 | } 53 | 54 | return season; 55 | } 56 | 57 | 58 | public ArrayList findAll(int hotelId) { 59 | ArrayList seasonArrayList = new ArrayList<>(); 60 | 61 | String query = "SELECT season_id,hotel_id, start_date, end_date ,season_type FROM hotel_seasons WHERE hotel_id = ? ORDER BY season_id ASC"; 62 | 63 | try { 64 | PreparedStatement statement = con.prepareStatement(query); 65 | statement.setInt(1, hotelId); 66 | ResultSet resultSet = statement.executeQuery(); 67 | 68 | while (resultSet.next()) { 69 | Season season = match(resultSet); 70 | // Sezon türüne göre başlangıç ve bitiş tarihlerini ayarla 71 | 72 | seasonArrayList.add(season); 73 | } 74 | 75 | } catch (SQLException e) { 76 | e.printStackTrace(); 77 | } 78 | 79 | return seasonArrayList; 80 | } 81 | public List getBySeasonList(int hotelId) { 82 | List seasons = new ArrayList<>(); 83 | String query = "SELECT * FROM hotel_seasons WHERE hotel_id = ?"; 84 | 85 | try (PreparedStatement pr = con.prepareStatement(query)) { 86 | pr.setInt(1, hotelId); 87 | ResultSet rs = pr.executeQuery(); 88 | 89 | while (rs.next()) { 90 | Season season = match(rs); 91 | seasons.add(season); // Her sezonu listeye ekle 92 | } 93 | } catch (SQLException e) { 94 | e.printStackTrace(); 95 | } 96 | 97 | return seasons; 98 | } 99 | 100 | 101 | 102 | private Season match(ResultSet rs) throws SQLException { 103 | Season season = new Season(); 104 | season.setSeasonId(rs.getInt("season_id")); 105 | season.setHotel_id(rs.getInt("hotel_id")); 106 | season.setSeason_start(LocalDate.parse(rs.getString("start_date"))); 107 | season.setSeason_end(LocalDate.parse(rs.getString("end_date"))); 108 | season.setSeasonName(rs.getString("season_type")); 109 | String seasonType = season.getSeasonName(); 110 | 111 | return season; 112 | } 113 | 114 | 115 | 116 | public boolean save(List seasons, int hotelId) { 117 | String insertQuery = "INSERT INTO hotel_seasons (hotel_id, start_date, end_date, season_type) VALUES (?, ?, ?, ?)"; 118 | boolean success = true; 119 | 120 | try (PreparedStatement pr = con.prepareStatement(insertQuery)) { 121 | for (Season season : seasons) { 122 | pr.setInt(1, hotelId); 123 | pr.setDate(2, Date.valueOf(season.getSeason_start())); 124 | pr.setDate(3, Date.valueOf(season.getSeason_end())); 125 | pr.setString(4, season.getSeasonName()); 126 | 127 | int rowsAffected = pr.executeUpdate(); 128 | if (rowsAffected != 1) { 129 | success = false; 130 | break; 131 | } 132 | } 133 | } catch (SQLException e) { 134 | e.printStackTrace(); 135 | success = false; 136 | } 137 | 138 | return success; 139 | } 140 | 141 | 142 | public boolean update(Season season) { 143 | String updateQuery = "UPDATE hotel_seasons " 144 | + "SET start_date = ?, end_date = ? " 145 | + "WHERE hotel_id = ? AND season_type = ?"; 146 | try (PreparedStatement pr = con.prepareStatement(updateQuery)) { 147 | pr.setDate(1, Date.valueOf(season.getSeason_start())); 148 | pr.setDate(2, Date.valueOf(season.getSeason_end())); 149 | pr.setInt(3, season.getHotel_id()); 150 | pr.setString(4, season.getSeasonName()); 151 | 152 | int rowsAffected = pr.executeUpdate(); 153 | return rowsAffected > 0; // Güncelleme başarılı ise true döndür 154 | 155 | } catch (SQLException e) { 156 | e.printStackTrace(); // Hata durumunda hatayı yazdır 157 | return false; // Güncelleme başarısız ise false döndür 158 | } 159 | } 160 | 161 | public ArrayList selectByQuery(String query) { 162 | ArrayList seasonArrayList = new ArrayList<>(); 163 | 164 | try (ResultSet rs = con.createStatement().executeQuery(query)) { 165 | while (rs.next()) { 166 | Season season = match(rs); 167 | seasonArrayList.add(season); 168 | } 169 | } catch (SQLException e) { 170 | e.printStackTrace(); 171 | } 172 | 173 | return seasonArrayList; 174 | } 175 | 176 | public Season getBySeason(int id) { 177 | Season obj = new Season(); 178 | String query ="SELECT * FROM hotel_seasons WHERE season_id = ?"; 179 | try { 180 | PreparedStatement pr = con.prepareStatement(query); 181 | pr.setInt(1, id); 182 | ResultSet rs = pr.executeQuery(); 183 | if (rs.next()) { 184 | 185 | obj.setSeason_start(LocalDate.parse(rs.getString("start_date"))); 186 | obj.setSeason_end(LocalDate.parse(rs.getString("end_date"))); 187 | obj.setSeasonName(rs.getString("season_type")); 188 | } 189 | 190 | } catch (SQLException e) { 191 | e.printStackTrace(); 192 | } 193 | return obj; 194 | 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /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 int saveAndGetHotelId(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 | // Önce veritabanında aynı e-posta adresiyle kayıt olup olmadığını kontrol et 86 | if (!isEmailExists(hotel.getHotel_email())) { 87 | PreparedStatement pr = con.prepareStatement(insertQuery, Statement.RETURN_GENERATED_KEYS); 88 | pr.setString(1, hotel.getHotel_name()); 89 | pr.setString(2, hotel.getHotel_city()); 90 | pr.setString(3, hotel.getHotel_district()); 91 | pr.setString(4, hotel.getHotel_fllAdres()); 92 | pr.setString(5, hotel.getHotel_email()); 93 | pr.setString(6, hotel.getHotel_phone()); 94 | pr.setInt(7, hotel.getHotel_star()); 95 | 96 | int rowsAffected = pr.executeUpdate(); 97 | if (rowsAffected == 1) { 98 | ResultSet generatedKeys = pr.getGeneratedKeys(); 99 | if (generatedKeys.next()) { 100 | return generatedKeys.getInt(1); // Yeni otel ID'sini döndür 101 | } 102 | } 103 | } else { 104 | Helper.showMsg("Bu e-posta ile daha önce kayıt yapılmış"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 105 | } 106 | } catch (SQLException throwables) { 107 | throwables.printStackTrace(); 108 | } 109 | return -1; // Hata durumunda veya başarısız eklemede -1 döndür 110 | } 111 | 112 | // Veritabanında verilen e-posta adresiyle kayıtlı otel var mı diye kontrol eden metod 113 | private boolean isEmailExists(String email) throws SQLException { 114 | String query = "SELECT COUNT(*) FROM public.hotels WHERE email = ?"; 115 | try (PreparedStatement pr = con.prepareStatement(query)) { 116 | pr.setString(1, email); 117 | ResultSet rs = pr.executeQuery(); 118 | if (rs.next()) { 119 | int count = rs.getInt(1); 120 | return count > 0; // Eğer count 0'dan büyükse e-posta adresiyle kayıtlı otel var demektir 121 | } 122 | } 123 | return false; 124 | } 125 | 126 | 127 | public ArrayList selectByQuery(String query) { 128 | ArrayList modelList = new ArrayList<>(); 129 | try { 130 | ResultSet rs = this.con.createStatement().executeQuery(query); 131 | while (rs.next()) { 132 | modelList.add(this.match(rs)); 133 | 134 | } 135 | } catch (SQLException throwables) { 136 | throwables.printStackTrace(); 137 | } 138 | return modelList; 139 | } 140 | 141 | public Hotel match(ResultSet rs) throws SQLException { 142 | Hotel obj = new Hotel(); 143 | obj.setHotel_id(rs.getInt("hotel_id")); 144 | obj.setHotel_name(rs.getString("hotel_name")); 145 | obj.setHotel_city(rs.getString("city")); 146 | obj.setHotel_district((rs.getString("district"))); 147 | obj.setHotel_fllAdres((rs.getString("full_address"))); 148 | obj.setHotel_email((rs.getString("email"))); 149 | obj.setHotel_phone((rs.getString("phone_number"))); 150 | obj.setHotel_star((rs.getInt("star"))); 151 | return obj; 152 | } 153 | public ArrayList getHotelCity(String hotelName){ 154 | ArrayList roomPropertiesList = new ArrayList<>(); 155 | Hotel obj; 156 | String query = "SELECT hotel_id,city FROM public.hotels WHERE hotel_name = ?"; 157 | try { 158 | PreparedStatement pr = con.prepareStatement(query); 159 | pr.setString(1, hotelName); 160 | ResultSet rs = pr.executeQuery(); 161 | while (rs.next()){ 162 | obj = new Hotel(); 163 | obj.setHotel_id(rs.getInt("hotel_id")); 164 | obj.setHotel_city(rs.getString("city")); 165 | 166 | roomPropertiesList.add(obj); 167 | } 168 | } catch (SQLException e) { 169 | e.printStackTrace(); 170 | } 171 | 172 | return roomPropertiesList; 173 | } 174 | 175 | public boolean delete(int id) { 176 | String query = "DELETE FROM public.hotels WHERE hotel_id =?"; 177 | try { 178 | PreparedStatement pr = con.prepareStatement(query); 179 | pr.setInt(1, id); 180 | return pr.executeUpdate() != -1; 181 | 182 | } catch (SQLException throwables) { 183 | throwables.printStackTrace(); 184 | } 185 | return true; 186 | 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /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 | 50 | GuestInfoAddView(int adultNum,int childNum){ 51 | add(container); 52 | this.guiInitilaze(600, 450); 53 | 54 | this.reser= new Reser(); 55 | this.reserManager = new ReserManager(); 56 | 57 | this.adultNum = adultNum; 58 | this.childNum = childNum; 59 | 60 | 61 | for(int i =0 ; i<= this.adultNum ;i++){ 62 | if(i==1){ 63 | fld_adult_name_1.setEnabled(true); 64 | fld_adult_nationalNo_1.setEnabled(true); 65 | fld_adult_country_1.setEnabled(true); 66 | }else if(i==2){ 67 | fld_adult_name_2.setEnabled(true); 68 | fld_adult_nationalNo_2.setEnabled(true); 69 | fld_adult_country_2.setEnabled(true); 70 | }else if(i==3){ 71 | fld_adult_name_3.setEnabled(true); 72 | fld_adult_nationalNo_3.setEnabled(true); 73 | fld_adult_country_3.setEnabled(true); 74 | } 75 | } 76 | for(int i =0 ; i<= this.childNum ;i++){ 77 | if(i==1){ 78 | fld_child_name_1.setEnabled(true); 79 | fld_child_nationalNo_1.setEnabled(true); 80 | fld_child_country_1.setEnabled(true); 81 | }else if(i==2){ 82 | fld_child_name_2.setEnabled(true); 83 | fld_child_nationalNo_2.setEnabled(true); 84 | fld_child_country_2.setEnabled(true); 85 | }else if(i==3){ 86 | fld_child_name_3.setEnabled(true); 87 | fld_child_nationalNo_3.setEnabled(true); 88 | fld_child_country_3.setEnabled(true); 89 | } 90 | } 91 | 92 | guest_save.addActionListener(e -> { 93 | 94 | // Her bir grup için JTextField dizilerini tanımlayalım 95 | JTextField[] groupA1 = {fld_adult_name_1, fld_adult_nationalNo_1, fld_adult_country_1}; 96 | JTextField[] groupA2 = {fld_adult_name_2, fld_adult_nationalNo_2, fld_adult_country_2}; 97 | JTextField[] groupA3 = {fld_adult_name_3, fld_adult_nationalNo_3, fld_adult_country_3}; 98 | JTextField[] groupC1 = {fld_child_name_1, fld_child_nationalNo_1, fld_child_country_1}; 99 | JTextField[] groupC2 = {fld_child_name_2, fld_child_nationalNo_2, fld_child_country_2}; 100 | JTextField[] groupC3 = {fld_child_name_3, fld_child_nationalNo_3, fld_child_country_3}; 101 | 102 | boolean groupA1Valid = checkFields(groupA1); 103 | boolean groupA2Valid = checkFields(groupA2); 104 | boolean groupA3Valid = checkFields(groupA3); 105 | boolean group1Valid = checkFields(groupC1); 106 | boolean group2Valid = checkFields(groupC2); 107 | boolean group3Valid = checkFields(groupC3); 108 | 109 | if (groupA1Valid && groupA2Valid && groupA3Valid &&group1Valid && group2Valid &&group3Valid) { 110 | Helper.showMsg("Kontroller Başarılı"); 111 | 112 | // Her bir grup için JTextField dizilerini tanımlayalım 113 | JTextField[][] groups = { 114 | {fld_adult_name_1, fld_adult_nationalNo_1, fld_adult_country_1}, 115 | {fld_adult_name_2, fld_adult_nationalNo_2, fld_adult_country_2}, 116 | {fld_adult_name_3, fld_adult_nationalNo_3, fld_adult_country_3}, 117 | {fld_child_name_1, fld_child_nationalNo_1, fld_child_country_1}, 118 | {fld_child_name_2, fld_child_nationalNo_2, fld_child_country_2}, 119 | {fld_child_name_3, fld_child_nationalNo_3, fld_child_country_3} 120 | }; 121 | 122 | // Reser nesnelerini tutacak bir liste oluşturalım 123 | //List resers = new ArrayList<>(); 124 | 125 | // Her bir grup için döngüyü kullanarak kontrol yapalım 126 | for (int i = 0; i < groups.length; i++) { 127 | JTextField[] group = groups[i]; 128 | if (isFieldListEmpty(group)) { 129 | continue; // Grup boş ise atla 130 | } 131 | 132 | // Grup dolu ise Reser nesnesi oluşturup bilgileri ekleyelim 133 | Reser reser = new Reser(); 134 | reser.setGuestFllName(group[0].getText()); 135 | reser.setGuestnationalNumber(group[1].getText()); 136 | reser.setGuestCountry(group[2].getText()); 137 | 138 | // Diğer özelliklerini de burada ayarlayabilirsiniz (örn. setGuestClass) 139 | if (i < 3) { 140 | reser.setGuestClass("Adult"); // İlk üç grup için Adult olarak ayarla 141 | } else { 142 | reser.setGuestClass("Child"); // Son üç grup için Child olarak ayarla 143 | } 144 | 145 | // Oluşturulan Reser nesnesini listeye ekleyelim 146 | reservations.add(reser); 147 | } 148 | 149 | // Listede en az bir eleman varsa kontroller başarılıdır 150 | if (!reservations.isEmpty()) { 151 | Helper.showMsg("Liste ekleme Başarılı"); 152 | 153 | // Daha sonra bu listeyi istediğiniz şekilde kullanabilirsiniz 154 | // Örneğin, veritabanına eklemek için saveAndGetReserId fonksiyonunu kullanabilirsiniz 155 | } else { 156 | Helper.showMsg("Lütfen en az bir alanı doldurun."); 157 | } 158 | 159 | } else { 160 | Helper.showMsg("Lütfen tüm alanları doldurun."); 161 | } 162 | 163 | }); 164 | } 165 | private boolean checkFields(JTextField[] fields) { 166 | for (JTextField field : fields) { 167 | if (field.isEnabled()) { 168 | String text = field.getText().trim(); 169 | if (text.isEmpty()) { 170 | return false; 171 | } 172 | } 173 | } 174 | return true; 175 | } 176 | 177 | } -------------------------------------------------------------------------------- /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 | return false; // Ekleme işlemi başarısız olduğunda false döndür 166 | } 167 | return true; // Ekleme işlemi başarılıysa true döndür 168 | } 169 | 170 | 171 | 172 | 173 | public ArrayList getListByGuestInfo(int id){ 174 | ArrayList reserGuestInfoList = new ArrayList<>(); 175 | String query = "SELECT * FROM guest_info WHERE reservations_id = ?"; 176 | 177 | try { 178 | PreparedStatement pr = con.prepareStatement(query); 179 | pr.setInt(1, id); 180 | ResultSet rs = pr.executeQuery(); 181 | while (rs.next()){ 182 | Reser resers =new Reser(); 183 | resers.setGuestId(rs.getInt("guest_id")); 184 | resers.setId(rs.getInt("reservations_id")); 185 | resers.setGuestFllName(rs.getString("full_name")); 186 | resers.setGuestnationalNumber(rs.getString("national_number")); 187 | resers.setGuestCountry(rs.getString("country")); 188 | resers.setGuestClass(rs.getString("guest_class")); 189 | 190 | reserGuestInfoList.add(resers); 191 | } 192 | } catch (SQLException e) { 193 | e.printStackTrace(); 194 | } 195 | 196 | return reserGuestInfoList; 197 | } 198 | 199 | } 200 | -------------------------------------------------------------------------------- /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/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 | 51 | public List getPropertyList(int hotelId) { 52 | List propertyList = new ArrayList<>(); 53 | 54 | String query = "SELECT * FROM public.hotel_property WHERE hotel_id = ?"; 55 | try (PreparedStatement ps = con.prepareStatement(query)) { 56 | ps.setInt(1, hotelId); 57 | ResultSet rs = ps.executeQuery(); 58 | 59 | while (rs.next()) { 60 | Array propertyNamesArray = rs.getArray("property_names"); 61 | if (propertyNamesArray != null) { 62 | // PostgreSQL array'i PgArray olarak elde et 63 | PgArray pgArray = (PgArray) propertyNamesArray; 64 | 65 | // PgArray'den Java dizisine dönüşüm 66 | Object[] pgElements = (Object[]) pgArray.getArray(); 67 | 68 | // Java dizisini String dizisine dönüştür 69 | String[] propertyNames = new String[pgElements.length]; 70 | for (int i = 0; i < pgElements.length; i++) { 71 | propertyNames[i] = (String) pgElements[i]; 72 | } 73 | 74 | // Listeye ekle 75 | propertyList.add(propertyNames); 76 | } 77 | } 78 | } catch (SQLException e) { 79 | throw new RuntimeException(e); 80 | } 81 | 82 | return propertyList; 83 | } 84 | 85 | public Property match(ResultSet rs) throws SQLException { 86 | Property property = new Property(); 87 | property.setPropertyID(rs.getInt("property_id")); 88 | property.setHotel_id(rs.getInt("hotel_id")); 89 | 90 | // Get the java.sql.Array from the ResultSet 91 | Array propertyNamesArray = rs.getArray("property_names"); 92 | 93 | if (propertyNamesArray != null) { 94 | // Convert java.sql.Array to Object array 95 | Object[] propertyNamesData = (Object[]) propertyNamesArray.getArray(); 96 | 97 | // Convert Object array to List 98 | List propertyNamesList = new ArrayList<>(); 99 | for (Object element : propertyNamesData) { 100 | if (element != null) { 101 | propertyNamesList.add(element.toString()); 102 | } 103 | } // Set the propertyNames list in the Property object 104 | property.setPropertyNames(propertyNamesList); 105 | } 106 | 107 | return property; 108 | } 109 | 110 | public ArrayList findAll() { 111 | String sql = "SELECT * FROM public.hotel_property ORDER BY property_id ASC"; 112 | return this.selectByQuery(sql); 113 | 114 | } 115 | 116 | public ArrayList selectByQuery(String query) { 117 | ArrayList modelList = new ArrayList<>(); 118 | try { 119 | ResultSet rs = this.con.createStatement().executeQuery(query); 120 | while (rs.next()) { 121 | modelList.add(this.match(rs)); 122 | 123 | } 124 | } catch (SQLException throwables) { 125 | throwables.printStackTrace(); 126 | } 127 | return modelList; 128 | } 129 | 130 | 131 | public boolean save(Property property, int hotelId) { 132 | String insertQuery = "INSERT INTO public.hotel_property (property_names, hotel_id) VALUES (?, ?)"; 133 | 134 | try { 135 | PreparedStatement pr = con.prepareStatement(insertQuery); 136 | Array propertyNamesArray = con.createArrayOf("text", property.getPropertyNames().toArray()); 137 | pr.setArray(1, propertyNamesArray); 138 | pr.setInt(2, hotelId); 139 | 140 | int rowsAffected = pr.executeUpdate(); 141 | return rowsAffected > 0; // Ekleme başarılıysa true döndür 142 | } catch (SQLException throwables) { 143 | throwables.printStackTrace(); 144 | } 145 | return false; // Hata durumunda veya başarısız eklemede false döndür 146 | } 147 | 148 | 149 | public boolean update(Property property) { 150 | String query = "UPDATE public.hotel_property SET " + 151 | "property_id = ?," + 152 | "property_names = ? " + // Düzeltme: Virgül gereksizdi 153 | "WHERE hotel_id = ?"; 154 | 155 | 156 | try { 157 | PreparedStatement pr = con.prepareStatement(query); 158 | pr.setInt(1, property.getPropertyID()); 159 | if (!property.getPropertyNames().contains("Otel Özellikleri")) { 160 | Array propertyNamesArray = con.createArrayOf("text", property.getPropertyNames().toArray()); 161 | pr.setArray(2, propertyNamesArray); 162 | } 163 | pr.setInt(3, property.getHotel_id()); 164 | return pr.executeUpdate() != -1; 165 | } catch (SQLException throwables) { 166 | throwables.printStackTrace(); 167 | } 168 | return true; 169 | } 170 | 171 | 172 | public boolean saveRoomProperty(Property property){ 173 | String query = "INSERT INTO room_properties (property, room_id, adultd_bed_num, child_bed_num, area ) VALUES (?,?,?,?,?)"; 174 | try { 175 | PreparedStatement pr = con.prepareStatement(query); 176 | pr.setString(1,property.getRoomProperty()); 177 | pr.setInt(2,property.getRoomId()); 178 | pr.setInt(3, property.getRoomAdultBedNum()); 179 | pr.setInt(4, property.getRoomChildBedNum()); 180 | pr.setInt(5, property.getRoomArea()); 181 | return pr.executeUpdate() != -1; 182 | } catch (SQLException e) { 183 | e.printStackTrace(); 184 | } 185 | return true; 186 | } 187 | 188 | public boolean delete(int id) { 189 | String query = "DELETE FROM public.hotel_property WHERE hotel_id =?"; 190 | try { 191 | PreparedStatement pr = con.prepareStatement(query); 192 | pr.setInt(1, id); 193 | return pr.executeUpdate() != -1; 194 | 195 | } catch (SQLException throwables) { 196 | throwables.printStackTrace(); 197 | } 198 | return true; 199 | 200 | } 201 | public ArrayList getListByRoomID( int id){ 202 | ArrayList roomPropertiesList = new ArrayList<>(); 203 | Property obj; 204 | Property property =new Property(); 205 | String query = "SELECT * FROM room_properties WHERE room_id = ?"; 206 | try { 207 | PreparedStatement pr = con.prepareStatement(query); 208 | pr.setInt(1, id); 209 | ResultSet rs = pr.executeQuery(); 210 | while (rs.next()){ 211 | obj = new Property(); 212 | obj.setRoomProperty(rs.getString("property")); 213 | obj.setRoomAdultBedNum(rs.getInt("adultd_bed_num")); 214 | obj.setRoomChildBedNum(rs.getInt("child_bed_num")); 215 | obj.setRoomArea(rs.getInt("area")); 216 | roomPropertiesList.add(obj); 217 | 218 | } 219 | } catch (SQLException e) { 220 | e.printStackTrace(); 221 | } 222 | 223 | return roomPropertiesList; 224 | } 225 | 226 | public Property getByBedNum(int id) { 227 | Property obj = new Property(); 228 | String query = "SELECT adultd_bed_num,child_bed_num FROM public.room_properties WHERE room_id = ?"; 229 | try { 230 | PreparedStatement pr = con.prepareStatement(query); 231 | pr.setInt(1, id); 232 | ResultSet rs = pr.executeQuery(); 233 | if (rs.next()) { 234 | obj.setRoomAdultBedNum(rs.getInt("adultd_bed_num")); 235 | obj.setRoomChildBedNum(rs.getInt("child_bed_num")); 236 | } 237 | 238 | } catch (SQLException e) { 239 | e.printStackTrace(); 240 | } 241 | return obj; 242 | 243 | } 244 | 245 | } 246 | 247 | -------------------------------------------------------------------------------- /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/ReservationAdd.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import business.*; 4 | import core.ComboItem; 5 | import core.Helper; 6 | import entity.*; 7 | 8 | import javax.swing.*; 9 | import java.awt.event.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | import java.awt.event.KeyAdapter; 12 | import java.awt.event.KeyEvent; 13 | import java.text.DecimalFormat; 14 | import java.time.LocalDate; 15 | import java.time.format.DateTimeFormatter; 16 | import java.time.temporal.ChronoUnit; 17 | import java.util.List; 18 | 19 | public class ReservationAdd extends Layout { 20 | private JPanel wrapper; 21 | private JPanel pnl_reservation; 22 | private JTextField fld_hotel_name; 23 | private JTextArea txtArea_hotel_address; 24 | private JTextField fld_hotel_phone; 25 | private JTextArea txtArea_hotel_property; 26 | private JTextField fld_room_type; 27 | private JTextArea txtArea_room_property; 28 | private JTextField fld_adult_numb; 29 | private JTextField fld_child_numb; 30 | private JTextField fld_check_start_date; 31 | private JTextField fld_check_end_date; 32 | private JTextField fld_Night_Price; 33 | private JTextField fld_reser_price; 34 | private JPanel pnl_top; 35 | private JTextField fld_client_name; 36 | private JTextField fld_client_phone; 37 | private JTextField fld_client_mail; 38 | private JTextArea txtArea_client_note; 39 | private JButton btn_add_reservation; 40 | private JPanel container; 41 | private JButton btn_reser_price; 42 | private JLabel lbl_season_name; 43 | private JLabel lbl_season_date; 44 | private JButton misafirBilgileriButton; 45 | private JComboBox cmb_AdultBedNums; 46 | private JComboBox cmb_ChildBedNum; 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 | List hotelPropertyList = property.getPropertyNames(); 98 | // JTextArea içeriğini temizle 99 | txtArea_hotel_property.setText(""); 100 | // Listede bulunan tüm özellikleri JTextArea'ya ekleyin 101 | for (String property : hotelPropertyList) { 102 | txtArea_hotel_property.append(property+"\n"); // Her özelliği yeni satıra ekleyin 103 | } 104 | 105 | //yetıskın cocuk yatak sayısı kapasıte verısını belırleme 106 | loadCmbBedNumsList(); 107 | 108 | 109 | String roomProperty =this.room.getRoomType(); 110 | fld_room_type.setText(roomProperty); 111 | 112 | String hotelType = typeManager.getByTypeId(this.room.getHotelTypeId()); 113 | txtArea_room_property.setText(hotelType); 114 | 115 | String roomNightPrince = String.valueOf(this.room.getRoomPrice()); 116 | fld_Night_Price.setText(roomNightPrince); 117 | 118 | seasonStartDate=seasonManager.getSeasonDate(this.room.getSeasonId()).getSeason_start(); 119 | seasonEndDate=seasonManager.getSeasonDate(this.room.getSeasonId()).getSeason_end(); 120 | 121 | String formattedStartDate=seasonStartDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy")); 122 | String formattedEndDate =seasonEndDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy")); 123 | lbl_season_date.setText(formattedStartDate+" - "+formattedEndDate); 124 | 125 | String seasonName=seasonManager.getSeasonDate(this.room.getSeasonId()).getSeasonName(); 126 | lbl_season_name.setText(seasonName); 127 | 128 | 129 | btn_reser_price.addActionListener(e -> { 130 | 131 | if(Helper.isValidDate(fld_check_start_date.getText(),("dd-MM-yyyy")) && Helper.isValidDate(fld_check_end_date.getText(),("dd-MM-yyyy") )) 132 | { 133 | reservationStartDate=(LocalDate.parse(fld_check_start_date.getText(), DateTimeFormatter.ofPattern("dd-MM-yyyy"))); 134 | reservationEndDate=(LocalDate.parse(fld_check_end_date.getText(), DateTimeFormatter.ofPattern("dd-MM-yyyy"))); 135 | daysBetween = (int) ChronoUnit.DAYS.between(reservationStartDate, reservationEndDate); 136 | 137 | }else{ 138 | Helper.showMsg("Geçersiz tarih girildi"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 139 | } 140 | if(!fld_check_start_date.getText().isEmpty() && !fld_check_end_date.getText().isEmpty()) { 141 | int comparison = reservationStartDate.compareTo(reservationEndDate); 142 | int comparisonSeasonStart = seasonStartDate.compareTo(reservationStartDate); 143 | int comparisonSeasonEnd = reservationEndDate.compareTo(seasonEndDate); 144 | if (comparisonSeasonStart < 0 && comparisonSeasonEnd < 0) { 145 | if ((comparison < 0)) { 146 | int roomPrince = this.room.getRoomPrice(); 147 | int adultPrice = this.room.getAdultPrice(); 148 | int childPrice = this.room.getChildPrice(); 149 | 150 | int reservationPrice = ((daysBetween * roomPrince) + (adultPrice * (int) cmb_AdultBedNums.getSelectedItem()) + (childPrice * (int) cmb_ChildBedNum.getSelectedItem())); 151 | 152 | fld_reser_price.setText(String.valueOf(reservationPrice)); 153 | // Biçimlendirici oluştur (Virgülden sonra iki ondalık basamak kullan) 154 | DecimalFormat decimalFormat = new DecimalFormat("#,##0.00"); 155 | // Sayıyı belirli bir biçimde formatla 156 | String formattedText = decimalFormat.format(reservationPrice); 157 | fld_reser_price.setText(formattedText + " TL "); 158 | 159 | } else { 160 | Helper.showMsg(reservationStartDate + " tarihi " + reservationEndDate + " tarihinden geride olamaz."); 161 | } 162 | } else { 163 | Helper.showMsg(formattedStartDate + " - " + formattedEndDate + " sezon tarihileri arsında olmalı."); 164 | } 165 | }else{ 166 | Helper.showMsg("Rezervasyon Tarihleri Boş olamaz"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 167 | } 168 | }); 169 | fld_check_start_date.addKeyListener(new KeyAdapter() { 170 | @Override 171 | public void keyReleased(KeyEvent e) { 172 | fld_reser_price.setText(null); 173 | } 174 | }); 175 | fld_check_end_date.addKeyListener(new KeyAdapter() { 176 | @Override 177 | public void keyReleased(KeyEvent e) { 178 | fld_reser_price.setText(null); 179 | } 180 | }); 181 | 182 | cmb_AdultBedNums.addActionListener(e -> { 183 | fld_reser_price.setText(null); 184 | GuestInfoAddView.reservations.clear(); 185 | }); 186 | cmb_ChildBedNum.addActionListener(e -> { 187 | fld_reser_price.setText(null); 188 | GuestInfoAddView.reservations.clear(); 189 | }); 190 | 191 | 192 | btn_add_reservation.addActionListener(e -> { 193 | 194 | List guestInfoList = GuestInfoAddView.reservations; 195 | 196 | if ((guestInfoList == null) || !guestInfoList.isEmpty()) { 197 | 198 | if (Helper.isFieldEmpty(fld_client_name) || Helper.isFieldEmpty(fld_client_phone)|| 199 | Helper.isFieldEmpty(fld_client_mail)||Helper.isAreaEmpty(txtArea_client_note)||Helper.isFieldEmpty(fld_reser_price)|| 200 | cmb_AdultBedNums.getSelectedItem() ==null ||(Integer) cmb_AdultBedNums.getSelectedItem() == 0 || 201 | cmb_ChildBedNum.getSelectedItem() ==null ) 202 | { 203 | Helper.showMsg("fill"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 204 | } else if (!Helper.isValidDate(fld_check_start_date.getText(),("dd-MM-yyyy")) || !Helper.isValidDate(fld_check_end_date.getText(),("dd-MM-yyyy"))) 205 | { 206 | Helper.showMsg("Geçersiz tarih girildi"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 207 | } else { 208 | String fldAdultBedNum = cmb_AdultBedNums.getSelectedItem().toString(); 209 | String fldChildBedNum = cmb_ChildBedNum.getSelectedItem().toString(); 210 | 211 | this.reser.setRoom_id(this.room.getId()); 212 | this.reser.setReserFllName(fld_client_name.getText()); 213 | this.reser.setReserPhone(fld_client_phone.getText()); 214 | this.reser.setReserEmail(fld_client_mail.getText()); 215 | this.reser.setReserNote(txtArea_client_note.getText()); 216 | this.reser.setReserCheckInDdate(fld_check_start_date.getText()); 217 | this.reser.setReserCheckOutDate(fld_check_end_date.getText()); 218 | this.reser.setAdultNumb(fldAdultBedNum); 219 | this.reser.setChildNumb(fldChildBedNum); 220 | this.reser.setTotalPrice(fld_reser_price.getText()); 221 | 222 | 223 | int reservationId = this.reserManager.saveAndGetReserlId(this.reser); 224 | if (reservationId > 0) { 225 | this.reser.setId(reservationId); 226 | if(this.reserManager.saveGuestInfoList(reservationId)) { 227 | Helper.showMsg("done"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 228 | dispose(); 229 | //Değerlendirme Formu 19 Rezervasyon yapılan odanın stoğu azalıyor 230 | if(this.roomManager.stockUpdate(this.room,-1)){ 231 | Helper.showMsg("Stok Azaltıldı"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 232 | } 233 | 234 | } 235 | else { 236 | Helper.showMsg("error"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 237 | } 238 | } else { 239 | Helper.showMsg("error"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 240 | } 241 | } 242 | }else { 243 | Helper.showMsg("Misafir Bilgileri Boş Olamaz"); //Değerlendirme Formu 24-25 Kullanıcıya başarılı işlemler için uygun pop up mesajları veriliyor ve kullanıcıya hatalı işlemler için uygun hata mesajları veriliyor 244 | } 245 | }); 246 | misafirBilgileriButton.addActionListener(e -> { 247 | int fldAdultBedNum=0; 248 | if(cmb_AdultBedNums.getSelectedItem()!=null){ 249 | fldAdultBedNum= (int) cmb_AdultBedNums.getSelectedItem(); 250 | } 251 | // int fldAdultBedNum= (int) cmb_AdultBedNums.getSelectedItem(); 252 | int fldChildBedNum = (int)cmb_ChildBedNum.getSelectedItem(); 253 | GuestInfoAddView guestInfoAddView = new GuestInfoAddView(fldAdultBedNum,fldChildBedNum); 254 | 255 | }); 256 | } 257 | 258 | 259 | public void loadCmbBedNumsList(){ 260 | // Integer dizisi oluşturalım 261 | Integer[] itemAdult = new Integer[adultBedNum + 1]; 262 | for (int i = 0; i <= adultBedNum; i++) { 263 | itemAdult[i] = i; 264 | } 265 | DefaultComboBoxModel cmbAdultModel = new DefaultComboBoxModel<>(itemAdult); 266 | cmb_AdultBedNums.setModel(cmbAdultModel); 267 | cmb_AdultBedNums.setSelectedIndex(0); 268 | 269 | // Integer dizisi oluşturalım 270 | Integer[] itemChild = new Integer[childBedNum + 1]; 271 | for (int i = 0; i <= childBedNum; i++) { 272 | itemChild[i] = i; 273 | } 274 | DefaultComboBoxModel cmbChildModel = new DefaultComboBoxModel<>(itemChild); 275 | cmb_ChildBedNum.setModel(cmbChildModel); 276 | cmb_ChildBedNum.setSelectedIndex(0); 277 | 278 | } 279 | 280 | } 281 | -------------------------------------------------------------------------------- /TurizmAcente-master/src/view/RoomAdd.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | --------------------------------------------------------------------------------