private void button_loadDoctor_Click(object sender, RoutedEventArgs e) { List <BackEndLayer.Doctor> d = m.SearchDoctorByID(data_doctorid.Text); if (d.Count > 0) { BackEndLayer.Doctor doc = d.First <BackEndLayer.Doctor>(); data_doctorid.IsReadOnly = true; data_dfname.Text = doc.firstName; data_dlname.Text = doc.lastName; data_dsalary.Text = doc.salary + ""; data_dgender.Text = ((doc.gender == 'm') ? "Male" : "Female"); } else { MessageBoxResult err = MessageBox.Show("The doctor does not exists."); } }
private void button_addDoctor_Click(object sender, RoutedEventArgs e) { String id = data_adoctorid.Text; String first = data_adfname.Text; String last = data_adlname.Text; String salary = data_adsalary.Text; char gender = (data_adgender.Text.Equals("Male") ? 'm' : 'f'); if (!m.isLegalName(first) || !m.isLegalName(last) || !m.isLegalInt(salary, 2499) || m.DoctorAlreadyExists(id)) { String error = "The following things need to be fixed:\n\n"; if (m.DoctorAlreadyExists(id)) { error += " Doctor is already in the system.\n"; } if (!m.isLegalName(first)) { error += " First name is not legal. Names must start with Captial letter.\n"; } if (!m.isLegalName(last)) { error += " Last name is not legal. Names must start with Captial letter.\n"; } if (!m.isLegalInt(salary, 2499)) { error += " Salary is not legal. Minimum value is 2500.\n"; } MessageBoxResult err = MessageBox.Show(error); } else { BackEndLayer.Doctor d = new BackEndLayer.Doctor(id, first, last, int.Parse(salary), gender); m.AddDoctor(d); data_adoctorid.Text = ""; data_adfname.Text = ""; data_adlname.Text = ""; data_adsalary.Text = ""; data_adgender.Text = ""; MessageBoxResult done = MessageBox.Show("The doctor is added successfully to the system database."); } }
private void button_saveDoctor_Click(object sender, RoutedEventArgs e) { String first = data_dfname.Text; String last = data_dlname.Text; String salary = data_dsalary.Text; char gender = (data_dgender.Text.Equals("Male") ? 'm' : 'f'); if (!m.isLegalName(first) || !m.isLegalName(last) || !m.isLegalInt(salary, 2499)) { String error = "The following things need to be fixed:\n\n"; if (!m.isLegalName(first)) { error += " First name is not legal. Names must start with Captial letter.\n"; } if (!m.isLegalName(last)) { error += " Last name is not legal. Names must start with Captial letter.\n"; } if (!m.isLegalInt(salary, 2499)) { error += " Salary is not legal. Minimum value is 2500.\n"; } MessageBoxResult err = MessageBox.Show(error); } else { BackEndLayer.Doctor d = new BackEndLayer.Doctor(data_doctorid.Text, first, last, int.Parse(salary), gender); m.EditDoctor(data_doctorid.Text, d); data_doctorid.IsReadOnly = false; data_doctorid.Text = ""; data_dfname.Text = ""; data_dlname.Text = ""; data_dsalary.Text = ""; data_dgender.Text = ""; MessageBoxResult done = MessageBox.Show("Done!"); } }