private void btnCalculate_Click(object sender, EventArgs e)
        {
            CheckEntry objCheckQuantity = new CheckEntry(txt_Quantity.Text, lbl_quantity.Text);
            CheckEntry objCheckUCost    = new CheckEntry(txt_unitCost.Text, lbl_unitCost.Text);

            if (!objCheckQuantity.isNull() && !objCheckUCost.isNull())
            {
                double uCost = double.Parse(txt_unitCost.Text);
                double quan  = double.Parse(txt_Quantity.Text);
                double tCost = uCost * quan;

                txt_TotalCost.Text = tCost.ToString();
            }
            else
            {
                MessageBox.Show("Enter a value in the Quantity and Unit Cost fields.");
            }
        }
Esempio n. 2
0
        private Boolean CheckValidUser()
        {
            bool addUser     = true;
            bool showMessage = true;

            //This series of if statements checks to see if required textboxes are null.
            //If null, the corresponding label is added to the output string.
            if (objCheckEntry.isNull(txtFirstName.Text, lblFirstName.Text))
            {
                output += "\n " + lblFirstName.Text;
                addUser = false;
            }

            if (objCheckEntry.isNull(txtLastName.Text, lblLastName.Text))
            {
                output += "\n " + lblLastName.Text;
                addUser = false;
            }

            if (objCheckEntry.isNull(cboxUserType.Text, lblUserType.Text))
            {
                output += "\n User Type";
                addUser = false;
            }

            if (objCheckEntry.isNull(txtEmail.Text, lblEmail.Text))
            {
                output += "\n " + lblEmail.Text;
                addUser = false;
            }
            else
            {
                if (!objCheckEntry.isValidEmail(txtEmail.Text))
                {
                    txtEmail.Text = "";
                    output       += "\n " + lblEmail.Text;
                    addUser       = false;
                    showMessage   = false;
                }
            }

            if (objCheckEntry.isNull(txtUsername.Text, lblUsername.Text))
            {
                output += "\n " + lblUsername.Text;
                addUser = false;
            }

            if (objCheckEntry.isNull(txtPassword.Text, lblPassword.Text))
            {
                output += "\n " + lblPassword.Text;
                addUser = false;
            }
            else
            {
                if (objPassword.DeterminePasswordStrength(txtPassword.Text) < 0)
                {
                    MessageBox.Show("Password is not Strong enough!");
                    txtPassword.Text       = "";
                    txtVerifyPassword.Text = "";
                    addUser     = false;
                    showMessage = false;
                }
            }

            if (objCheckEntry.isNull(txtVerifyPassword.Text, lblVerifyPw.Text))
            {
                output += "\n " + lblVerifyPw.Text;
                addUser = false;
            }
            else
            {
                if (txtPassword.Text != txtVerifyPassword.Text)
                {
                    MessageBox.Show("Password and Verify Password must match!");
                    txtPassword.Text       = "";
                    txtVerifyPassword.Text = "";
                    addUser     = false;
                    showMessage = false;
                }
            }

            if (showMessage == true && addUser == false)
            {
                MessageBox.Show("The following fields must contain a value: " + output);
            }
            output = "";

            return(addUser);
        }