private void saveButton_Click(object sender, EventArgs e) { bool textBoxesNotEmpty; if (string.IsNullOrWhiteSpace(titleTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(descriptionTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(locationTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(contactTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(typeTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(urlTextBox.Text)) { textBoxesNotEmpty = false; } else { textBoxesNotEmpty = true; } if (textBoxesNotEmpty && validAppt) { int custSelected = Convert.ToInt32(customerDataGridView.Rows[customerDataGridView.CurrentCell.RowIndex].Cells[0].Value); Appointment appt = new Appointment(); appt.customerId = custSelected; appt.userId = currentUser.userId; appt.title = titleTextBox.Text; appt.description = descriptionTextBox.Text; appt.location = locationTextBox.Text; appt.contact = contactTextBox.Text; appt.type = typeTextBox.Text; appt.url = urlTextBox.Text; appt.start = startDateTimePicker.Value.ToUniversalTime();//all times are stored and compared as UTC, and displayed to the user in their local time. appt.end = endDateTimePicker.Value.ToUniversalTime(); DataProcedures data = new DataProcedures(); if (data.addAppointment(appt) != -1) { MainScreen mainScreen = new MainScreen(currentUser); this.Hide(); mainScreen.Show(); } } else { fillFieldsLabel.Visible = true; } }
private void saveButton_Click(object sender, EventArgs e) { bool textBoxesNotEmpty; if (string.IsNullOrWhiteSpace(nameTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(phNumberTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(addressTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(address2TextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(cityTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(postalCodeTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(countryTextBox.Text)) { textBoxesNotEmpty = false; } else { textBoxesNotEmpty = true; } if (textBoxesNotEmpty) { DataProcedures dbProcedure = new DataProcedures(); CustomerInformation custInfo = new CustomerInformation(); custInfo.customerID = custId; custInfo.customerName = nameTextBox.Text; custInfo.phone = phNumberTextBox.Text; custInfo.address = addressTextBox.Text; custInfo.address2 = address2TextBox.Text; custInfo.city = cityTextBox.Text; custInfo.postalCode = postalCodeTextBox.Text; custInfo.country = countryTextBox.Text; bool insertCustomerInfo = dbProcedure.saveCustomerInformaion(custInfo); if (insertCustomerInfo) { MainScreen mainScreen = new MainScreen(currentUser); this.Hide(); mainScreen.Show(); } } else { fillFieldsLabel.Visible = true; } }
private void saveButton_Click(object sender, EventArgs e) { bool textBoxesNotEmpty; if (string.IsNullOrWhiteSpace(titleTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(descriptionTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(locationTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(contactTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(typeTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(urlTextBox.Text)) { textBoxesNotEmpty = false; } else { textBoxesNotEmpty = true; } if (textBoxesNotEmpty) { if (validAppt) { int custSelected = Convert.ToInt32(customerDataGridView.Rows[customerDataGridView.CurrentCell.RowIndex].Cells[0].Value); Appointment appt = new Appointment(); appt.appointmentId = apptId; appt.customerId = custSelected; appt.userId = currentUser.userId; appt.title = titleTextBox.Text; appt.description = descriptionTextBox.Text; appt.location = locationTextBox.Text; appt.contact = contactTextBox.Text; appt.type = typeTextBox.Text; appt.url = urlTextBox.Text; appt.start = startDateTimePicker.Value.ToUniversalTime(); appt.end = endDateTimePicker.Value.ToUniversalTime(); DataProcedures data = new DataProcedures(); if (data.updateAppointment(appt)) { MainScreen mainScreen = new MainScreen(currentUser); this.Hide(); mainScreen.Show(); } } else { dateTimeErrorlabel.Text = "Please enter valid times."; dateTimeErrorlabel.Left = 72; dateTimeErrorlabel.Visible = true; } } else { fillFieldsLabel.Visible = true; } }
private void saveButton_Click(object sender, EventArgs e) { bool textBoxesNotEmpty; if (string.IsNullOrWhiteSpace(nameTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(phNumberTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(addressTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(address2TextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(cityTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(postalCodeTextBox.Text)) { textBoxesNotEmpty = false; } else if (string.IsNullOrWhiteSpace(countryTextBox.Text)) { textBoxesNotEmpty = false; } else { textBoxesNotEmpty = true; } if (textBoxesNotEmpty) { DataProcedures data = new DataProcedures(); Customer customer = new Customer(); Address address = new Address(); City city = new City(); Country country = new Country(); customer.customerName = nameTextBox.Text; customer.createdBy = currentUser.username; address.createdBy = currentUser.username; city.createdBy = currentUser.username; country.createdBy = currentUser.username; address.address = addressTextBox.Text; address.address2 = address2TextBox.Text; address.postalCode = postalCodeTextBox.Text; address.phone = phNumberTextBox.Text; city.city = cityTextBox.Text; country.country = countryTextBox.Text; city.countryId = data.addCountry(country); address.cityId = data.addCity(city); customer.addressId = data.addAddress(address); if (data.addCustomer(customer)) { MainScreen mainScreen = new MainScreen(currentUser); this.Hide(); mainScreen.Show(); } } else { fillFieldsLabel.Visible = true; } }