Class Problem

Hi, with the following code, only when the checkbox is checked will it show the rest of the values in the labels (shown at bottom). Needs to be a bool. If the checkbox is not checked it also needs to show a value.

Any ideas?

   customer = new Customer();
            int phone = 0;
            int custNum = 0;
            bool mailList = false;

            if (nameTextBox.Text ==  "")
            {
                MessageBox.Show("Invalid Name");
                return;
            }

            if (addressTextBox.Text == "")
            {
                MessageBox.Show("Invalid Address");
                return;
            }
            
            
            customer.Name = nameTextBox.Text;
            customer.Address = addressTextBox.Text;


            if (int.TryParse(phoneNumberTextBox.Text, out phone))
            {
                if (int.TryParse(customerNumberTextBox.Text, out custNum))
                {
                    customer.CustomerNumber = custNum;
                    customer.Phone = phone;

                    if (mailingListSubscribeCheckBox.Checked)
                    {
                        mailList = true;
                        mailingListValueLabel.Text = "You are subscribed";
                        return;
                    }
                    else 
                    {
                        mailList = false;
                        mailingListValueLabel.Text = "You are not subscribed";
                        return;
                    }

                }
                else
                {
                    MessageBox.Show("Invalid Customer Number");
                    return;
                }
            }


            else
            {
                MessageBox.Show("Invalid Phone Number");
                return;
            }
            nameValueLabel.Text = customer.Name;
            addressValueLabel.Text = customer.Address;
            phoneNumberValueLabel.Text = customer.Phone.ToString();
            customerNumberValueLabel.Text = customer.CustomerNumber.ToString();
            mailingListSubscribeCheckBox.Checked = customer.MailingList;

Open in new window

LVL 3
Computer GuyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

plusone3055Commented:
change bool mailList from false to TRUE on line 4

I do not belive the code  here is complete.
I would imagine that somewhere in the code that you did not provide there is an if statement that says if bool maillist is true then display
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.