// Save Button click private void appointmentSaveButton_Click(object sender, EventArgs e) { // If inputs are valid, continue if (inputValidation()) { // If appointment is within business hours or user clicked 'Yes', continue if (checkBusinessHours(appointmentStartDate.Value, appointmentEndDate.Value)) { // Store data within form appointmentID = DataInterface.getNextID("appointmentId", "appointment", DataInterface.getAppointmentIDList()); 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 appointment being created overlaps an existing appointment if (checkForOverlap(DateTime.Parse(start), DateTime.Parse(end)) == true) { // If there is overlap, prompt user and cancel save MessageBox.Show("The appointment you are trying to add overlaps an existing appointment." + "\n\nPlease correct and try again."); return; } // If no overlap, continue with save else { // Use DataInterface method to pass data to query for creating new appointment DataInterface.createAppointment(customerID, title, description, location, contact, url, start, end, currentUser); // Set MainForms form to this form, show mainForm again, close this form MainForm.addAppointmentForm = this; mainForm.Show(); MainForm.addAppointmentForm.Close(); } } } // If inputs are not valid or user chose to not allow it outside business hours, cancel save return; }
// Save Button click private void customerSaveButton_Click(object sender, EventArgs e) { // Check if inputs are valid if (validateInputs()) { // If valid, obtain data from form controls ID = DataInterface.getNextID("customerId", "customer", DataInterface.getCustomerIDList()); name = customerNameTextBox.Text; address = customerAddressTextBox.Text; address2 = customerAddress2TextBox.Text; city = customerCityTextBox.Text; zipCode = customerZipCodeTextBox.Text; country = customerCountryTextBox.Text; phone = customerPhoneTextBox.Text; active = customerActiveCheckBox.Checked; // Send data to DataInterface to create new customer DataInterface.createCustomer(name, address, city, country, zipCode, phone, active, currentUser, address2); // Set CustomerMainForm's reference to this form, show CustomerMainForm, close this form CustomerMainForm.addCustomer = this; customerForm.Show(); CustomerMainForm.addCustomer.Close(); } }