private void buttonShowCourses_click(object sender, RoutedEventArgs e) { int id; if (textBoxID.Text == "") { MessageBox.Show("Please Get a Doctor first !"); return; } else { id = int.Parse(textBoxID.Text); } CoursesWindow coursesWindow = new CoursesWindow(id); App.Current.MainWindow = coursesWindow; coursesWindow.Show(); }
private void buttonAddNewUser_Click(object sender, RoutedEventArgs e) { try { bool result = false; if (textBoxName.Text == string.Empty || textBoxTitle.Text == string.Empty) { MessageBox.Show("Fill All Fields Plz!"); return; } else { result = _exHandler.IsValidString(textBoxName.Text); if (!result) { MessageBox.Show("Enter A Valid Name plz!"); return; } result = _exHandler.IsValidString(textBoxTitle.Text); if (!result) { MessageBox.Show("Enter A Valid Title plz!"); return; } if (_doctorImage == null) { MessageBox.Show("Upload Photo plz!"); return; } } HttpResponseMessage response = _employeeHandler.AddNewDoctor(textBoxName.Text, textBoxTitle.Text, getImageByteArray(_doctorImage)); if (response.IsSuccessStatusCode) { MessageBox.Show("New Doctor Added Successfully."); clearTextBoxes(); buttonShowAllDoctors.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); //Get Doctor ID and Open CoursesWindow and path id to it. var doctors = _employeeHandler.GetAllDoctors(); int doctorId = 0; if (doctors == null) { MessageBox.Show("Error Accured When Trying To Get Doctors Data!"); } else if (doctors.Count() < 1) { MessageBox.Show("There is no Doctors to Display!"); } else { List <Doctor> mydoctors = doctors.ToList(); doctorId = mydoctors.Max(item => item.Id); } CoursesWindow coursesWindow = new CoursesWindow(doctorId); App.Current.MainWindow = coursesWindow; coursesWindow.Show(); } else { MessageBox.Show(response.StatusCode + "With Message : " + response.ReasonPhrase); } } catch (Exception ex) { MessageBox.Show(" There is an ERROR ! with messamge :" + ex.Message); } }