//Choosing Date of Arrival, date of departure and kennelType confirmation button private void btnConfirm_Click(object sender, EventArgs e) { //Validation //Unselected combo box if (cboType.SelectedIndex == -1) { MessageBox.Show("You must select a type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; cboType.Focus(); } //DepDate < ArrDate if (dtpDeparture.Value < dtpArrival.Value) { MessageBox.Show("Departure date cannot be before the Arrival Date", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Cant book more than 30 days in advance if (dtpArrival.Value.Subtract(DateTime.Today).Days > 30) { MessageBox.Show("Cannot make a booking greater than 30 in advance", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //ArrDate > DepDate if (dtpArrival.Value > dtpDeparture.Value) { MessageBox.Show("Arrival Date cannot be greater than Departure Date", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //Check if kennel is available for chosen type on dates specified txtKennelNo.Text = getKennel(cboType.Text.Substring(0, 2), dtpArrival.Value, dtpDeparture.Value).ToString(); if (txtKennelNo.Text.Equals("0")) { MessageBox.Show("No Kennels of this type available for dates requested", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //Calculate cost of booking KennelType kennelType = new KennelType(); TimeSpan ts = dtpDeparture.Value - dtpArrival.Value; int noDays = ts.Days; decimal rate = kennelType.getKennelRate(cboType.Text); txtCost.Text = (rate * noDays).ToString("000.00"); //if available, get customer details grpCustomer.Visible = true; }//end confirm selection details method