//event for clicking the appointment block private void ApptBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ApptBlockControl apptBlock = (ApptBlockControl)sender; if (apptBlock.isEnabled()) { ApptWindow apptWindow = new ApptWindow(apptBlock, apptBlock.getApptRepresenting()); apptWindow.Owner = Window.GetWindow(this); apptWindow.Show(); } else { //save and close string apptStatus = "Not Arrived"; apptBlock.setApptRepresenting(new Appointment(patient, apptType, apptStatus, potentialLength, this.startBlock, this.time)); //saves the appointment to the block (probably dont need this) daySched.setAppointmentAtTime(apptBlock.getApptRepresenting(), Array.IndexOf(apptBlocks, apptBlock)); //save the appointment to the schedule //add the appointment to the patient as well this.patient.addAppointment(apptBlock.getApptRepresenting()); //MessageBox.Show("SAVED"); Window.GetWindow(this).Close(); //force the windows to update MediSchedData.forceRefresh(); } }
//saves billing info private void saveBilling() { this.billStreetBox.Visibility = Visibility.Hidden; this.billCityBox.Visibility = Visibility.Hidden; this.billProvBox.Visibility = Visibility.Hidden; this.billCountryBox.Visibility = Visibility.Hidden; this.billPhoneBox.Visibility = Visibility.Hidden; this.billPostalBox.Visibility = Visibility.Hidden; this.billStreetBlock.Text = this.billStreetBox.Text; this.billCityBlock.Text = this.billCityBox.Text; this.billProvBlock.Text = this.billProvBox.Text; this.billCountryBlock.Text = this.billCountryBox.Text; this.billPhoneBlock.Text = this.billPhoneBox.Text; this.billPostalBlock.Text = this.billPostalBox.Text; this.billStreetBlock.Visibility = Visibility.Visible; this.billCityBlock.Visibility = Visibility.Visible; this.billProvBlock.Visibility = Visibility.Visible; this.billCountryBlock.Visibility = Visibility.Visible; this.billPhoneBlock.Visibility = Visibility.Visible; this.billPostalBlock.Visibility = Visibility.Visible; //save to the object this.patient.billAddress = this.billStreetBlock.Text; this.patient.billCity = this.billCityBlock.Text; this.patient.billProvince = this.billProvBlock.Text; this.patient.billCountry = this.billCountryBlock.Text; this.patient.billPhone = this.billPhoneBlock.Text; this.patient.billPostal = this.billPostalBlock.Text; //force the db to refresh MediSchedData.forceRefresh(); }
//when the user clicks the delete doctor button private void deleteDoctorButton_Click(object sender, RoutedEventArgs e) { if (docListGrid.SelectedItem != null) { MediSchedData.deleteDoc((docListGrid.SelectedItem as Doctor)); docListGrid.Items.Remove(docListGrid.SelectedItem); } }
//loads patients into the box private void loadPatients() { this.PatientList.Items.Clear(); foreach (Patient patient in MediSchedData.getPatientList()) { this.PatientList.Items.Add(patient); } }
public MainWindow() { MediSchedData.setUpFakeDb(); //setting up the fake database InitializeComponent(); MediSchedData.dbChanged += handleDbChange; loadDaySchedules(); }
//searches patients private void searchText(object sender, TextChangedEventArgs e) { string searchText = txtNameToSearch.Text; this.PatientList.Items.Clear(); foreach (Patient patient in MediSchedData.getPatientList()) { if (patient.PatientName.ToLower().Contains(searchText.ToLower())) { this.PatientList.Items.Add(patient); } } }
//gets the number of open appointments for all doctors private int getNumApptsForAllDoctorsByDay(int year, int month, int day) { int numAppts = 0; List <Doctor> allDoctors = MediSchedData.getDocList(); foreach (Doctor doc in allDoctors) { if (doc.worksOn((int)new DateTime(year, month, day).DayOfWeek)) { numAppts += MediSchedData.getDaySchedule(doc, year, month, day).getNumAppointments(); } } return(numAppts); }
//saves personal info private void savePersonal() { this.nameBox.Visibility = Visibility.Hidden; this.emailBox.Visibility = Visibility.Hidden; this.streetBox.Visibility = Visibility.Hidden; this.cityBox.Visibility = Visibility.Hidden; this.provBox.Visibility = Visibility.Hidden; this.countryBox.Visibility = Visibility.Hidden; this.phoneBox.Visibility = Visibility.Hidden; this.ageBox.Visibility = Visibility.Hidden; this.bloodBox.Visibility = Visibility.Hidden; this.nameBlock.Text = this.nameBox.Text; this.emailBlock.Text = this.emailBox.Text; this.streetBlock.Text = this.streetBox.Text; this.cityBlock.Text = this.cityBox.Text; this.provBlock.Text = this.provBox.Text; this.countryBlock.Text = this.countryBox.Text; this.phoneBlock.Text = this.phoneBox.Text; this.ageBlock.Text = this.ageBox.Text; this.bloodBlock.Text = this.bloodBox.Text; this.displayPatientname.Text = this.nameBox.Text; this.nameBlock.Visibility = Visibility.Visible; this.emailBlock.Visibility = Visibility.Visible; this.streetBlock.Visibility = Visibility.Visible; this.cityBlock.Visibility = Visibility.Visible; this.provBlock.Visibility = Visibility.Visible; this.countryBlock.Visibility = Visibility.Visible; this.phoneBlock.Visibility = Visibility.Visible; this.ageBlock.Visibility = Visibility.Visible; this.bloodBlock.Visibility = Visibility.Visible; //save to the object this.patient.PatientName = this.nameBox.Text; this.patient.email = this.emailBox.Text; this.patient.address = this.streetBox.Text; this.patient.city = this.cityBox.Text; this.patient.province = this.provBox.Text; this.patient.country = this.countryBox.Text; this.patient.phone = this.phoneBox.Text; this.patient.age = this.ageBox.Text; this.patient.bloodType = this.bloodBox.Text; //force db to refresh MediSchedData.forceRefresh(); }
//loads the day schedules private void loadDaySchedules() { SchedDayControl schedDay = null; List <Doctor> allDoctors = MediSchedData.getDocList(); this.scheduleGrid.Children.Clear(); foreach (Doctor doc in allDoctors) { if (doc.worksOn((int)time.DayOfWeek)) { schedDay = new SchedDayControl(doc, MediSchedData.getDaySchedule(doc, time.Year, time.Month, time.Day)); this.scheduleGrid.Children.Add(schedDay); } } }
//DataTable dt = new DataTable(); //initially loading data fromt he big boy fake database public DoctorsWindow() { DoctorsWindow.newWindowOpened += handleNewWindow; MainWindow.mainClosed += handleMainClose; DoctorsWindow.newWindowOpened(this, null); InitializeComponent(); //load data List <Doctor> ls = MediSchedData.getDocList(); if (ls.Count > 0) { for (int i = 0; i < ls.Count; i++) { //docListGrid.Items.Add(new Doctor() {ID = ls[i].ID, Name = ls[i].Name, Days = ls[i].Days, Hours = ls[i].Hours }); docListGrid.Items.Add(ls[i]); } } }
//press ok on new patient window private void OkButtonStyle(object sender, RoutedEventArgs e) { bool canClose = true; //maybe prevent from adding patient with no name if (string.IsNullOrEmpty(nameBlock.Text.Trim())) { canClose = false; nameBlock.BorderBrush = new SolidColorBrush(Colors.Red); } else { nameBlock.BorderBrush = new SolidColorBrush(Colors.Gray); } if (canClose) { //create patient from form data Patient newPatient = new Patient(this.nameBlock.Text, this.emailBlock.Text, this.streetBlock.Text, this.cityBlock.Text, this.provBlock.Text, this.countryBlock.Text, this.phoneBlock.Text, this.ageBlock.Text, this.bloodBlock.Text, this.billStreetBox.Text, this.billCityBox.Text, this.billProvBox.Text, this.billCountryBox.Text, this.billPhoneBox.Text, this.billPostalBox.Text); MediSchedData.addPatientToList(newPatient); if (fromAppointment) { NewApptMonth apptmonthWindow = new NewApptMonth(newPatient); apptmonthWindow.Owner = this.Owner; apptmonthWindow.Show(); } else { //maybe open the thing for that patient but probably not } this.Close(); } }
//event for clicking the delete button (currently does nothing) private void deleteButton_Click(object sender, RoutedEventArgs e) { //delete the appointment this.Close(); MediSchedData.deleteAppointment(this.apptRepresenting); }
//sets the notes public void setNotes(string notes) { this.notes = notes; MediSchedData.forceRefresh(); }
private void okButton_Click(object sender, RoutedEventArgs e) { DoctorsWindow parentDoc = (DoctorsWindow)this.Owner; string cbox1Val = ""; string cbox2Val = ""; canAdd = true; if (parentDoc != null) { Doctor rowToBeUpdated = (Doctor)parentDoc.docListGrid.SelectedItem; string dash = "-"; if (startTBlock1.Text.Length == 0 && startTBlock2.Text.Length == 0 && endTBlock1.Text.Length == 0 && endTBlock2.Text.Length == 0) { dash = ""; } if (mondayBox.IsChecked == true) { isM = true; } else if (mondayBox.IsChecked == false) { isM = false; } if (tuesdayBox.IsChecked == true) { isT = true; } else if (tuesdayBox.IsChecked == false) { isT = false; } if (wednesdayBox.IsChecked == true) { isW = true; } else if (wednesdayBox.IsChecked == false) { isW = false; } if (thursdayBox.IsChecked == true) { isR = true; } else if (thursdayBox.IsChecked == false) { isR = false; } if (fridayBox.IsChecked == true) { isF = true; } else if (fridayBox.IsChecked == false) { isF = false; } this.workingDays = ""; if (isM) { this.workingDays = "M"; } if (isT) { this.workingDays += "T"; } if (isW) { this.workingDays += "W"; } if (isR) { this.workingDays += "R"; } if (isF) { this.workingDays += "F"; } if (string.IsNullOrEmpty(docNameBlock.Text.Trim())) { canAdd = false; docNameBlock.BorderBrush = new SolidColorBrush(Colors.Red); } else { docNameBlock.BorderBrush = new SolidColorBrush(Colors.Gray); } //check if name or time is empty /* * if (string.IsNullOrEmpty(startTBlock1.Text.Trim()) || string.IsNullOrEmpty(startTBlock2.Text.Trim()) || * !Regex.IsMatch(startTBlock1.Text, @"^[0-9]*$") || !Regex.IsMatch(startTBlock2.Text, @"^[0-9]*$")) */ if (string.IsNullOrEmpty(startTBlock1.Text.Trim()) || string.IsNullOrEmpty(startTBlock2.Text.Trim()) || !Regex.IsMatch(startTBlock1.Text, @"^[0-9]*$") || !Regex.IsMatch(startTBlock2.Text, @"^\d{2}$")) { canAdd = false; startTBlock1.BorderBrush = new SolidColorBrush(Colors.Red); startTBlock2.BorderBrush = new SolidColorBrush(Colors.Red); } else { startTBlock1.BorderBrush = new SolidColorBrush(Colors.Gray); startTBlock2.BorderBrush = new SolidColorBrush(Colors.Gray); } if (string.IsNullOrEmpty(endTBlock1.Text.Trim()) || string.IsNullOrEmpty(endTBlock2.Text.Trim()) || !Regex.IsMatch(endTBlock1.Text, @"^[0-9]*$") || !Regex.IsMatch(endTBlock2.Text, @"^\d{2}$")) { canAdd = false; endTBlock1.BorderBrush = new SolidColorBrush(Colors.Red); endTBlock2.BorderBrush = new SolidColorBrush(Colors.Red); } else { endTBlock1.BorderBrush = new SolidColorBrush(Colors.Gray); endTBlock2.BorderBrush = new SolidColorBrush(Colors.Gray); } //check for valid time if (canAdd) { if ((this.amPmComboBox1.SelectedIndex == 1 && this.amPmComboBox2.SelectedIndex == 0) || (this.amPmComboBox1.SelectedIndex == this.amPmComboBox2.SelectedIndex) && (Int32.Parse(startTBlock1.Text) > Int32.Parse(endTBlock1.Text) || (Int32.Parse(startTBlock2.Text) > Int32.Parse(endTBlock2.Text)) && Int32.Parse(startTBlock1.Text) > 12 || Int32.Parse(endTBlock1.Text) > 12 || Int32.Parse(startTBlock2.Text) > 59 || Int32.Parse(endTBlock2.Text) > 59)) { canAdd = false; startTBlock1.BorderBrush = new SolidColorBrush(Colors.Red); startTBlock2.BorderBrush = new SolidColorBrush(Colors.Red); endTBlock1.BorderBrush = new SolidColorBrush(Colors.Red); endTBlock2.BorderBrush = new SolidColorBrush(Colors.Red); } else { startTBlock1.BorderBrush = new SolidColorBrush(Colors.Gray); startTBlock2.BorderBrush = new SolidColorBrush(Colors.Gray); endTBlock1.BorderBrush = new SolidColorBrush(Colors.Gray); endTBlock2.BorderBrush = new SolidColorBrush(Colors.Gray); } } if (canAdd) { //canAdd = true; //if row is selected and edit button is clicked if (rowToBeUpdated != null && isEdit == true) { cbox1Val = amPmComboBox1.Text; cbox2Val = amPmComboBox2.Text; rowToBeUpdated.Name = docNameBlock.Text; rowToBeUpdated.Hours = startTBlock1.Text + ':' + startTBlock2.Text + cbox1Val + dash + endTBlock1.Text + ':' + endTBlock2.Text + cbox2Val; rowToBeUpdated.Days = this.workingDays; //MediSchedData.updateDocInfo(rowToBeUpdated.ID, rowToBeUpdated.Name, rowToBeUpdated.Hours, rowToBeUpdated.Days); MediSchedData.updateDoc(rowToBeUpdated); parentDoc.docListGrid.Items.Refresh(); } else if (isEdit == false) //otherwise they clicked the add new doctor button { cbox1Val = amPmComboBox1.Text; cbox2Val = amPmComboBox2.Text; List <Doctor> docLs = MediSchedData.getDocList(); int lastID = 0; if (docLs.Count != 0) { lastID = docLs[docLs.Count - 1].ID; } Doctor newDoc = new Doctor(docNameBlock.Text, this.workingDays, (startTBlock1.Text + ':' + startTBlock2.Text + cbox1Val + dash + endTBlock1.Text + ':' + endTBlock2.Text + cbox2Val)); parentDoc.docListGrid.Items.Add(newDoc); MediSchedData.addDocToList(newDoc); } } } if (canAdd) { this.Close(); } }