Thursday, September 19, 2024 9:15:45 PM
> settings

Customize


Authenticate

> Form1.cs
/*
 * Bryan
 * Vacation Picker
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;

namespace bryan_vacationPicker
{
    public partial class Form1 : Form
    {
        BindingList<string> orders = new BindingList<string>();
        List<string> order = new List<string>();
        Order currentOrder;

        /// <summary>
        /// Initialize the form
        /// </summary>
        public Form1()
        {
            InitializeComponent();

            list_orders.DataSource = orders;
            list_CurrentOrder.DataSource = order;
        }

        /// <summary>
        /// On exit button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_exit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }


        /// <summary>
        /// When we selected a different package, create a new order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cb_vacationPackages_SelectedIndexChanged(object sender, EventArgs e)
        {
            order.Clear();
            currentOrder = new Order();

            panel_BaronCliff.Visible = false;
            panel_DevilsCourthouse.Visible = false;
            panel_ScubaBahama.Visible = false;
            panel_SkyDiveColorado.Visible = false;

            // Clear out the nums
            num_partyMembers.Value = 0;
            num_bc_equipment.Value = 0;
            num_dc_instructions.Value = 0;
            num_dc_rentingEquipment.Value = 0;
            num_sd_equipment.Value = 0;
            cb_sd_lodging.SelectedIndex = -1;

            // Figure out sh*t
            switch (cb_vacationPackages.SelectedIndex)
            {
                // Devil's Courthouse Adventure
                case 0:
                    lb_PackageName.Text = "Devil's Courthouse Adventure Weekend";
                    tb_Information.Text = @"An action packed three days weekend spent camping, rock climbing, and rappelling at Devil’s Courthouse, North Carolina.
This getaway for novices and expert alike.
Climbing instructor is available to beginners at an optional low price.
Camping equipment rental is also available.

    Rates:
        Base charge:               $350/per person
        Climbing instruction:     $100/per person
        Equipment rental:         $40/day per person";
                    panel_DevilsCourthouse.Visible = true;

                    currentOrder.base_charge = 350m;
                    currentOrder.days = 3;
                    break;

                // Scuba Bahama
                case 1:
                    lb_PackageName.Text = "Scuba Bahama";
                    tb_Information.Text = @"A week-long cruise to Bahama with three day with three days of scuba diving. Those with prior experience may dive right in, while beginners should choose to take the optional, but very affordable lesson.

    Rates:
        Base charge:                $1000/per person
        Scuba instruction:         $100/per person";
                    panel_ScubaBahama.Visible = true;

                    currentOrder.base_charge = 1000m;
                    currentOrder.days = 0;
                    break;

                // Sky Dive Colorado
                case 2:
                    lb_PackageName.Text = "Sky Dive Colorado";
                    tb_Information.Text = @"Four thrilling days with expert sky diving instructors in Colorado Springs. For lodging, you may choose either the Wilderness Lodge or Luxury Inn.

    Rates:
        Base charge:                $400/per person
        Wilderness Lodge:        $65/day per person
        Luxury Inn                     $120/day per person";
                    panel_SkyDiveColorado.Visible = true;

                    currentOrder.base_charge = 400m;
                    currentOrder.days = 4;
                    break;

                // Baron Cliff
                case 3:
                    lb_PackageName.Text = "Baron Cliff";
                    tb_Information.Text = @"Eight days spent hiking and exploring caves in the Barron Cliff Wilderness , in Tennessee. Camping equipment rental is available.

    Rates:
        Base charge:                $700/per person
        Equipment rental:          $40/day per person";
                    panel_BaronCliff.Visible = true;

                    currentOrder.base_charge = 700m;
                    currentOrder.days = 8;
                    break;

                // Don't care
                default:
                    lb_PackageName.Visible = false;
                    tb_Information.Visible = false;
                    lb_partyMembers.Visible = false;
                    num_partyMembers.Visible = false;
                    return;
            }

            currentOrder.name = lb_PackageName.Text;

            lb_PackageName.Visible = true;
            tb_Information.Visible = true;
            lb_partyMembers.Visible = true;
            num_partyMembers.Visible = true;

            order = currentOrder.ToList();
            list_CurrentOrder.DataSource = order;
        }


        /// <summary>
        /// Button click for adding order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_addOrder_Click(object sender, EventArgs e)
        {
            if (currentOrder != null)
            {
                currentOrder.AddToBindingList(ref orders);

                num_partyMembers.Value = 0;
                num_bc_equipment.Value = 0;
                num_dc_instructions.Value = 0;
                num_dc_rentingEquipment.Value = 0;
                num_sd_equipment.Value = 0;
                order.Clear();
            }
        }



        /// <summary>
        /// Update the order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void updateOrder(object sender, EventArgs e)
        {
            currentOrder.num_instructions = num_dc_instructions.Value + num_sb_instructions.Value;
            currentOrder.num_equipment = num_dc_rentingEquipment.Value + num_sd_equipment.Value + num_bc_equipment.Value;
            currentOrder.num_members = num_partyMembers.Value;
            currentOrder.lodging_index = cb_sd_lodging.SelectedIndex;

            order = currentOrder.ToList();
            list_CurrentOrder.DataSource = order;

            // Enable the button.
            btn_addOrder.Enabled =
                (
                    currentOrder.name != "Devil's Courthouse Adventure Weekend"
                    && currentOrder.name != "Sky Dive Colorado"
                    && currentOrder.num_members > 0
                )
                ^
                (
                    currentOrder.name == "Devil's Courthouse Adventure Weekend"
                    && currentOrder.num_members >= currentOrder.num_instructions
                )
                ^
                (
                    currentOrder.name == "Sky Dive Colorado"
                    && currentOrder.num_members > 0
                    && cb_sd_lodging.SelectedIndex != -1
                );
        }
    }
}
All opinions represented herein are my own
- © 2024 itsthedevman
- build 3c15a1b