示例#1
0
 private void searchButton_Click(object sender, EventArgs e)
 {
     if (nameRadioButton.Checked)
     {
         if (firstNameTextBox.Text == "" || lastNameTextBox.Text == "")
         {
             MessageBox.Show("Please enter both a first and last name.", "Incorrect Details");
             return;
         }
         parent.PopulateAppointments(firstNameTextBox.Text, lastNameTextBox.Text);
         parent.searchByName = true;
         parent.fName        = firstNameTextBox.Text;
         parent.lName        = lastNameTextBox.Text;
     }
     if (dateRadioButton.Checked)
     {
         if (dateTimePicker1.Value == null || dateTimePicker2.Value == null)
         {
             MessageBox.Show("Please choose two dates to see appointments between.", "Incorrect Dates");
         }
         if (dateTimePicker1.Value > dateTimePicker2.Value)
         {
             MessageBox.Show("Minimum date cannot be further in future than maximum date.", "Incorrect Dates");
             return;
         }
         parent.PopulateAppointments(dateTimePicker1.Value, dateTimePicker2.Value);
         parent.searchByName = false;
         parent.d1           = dateTimePicker1.Value;
         parent.d2           = dateTimePicker2.Value;
     }
     this.Close();
     this.Dispose();
 }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!editMode)
            {
                try
                {
                    app                 = new Appointment();
                    app.StaffId         = staff[staffcomboBox1.SelectedIndex].ID;
                    app.PatientId       = patients[patientcomboBox2.SelectedIndex].ID;
                    app.AppointmentDate = dateTimePicker1.Value;
                    app.AppointmentTime = DateTime.ParseExact(timeslotcomboBox1.SelectedItem.ToString(), "HH:mm:ss", CultureInfo.InvariantCulture);
                    app.Cause           = causeTextBox.Text;
                    app.Status          = statusComboBox.SelectedItem.ToString();
                    af.InsertAppointment(app);
                    MessageBox.Show("Appointment created successfully.", "Success");
                }catch (Exception ex1)
                {
                    MessageBox.Show("Some input fields have been left blank.", "Please Fill All Forms");
                    MessageBox.Show("ex1: " + ex1);
                    return;
                }
            }
            else
            {
                try
                {
                    app.StaffId         = staff[staffcomboBox1.SelectedIndex].ID;
                    app.PatientId       = patientID;
                    app.AppointmentDate = dateTimePicker1.Value;
                    if (timeslotcomboBox1.SelectedItem != null)
                    {
                        app.AppointmentTime = DateTime.ParseExact(timeslotcomboBox1.SelectedItem.ToString(), "HH:mm:ss", CultureInfo.InvariantCulture);
                    }
                    app.Cause  = causeTextBox.Text;
                    app.Status = statusComboBox.SelectedItem.ToString();
                    af.UpdateAppointment(app);
                    MessageBox.Show("Appointment updated successfully.", "Success");
                }catch (Exception ex2)
                {
                    MessageBox.Show("Some input fields have been left blank.", "Please Fill All Forms");
                    MessageBox.Show("ex2: " + ex2);
                    return;
                }
            }

            if (parent.searchByName)
            {
                parent.PopulateAppointments(parent.fName, parent.lName);
            }
            else
            {
                parent.PopulateAppointments(parent.d1, parent.d2);
            }
            this.Close();
        }