I have been working on this sample project for a week now but I am not having luck. I am trying to create a day calendar in c#.
Here is my table layout
ID StartTime EndTime Description Subject
08:15 09:30 Meeting
09:30 10:30 Workout
12:00 13:00 Lunch
12:00 13:00 Meeting with John
13:15 14:30 Meeting Offsite
My other table is a Time table that lists times of the day in hour, minute, and second.
The SQL Statement below lists the appointment in gridview. However duplicate times show up when there is an duplicate appointment. Second. How can I show times without being specific. Like in my SQL Statement below, I list the times every 15 minutes. The appointment does not show on the gridview if it is in anything but 15 minute intervals.
Also when I have the appointments listed I would like to highlight the cells. The code below only highlight the first set of times and nothing else.
SELECT MHour, MMinutes, ApptSub FROM (SELECT row_number() over (partition by MMinutes order by MMinutes, ApptTimes) as SeqNum, MHour, MMinutes, ApptTimes, CASE WHEN ApptSub IS NULL THEN '1' ELSE ApptSub END AS ApptSub FROM (SELECT TimeTable.MHour, TimeTable.MMinutes, CASE WHEN Appt.ApptStart IS NULL THEN 'N' ELSE Appt.ApptStart END AS ApptStart, CASE WHEN Appt_1.ApptEndDisplay IS NULL THEN 'N' ELSE Appt_1.ApptEndDisplay END AS ApptEnd, Appt.ApptSubject, Appt_1.ApptSubject AS ApptSubject2 FROM (SELECT DISTINCT MilitaryHour + ':00' AS MHour, MilitaryHour + ':' + Minute AS MMinutes FROM dim_Time WHERE (Minute IN ('00', '15', '30', '45'))) AS TimeTable LEFT OUTER JOIN Appt AS Appt_1 ON TimeTable.MMinutes = Appt_1.ApptEndDisplay LEFT OUTER JOIN Appt ON TimeTable.MMinutes = Appt.ApptStart) T1 Cross Apply (VALUES (ApptStart, ApptSubject),(ApptEnd, ApptSubject2))c (ApptTimes, ApptSub)) T2 WHERE SEQNUM = '1' OR ApptTimes != 'N' ORDER BY MHour, MMinutes, ApptTimes ASC, SeqNum DESC
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
for (int i = 0; i < 1; i++)
bool begin = false;
foreach (GridViewRow row in GridView1.Rows)
if (row.Cells[i + 2].Text != "1")
row.Cells[i + 2].BackColor = System.Drawing.Color.Blue;
if (!begin) begin = true;
if (begin) row.Cells[i + 2].BackColor = System.Drawing.Color.Blue;