Beispiel #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);
     }
 }
Beispiel #2
0
 //
 // Event when anyone clicks on Number of places text box
 private void NumberOfPlacesTextBox1_MouseClick(object sender, MouseEventArgs e)
 {
     NumberOfPlacesTextBox1.SelectAll();
 }
Beispiel #3
0
 //
 // Method for calculating the price based on selection
 private void ItemPricingMethod()
 {
     //
     // To check if event and location are selected
     if (EventListBox1.SelectedIndex != -1 && LocationListBox1.SelectedIndex != -1)
     {
         //
         // To check if Number of Places is entered
         if (NumberOfPlacesTextBox1.Text != "")
         {
             try
             {
                 NumberOfPlaces = int.Parse(NumberOfPlacesTextBox1.Text);
                 //
                 // Handling negative values in quantity
                 if (NumberOfPlaces <= 0)
                 {
                     MessageBox.Show("Investment amount should be positive value, setting the default value as 1", "I/P Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                     //
                     // Bringing the focus back to number of places textbox for user edit
                     NumberOfPlacesTextBox1.Text = "1";
                     NumberOfPlaces = 1;
                     NumberOfPlacesTextBox1.Focus();
                     NumberOfPlacesTextBox1.SelectAll();
                 }
                 else
                 {
                     if (MealOptionsListBox1.SelectedIndex != -1)
                     {
                         ItemCost = (EVENTPRICING[EventListBox1.SelectedIndex, LocationListBox1.SelectedIndex] + MEALPRICING[EventListBox1.SelectedIndex, MealOptionsListBox1.SelectedIndex]) * NumberOfPlaces;
                     }
                     else
                     {
                         MealOptionsListBox1.SelectedIndex = 3;
                         ItemCost = (EVENTPRICING[EventListBox1.SelectedIndex, LocationListBox1.SelectedIndex]) * NumberOfPlaces;
                     }
                     AddToCartButton1.Enabled      = true;
                     TotalItemCostValueLabel1.Text = ItemCost.ToString() + String.Format("\u20AC");
                 }
             }
             catch
             {
                 NumberOfPlacesTextBox1.Text = "1";
                 NumberOfPlaces = 1;
                 MessageBox.Show("Number of places should be valid positive integer value, setting the default places to 1", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 NumberOfPlacesTextBox1.Focus();
                 NumberOfPlacesTextBox1.SelectAll();
             }
         }
         else
         {
             NumberOfPlacesTextBox1.Text = "1";
             NumberOfPlaces = 1;
             if (MealOptionsListBox1.SelectedIndex != -1)
             {
                 ItemCost = (EVENTPRICING[EventListBox1.SelectedIndex, LocationListBox1.SelectedIndex] + MEALPRICING[EventListBox1.SelectedIndex, MealOptionsListBox1.SelectedIndex]);
             }
             else
             {
                 MealOptionsListBox1.SelectedIndex = 3;
                 ItemCost = (EVENTPRICING[EventListBox1.SelectedIndex, LocationListBox1.SelectedIndex]);
             }
             AddToCartButton1.Enabled      = true;
             TotalItemCostValueLabel1.Text = ItemCost.ToString() + String.Format("\u20AC");
         }
     }
 }