C# ToolStripMenuItem disabled depending on the user account
Th3Rimas
Messages postés
14
Statut
Membre
-
Th3Rimas Messages postés 14 Statut Membre -
Th3Rimas Messages postés 14 Statut Membre -
3 réponses
-
Bonsoir,
au moment de la connection tu testes le statut de la personne,
si il est bon alors le menu est enabled sinon il est disabled.
-
j'ai fait ce code mais lorseque je choisi User en type ca marche pas il marche juste avec le type Admin je veux une solution !
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=YOUMANI\YOUMANI;Initial Catalog=GestPharma;Integrated Security=True");
SqlDataAdapter da = new SqlDataAdapter("select count(*) from personnel where username ='" + textBox1.Text + "'and password='" + textBox2.Text + "' and role = '"+ comboBox1.Text+"'", con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
/*this.Hide();
MenuAdmin ms = new MenuAdmin();
ms.Show();*/
SqlDataAdapter da1 = new SqlDataAdapter("select role from personnel where username ='" + textBox1.Text + "'and password='" + textBox2.Text + "'", con);
DataTable dt1 = new DataTable();
da1.Fill(dt1);
if (dt1.Rows[0][0].ToString() == "Admin")
{
this.Hide();
MenuAdmin ma = new MenuAdmin();
ma.Show();
}
else
{
MessageBox.Show("Please check your Username And Password");
}
if (dt1.Rows[0][0].ToString() == "User")
{
this.Hide();
MenuUser mu = new MenuUser();
mu.Show();
}
}
else
{
MessageBox.Show("Please check your Username And Password");
}
}
-
-
-

