add check if any box is emtpy

This commit is contained in:
Strati 2018-08-19 18:37:09 +02:00
parent eecfb2d03f
commit b5aa5cc201
2 changed files with 97 additions and 16 deletions

View File

@ -55,6 +55,17 @@ namespace WpfWebClient
ComboBoxFoodPlace.ItemsSource = fplist;
ComboBoxFoodPlace.DisplayMemberPath = "Name";
// check for proper data
if (strainlist.Count == 0)
{
System.Windows.MessageBox.Show("Please create at least one Strain", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (fplist.Count == 0)
{
System.Windows.MessageBox.Show("Please create at least one Food Place", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
client.Close();
}
@ -64,29 +75,75 @@ namespace WpfWebClient
Exam exam = new Exam();
exam.Date = dateboxExamDate.SelectedDate.Value;
exam.Doctor = (Doctor)ComboBoxDoctors.SelectedValue;
exam.Patient = (Person)ComboBoxPatients.SelectedValue;
exam.Description = txtDescription.Text;
exam.Strain = (Strain)ComboBoxStrains.SelectedValue;
// check if any box is empty
client.WriteExam(exam);
if (ComboBoxDoctors.SelectedIndex == -1)
{
System.Windows.MessageBox.Show("Please choose a doctor", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
PatientAtFoodPlace patf = new PatientAtFoodPlace();
if (dateboxExamDate.SelectedDate == null)
{
System.Windows.MessageBox.Show("Please enter a date of consultation", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (ComboBoxPatients.SelectedIndex == -1)
{
System.Windows.MessageBox.Show("No Patient? Really?", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (ComboBoxStrains.SelectedIndex == -1)
{
System.Windows.MessageBox.Show("Why would you fill out an exam when there is no strain?", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
exam.Date = dateboxExamDate.SelectedDate.Value;
exam.Doctor = (Doctor)ComboBoxDoctors.SelectedValue;
exam.Patient = (Person)ComboBoxPatients.SelectedValue;
exam.Description = txtDescription.Text;
exam.Strain = (Strain)ComboBoxStrains.SelectedValue;
patf.FoodPlace = (FoodPlace)ComboBoxFoodPlace.SelectedValue;
patf.Patient = (Person)ComboBoxPatients.SelectedValue;
patf.PatientID = ComboBoxPatients.SelectedIndex;
patf.VistingDate = dateboxFoodplaceDate.SelectedDate.Value;
client.WriteExam(exam);
}
client.WriteRelation(patf);
PatientAtFoodPlace patf = new PatientAtFoodPlace();
// Show success msgbox
System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
// check if any box is empty
if (ComboBoxFoodPlace.SelectedIndex == -1)
{
System.Windows.MessageBox.Show("Please choose a food place", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (dateboxFoodplaceDate.SelectedDate == null)
{
System.Windows.MessageBox.Show("Please enter a date at Foodplace", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
patf.FoodPlace = (FoodPlace)ComboBoxFoodPlace.SelectedValue;
patf.Patient = (Person)ComboBoxPatients.SelectedValue;
patf.PatientID = ComboBoxPatients.SelectedIndex;
patf.VistingDate = dateboxFoodplaceDate.SelectedDate.Value;
client.WriteRelation(patf);
// Show success msgbox
System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
client.Close();
}
}
}

View File

@ -44,7 +44,30 @@ namespace WpfWebClient
FoodPlace fp = new FoodPlace();
// check if any box is empty
if (ComboBoxFPCities.SelectedIndex == -1)
{
System.Windows.MessageBox.Show("Please select a city", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (txtFoodPlaceName.Text == null)
{
System.Windows.MessageBox.Show("Please enter a name for the food place", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (txtFoodPlaceHouseNumber.Text == null)
{
System.Windows.MessageBox.Show("Please enter a house number", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (txtFoodPlaceStreetName.Text == null)
{
System.Windows.MessageBox.Show("Please enter a street name", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
fp.Streetname = txtFoodPlaceStreetName.Text;
fp.Streetnumber = txtFoodPlaceHouseNumber.Text;
fp.Name = txtFoodPlaceName.Text;
@ -53,8 +76,9 @@ namespace WpfWebClient
client.WriteFoodPlace(fp);
// Show success msgbox
System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
// Show success msgbox
System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
client.Close();
}