-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
79 lines (67 loc) · 2.8 KB
/
Copy pathProgram.cs
File metadata and controls
79 lines (67 loc) · 2.8 KB
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
// ============================================================
// Program.cs — Application Entry Point
//
// This file:
// 1. Initialises the SQLite database (creates tables)
// 2. Seeds sample data on first run
// 3. Creates repository instances (our "services")
// 4. Injects them into the UI menus
// 5. Runs the main menu loop
//
// Think of this as the "wiring" file — it connects every
// other part of the project together.
// ============================================================
using SMS.Data;
using SMS.Helpers;
using SMS.Services;
using SMS.UI;
// ── 1. Database setup ────────────────────────────────────────
DatabaseHelper.InitializeDatabase(); // creates sms.db + all tables
SeedData.Run(); // inserts sample data (once only)
// ── 2. Create repositories ───────────────────────────────────
// Each repository handles one "table group" in the database.
var adminRepo = new AdminRepository();
var studentRepo = new StudentRepository();
var courseRepo = new CourseRepository();
var gradeRepo = new GradeRepository();
var attendanceRepo = new AttendanceRepository();
var feeRepo = new FeeRepository();
var timetableRepo = new TimetableRepository();
// ── 3. Create menus (inject repositories) ────────────────────
var adminMenu = new AdminMenu(
adminRepo, studentRepo, courseRepo,
gradeRepo, attendanceRepo, feeRepo, timetableRepo);
var studentMenu = new StudentMenu(
studentRepo, courseRepo, gradeRepo,
attendanceRepo, feeRepo, timetableRepo);
// ── 4. Main loop ─────────────────────────────────────────────
while (true)
{
ConsoleUI.Banner();
int choice = ConsoleUI.ReadInt("\n Select option", 0, 4);
Console.Clear();
switch (choice)
{
case 1: // Admin Login
var admin = adminMenu.Login();
if (admin != null) adminMenu.Run(admin);
break;
case 2: // Admin Signup
adminMenu.Signup();
ConsoleUI.Pause();
break;
case 3: // Student Login
var student = studentMenu.Login();
if (student != null) studentMenu.Run(student);
break;
case 4: // Student Signup
studentMenu.Signup();
ConsoleUI.Pause();
break;
case 0: // Exit
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("\n Thank you for using the Student Management System. Goodbye!\n");
Console.ResetColor();
return;
}
}