❔ Need Help with windows form program

OOnanay12/28/2022
private void submitButton_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                PersonalInformation pModel = new PersonalInformation(
                    firstNameTxtBox.Text,
                    middleNameTxtBox.Text,
                    lastNameTxtBox.Text,
                    ageTxtBox.Text);

                myAddress adModel = new myAddress(
                    cityTxtBox.Text,
                    barangayTxtBox.Text,
                    streetTxtBox.Text,
                    housenumTxtBox.Text);
                

                userInfo userModel = new userInfo(
                    userNameTxtBox.Text,
                    passwordTxtBox.Text);
                

                cardInformation cardModel = new cardInformation(
                    pinCodeTxtBox.Text
                    );




                foreach (IatmDataConnection db in GlobalConfig.Connections)
                {
                    db.personalInformationReg(pModel);
                    db.myAddressReg(adModel);
                    db.userInfoReg(userModel);
                    db.cardInformationReg(cardModel);
                }

            }
            else
            {
                MessageBox.Show("This form has an Invalid information. Please Check it and try again.");
            }


the else statement keeps on getting executed even though I am filling up all textboxes . TYIA ❤️
AAntonC12/28/2022
well if else executes then ValidateForm returns false
AAntonC12/28/2022
also use early returns
OOnanay12/28/2022
I fixed it hehehe, its the program in the bottom
AAccord12/29/2022
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.