Conditional User input Form
I am trying to make a Form (Form 3) that if the User clicks ok then it continues the previous code from (Form 1)
Form 1 Entry Point
Form 3 Exit Point
switch (comboBox_Type.SelectedIndex)
{
case 0: //Main Hub
GlobalClass.IP = "10.247.247.130";
NetworkSet();
break;
case 1: //Extension Hub
GlobalClass.IP = "10.247.247.150";
NetworkSet();
break;
case 2: //ALARM Module
GlobalClass.IP = "10.247.247.170";
NetworkSet();
break;
case 3: //NVR Module
GlobalClass.IP = "10.247.247.180";
NetworkSet();
break;
case 4: //Custom
GlobalClass.IP = "";
Form3 thirdForm = new Form3();
thirdForm.ShowDialog();
NetworkSet();
break;
default:
break;
}
switch (comboBox_Type.SelectedIndex)
{
case 0: //Main Hub
GlobalClass.IP = "10.247.247.130";
NetworkSet();
break;
case 1: //Extension Hub
GlobalClass.IP = "10.247.247.150";
NetworkSet();
break;
case 2: //ALARM Module
GlobalClass.IP = "10.247.247.170";
NetworkSet();
break;
case 3: //NVR Module
GlobalClass.IP = "10.247.247.180";
NetworkSet();
break;
case 4: //Custom
GlobalClass.IP = "";
Form3 thirdForm = new Form3();
thirdForm.ShowDialog();
NetworkSet();
break;
default:
break;
}
public void BtnOk_Click(object sender, EventArgs e)
{
string Errors = null;
//&& IsAddressValid(NewSM.Text) == true && IsAddressValid(NewGW.Text) == true
if (IsAddressValid(NewIP.Text) != true)
{
Errors += "INVALID IP ADDRESS\n";
}
if (IsAddressValid(NewSM.Text) != true)
{
Errors += "INVALID SUBMASK ADDRESS\n";
}
if (IsAddressValid(NewGW.Text) != true)
{
Errors += "INVALID GATEWAY ADDRESS\n";
}
if (string.IsNullOrEmpty(Errors))
{
GlobalClass.IP = NewIP.Text;
GlobalClass.Mask = NewSM.Text;
GlobalClass.Gateway = NewGW.Text;
Close();
}
else {
MessageBox.Show(Errors, "Error");
}
}
private void BtnCnl_Click(object sender, EventArgs e) => Close();
public void BtnOk_Click(object sender, EventArgs e)
{
string Errors = null;
//&& IsAddressValid(NewSM.Text) == true && IsAddressValid(NewGW.Text) == true
if (IsAddressValid(NewIP.Text) != true)
{
Errors += "INVALID IP ADDRESS\n";
}
if (IsAddressValid(NewSM.Text) != true)
{
Errors += "INVALID SUBMASK ADDRESS\n";
}
if (IsAddressValid(NewGW.Text) != true)
{
Errors += "INVALID GATEWAY ADDRESS\n";
}
if (string.IsNullOrEmpty(Errors))
{
GlobalClass.IP = NewIP.Text;
GlobalClass.Mask = NewSM.Text;
GlobalClass.Gateway = NewGW.Text;
Close();
}
else {
MessageBox.Show(Errors, "Error");
}
}
private void BtnCnl_Click(object sender, EventArgs e) => Close();
0 Replies