示例#1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //Declare local variables
            string  name, type;
            decimal hours;
            int     size;

            //Assign value to variables
            name  = textBoxName.Text;
            type  = Convert.ToString(comboBoxType.SelectedItem);
            hours = Convert.ToInt32(numericUpDownHours.Value);
            size  = Convert.ToInt32(comboBoxSize.SelectedItem);

            // Verify values have been entered
            if (textBoxName.Text == null || comboBoxType.SelectedItem == null || comboBoxSize.SelectedItem == null)
            {
                MessageBox.Show("Customer Name, Hours Used, Charter Type, and Charter Size are required.", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxName.Focus();
                return;
            }

            //Instatiate a new CharterManager object
            if (aCharterManager is null)
            {
                aCharterManager = new CharterManager();
            }

            //Call addCharter method to add new charter object
            aCharterManager.AddCharter(name, type, size, hours);

            //Disable/enable controls
            mnuAllCharters.Enabled     = true;
            mnuChartersSummary.Enabled = true;
            mnuNumOfCharters.Enabled   = true;
            buttonAdd.Enabled          = false;
        }
示例#2
0
 private void Program16_ChartersSummary_Load(object sender, EventArgs e)
 {
     //Display information in summary label
     lblSummary.Text = $"Lowest Charter Fee: {CharterManager.FindLowestCharterFee().ToString("c2")} \r\nTotal Charter Fees: {CharterManager.GetTotalCharterFees().ToString("c2")} \r\nAverage Charter Fee: {CharterManager.GetAverageCharterFee().ToString("c2")}";
 }