示例#1
0
        private void btnBook_Click(object sender, EventArgs e)
        {
            bkgDetailsList.Clear();
            if (noSelected == 0)
            {
                MessageBox.Show("You have not selected any booking slot.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                bkgDetailsList.Clear();
                int controlIndex = 0;
                foreach (Control c in collectionClickedButtons)
                {
                    char cRow  = char.Parse(c.Name.Substring(3, 1));
                    int  cRow_ = 0;
                    switch (cRow)
                    {
                    case 'A':
                        cRow_ = 1;
                        break;

                    case 'B':
                        cRow_ = 2;
                        break;

                    case 'C':
                        cRow_ = 3;
                        break;
                    }

                    BookingDetails bd = new BookingDetails()
                    {
                        subFacilityBooked = subfacilitiesListNames[cRow_ - 1], slotBooked = Int32.Parse(c.Name.Substring(4, 1))
                    };
                    bkgDetailsList.Add(bd);
                    controlIndex++;
                }

                frmBookingDetail frmBD = new frmBookingDetail();
                frmBD.setTxtFacilityID(cmbSports.Text);
                frmBD.SetLbSelectedSlotSF(bkgDetailsList);
                for (int i = 0; i < noSelected; i++)
                {
                    frmBD.setLbSelFacility(cmbSports.Text);
                }
                frmBD.ShowDialog();
                LoadBookingSlots();
                collectionClickedButtons.Clear();
            }
        }
示例#2
0
        protected void con_Click(object sender, EventArgs e)
        {
            //This event is triggered when a visible Button is clicked.
            #region Button Clicks for displayed booking slots
            Button dynamicButton = (sender as Button);
            if (dynamicButton.BackColor == Color.Green) //already clicked before
            {
                dynamicButton.BackColor = Color.LightGreen;
                collectionClickedButtons.Remove(dynamicButton);
                noSelected--; //unselected
            }
            else
            if (dynamicButton.BackColor == Color.Red)
            {
                this.getFacilityID();
                char   redButtonSubfacility = char.Parse(dynamicButton.Name.Substring(3, 1));
                string subfname             = redButtonSubfacility.ToString();
                int    fid = this.getFacilityID();
                int    redButtonSubfacility_ = ctx.SubFacilities.First(x => x.subfacilityname == subfname && x.facilityid == fid).subfacilityid;
                int    redButtonTimeslotID   = Int32.Parse(dynamicButton.Name.Substring(4, 1));
                redButtonTransID = ctx.TransactionDetails.First
                                       (x => x.facilityid == fid && x.subfacilityid == redButtonSubfacility_ && x.date == dtpBookingDate.Value &&
                                       x.timeslotid == redButtonTimeslotID).transactiondetailid;
                frmBookingDetail frmBD = new frmBookingDetail();
                frmBD.ShowDialog();
                LoadBookingSlots();
            }
            else
            {
                dynamicButton.BackColor = Color.Green;
                collectionClickedButtons.Add(dynamicButton);
                noSelected++;
            }
            #endregion

            if (noSelected > 0)
            {
                btnBook.Enabled = true;
            }
            else
            {
                btnBook.Enabled = false;
            }
        }