I want to add in My project that admin can set access control to user.
Suppose admin can select user name and module name and save it to database.
When user successfully logged in he can only show the specific toolstripMenueItem which are added by Admin.
But I have no idea how to do it.
I simply add the user credentials and module name by admin. and when user try to log in I retrieve that control name into a string type variable, and try to do like this..
public void AccessControl()
{
SqlConnection conn = new SqlConnection("Data Source=MYSOFTIT-05-PC\\SQLEXPRESS;Initial Catalog=Point_Of_Sale;Integrated Security=True");
conn.Open();
SqlCommand scmd = new SqlCommand("SELECT Control FROM Roll WHERE Email = 'taherak17@gmail.com'; ", conn);
SqlDataAdapter dataAdapter = new SqlDataAdapter(scmd);
DataTable dt = new DataTable();
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
SqlDataReader myReader = null;
myReader = scmd.ExecuteReader();
while (myReader.Read())
{
var a = (myReader[0].ToString());
}
conn.Close();
}
private void Login_Load(object sender, EventArgs e)
{
AccessControl();
}
But the struck is how i define ToolStripMenuItem enabled or disabled according to database value? This is my Interface, and specific menu items are disable or enabled This is my Roll table