After a bit more digging and reading though my own question I managed to come up with a solution to both parts of my own question, I have posted part of the code bellow:
For the StartTime and EndTime I am using variable types of DateTime and then I am converting it to a string with the format of HH:mm (16:10) for the interval I am using TimeSpan for this section. I have the 3 variables as inputs to a function and then call access these vars within the script below, I then call and external function to check if the booking Exists or not returning false if slot booked or true if slot free.
Table AppointmentTable = new Table();
DateTime time = startTime;
while (time <= endTime)
{
TableRow tblr_row = new TableRow();
TableCell tblc_cell = new TableCell();
TableCell tblc_time = new TableCell();
try
{
if(Appointments.checkIfBookingExsists(time) == true)
{
tblc_time.Text = time.ToString("HH:mm");
tblc_cell.Text = "Booked";
tblc_cell.CssClass = "Booked";
}
else if(Appointments.checkIfBookingExsists(time) == false)
{
tblc_time.Text = time.ToString("HH:mm");
tblc_cell.Text = "Book";
tblc_cell.CssClass = "Book";
}
}
catch (Exception ex)
{
tblc_time.Text = time.ToString("HH:mm");
tblc_cell.Text = ex.Message;
}
tblc_time.CssClass = "tableCell";
tblr_row.Controls.Add(tblc_time);
tblr_row.Controls.Add(tblc_cell);
AppointmentTable.CssClass = "table1";
AppointmentTable.Controls.Add(tblr_row);
//Move interval 16:10 > 16:20 interval 10 minutes
time = time.Add(interval);
}
Page.Controls.Add(AppointmentTable);
I am not one of these people that is just looking for 'FREE CODE' but a hard working Network Engineer that has an interest in application development. I will always attempt to solve my own issues, but sometimes will ask for assistance. I understand the description of the question was 'bare or sketchy' but in the end I have found a solution.
Hope someone else can put this code to better use than I have!! :)