//when the user clicks the add doctor button + private void addDoctorButton_Click(object sender, RoutedEventArgs e) { NewDoctorWindow newDocWindow = new NewDoctorWindow(false); //false-> clear edit mode newDocWindow.Owner = this; newDocWindow.Show(); }
//when the user clicks the edit doctor button private void editDoctorButton_Click(object sender, RoutedEventArgs e) { if (docListGrid.SelectedItem != null) { Doctor doc = (Doctor)docListGrid.SelectedItem; NewDoctorWindow newDocWindow = new NewDoctorWindow(doc.Name, doc.Days, doc.Hours, true); //true -> set edit mode newDocWindow.Owner = this; newDocWindow.Show(); } }
public NewDoctorWindow(bool editOrAdd) { NewDoctorWindow.newWindowOpened += handleNewWindow; MainWindow.mainClosed += handleMainClose; NewDoctorWindow.newWindowOpened(this, null); InitializeComponent(); this.workingDays = ""; docNameBlock.Text = ""; startTBlock1.Text = ""; startTBlock2.Text = ""; endTBlock1.Text = ""; endTBlock2.Text = ""; this.isEdit = editOrAdd; }
public NewDoctorWindow(string name, string days, string hours, bool editOrAdd) { NewDoctorWindow.newWindowOpened += handleNewWindow; MainWindow.mainClosed += handleMainClose; NewDoctorWindow.newWindowOpened(this, null); InitializeComponent(); docNameBlock.Text = name; this.workingDays = days; this.isEdit = editOrAdd; string[] amPmSplitter = new string[] { "AM", "PM" }; if (hours.Length != 0) { startTBlock1.Text = hours.Split('-')[0].Split(':')[0]; startTBlock2.Text = hours.Split('-')[0].Split(':')[1].Split(amPmSplitter, StringSplitOptions.RemoveEmptyEntries)[0]; if (hours.Split('-')[0].Contains("AM")) { this.amPmComboBox1.SelectedIndex = 0; } else { this.amPmComboBox1.SelectedIndex = 1; } endTBlock1.Text = hours.Split('-')[1].Split(':')[0]; endTBlock2.Text = hours.Split('-')[1].Split(':')[1].Split(amPmSplitter, StringSplitOptions.RemoveEmptyEntries)[0]; if (hours.Split('-')[1].Contains("AM")) { this.amPmComboBox2.SelectedIndex = 0; } else { this.amPmComboBox2.SelectedIndex = 1; } } if (mondayBox.IsChecked == false & workingDays.Contains("M")) { mondayBox.IsChecked = true; } if (tuesdayBox.IsChecked == false & workingDays.Contains("T")) { tuesdayBox.IsChecked = true; } if (wednesdayBox.IsChecked == false & workingDays.Contains("W")) { wednesdayBox.IsChecked = true; } if (thursdayBox.IsChecked == false & workingDays.Contains("R")) { thursdayBox.IsChecked = true; } if (fridayBox.IsChecked == false & workingDays.Contains("F")) { fridayBox.IsChecked = true; } }