I have 2 forms in one project. One form is used as "login screen" and the other one is used as program after login. I have a problem with closing forms completely, because if I press the 'x' button on top right project can still be found as background process.
GIF of the problem: click me
Code i'm using:
private void bVpisi_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"Data Source=LUKA-PRENOSNIK\SQLEXPRESS;Database=Registracija;Trusted_Connection=True");
SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM Registracija WHERE Up_ime='" + tbUp_ime.Text + "' AND Geslo='" + tbGeslo.Text + "'", conn);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
Glavna g = new Glavna();
g.Show();
}
else
{
MessageBox.Show("Vnesena kombinacija uporabniškega imena in gesla nista pravilna!");
}
}
}
Thank you or your help!