public void loadprofile(object sender, MouseButtonEventArgs e) { ListViewItem itm = sender as ListViewItem; ScheduleHolder schedule = itm.Content as ScheduleHolder; subparent.loadPatientInfo(schedule.PatientID, "appointment"); }
/// <summary> /// Fetch all apointments for selected dates on the calendar /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e) { SelectedDatesCollection collection = calendar.SelectedDates; string patch = ""; if (collection.Count > 0) { patch = " where "; } foreach (DateTime dt in collection) { patch += "patientid=" + subparent.PatientId + " and convert(date,date)=str_to_date('" + dt.ToShortDateString() + "','%m/%d/%Y')"; if (collection.IndexOf(dt) < (collection.Count - 1)) { patch += " or "; } } if (patch.Equals("")) { patch = " where patientid=" + subparent.PatientId; } listView0.Items.Clear(); DataTable qry = parent.query("select scheduleid, (select concat(lastname,' ',firstname) from doctor where doctor.doctorid=schedule.doctorid) as name,(select specialization from doctor where doctor.doctorid=schedule.doctorid) as specialization, status as attended, schedule.date as schedule, date_added as created from schedule " + patch + " "); foreach (DataRow rw in qry.Rows) { ScheduleHolder schedule = new ScheduleHolder(); schedule.ID = int.Parse(rw["scheduleid"].ToString()); schedule.doctor_name = (rw["name"].ToString()); schedule.specialization = (rw["specialization"].ToString()); schedule.attended = (rw["attended"].ToString()); schedule.schedule = (rw["schedule"].ToString()); schedule.created = (rw["created"].ToString()); listView0.Items.Add(schedule); } }
/// <summary> /// Add all schedules for current date to a listview. Trigger calendar date change event /// </summary> /// <param name="root"></param> /// <param name="_sub"></param> public appointment(MainWindow root, patient_frame _sub) { parent = root; subparent = _sub; InitializeComponent(); DataTable qry = parent.query("select scheduleid, (select concat(lastname,' ',firstname) from doctor where doctor.doctorid=schedule.doctorid) as name, status as attended, schedule.date as schedule, date_added as created from schedule where convert(date,date)=str_to_date('" + DateTime.Now.ToShortDateString() + "','%m/%d/%Y') and patientid = " + subparent.PatientId); foreach (DataRow rw in qry.Rows) { ScheduleHolder schedule = new ScheduleHolder(); schedule.ID = int.Parse(rw["scheduleid"].ToString()); schedule.doctor_name = (rw["name"].ToString()); schedule.attended = (rw["attended"].ToString()); schedule.schedule = (rw["schedule"].ToString()); schedule.created = (rw["created"].ToString()); listView1.Items.Add(schedule); } calendar_SelectedDatesChanged(null, null); }