예제 #1
0
        public List<ScreenBO> LoadGrantedScreensByRoleID(int roleId)
        {
            DBEgine dbEgine = new DBEgine();

            List<ScreenBO> screenList = new List<ScreenBO>();

            try
            {
                dbEgine.DBOpen();

                SqlParameter[] parms = new SqlParameter[1];

                SqlParameter p1 = new SqlParameter();
                p1.ParameterName = "@RoleId";
                p1.SqlDbType = SqlDbType.Int;
                p1.Direction = ParameterDirection.Input;
                p1.Value = roleId;
                parms[0] = p1;

                SqlDataReader drScreenList = dbEgine.ExecuteReader("UserManagement.UM_LoadGrantedScreensByRoleID", parms);

                while (drScreenList.Read())
                {
                    ScreenBO objscreen = new ScreenBO();

                    objscreen.ScreenId = drScreenList.GetInt32(drScreenList.GetOrdinal("ScreenId"));
                    objscreen.ScreenName = drScreenList.GetValue(drScreenList.GetOrdinal("Screen")).ToString();
                    objscreen.Url = drScreenList.GetValue(drScreenList.GetOrdinal("URL")).ToString();
                    objscreen.ScreenParentId = drScreenList.GetInt32(drScreenList.GetOrdinal("ScreenParentId"));
                    objscreen.IsMenu = drScreenList.GetBoolean(drScreenList.GetOrdinal("IsMenu"));
                    objscreen.IsEnable = drScreenList.GetBoolean(drScreenList.GetOrdinal("IsEnable"));
                    objscreen.ScreenOrderId = drScreenList.GetInt32(drScreenList.GetOrdinal("ScreenOrderId"));

                    List<ScreenFunctionsBO> listScreenFuntions = new ScreenFunctionsDAL().LoadScreenFunctions(objscreen.ScreenId, roleId);

                    objscreen.ScreenFunctions = new List<ScreenFunctionsBO>();

                    if (listScreenFuntions != null && listScreenFuntions.Count > 0)
                    {
                        objscreen.ScreenFunctions = listScreenFuntions;
                    }

                    screenList.Add(objscreen);

                }
                dbEgine.DBClose();

                return screenList;
            }
            catch
            {
                throw;
            }

            finally
            {
                dbEgine.DBClose();
            }
        }
예제 #2
0
        private void AddNodes(TreeNode node, ScreenBO[] allScreens, string parentId,string screenName)
        {
            var selectedScreen = from selectedrows in allScreens
                                 where selectedrows.ScreenParentId == Convert.ToInt32(parentId)
                                 select selectedrows;

            ScreenBO[] selectedRows = selectedScreen.ToArray<ScreenBO>();

            if (selectedRows.Length > 0)
            {
                foreach (ScreenBO dtoScreen in selectedRows)
                {
                    TreeNode childNode = new TreeNode(dtoScreen.ScreenName);

                    AddNodes(childNode, allScreens, Convert.ToString(dtoScreen.ScreenId), dtoScreen.ScreenName);

                    node.Nodes.Add(childNode);
                }

            }
            else
            {
                node.Name = Common.PARENT_OF_FUNCTIONS + "_" + parentId.ToString();

                var selectedScreenFunction = from selectedrows in allScreens
                                             where selectedrows.ScreenId == Convert.ToInt32(parentId)
                                             select selectedrows;

                ScreenBO[] selectedFunctions = selectedScreenFunction.ToArray<ScreenBO>();

                if (selectedFunctions.Length > 0)
                {
                    foreach (ScreenFunctionsBO screenFun in selectedFunctions[0].ScreenFunctions)
                    {

                        var child = new TreeNode();

                        child.Name = screenFun.ScreenFunctionCode;
                        child.Text = screenFun.FunctionName;

                        if (screenFun.IsGranted)
                        {
                            child.Checked = true;
                        }

                        node.Nodes.Add(child);
                    }

                }
            }
        }
예제 #3
0
        private void visitChildNodes(TreeNode node)
        {
            string b = node.Text;
            string[] nodeValues = node.Name.Split('_');

            ScreenBO screen = new ScreenBO();

            if (nodeValues.Length > 0 && nodeValues[0] == Common.PARENT_OF_FUNCTIONS)
            {
                screen.ScreenId = Convert.ToInt32(nodeValues[1]);

                List<ScreenFunctionsBO> ScreenFunList = new List<ScreenFunctionsBO>();

                foreach (TreeNode childNode in node.Nodes)
                {
                    ScreenFunctionsBO Screenfun = new ScreenFunctionsBO();

                    Screenfun.ScreenFunctionCode = childNode.Name;
                    if (childNode.Checked)
                    {
                        Screenfun.IsGranted = true;
                    }
                    else
                    {
                        Screenfun.IsGranted = false;
                    }
                    ScreenFunList.Add(Screenfun);
                }

                screen.ScreenFunctions = ScreenFunList;

                screenList.Add(screen);

            }
            else
            {

                for (int j = 0; j < node.Nodes.Count; j++)
                {
                    visitChildNodes(node.Nodes[j]);
                }
            }
        }
예제 #4
0
        private void LoadMenu(ScreenBO[] allScreens, ScreenBO[] parentScreens)
        {
            try
            {
                foreach (ScreenBO dtoscreen in parentScreens)
                {
                    TreeNode MainNode = new TreeNode(dtoscreen.ScreenName);

                    AddNodes(MainNode, allScreens, Convert.ToString(dtoscreen.ScreenId), dtoscreen.ScreenName);

                    treeViewScreens.Nodes.Add(MainNode);
                    treeViewScreens.ExpandAll();
                }

            }
            catch
            {
                MessageBoxClass.ShowMessage(CommonMethods.GetError("U_012"), true);
            }
        }
예제 #5
0
        public List<ScreenBO> LoadUserPermissionByUserId(UserBO obj)
        {
            DBEgine dbEgine = new DBEgine();
            List<ScreenBO> screenList = new List<ScreenBO>();

            try
            {

                dbEgine.DBOpen();

                SqlParameter[] parms = new SqlParameter[1];

                SqlParameter p1 = new SqlParameter();
                p1.ParameterName = "in_userId";
                p1.SqlDbType = SqlDbType.Int;
                p1.Direction = ParameterDirection.Input;
                p1.Value = obj.UserId;
                parms[0] = p1;

                SqlDataReader drUserPermission = dbEgine.ExecuteReader("UserManagement.UM_LoadUserPermissionByUserId", parms);

                while (drUserPermission.Read())
                {
                    ScreenBO objscreen = new ScreenBO();

                    objscreen.ScreenId = drUserPermission.GetInt32(drUserPermission.GetOrdinal("ScreenId"));
                    objscreen.ScreenName = drUserPermission.GetValue(drUserPermission.GetOrdinal("Screen")).ToString();
                    objscreen.Url = drUserPermission.GetValue(drUserPermission.GetOrdinal("Url")).ToString();
                    objscreen.IsEnable = drUserPermission.GetBoolean(drUserPermission.GetOrdinal("IsEnable"));
                    objscreen.ScreenOrderId = drUserPermission.GetInt32(drUserPermission.GetOrdinal("ScreenOrderId"));
                    objscreen.TotalPerType = drUserPermission.GetInt32(drUserPermission.GetOrdinal("TotalPerType"));

                    List<PermisionTypeBO> perTypeList = new List<PermisionTypeBO>();

                    // for(int i=0; i< objscreen.TotalPerType; i++)

                    // {
                    int i = 0;
                    do
                    {
                        i = i + 1;

                        PermisionTypeBO objPerType = new PermisionTypeBO();

                        objPerType.ScreenPermissionId = drUserPermission.GetInt32(drUserPermission.GetOrdinal("ScreenPermissionId"));
                        objPerType.IsActive = drUserPermission.GetBoolean(drUserPermission.GetOrdinal("IsActive"));

                        perTypeList.Add(objPerType);
                    } while ((i < objscreen.TotalPerType) && drUserPermission.Read());

                    //  }

                    objscreen.PermissionType = perTypeList;
                    perTypeList = null;

                    screenList.Add(objscreen);

                }
                dbEgine.DBClose();

                return screenList;
            }
            catch
            {
                throw;
            }

            finally
            {
                dbEgine.DBClose();
            }
        }
예제 #6
0
        public List<ScreenBO> LoadScreensbyUserName(string userName)
        {
            DBEgine dbEgine = new DBEgine();

            List<ScreenBO> screenList = new List<ScreenBO>();

            try
            {
                dbEgine.DBOpen();

                SqlParameter[] parms = null;

                SqlDataReader drScreenList = dbEgine.ExecuteReader("UserManagement.UM_LoadScreens", parms);

                while (drScreenList.Read())
                {
                    ScreenBO objscreen = new ScreenBO();

                    objscreen.ScreenId = drScreenList.GetInt32(drScreenList.GetOrdinal("ScreenId"));
                    objscreen.ScreenName = drScreenList.GetValue(drScreenList.GetOrdinal("Screen")).ToString();
                    objscreen.Url = drScreenList.GetValue(drScreenList.GetOrdinal("URL")).ToString();
                    objscreen.ScreenParentId = drScreenList.GetInt32(drScreenList.GetOrdinal("ScreenParentId"));
                    objscreen.IsMenu = drScreenList.GetBoolean(drScreenList.GetOrdinal("IsMenu"));
                    objscreen.ShowOnMenu = drScreenList.GetBoolean(drScreenList.GetOrdinal("ShowOnMenu"));
                    objscreen.IsEnable = drScreenList.GetBoolean(drScreenList.GetOrdinal("IsEnable"));
                    objscreen.ScreenOrderId = drScreenList.GetInt32(drScreenList.GetOrdinal("ScreenOrderId"));

                    List<ScreenFunctionsBO> listScreenFuntions = new ScreenFunctionsDAL().LoadGrantedScreenFunctionsbyScreenIDandUserName(objscreen.ScreenId, userName);

                    objscreen.ScreenFunctions = new List<ScreenFunctionsBO>();
                    if (listScreenFuntions != null && listScreenFuntions.Count > 0)
                    {
                        objscreen.ScreenFunctions = listScreenFuntions;
                    }

                    screenList.Add(objscreen);

                }
                dbEgine.DBClose();

                return screenList;
            }
            catch
            {
                throw;
            }

            finally
            {
                dbEgine.DBClose();
            }
        }