private int ValidateData()
{
int flag = 1;
if (txtEmpNo.TextLength < 8)
{
MessageBox.Show("Employee Number must be 8 Digits Long","Message");
flag = 0;
}
return flag;
}
private void btnProfile_Click(object sender, EventArgs e)
{
try
{
Profile pf = new Profile("");
if (ValidateData() == 1)
{
if (pf!=null)
{
pf = new Profile("");
pf.Focus();
}
else
{
pf = new Profile(txtEmpNo.Text);
pf.Show();
}
Qualification qa = new Qualification("");
qa.Close();
Experience ex = new Experience("");
ex.Close();
History hs = new History("");
hs.Close();
}
}
catch (Exception ex)
{
if (ex is IndexOutOfRangeException)
{
MessageBox.Show("Employee Not Found");
}
else if (ex is OleDbException)
{
MessageBox.Show("Please Enter Employee Valid No.");
}
else
{
MessageBox.Show(ex.ToString());
}
}
}
これらのボタンをクリックすると別の 4 つのフォームが開く 4 つのボタンを含む 1 つのメイン フォームを作成しました。自動的に閉じます...そして2番目のことは、フォームがすでに開いている場合は、もう一度開かずにフォーカスするだけです...
これについてはすでにいくつかのコーディングを行っていますが、望ましい出力を得ることができません。