View and delete appointments

This commit is contained in:
Spudnut2000
2025-06-19 22:27:18 -05:00
parent cef0cb9451
commit aad159f026
5 changed files with 138 additions and 55 deletions

View File

@@ -421,7 +421,7 @@ namespace C969Project.Data
return null;
}
public static List<Appointment> RetrieveAllAppointments()
public static List<Appointment> RetrieveAllAppointments(int? userId = null)
{
using MySqlConnection connection = new MySqlConnection(AppSettings.GetSetting("ConnectionStrings", "DefaultConnection"));
try
@@ -436,7 +436,11 @@ namespace C969Project.Data
List<Appointment> appointments = new List<Appointment>();
using MySqlCommand command = new MySqlCommand("SELECT * FROM client_schedule.appointment", connection);
string query = "SELECT * FROM client_schedule.appointment";
if (userId.HasValue) query += " WHERE userId = @userId";
using MySqlCommand command = new MySqlCommand(query, connection);
if (userId.HasValue) command.Parameters.AddWithValue("@userId", userId.Value);
using MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{