C
C#2y ago
paultit_

❔ Need Help with windows form program

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.");
}
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 ❤️
3 Replies
Anton
Anton2y ago
well if else executes then ValidateForm returns false also use early returns
paultit_
paultit_2y ago
I fixed it hehehe, its the program in the bottom
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server
More Posts