예제 #1
0
        // This is the event handler for the submit button. It collects the information from the various text boxes
        // and uses it to update the booking check in or check out info.
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            if (txtDate.Text == "")
            {
                MessageBox.Show("You must fill out the date box.");
                txtDate.Focus();
                return;
            }
            try
            {
                DateTime.Parse(txtDate.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("You must enter the date in the proper format(mm/dd/yyyy).");
                txtDate.Focus();
                return;
            }

            if (txtTime.Text == "")
            {
                MessageBox.Show("You must fill out the time box.");
                txtTime.Focus();
                return;
            }
            try
            {
                DateTime.Parse(txtTime.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("You must enter the date in the proper format(HH:MM:SS am/pm).");
                txtTime.Focus();
                return;
            }

            DateTime newDateTime = DateTime.Parse(txtDate.Text + " " + txtTime.Text);

            if (_isCheckout)
            {
                try
                {
                    if (_bookingManager.EditBookingCheckOut(_booking.BookingID, newDateTime))
                    {
                        _facilitySchedule.PopulateBookings();
                        _facilitySchedule.ClearTextBoxes();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
            }
            // if this is the check in page
            else
            {
                try
                {
                    if (_bookingManager.EditBookingCheckIn(_booking.BookingID, newDateTime))
                    {
                        _facilitySchedule.PopulateBookings();
                        _facilitySchedule.ClearTextBoxes();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
            }


            this.Close();
        }