I’m making a page to allow lecture create consultation slot, the way I make is populate button control in loop for 5 times(5 working days). I need to disabled the button got class in timetable and identify the button with button content then store into database. when lecturer click the button it pop up with date of column(day) + time slot.
Data for verify and disable button from table of timetable
start_time -> 2011-11-08 08:00:00
end_time -> 2011-11-08 10:00:00
Then I plan to use end_time – start_time = 2 hour, if 2 hour then 08:00, 08:30, 09:00, 09:30 4 button from start_time will be disable. I create the button with
string[] timeslot = {"08:00 AM", "08:30 AM", "09:00 AM", "09:30 AM", "10:00 AM", "10:30 AM", "11:00 AM", "11:30 AM", "12:00 PM", "12:30 PM", "01:00 PM", "01:30 PM", "02:00 PM", "02:30 PM", "03:00 PM", "03:30 PM", "04:00 PM", "04:30 PM", "05:00 PM", "05:30 PM"};
for (int i = 0; i < 20; i++)
{
Button btnMonday = new Button
{
Height = 38,
Width = 256,
Content = timeslot[i],
Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xB1, 0xB1, 0xB1))
};
// Sets dependency properties
btnMonday.SetValue(Grid.ColumnProperty, 0);
btnMonday.SetValue(Grid.RowProperty, i);
// Adds the dynamically created control to the canvas
LayoutRoot.Children.Add(btnMonday);
}
I created the button for Monday column, but I can’t assume Monday is gettime.now(), may I know how could I get the date for day of current week ?
Since
DayOfWeekis an enum, it can be casted to an int.Then you can take that number of days from
DateTime.TodayYou could then Add the day of the week back again that you want
Update:
As for getting 30 minute chunks: