Пример #1
0
 private void createMainHeaderButtons()
 {
     try
     {
         MenuPrivilegeDB mpDB     = new MenuPrivilegeDB();
         MenuItemDB      dbrecord = new MenuItemDB();
         menuitems = dbrecord.getMenuItems();
         MenuPrivilegeDB mpdb = new MenuPrivilegeDB();
         menuPrivString  = mpdb.getUserMenuPrivilege(Login.userLoggedIn);
         userOptionArray = menuPrivString.Split(';');
         intex           = 0;
         removpnlcontrols();
         foreach (menuitem menu in menuhdritems)
         {
             int             count = 0;
             List <menuitem> mnm   = menuitems.Where(x => x.menugrp == menu.menugrp).ToList();
             foreach (menuitem menuin in mnm)
             {
                 if (Utilities.checkMenuPrivilege(menuin.menuItemID, userOptionArray) >= 0)
                 {
                     if (menuin.menuitemStatus == 1)
                     {
                         count++;
                     }
                 }
             }
             if (count > 0)
             {
                 val = 0;
                 addButtonheader(menu.menugrp, intex, menu.menugrp);
                 intex++;
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Main() : Error 3");
     }
 }
Пример #2
0
        ////private void applyPrivilege()
        ////{
        ////    try
        ////    {

        ////    }
        ////    catch (Exception)
        ////    {
        ////    }
        ////}
        private void fillUserMenuPrivileges()
        {
            try
            {
                MenuPrivilegeDB mpdb     = new MenuPrivilegeDB();
                string          mpString = mpdb.getUserMenuPrivilege(userIDSelected);
                if (mpString.Length > 0)
                {
                    userPrivilegeExists = true;
                }
                string[] strArr = mpString.Split(';');
                int      intex  = 0;
                foreach (DataGridViewRow row in grdUserPrivileges.Rows)
                {
                    try
                    {
                        string docID = row.Cells[0].Value.ToString();
                        intex = Utilities.checkMenuPrivilege(docID, strArr);
                        if (intex >= 0)
                        {
                            string[] prvArr = strArr[intex].Split(',');
                            if (prvArr[1].Equals("V"))
                            {
                                row.Cells[2].Value = "true";
                            }
                            if (prvArr[2].Equals("A"))
                            {
                                row.Cells[3].Value = "true";
                            }
                            if (prvArr[3].Equals("E"))
                            {
                                row.Cells[4].Value = "true";
                            }
                            if (prvArr[4].Equals("D"))
                            {
                                row.Cells[5].Value = "true";
                            }
                            try
                            {
                                if (prvArr[5].Equals("M"))
                                {
                                    row.Cells[6].Value = "true";
                                }
                            }
                            catch (Exception ex)
                            {
                                row.Cells[6].Value = "false";
                            }
                            //DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[2];
                            //chk.Selected = true;
                        }
                        else
                        {
                            row.Cells[2].Value = "false";
                            row.Cells[3].Value = "false";
                            row.Cells[4].Value = "false";
                            row.Cells[5].Value = "false";
                            row.Cells[6].Value = "false";
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception)
            {
            }
        }