Exemplo n.º 1
0
        private void LOADCHECKBX(string rcvid)
        {
            int count = 0, menuno = 0;

            chklstbx.ColumnWidth = 350;

            if (this.chklstbx.Items.Count != 0 && rcvid != "reset")
            {
                return;
            }

            //fetch the menu items and add it into checklistbox
            foreach (ToolStripMenuItem item in wfMain.Mainmenustrip.Items)
            {
                if (count < 2)
                {
                    count = count + 1;

                    foreach (ToolStripMenuItem subitem in item.DropDownItems.OfType <ToolStripMenuItem>())
                    {
                        string chkname;
                        switch (item.Name)
                        {
                        case "Utilities":
                            chkname = item.Name + "........" + subitem.Name;
                            break;

                        case "Master":
                            chkname = item.Name + "..........." + subitem.Name;
                            break;

                        default:
                            chkname = item.Name + "....." + subitem.Name;
                            break;
                        }
                        if (rcvid == "" || rcvid == "reset")
                        {
                            if (rcvid == "")
                            {
                                // add the name only for new user
                                chklstbx.Items.Add(chkname, true);
                            }
                            else
                            {
                                //check state on reset
                                chklstbx.SetItemChecked(menuno, true);
                            }
                        }
                        else
                        {
                            //if user already exists,set according to his settings
                            qry = "SELECT UAmenu,UAenable FROM userattribute WHERE UAuserid='" + rcvid + "'";
                            dt  = objData.getDataTable(qry);
                            chklstbx.Items.Add(chkname);
                            //check if menuno corresponds to name
                            chklstbx.SetItemChecked(menuno, (bool)dt.Rows[menuno][1]);
                        }
                        menuno += 1;
                    }
                }
                else
                {
                    return;
                }
            }
        }