mirror of
https://github.com/BalrajSinghGidda/Smart-College-Management-System.git
synced 2026-04-07 09:37:22 +00:00
Third Iteration
This commit is contained in:
57
.classpath
Normal file
57
.classpath
Normal file
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="target/generated-sources/annotations">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="ignore_optional_problems" value="true"/>
|
||||
<attribute name="m2e-apt" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="ignore_optional_problems" value="true"/>
|
||||
<attribute name="m2e-apt" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
34
.project
Normal file
34
.project
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>management-system</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1770804693954</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
4
.settings/org.eclipse.core.resources.prefs
Normal file
4
.settings/org.eclipse.core.resources.prefs
Normal file
@@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
2
.settings/org.eclipse.jdt.apt.core.prefs
Normal file
2
.settings/org.eclipse.jdt.apt.core.prefs
Normal file
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.apt.aptEnabled=false
|
||||
9
.settings/org.eclipse.jdt.core.prefs
Normal file
9
.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
|
||||
org.eclipse.jdt.core.compiler.compliance=21
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=21
|
||||
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
BIN
college.db
BIN
college.db
Binary file not shown.
@@ -118,29 +118,63 @@ public class AdminDashboard {
|
||||
root.setCenter(content);
|
||||
}
|
||||
|
||||
public static void loadEventsIntoList(ListView<String> listView) {
|
||||
try (Connection conn = DatabaseManager.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT title, description, event_date FROM events ORDER BY event_date ASC")) {
|
||||
while (rs.next()) {
|
||||
listView.getItems().add(rs.getString("event_date") + " - " + rs.getString("title") + "\n" + rs.getString("description"));
|
||||
}
|
||||
} catch (SQLException e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
private void showEventManagement(BorderPane root) {
|
||||
VBox content = new VBox(15);
|
||||
content.setPadding(new Insets(20));
|
||||
Label title = new Label("Manage Events");
|
||||
Label title = new Label("College Events");
|
||||
title.setStyle("-fx-font-size: 24px; -fx-font-weight: bold;");
|
||||
|
||||
TextField txtTitle = new TextField(); txtTitle.setPromptText("Event Title");
|
||||
DatePicker datePicker = new DatePicker();
|
||||
TextArea txtDesc = new TextArea(); txtDesc.setPromptText("Event Description");
|
||||
Button btnAdd = new Button("Add Event");
|
||||
ListView<String> listView = new ListView<>();
|
||||
loadEventsIntoList(listView);
|
||||
|
||||
btnAdd.setOnAction(e -> {
|
||||
try (Connection conn = DatabaseManager.getConnection();
|
||||
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO events (title, description, event_date) VALUES (?, ?, ?)")) {
|
||||
pstmt.setString(1, txtTitle.getText());
|
||||
pstmt.setString(2, txtDesc.getText());
|
||||
pstmt.setString(3, datePicker.getValue().toString());
|
||||
pstmt.executeUpdate();
|
||||
new Alert(Alert.AlertType.INFORMATION, "Event added!").show();
|
||||
} catch (SQLException ex) { ex.printStackTrace(); }
|
||||
Button btnShowForm = new Button("Create New Event");
|
||||
btnShowForm.setStyle("-fx-background-color: #128c7e; -fx-text-fill: white; -fx-font-weight: bold;");
|
||||
|
||||
btnShowForm.setOnAction(e -> {
|
||||
// Creation Form
|
||||
VBox form = new VBox(10);
|
||||
form.setPadding(new Insets(10));
|
||||
form.setStyle("-fx-border-color: #dcdcdc; -fx-border-radius: 5; -fx-padding: 15;");
|
||||
|
||||
TextField txtTitle = new TextField(); txtTitle.setPromptText("Event Title");
|
||||
DatePicker datePicker = new DatePicker();
|
||||
TextArea txtDesc = new TextArea(); txtDesc.setPromptText("Event Description");
|
||||
|
||||
HBox actions = new HBox(10);
|
||||
Button btnSave = new Button("Post Event");
|
||||
Button btnCancel = new Button("Cancel");
|
||||
actions.getChildren().addAll(btnSave, btnCancel);
|
||||
|
||||
btnSave.setOnAction(ev -> {
|
||||
if (txtTitle.getText().isEmpty() || datePicker.getValue() == null) return;
|
||||
try (Connection conn = DatabaseManager.getConnection();
|
||||
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO events (title, description, event_date) VALUES (?, ?, ?)")) {
|
||||
pstmt.setString(1, txtTitle.getText());
|
||||
pstmt.setString(2, txtDesc.getText());
|
||||
pstmt.setString(3, datePicker.getValue().toString());
|
||||
pstmt.executeUpdate();
|
||||
new Alert(Alert.AlertType.INFORMATION, "Event added!").show();
|
||||
showEventManagement(root); // Refresh view
|
||||
} catch (SQLException ex) { ex.printStackTrace(); }
|
||||
});
|
||||
|
||||
btnCancel.setOnAction(ev -> content.getChildren().remove(form));
|
||||
|
||||
form.getChildren().addAll(new Label("New Event Details"), txtTitle, datePicker, txtDesc, actions);
|
||||
content.getChildren().add(form);
|
||||
});
|
||||
|
||||
content.getChildren().addAll(title, txtTitle, datePicker, txtDesc, btnAdd);
|
||||
content.getChildren().addAll(title, listView, btnShowForm);
|
||||
root.setCenter(content);
|
||||
}
|
||||
|
||||
@@ -226,6 +260,42 @@ public class AdminDashboard {
|
||||
root.setCenter(content);
|
||||
}
|
||||
|
||||
public static void loadNoticesIntoList(ListView<String> listView) {
|
||||
try (Connection conn = DatabaseManager.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(
|
||||
"SELECT n.title, n.content, n.date, u.role " +
|
||||
"FROM notices n " +
|
||||
"LEFT JOIN users u ON n.posted_by = u.id " +
|
||||
"ORDER BY n.id DESC")) {
|
||||
while (rs.next()) {
|
||||
String role = rs.getString("role");
|
||||
String prefix = "ADMIN".equals(role) ? "[PRIORITY] " : "";
|
||||
String notice = prefix + rs.getString("date") + " - " + rs.getString("title") + "\n" + rs.getString("content");
|
||||
listView.getItems().add(notice);
|
||||
}
|
||||
} catch (SQLException e) { e.printStackTrace(); }
|
||||
|
||||
// Custom cell factory for highlighting
|
||||
listView.setCellFactory(lv -> new ListCell<String>() {
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText(null);
|
||||
setStyle("");
|
||||
} else {
|
||||
setText(item);
|
||||
if (item.startsWith("[PRIORITY]")) {
|
||||
setStyle("-fx-font-weight: bold; -fx-text-fill: #d32f2f;"); // Red bold for priority
|
||||
} else {
|
||||
setStyle("");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showNoticeManagement(BorderPane root) {
|
||||
VBox content = new VBox(15);
|
||||
content.setPadding(new Insets(20));
|
||||
@@ -242,10 +312,11 @@ public class AdminDashboard {
|
||||
btnPost.setOnAction(e -> {
|
||||
if (txtTitle.getText().isEmpty() || txtContent.getText().isEmpty()) return;
|
||||
try (Connection conn = DatabaseManager.getConnection();
|
||||
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO notices (title, content, date) VALUES (?, ?, ?)")) {
|
||||
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO notices (title, content, date, posted_by) VALUES (?, ?, ?, ?)")) {
|
||||
pstmt.setString(1, txtTitle.getText());
|
||||
pstmt.setString(2, txtContent.getText());
|
||||
pstmt.setString(3, java.time.LocalDate.now().toString());
|
||||
pstmt.setInt(4, userId);
|
||||
pstmt.executeUpdate();
|
||||
txtTitle.clear();
|
||||
txtContent.clear();
|
||||
|
||||
@@ -37,12 +37,13 @@ public class FacultyDashboard {
|
||||
Button btnMarks = createSidebarButton("Marks Entry");
|
||||
Button btnTimetable = createSidebarButton("My Timetable");
|
||||
Button btnEvents = createSidebarButton("Events");
|
||||
Button btnNotices = createSidebarButton("Notices");
|
||||
Button btnChat = createSidebarButton("Global Chat");
|
||||
Button btnPrivateChat = createSidebarButton("Private Chat");
|
||||
Button btnSettings = createSidebarButton("Settings");
|
||||
Button btnLogout = createSidebarButton("Logout");
|
||||
|
||||
sidebar.getChildren().addAll(brand, new Separator(), btnAttendance, btnMarks, btnTimetable, btnEvents, btnChat, btnPrivateChat, btnSettings, btnLogout);
|
||||
sidebar.getChildren().addAll(brand, new Separator(), btnAttendance, btnMarks, btnTimetable, btnEvents, btnNotices, btnChat, btnPrivateChat, btnSettings, btnLogout);
|
||||
root.setLeft(sidebar);
|
||||
|
||||
applyTheme(root);
|
||||
@@ -52,6 +53,7 @@ public class FacultyDashboard {
|
||||
btnMarks.setOnAction(e -> showMarksEntry(root));
|
||||
btnTimetable.setOnAction(e -> showTimetable(root));
|
||||
btnEvents.setOnAction(e -> showEvents(root));
|
||||
btnNotices.setOnAction(e -> showNotices(root));
|
||||
btnChat.setOnAction(e -> AdminDashboard.showChat(root, username, userId));
|
||||
btnPrivateChat.setOnAction(e -> root.setCenter(new PrivateChatUI(userId).getView()));
|
||||
btnSettings.setOnAction(e -> root.setCenter(new SettingsUI(userId, () -> applyTheme(root)).getView()));
|
||||
@@ -62,6 +64,68 @@ public class FacultyDashboard {
|
||||
stage.setScene(scene);
|
||||
}
|
||||
|
||||
private void showEvents(BorderPane root) {
|
||||
VBox content = new VBox(15);
|
||||
content.setPadding(new Insets(20));
|
||||
Label title = new Label("College Events");
|
||||
title.setStyle("-fx-font-size: 24px; -fx-font-weight: bold;");
|
||||
|
||||
ListView<String> listView = new ListView<>();
|
||||
AdminDashboard.loadEventsIntoList(listView);
|
||||
|
||||
Button btnShowForm = new Button("Create New Event");
|
||||
btnShowForm.setStyle("-fx-background-color: #128c7e; -fx-text-fill: white; -fx-font-weight: bold;");
|
||||
|
||||
btnShowForm.setOnAction(e -> {
|
||||
VBox form = new VBox(10);
|
||||
form.setPadding(new Insets(15));
|
||||
form.setStyle("-fx-border-color: #dcdcdc; -fx-border-radius: 5;");
|
||||
|
||||
TextField txtTitle = new TextField(); txtTitle.setPromptText("Event Title");
|
||||
DatePicker datePicker = new DatePicker();
|
||||
TextArea txtDesc = new TextArea(); txtDesc.setPromptText("Event Description");
|
||||
|
||||
HBox actions = new HBox(10);
|
||||
Button btnSave = new Button("Post Event");
|
||||
Button btnCancel = new Button("Cancel");
|
||||
actions.getChildren().addAll(btnSave, btnCancel);
|
||||
|
||||
btnSave.setOnAction(ev -> {
|
||||
if (txtTitle.getText().isEmpty() || datePicker.getValue() == null) return;
|
||||
try (Connection conn = DatabaseManager.getConnection();
|
||||
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO events (title, description, event_date) VALUES (?, ?, ?)")) {
|
||||
pstmt.setString(1, txtTitle.getText());
|
||||
pstmt.setString(2, txtDesc.getText());
|
||||
pstmt.setString(3, datePicker.getValue().toString());
|
||||
pstmt.executeUpdate();
|
||||
new Alert(Alert.AlertType.INFORMATION, "Event added!").show();
|
||||
showEvents(root);
|
||||
} catch (SQLException ex) { ex.printStackTrace(); }
|
||||
});
|
||||
|
||||
btnCancel.setOnAction(ev -> content.getChildren().remove(form));
|
||||
|
||||
form.getChildren().addAll(new Label("New Event Details"), txtTitle, datePicker, txtDesc, actions);
|
||||
content.getChildren().add(form);
|
||||
});
|
||||
|
||||
content.getChildren().addAll(title, listView, btnShowForm);
|
||||
root.setCenter(content);
|
||||
}
|
||||
|
||||
private void showNotices(BorderPane root) {
|
||||
VBox content = new VBox(15);
|
||||
content.setPadding(new Insets(20));
|
||||
Label title = new Label("College Notices");
|
||||
title.setStyle("-fx-font-size: 22px; -fx-font-weight: bold;");
|
||||
|
||||
ListView<String> listView = new ListView<>();
|
||||
AdminDashboard.loadNoticesIntoList(listView);
|
||||
|
||||
content.getChildren().addAll(title, listView);
|
||||
root.setCenter(content);
|
||||
}
|
||||
|
||||
private void applyTheme(BorderPane root) {
|
||||
root.getStylesheets().clear();
|
||||
root.getStylesheets().add(getClass().getResource("/com/college/management/css/chat.css").toExternalForm());
|
||||
@@ -86,25 +150,6 @@ public class FacultyDashboard {
|
||||
root.setCenter(content);
|
||||
}
|
||||
|
||||
private void showEvents(BorderPane root) {
|
||||
VBox content = new VBox(15);
|
||||
content.setPadding(new Insets(20));
|
||||
Label title = new Label("Upcoming Events");
|
||||
title.setStyle("-fx-font-size: 22px; -fx-font-weight: bold;");
|
||||
|
||||
ListView<String> listView = new ListView<>();
|
||||
try (Connection conn = DatabaseManager.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT title, description, event_date FROM events ORDER BY event_date ASC")) {
|
||||
while (rs.next()) {
|
||||
listView.getItems().add(rs.getString("event_date") + " - " + rs.getString("title") + "\n" + rs.getString("description"));
|
||||
}
|
||||
} catch (SQLException e) { e.printStackTrace(); }
|
||||
|
||||
content.getChildren().addAll(title, listView);
|
||||
root.setCenter(content);
|
||||
}
|
||||
|
||||
private void setupTimetableTable(TableView<TimetableEntry> table) {
|
||||
TableColumn<TimetableEntry, String> colDay = new TableColumn<>("Day");
|
||||
colDay.setCellValueFactory(new PropertyValueFactory<>("day"));
|
||||
|
||||
@@ -120,13 +120,7 @@ public class StudentDashboard {
|
||||
title.setStyle("-fx-font-size: 22px; -fx-font-weight: bold;");
|
||||
|
||||
ListView<String> listView = new ListView<>();
|
||||
try (Connection conn = DatabaseManager.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT title, description, event_date FROM events ORDER BY event_date ASC")) {
|
||||
while (rs.next()) {
|
||||
listView.getItems().add(rs.getString("event_date") + " - " + rs.getString("title") + "\n" + rs.getString("description"));
|
||||
}
|
||||
} catch (SQLException e) { e.printStackTrace(); }
|
||||
AdminDashboard.loadEventsIntoList(listView);
|
||||
|
||||
content.getChildren().addAll(title, listView);
|
||||
root.setCenter(content);
|
||||
@@ -199,13 +193,7 @@ public class StudentDashboard {
|
||||
title.setStyle("-fx-font-size: 22px; -fx-font-weight: bold;");
|
||||
|
||||
ListView<String> listView = new ListView<>();
|
||||
try (Connection conn = DatabaseManager.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT title, content, date FROM notices ORDER BY id DESC")) {
|
||||
while (rs.next()) {
|
||||
listView.getItems().add(rs.getString("date") + " - " + rs.getString("title") + "\n" + rs.getString("content"));
|
||||
}
|
||||
} catch (SQLException e) { e.printStackTrace(); }
|
||||
AdminDashboard.loadNoticesIntoList(listView);
|
||||
|
||||
content.getChildren().addAll(title, listView);
|
||||
root.setCenter(content);
|
||||
|
||||
BIN
target/classes/com/college/management/AdminDashboard$1.class
Normal file
BIN
target/classes/com/college/management/AdminDashboard$1.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,7 @@ com/college/management/App.class
|
||||
com/college/management/PrivateChatUI$1.class
|
||||
com/college/management/ChatService.class
|
||||
com/college/management/User.class
|
||||
com/college/management/AdminDashboard$1.class
|
||||
com/college/management/FacultyDashboard$TimetableEntry.class
|
||||
com/college/management/StudentDashboard$MarkRecord.class
|
||||
com/college/management/ChatMessage.class
|
||||
|
||||
Reference in New Issue
Block a user