Пример #1
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            //Verify event name has been entered
            if (textBoxName.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Event name is required", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxName.Focus();
                return;
            }

            //Declare local variables
            string eventName;
            int    numOfGuests;
            bool   barOpen, dinnerWithWine;

            //Assign values to variables
            eventName      = textBoxName.Text;
            numOfGuests    = Convert.ToInt32(numericUpDownGuests.Value);
            barOpen        = checkBoxOpenBar.Checked;
            dinnerWithWine = checkBoxWine.Checked;

            //Instantiate a CateringEvent object
            createEvent = new CateringEvent(eventName, numOfGuests, entreType, barOpen, dinnerWithWine);

            //Access CalcEventCharges method and display result
            labelResult.Text = $" Entre Charge: {createEvent.EntreCharge.ToString("c2")} \r\n Drinks Charge: {createEvent.DrinksCharge.ToString("c2")} \r\n Surcharge: {createEvent.Surcharge.ToString("c2")} \r\n Total: {createEvent.TotalCharge.ToString("c2")}";

            //Disable/Enable controls
            buttonCreate.Enabled = false;
            textBoxName.Enabled  = false;
            buttonModify.Enabled = true;
        }
Пример #2
0
        private void buttonModify_Click(object sender, EventArgs e)
        {
            //Declare local variables
            string eventName;
            int    numOfGuests;
            bool   barOpen, dinnerWithWine;

            //Assign values to variables
            eventName      = textBoxName.Text;
            numOfGuests    = Convert.ToInt32(numericUpDownGuests.Value);
            barOpen        = checkBoxOpenBar.Checked;
            dinnerWithWine = checkBoxWine.Checked;

            //Instantiate a CateringEvent object
            modifyEvent = new CateringEvent(eventName, numOfGuests, entreType, barOpen, dinnerWithWine);

            //Access CalcEventCharges method and display result
            labelResult.Text = $" Entre Charge: {modifyEvent.EntreCharge.ToString("c2")} \r\n Drinks Charge: {modifyEvent.DrinksCharge.ToString("c2")} \r\n Surcharge: {modifyEvent.Surcharge.ToString("c2")} \r\n Total: {modifyEvent.TotalCharge.ToString("c2")}";

            //Disable/Enable controls
            buttonCreate.Enabled = false;
            textBoxName.Enabled  = false;
            buttonModify.Enabled = true;
        }