Ejemplo n.º 1
0
 //
 // event and action defiened for the click of add to cart button
 private void AddToCartButton1_Click(object sender, EventArgs e)
 {
     AddToCartButton1.Enabled = false;
     AvailablePlaces          = PlacesAvailable[EventListBox1.SelectedIndex, LocationListBox1.SelectedIndex];
     //
     // to check if available places is greater than 0
     if (AvailablePlaces != 0)
     {
         //
         // To check if number of places entered is less than available
         if ((AvailablePlaces - NumberOfPlaces) >= 0)
         {
             PlacesAvailable[EventListBox1.SelectedIndex, LocationListBox1.SelectedIndex] = AvailablePlaces - NumberOfPlaces;
             TotalBookingCost = TotalBookingCost + ItemCost;
             TotalBookingAmountAnsLabel1.Text = TotalBookingCost + String.Format("\u20AC");
             BookingListBox1.Items.Add(EVENTSNAME[EventListBox1.SelectedIndex] + "\t" + LOCATIONNAMES[LocationListBox1.SelectedIndex] + "\t" + NumberOfPlaces + "\t" + ItemCost + String.Format("\u20AC"));
             CompleteOrderButton1.Enabled = true;
             BookingMessage = BookingMessage + "Event Details:\n1.Event Name:" + EVENTSNAME[EventListBox1.SelectedIndex] + "\n2.Location:" + LOCATIONNAMES[LocationListBox1.SelectedIndex] + "\n3.Meal Option Selected:" + MEALTYPES[MealOptionsListBox1.SelectedIndex] + "\n4.Total Number of Places Selected:" + NumberOfPlaces + "\n5.Total Event Cost:" + ItemCost + "\n\n";
             EventListBox1.ClearSelected();
             LocationListBox1.ClearSelected();
             MealOptionsListBox1.ClearSelected();
             NumberOfPlacesTextBox1.Text   = "";
             TotalItemCostValueLabel1.Text = "";
             LocationAvailableListbox1.Items.Clear();
         }
         //
         // to set the number of places to the maximum available stock
         else
         {
             NumberOfPlacesTextBox1.Text = AvailablePlaces.ToString();
             MessageBox.Show("Number of places you entered exceed the available stock. There are only " + AvailablePlaces + " available", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
             NumberOfPlacesTextBox1.Focus();
             NumberOfPlacesTextBox1.SelectAll();
         }
     }
     else
     {
         MessageBox.Show("Unfortunately, There are no available place for the event and location. Please revise the booking", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
 //
 // Event and action defiened for the click of clear button
 private void ClearButton1_Click(object sender, EventArgs e)
 {
     EventListBox1.ClearSelected();
     LocationListBox1.ClearSelected();
     AddToCartButton1.Enabled      = false;
     CompleteOrderButton1.Enabled  = false;
     NumberOfPlacesTextBox1.Text   = "";
     TotalItemCostValueLabel1.Text = "";
     MealOptionsListBox1.ClearSelected();
     LocationAvailableListbox1.Items.Clear();
     //
     // Code to get back the number of places which got changes due to add in cart option but user has not confirmed the booking
     if (BookingListBox1.Items.Count > 0)
     {
         Array.Copy(PlacesAvailableBeforeConfirmation, PlacesAvailable, PlacesAvailableBeforeConfirmation.Length);
         BookingListBox1.Items.Clear();
     }
     NumberOfPlacesTextBox1.Text = "1";
     TotalBookingCost            = 0m;
     ItemCost       = 0m;
     BookingMessage = "";
     TotalBookingAmountAnsLabel1.Text = "";
 }