private void btnLogin_Click(object sender, EventArgs e) { Login login = GetLogin(tbUser.Text, tbPass.Text); if (login != null) { MyConfig.BuildFile(login); DialogResult = DialogResult.OK; } else { tryCount++; if (tryCount > 3) { Application.Exit(); } lblName.Text = "Invalid User name or password"; tbPass.Text = ""; tbUser.Text = ""; } }