コード例 #1
0
ファイル: MainForm.cs プロジェクト: trlatimer/schedulingApp
        // Add Button Click
        private void mainAddButton_Click(object sender, EventArgs e)
        {
            DataInterface.DBClose();
            AddAppointmentForm appointmentForm = new AddAppointmentForm();

            AddAppointmentForm.mainForm = this;
            appointmentForm.Show();
        }
コード例 #2
0
        // Save Button Click
        private void appointmentSaveButton_Click(object sender, EventArgs e)
        {
            // Check if inputs are valid, if so, continue
            if (inputValidation())
            {
                // Check if edited times are within business hours or approved by user, if so, continue
                if (AddAppointmentForm.checkBusinessHours(appointmentStartDate.Value, appointmentEndDate.Value))
                {
                    // Set data from form to variables
                    appointmentID = MainForm.selectedAppointmentID;
                    customerID    = selectedCustomerID;
                    title         = appointmentTitleTextBox.Text;
                    description   = appointmentDescriptionTextBox.Text;
                    location      = appointmentLocationTextBox.Text;
                    contact       = appointmentContactTextBox.Text;
                    url           = appointmentURLTextBox.Text;
                    start         = appointmentStartDate.Value.ToUniversalTime().ToString("u");
                    end           = appointmentEndDate.Value.ToUniversalTime().ToString("u");

                    // Check if there is overlap with times provided
                    if (AddAppointmentForm.checkForOverlap(DateTime.Parse(start), DateTime.Parse(end)) == true)
                    {
                        // If there is overlap, display message and cancel save
                        MessageBox.Show("The appointment you are trying to add overlaps an existing appointment." +
                                        "\n\nPlease correct and try again.");
                        return;
                    }
                    else
                    {
                        // If no overlap, call update method to update appointment, pass variables obtained from form
                        DataInterface.updateAppointment(appointmentID, customerID, title, description, location, contact, url, start, end);
                        MainForm.updateAppointmentForm = this;
                        mainForm.Show();
                        MainForm.updateAppointmentForm.Close();
                    }
                }
            }
        }