コード例 #1
0
        public List <UserRoleRights> GetUserModuleMenu(string UserID, int MainMenuID, string _commandText)
        {
            List <UserRoleRights> objUsers = new List <UserRoleRights>();

            try
            {
                using (DbCommand command = _db.GetStoredProcCommand(_commandText))
                {
                    using (DbConnection connection = _db.CreateConnection())
                    {
                        connection.Open();
                        command.Connection = connection;

                        var parameter = command.CreateParameter();
                        parameter.ParameterName = "@UserID";
                        parameter.Value         = UserID;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@ModuleID";
                        parameter.Value         = MainMenuID;
                        command.Parameters.Add(parameter);

                        using (IDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                UserRoleRights newItem = new UserRoleRights();
                                newItem.UserId         = Convert.ToInt64(reader["UserId"]);
                                newItem.RoleName       = reader["RoleName"].ToString();
                                newItem.RightName      = reader["RightName"].ToString();
                                newItem.RoleID         = Convert.ToInt64(reader["RoleId"]);
                                newItem.MenuName       = reader["RightName"].ToString();
                                newItem.ParentMenuName = reader["ParentMenuName"].ToString();
                                newItem.MenuID         = Convert.ToInt64(reader["MenuID"]);
                                newItem.ParentMenuID   = Convert.ToInt32(reader["ParentID"]);
                                newItem.NavigateURL    = reader["NavigateURL"].ToString();
                                newItem.NavigateMenu   = reader["NavigateMenu"].ToString();
                                objUsers.Add(newItem);
                            }
                        }
                        connection.Close();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(objUsers);
        }
コード例 #2
0
        public List <UserRoleRights> GetUserMenuPermission(string UserID, int MainMenuID, string _commandText)
        {
            List <UserRoleRights> objUsers = new List <UserRoleRights>();

            try
            {
                using (DbCommand command = _db.GetStoredProcCommand(_commandText))
                {
                    using (DbConnection connection = _db.CreateConnection())
                    {
                        connection.Open();
                        command.Connection = connection;

                        var parameter = command.CreateParameter();
                        parameter.ParameterName = "@UserEmail";
                        parameter.Value         = UserID;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@MainMenuID";
                        parameter.Value         = MainMenuID;
                        command.Parameters.Add(parameter);

                        using (IDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                UserRoleRights newItem = new UserRoleRights();
                                newItem.UserId         = Convert.ToInt64(reader["UserId"]);
                                newItem.FirstName      = reader["FirstName"].ToString();
                                newItem.RoleName       = reader["RoleName"].ToString();
                                newItem.RightName      = reader["RightName"].ToString();
                                newItem.Email          = reader["Email"].ToString();
                                newItem.RoleID         = Convert.ToInt64(reader["RoleId"]);
                                newItem.MenuName       = reader["RightName"].ToString();
                                newItem.ParentMenuName = reader["ParentMenuName"].ToString();
                                newItem.MenuID         = Convert.ToInt64(reader["MenuID"]);
                                newItem.ParentMenuID   = Convert.ToInt32(reader["ParentID"]);
                                newItem.NavigateURL    = reader["NavigateURL"].ToString();
                                newItem.NavigateMenu   = reader["NavigateMenu"].ToString();

                                //newItem.UserId = reader.GetInt32(0);
                                //newItem.FirstName = reader.GetString(1);
                                //newItem.RoleName = reader.GetString(2);
                                //newItem.RightName = reader.GetString(3);
                                //newItem.Email = reader.GetString(4);
                                //newItem.RoleID = reader.GetInt32(5);
                                //newItem.MenuName = reader.GetString(6);
                                //newItem.MenuID = reader.GetInt32(7);

                                HttpContext.Current.Session["userid"] = Convert.ToString(reader["UserId"]);
                                objUsers.Add(newItem);
                            }
                        }
                        connection.Close();
                    }
                }
            }
            catch (Exception)
            {
            }

            return(objUsers);
        }