Exemple #1
0
        private void ViewReceiptButton_Click(object sender, EventArgs e)
        {
            if (BookingMemberDataGrid.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select a Booking Transaction to View Receipt.");
                return;
            }

            var bookingReceipt = new ViewBookingReceipt(Int32.Parse(BookingMemberDataGrid.SelectedCells[0].Value.ToString()));

            bookingReceipt.ShowDialog();
        }
Exemple #2
0
        private void BookButton1_Click(object sender, EventArgs e)
        {
            if (BookingManagerDataGrid.SelectedCells[0].Value.ToString() != "Vacant")
            {
                MessageBox.Show("Cannot book timeslot that has already been booked.");
                return;
            }

            if (MemberIdTextBox.Text == "")
            {
                MessageBox.Show("Member ID is a required field.");
                return;
            }

            if (FirstNameTextBox.Text == "First Name" || LastNameTextBox.Text == "Last Name")
            {
                MessageBox.Show("Member ID is invalid.");
                return;
            }

            string   facility       = BookingManagerDataGrid.SelectedCells[0].OwningColumn.HeaderText;
            int      facilityId     = context.Facilities.Where(x => x.Name == facility).FirstOrDefault().FacilityID;
            DateTime insertDateTime = new DateTime(BookingDateTimePicker.Value.Year, BookingDateTimePicker.Value.Month, BookingDateTimePicker.Value.Day, 0, 0, 0);

            Booking b = new Booking()
            {
                FacilityID    = facilityId,
                MemberID      = Int32.Parse(MemberIdTextBox.Text),
                BookingDate   = insertDateTime,
                Timeslot      = BookingManagerDataGrid.SelectedCells[0].RowIndex + 1,
                Status        = 1,
                DateRequested = System.DateTime.Now
            };

            context.Bookings.Add(b);
            context.SaveChanges();

            LoadBookingDataGrid();
            parent.LoadBookingDataGrid();
            MessageBox.Show($"Booking successful.");
            var bookingReceipt = new ViewBookingReceipt(b.BookingID);

            bookingReceipt.ShowDialog();
        }