private void SaveButton_Click(object sender, EventArgs e) { try { string patientFirstName = ""; string patientLastName = ""; ISingleResult <getPatientByIDResult> result = doAction.getPatientByID(thisPatientID); foreach (getPatientByIDResult r in result) { patientFirstName = r.FirstName; patientLastName = r.LastName; } doAction.CreateAppointment(patientFirstName, patientLastName, AppointmentDetails.Text, dateTimePicker1.Value, dateTimePicker2.Value, thisPatientID, System.DateTime.Now, this.providerID); calendarItem.StartDate = dateTimePicker1.Value; calendarItem.EndDate = dateTimePicker2.Value; ISingleResult <getJustCreatedAppointmentIDResult> result1 = doAction.getJustCreatedAppointmentID(); int apptID = 0; foreach (getJustCreatedAppointmentIDResult r in result1) { apptID = r.appointmentID; } string apptText = patientFirstName + " " + patientLastName + "\n" + GetProviderName() + "\n" + AppointmentDetails.Text; CalendarItem cal = new CalendarItem(calendar1, dateTimePicker1.Value, dateTimePicker2.Value, apptText, patientFirstName, patientLastName, apptID, thisPatientID, this.providerID, "Scheduled"); cal.BackgroundColor = Color.Blue; schedulingCalendar.GetCalendarItems().Add(cal); schedulingCalendar.PlaceItems(items); this.Close(); } catch (Exception ex) { MessageBox.Show("Please enter valid dates and times"); } }
private void Save_Click(object sender, EventArgs e) { if (PatientListView.Rows.Count > 0) { if (!isUpdated) { try { int rowIndex = PatientListView.CurrentRow.Index; var selectedPatientIDCell = this.PatientListView["PatientID", rowIndex]; selectedPatientID = (Int32)selectedPatientIDCell.Value; string firstName = (String)this.PatientListView["FirstName1", rowIndex].Value; string lastName = (String)this.PatientListView["LastName1", rowIndex].Value; doAction.CreateAppointment(firstName, lastName, AppointmentDetails.Text, dateTimePicker1.Value, dateTimePicker2.Value, selectedPatientID, System.DateTime.Now, providerID); string calText = firstName + " " + lastName + "\n" + GetProviderName() + "\n" + AppointmentDetails.Text; calendarItem.StartDate = dateTimePicker1.Value; calendarItem.EndDate = dateTimePicker2.Value; ISingleResult <getJustCreatedAppointmentIDResult> result = doAction.getJustCreatedAppointmentID(); int apptID = 0; foreach (getJustCreatedAppointmentIDResult r in result) { apptID = r.appointmentID; } CalendarItem cal = new CalendarItem(calendar1, dateTimePicker1.Value, dateTimePicker2.Value, calText, firstName, lastName, apptID, selectedPatientID, providerID, "Scheduled"); cal.BackgroundColor = Color.Blue; Console.WriteLine("this item text on main screen: " + calendarItem.Text); scheduleForm.GetCalendarItems().Add(cal); scheduleForm.PlaceItems(scheduleForm.GetCalendarItems()); saved = true; this.Close(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("This patient is not in the system. Please add them as a new patient"); this.Close(); Exception ex2 = ex; while (ex2.InnerException != null) { ex2 = ex2.InnerException; } Console.WriteLine(ex.InnerException); throw; } } else { try { int rowIndex = PatientListView.CurrentRow.Index; var selectedPatientIDCell = this.PatientListView["PatientID", rowIndex]; selectedPatientID = (Int32)selectedPatientIDCell.Value; string firstName = (String)this.PatientListView["FirstName1", rowIndex].Value; string lastName = (String)this.PatientListView["LastName1", rowIndex].Value; doAction.editAppointment(calendarItem.AppointmentID, firstName, lastName, AppointmentDetails.Text, dateTimePicker1.Value, dateTimePicker2.Value, selectedPatientID, providerID); string calText = firstName + " " + lastName + "\n" + GetProviderName() + "\n" + AppointmentDetails.Text; calendarItem.StartDate = dateTimePicker1.Value; calendarItem.EndDate = dateTimePicker2.Value; scheduleForm.GetCalendarItems().Remove(calendarItem); CalendarItem cal = new CalendarItem(calendar1, dateTimePicker1.Value, dateTimePicker2.Value, calText, firstName, lastName, calendarItem.AppointmentID, selectedPatientID, providerID, "Scheduled"); cal.BackgroundColor = calendarItem.BackgroundColor; scheduleForm.GetCalendarItems().Add(cal); calendar1.Items.Clear(); scheduleForm.PlaceItems(scheduleForm.GetCalendarItems()); saved = true; this.Close(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("This patient is not in the system. Please add them as a new patient"); this.Close(); Exception ex2 = ex; while (ex2.InnerException != null) { ex2 = ex2.InnerException; } Console.WriteLine(ex.InnerException); throw; } } } }