예제 #1
0
        }         // end of previous method - dataGridViewFleet_SelectionChanged()

        // ------------------------------------------------------------------------------------------------------

        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonModifyCustomerSubmit_Click(object sender, EventArgs e)
        {
            int    cID       = int.Parse(numericUpDownModifyCustomerID.Value.ToString());
            string title     = textBoxModifyTitle.Text;
            string firstName = textBoxModifyFirstName.Text;
            string lastName  = textBoxModifyLastName.Text;

            Customer.GenderEnum gender = (Customer.GenderEnum)comboBoxModifyGender.SelectedValue;
            string DOB = textBoxModifyDOB.Text;

            Customer newCustomer = new Customer(cID, title, firstName, lastName, gender, DOB);

            customers.RemoveCustomer(selectedCustomer);
            customers.AddCustomer(newCustomer);

            PopulateDataGridViewCustomers();
        }        // end of previous method - dataGridViewFleet_SelectionChanged()
예제 #2
0
        }        // end of previous method - dataGridViewFleet_SelectionChanged()

        // ------------------------------------------------------------------------------------------------------

        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void buttonAddCustomerSubmit_Click(object sender, EventArgs e)
        {
            // Validate Required Inputs

            // Validate Title
            if (string.IsNullOrWhiteSpace(textBoxAddCustomerTitle.Text))
            {
                MessageBox.Show("Error! - Title is required!");
                return;
            }
            // Validate FirstName
            if (string.IsNullOrWhiteSpace(textBoxAddCustomerFirstName.Text))
            {
                MessageBox.Show("Error! - First Name is required!");
                return;
            }

            // Validate LastName
            if (string.IsNullOrWhiteSpace(textBoxAddCustomerLastName.Text))
            {
                MessageBox.Show("Error! - Last Name is required!");
                return;
            }

            if (string.IsNullOrWhiteSpace(textBoxAddCustomerDOB.Text))
            {
                MessageBox.Show("Error! - Date Of Birth (DOB) is required!");
                return;
            }

            int    cID       = int.Parse(numericUpDownAddCustomerID.Value.ToString());
            string title     = textBoxAddCustomerTitle.Text;
            string firstName = textBoxAddCustomerFirstName.Text;
            string lastName  = textBoxAddCustomerLastName.Text;

            Customer.GenderEnum gender = (Customer.GenderEnum)comboBoxAddCustomerGender.SelectedValue;
            string DOB = textBoxAddCustomerDOB.Text;

            Customer newCustomer = new Customer(cID, title, firstName, lastName, gender, DOB);

            customers.AddCustomer(newCustomer);

            PopulateDataGridViewCustomers();

            // Check ID is unique and only + 1.
            int LastAddedID = customers.LastAddedID;
            int nextID      = LastAddedID + 1;

            if (LastAddedID == nextID - 1)
            {
                numericUpDownAddCustomerID.Value = nextID;
                customers.LastAddedID            = nextID;
            }

            // Resets Values in Inputs

            textBoxAddCustomerTitle.Text     = null;
            textBoxAddCustomerFirstName.Text = null;
            textBoxAddCustomerLastName.Text  = null;
            textBoxAddCustomerDOB.Text       = null;
        }        // end of previous method - dataGridViewFleet_SelectionChanged()