- Timestamp:
- Dec 8, 2010, 9:44:29 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Scheduling/trunk/cs/bsdx0200GUISourceCode/UCPatientAppts.cs
r1011 r1038 32 32 catch (Exception ex) { MessageBox.Show(ex.Message); } 33 33 34 dvAppt = new DataView(dtAppt);35 dvAppt.Sort = "ApptDate ASC";36 34 SetPastFilter(false); 37 dgAppts.DataSource = dvAppt;38 35 36 // dgAppts.DataSource = dvAppt; 39 37 } 40 38 /// <summary> 41 39 /// Sets the filter for the DataView on whether to show past appointments or not 40 /// Uses LINQ. Must use .Net 3.5 or above. Hope the LINQ is self-explanatory. 42 41 /// </summary> 43 42 /// <param name="ShowPastAppts">boolean - self explanatory</param> 44 43 void SetPastFilter(bool ShowPastAppts) 45 44 { 46 if (ShowPastAppts) dvAppt.RowFilter = ""; 47 else dvAppt.RowFilter = "ApptDate > " + "'" + DateTime.Today.ToShortDateString() + "'"; 45 if (ShowPastAppts) 46 { 47 var uncancelledAppts = from appt in dtAppt.AsEnumerable() 48 orderby appt.Field<DateTime>("ApptDate") 49 select appt; 50 51 dvAppt = uncancelledAppts.AsDataView(); 52 } 53 else 54 { 55 var uncancelledAppts = from appt in dtAppt.AsEnumerable() 56 where appt.Field<DateTime>("ApptDate") > DateTime.Today 57 orderby appt.Field<DateTime>("ApptDate") 58 select appt; 59 60 dvAppt = uncancelledAppts.AsDataView(); 61 } 62 63 // It's strange that I have to bind it here; but look like dvAppt points to a new memory 64 // location when reassigned up above in the LINQ statement, so we have to rebind it. 65 dgAppts.DataSource = dvAppt; 48 66 } 49 67
Note:
See TracChangeset
for help on using the changeset viewer.