Beispiel #1
0
        /// <summary>
        /// To generate child menu based on parentid from database
        /// </summary>

        private void GenerateChildMenu(string parentMenuID)
        {
            DataView menuView = new DataView(subMenuTable);

            menuView.RowFilter = "PARENTMENUID = " + parentMenuID;

            for (int i = 0; i < menuView.Count; i++)
            {
                objPriv        = new RolePrivilegesBO();
                objPriv.MenuID = Convert.ToInt32(menuView[i]["CHILDMENUID"]);

                //sb.Clear();
                //paddingCount = Convert.ToInt32(menuView[i]["CHILDLEVEL"]);
                //for (int j = 1; j < paddingCount; j++)
                //{
                //    if (paddingCount == 2)
                //        sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;------");
                //    else if (j < (paddingCount - 1))
                //        sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                //    else
                //        sb.Append("------");
                //}

                objPriv.ParentMenuID    = Convert.ToInt32(menuView[i]["PARENTMENUID"]);
                objPriv.MenuDescription = menuView[i]["MENUDESCRIPTION"].ToString();
                objPriv.ChildMenuCount  = Convert.ToInt32(menuView[i]["CHILDMENUCOUNT"]);
                objPriv.MenuLevel       = Convert.ToInt32(menuView[i]["CHILDLEVEL"]);
                RolePrivilegesLst.Add(objPriv);

                GenerateChildMenu(menuView[i]["CHILDMENUID"].ToString());
            }
            menuView = null;
        }
Beispiel #2
0
        /// <summary>
        /// Set Grid Data source
        /// </summary>
        /// <param name="addRow"></param>
        /// <param name="deleteRow"></param>e
        private void GenerateMenuItems()
        {
            RolePrivilegesLst = new RolePrivilegesList();
            RolePrivilegesBLL objRolePrivBLL = new RolePrivilegesBLL();

            DataTable mainMenuTable = objRolePrivBLL.GetRolePrivileges();

            subMenuTable = mainMenuTable.Copy();

            DataView MainMenuView = mainMenuTable.AsDataView();
            DataView SubMenuView  = subMenuTable.AsDataView();

            MainMenuView.RowFilter = "PARENTMENUID=0";

            for (int i = 0; i < MainMenuView.Count; i++)
            {
                objPriv                 = new RolePrivilegesBO();
                objPriv.MenuID          = Convert.ToInt32(MainMenuView[i]["CHILDMENUID"]);
                objPriv.MenuDescription = MainMenuView[i]["MENUDESCRIPTION"].ToString();
                objPriv.ChildMenuCount  = Convert.ToInt32(MainMenuView[i]["CHILDMENUCOUNT"]);
                objPriv.MenuLevel       = Convert.ToInt32(MainMenuView[i]["CHILDLEVEL"]);
                objPriv.ParentMenuID    = Convert.ToInt32(MainMenuView[i]["PARENTMENUID"]);

                RolePrivilegesLst.Add(objPriv);

                GenerateChildMenu(MainMenuView[i]["CHILDMENUID"].ToString());
            }

            mainMenuTable = null;

            rptRolePrivileges.DataSource = RolePrivilegesLst;
            rptRolePrivileges.DataBind();
        }
Beispiel #3
0
        /// <summary>
        /// To Get ROLE PRI Id
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public RolePrivilegesList GetROLEPRIId(int UserID)
        {
            OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString);
            OracleCommand    cmd;

            string proc = "USP_MST_GET_ROLEBYUSERID";

            cmd             = new OracleCommand(proc, cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("USERID_", UserID);
            cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

            cmd.Connection.Open();

            OracleDataReader   dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            RolePrivilegesBO   RolePrivilegesObj  = null;
            RolePrivilegesList RolePrivilegesList = new RolePrivilegesList();

            while (dr.Read())
            {
                RolePrivilegesObj = new RolePrivilegesBO();

                if (!dr.IsDBNull(dr.GetOrdinal("USERID")))
                {
                    RolePrivilegesObj.UserID = dr.GetInt32(dr.GetOrdinal("USERID"));
                }
                if (!dr.IsDBNull(dr.GetOrdinal("MENUID")))
                {
                    RolePrivilegesObj.MenuID = dr.GetInt32(dr.GetOrdinal("MENUID"));
                }
                if (!dr.IsDBNull(dr.GetOrdinal("MENULEVEL")))
                {
                    RolePrivilegesObj.MenuLevel = dr.GetInt32(dr.GetOrdinal("MENULEVEL"));
                }
                if (!dr.IsDBNull(dr.GetOrdinal("MENUNAME")))
                {
                    RolePrivilegesObj.MenuName = dr.GetString(dr.GetOrdinal("MENUNAME"));
                }
                if (!dr.IsDBNull(dr.GetOrdinal("CANVIEW")))
                {
                    RolePrivilegesObj.CanView = dr.GetString(dr.GetOrdinal("CANVIEW"));
                }
                if (!dr.IsDBNull(dr.GetOrdinal("CANUPDATE")))
                {
                    RolePrivilegesObj.CanUpdate = dr.GetString(dr.GetOrdinal("CANUPDATE"));
                }
                if (!dr.IsDBNull(dr.GetOrdinal("CHILDMENUCOUNT")))
                {
                    RolePrivilegesObj.ChildMenuCount = dr.GetInt32(dr.GetOrdinal("CHILDMENUCOUNT"));
                }

                if (!dr.IsDBNull(dr.GetOrdinal("PROJDEPENDENT")))
                {
                    RolePrivilegesObj.ProjectDependent = dr.GetString(dr.GetOrdinal("PROJDEPENDENT"));
                }
                else
                {
                    RolePrivilegesObj.ProjectDependent = "N";
                }

                if (!dr.IsDBNull(dr.GetOrdinal("PAPDEPENDENT")))
                {
                    RolePrivilegesObj.PAPDependent = dr.GetString(dr.GetOrdinal("PAPDEPENDENT"));
                }
                else
                {
                    RolePrivilegesObj.PAPDependent = "N";
                }

                RolePrivilegesList.Add(RolePrivilegesObj);
            }

            dr.Close();
            return(RolePrivilegesList);
        }