private void MenuStripItemsVisible() { SecurityRepository repo = new SecurityRepository(); DataTable dtAllMenuItems = repo.CreateDataTable(repo.GetUserRights(LoggedDetails.LoggedUserId)); if (commonFunctions.Loginuser.Trim().ToUpper() != "ADMIN") { if (dtAllMenuItems.Rows.Count != 0) { for (int i = 0; i < dtAllMenuItems.Rows.Count; i++) { if (Convert.ToBoolean(dtAllMenuItems.Rows[i]["dtAccess"].ToString()) == false) { string strEditUIName = (dtAllMenuItems.Rows[i]["Code"].ToString()).Replace(" ", ""); string strtlStrpMenuItemName = strEditUIName; List <ToolStripMenuItem> myItems = GetItems(this.menuStrip); foreach (var item in myItems) { item.ForeColor = Color.RoyalBlue; item.Text = item.Text.ToUpper(); if (item.Name == strtlStrpMenuItemName) { item.Enabled = false; } } //List<ToolStripMenuItem> tootlstrips = GetItems(this.toolStrip); foreach (ToolStripItem ctrl in this.toolStrip.Items) { //listBox1.Items.Add(ctrl.Name); ctrl.Text = ctrl.Text.ToUpper(); if (ctrl.Name.Trim().ToUpper() == "T" + strtlStrpMenuItemName.Trim().ToUpper()) { ctrl.Enabled = false; } } //foreach (ToolStripItem ctrl in this.contextMenuStrip1.Items) //{ // //listBox1.Items.Add(ctrl.Name); // ctrl.Text = ctrl.Text.ToUpper(); // ctrl.ForeColor = Color.RoyalBlue; // if (ctrl.Name.Trim().ToUpper() == "C" + strtlStrpMenuItemName.Trim().ToUpper()) // { // ctrl.Enabled = false; // } //} } else { string strEditUIName = (dtAllMenuItems.Rows[i]["Code"].ToString()).Replace(" ", ""); string strtlStrpMenuItemName = strEditUIName; List <ToolStripMenuItem> myItems = GetItems(this.menuStrip); foreach (var item in myItems) { item.ForeColor = Color.RoyalBlue; item.Text = item.Text.ToUpper(); if (item.Name == strtlStrpMenuItemName) { item.Enabled = true; } } //List<ToolStripMenuItem> tootlstrips = GetItems(this.toolStrip); foreach (ToolStripItem ctrl in this.toolStrip.Items) { //listBox1.Items.Add(ctrl.Name); ctrl.ForeColor = Color.RoyalBlue; ctrl.Text = ctrl.Text.ToUpper(); if (ctrl.Name.Trim().ToUpper() == "T" + strtlStrpMenuItemName.Trim().ToUpper()) { ctrl.Enabled = true; } } //foreach (ToolStripItem ctrl in this.contextMenuStrip1.Items) //{ // //listBox1.Items.Add(ctrl.Name); // ctrl.Text = ctrl.Text.ToUpper(); // ctrl.ForeColor = Color.RoyalBlue; // if (ctrl.Name.Trim().ToUpper() == "C" + strtlStrpMenuItemName.Trim().ToUpper()) // { // ctrl.Enabled = true; // } //} } } } else { //implement locking system } } else { // if login user is administrator } }//end