Esempio n. 1
0
        // Utility: Reloads the form with relevant data
        private void ReloadForm()
        {
            context = new SportsFacilitiesEntities();

            // Show Booking Information
            var   venueQuery = from x in context.Venue where x.VenueID == venueID select x;
            Venue v          = venueQuery.First();

            if (v != null)
            {
                CategoryLabel.Text = v.Category;
                NameLabel.Text     = v.VenueName;
                AddressLabel.Text  = v.VenueAddress;
                TimeSlotLabel.Text = this.timeslot;
                DateLabel.Text     = this.bookedDate.ToString("dd/MM/yyyy");
                RemarkLabel.Text   = remark;
            }

            // Show Customer information
            Console.WriteLine(customerId);
            var       customerQuery = from x in context.Customers where x.CustomerID == customerId select x;
            Customers c             = customerQuery.First();

            if (c != null)
            {
                CustomerIdLabel.Text             = c.CustomerID.ToString();
                CustomerNameLabel.Text           = c.CustomerName;
                CustomerPhoneNumberLabel.Text    = c.PhoneNumber;
                CustomerAddressLabel.Text        = c.CustomerAddress;
                CustomerEmailLabel.Text          = c.Email;
                CustomerAgeLabel.Text            = c.Age.ToString();
                CustomerNotesLabel.Text          = c.Notes;
                CustomerMemberCategoryLabel.Text = c.MemberCategory;
            }
        }
Esempio n. 2
0
        private void CIDtextbox_KeyDown(object sender, KeyEventArgs e)
        {
            SportsFacilitiesEntities context = new SportsFacilitiesEntities();

            if (e.KeyCode == Keys.Enter)
            {
                int       i = Int32.Parse(CIDtextbox.Text);
                var       q = from x in context.Customers where x.CustomerID == i select x;
                Customers c = q.First();
                CustName.Text = c.CustomerName;
                Phone.Text    = c.PhoneNumber;
                Address.Text  = c.CustomerAddress;
                Email.Text    = c.Email;
                Age.Text      = Convert.ToString(c.Age);
                Status.Text   = Convert.ToBoolean(c.Status) ? "Active" : "InActive";
                Notes.Text    = c.Notes;
            }
        }
Esempio n. 3
0
        // UTILITY: Refreshes the Avaialability datagrid.
        private void RefreshAvailabilityDataGrid()
        {
            // selectionbackcolor, back color
            context = new SportsFacilitiesEntities();

            if (VenueComboBox.SelectedIndex != -1)
            {
                var AddressQuery = from x in context.Venue where x.VenueName == VenueComboBox.SelectedItem.ToString() select x;
                AddressLabel.Text = AddressQuery.First <Venue>().VenueAddress;


                var AvailabilityQuery = from x in context.Availability
                                        join y in context.Venue
                                        on x.VenueID equals y.VenueID
                                        where y.VenueName == VenueComboBox.SelectedItem.ToString()
                                        select new
                {
                    availabilities = x,
                    venues         = y
                };

                // Repopulate the table.
                AvailabilityDataGrid.Rows.Clear();

                var firstQ = AvailabilityQuery.First();
                AvailabilityDataGrid.Rows.Clear();
                foreach (var v in AvailabilityQuery)
                {
                    AvailabilityDataGrid.Rows.Add(v.venues.VenueName, this.AvailabilityBoolToString(v.availabilities.C9am), this.AvailabilityBoolToString(v.availabilities.C10am), this.AvailabilityBoolToString(v.availabilities.C11am), this.AvailabilityBoolToString(v.availabilities.C12pm), this.AvailabilityBoolToString(v.availabilities.C1pm), this.AvailabilityBoolToString(v.availabilities.C2pm), this.AvailabilityBoolToString(v.availabilities.C3pm), this.AvailabilityBoolToString(v.availabilities.C4pm), this.AvailabilityBoolToString(v.availabilities.C5pm));
                    foreach (DataGridViewRow r in AvailabilityDataGrid.Rows)
                    {
                        foreach (DataGridViewCell c in r.Cells)
                        {
                            if (c.Value.Equals(BOOKING_OCCUPIED))
                            {
                                c.Style = new DataGridViewCellStyle();
                                c.Style.SelectionBackColor = Color.Black;
                                c.Style.BackColor          = Color.Black;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 private void BookingForm_Load(object sender, EventArgs e)
 {
     context = new SportsFacilitiesEntities();
 }
Esempio n. 5
0
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            BookingCompleteDialog bookingCompleteDialog = new BookingCompleteDialog();

            bookingCompleteDialog.Location     = this.Location;
            bookingCompleteDialog.FormClosing += delegate {
                ConfirmButton.Enabled          = false;
                this.toolStripStatusLabel.Text = "Booking has been completed!";
                ConfirmationLabel.Visible      = true;
            };

            try
            {
                // Build a new Booking transaction object to insert into
                BookingTransaction newBookingTransaction = new BookingTransaction()
                {
                    CustomerID  = this.customerId,
                    VenueID     = this.venueID,
                    DateCreated = DateTime.Now,
                    BookedDate  = bookedDate,
                    BookedHour  = timeslot,
                    Status      = "Confirmed",
                    Remark      = remark
                };
                context.BookingTransaction.Add(newBookingTransaction);
                context.SaveChanges();

                context = new SportsFacilitiesEntities();

                // Update the availability table to show that the timeslot is occupied
                var          query        = from x in context.Availability where venueID == x.VenueID select x;
                Availability availability = query.First();

                switch (timeslot)
                {
                case "9am":
                    availability.C9am = true;
                    break;

                case "10am":
                    availability.C10am = true;
                    break;

                case "11am":
                    availability.C11am = true;
                    break;

                case "12pm":
                    availability.C12pm = true;
                    break;

                case "1pm":
                    availability.C1pm = true;
                    break;

                case "2pm":
                    availability.C2pm = true;
                    break;

                case "3pm":
                    availability.C3pm = true;
                    break;

                case "4pm":
                    availability.C4pm = true;
                    break;

                case "5pm":
                    availability.C5pm = true;
                    break;
                }
            }

            catch (Exception ex)
            {
                toolStripStatusLabel.Text = ex.ToString();
                Console.WriteLine("\n\n" + ex.ToString());
            }

            context.SaveChanges();
            bookingCompleteDialog.ShowDialog();
        }