protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ViewState["s_d"]   = String.Empty;
            ViewState["s_f"]   = "client";
            ViewState["is_ff"] = Util.IsBrowser(this, "Firefox");
            ViewState["edit"]  = RoleAdapter.IsUserInRole("db_MediaSalesEdit");

            imbtn_new_sale.Visible = (bool)ViewState["edit"];
            Util.MakeYearDropDown(dd_year, 2011);
            Util.MakeOfficeDropDown(dd_office, false, false);
            TerritoryLimit();
            rts_status.SelectedIndex = 0;

            BindSales(null, null);
        }
        SetBrowserSpecifics();

        // Rebind invoiced sales when sorting/exporting
        if ((Request["__EVENTARGUMENT"] != null && rts_status.SelectedTab.Text == "Approved" && Request["__EVENTARGUMENT"].ToString().Contains("Sort")) ||
            (Request["__EVENTTARGET"] != null && Request["__EVENTTARGET"].ToString().Contains("dd_snow")))
        {
            BindSales(null, null);
        }

        AppendStatusUpdatesToLog();
        ScrollLog();
    }
 public RoleService(IUnitOfWork unitOfWork, RoleBuilder roleBuilder, RoleAdapter roleAdapter, RoleBusinessRules roleBusinessRules)
 {
     this.unitOfWork        = unitOfWork;
     this.roleBuilder       = roleBuilder;
     this.roleAdapter       = roleAdapter;
     this.roleBusinessRules = roleBusinessRules;
 }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["ent_id"] != null && !String.IsNullOrEmpty(Request.QueryString["ent_id"]) &&
                Request.QueryString["t"] != null && !String.IsNullOrEmpty(Request.QueryString["t"]) &&
                Request.QueryString["sb_id"] != null && !String.IsNullOrEmpty(Request.QueryString["sb_id"]))
            {
                hf_ent_id.Value      = Request.QueryString["ent_id"];
                hf_office.Value      = Request.QueryString["t"];
                hf_old_book_id.Value = Request.QueryString["sb_id"];

                Util.MakeOfficeDropDown(dd_office_list, false, true);
                if (dd_office_list.Items.IndexOf(dd_office_list.Items.FindByText(hf_office.Value)) != -1)
                {
                    dd_office_list.SelectedIndex = dd_office_list.Items.IndexOf(dd_office_list.Items.FindByText(hf_office.Value));
                }
                if (!RoleAdapter.IsUserInRole("db_Admin") && !RoleAdapter.IsUserInRole("db_HoS"))
                {
                    dd_office_list.Enabled = false;
                }

                SetSaleInfo();
                SetDestinationBooks(null, null);
            }
            else
            {
                Util.PageMessage(this, "There was an error getting the sale information. Please close this window and retry.");
            }
        }
    }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String UserIP       = HttpContext.Current.Request.UserHostAddress.ToString();
            bool   IsRestricted = !Util.office_ips.Contains(UserIP);
            if (IsRestricted)
            {
                Response.Redirect("~/default.aspx");
            }

            bool IsAdmin = RoleAdapter.IsUserInRole("db_Admin");
            ViewState["IsAdmin"]    = IsAdmin;
            div_admin_panel.Visible = IsAdmin;

            // Set up region (if no region specified we use Norwich)
            if (Request.QueryString["r"] != null && !String.IsNullOrEmpty(Request.QueryString["r"]))
            {
                String Region = Request.QueryString["r"].ToLower();
                if (Region == "us" || Region == "us" || Region.Contains("america"))
                {
                    hf_region.Value = "Americas";
                }
            }

            BindLeaderboard(null, null);
        }
    }
Exemple #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!User.Identity.IsAuthenticated)
            {
                Response.Redirect("~/login.aspx?ReturnUrl=dashboard/smartsocial/analytics.aspx");
            }

            bool has_permission = RoleAdapter.IsUserInRole("db_SmartSocialAnalytics");
            if (has_permission)
            {
                div_main.Visible = true;
                BindAnalytics();

                if (!User.Identity.Name.Contains("pickering"))
                {
                    Util.WriteLogWithDetails("Viewing SMARTsocial analytics.", "smartsocialanalytics_log");
                }
            }
            else
            {
                Util.PageMessageAlertify(this, "You do not have permissions to view stats on this page!", "Uh-oh");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Set args
            if (Request.QueryString["off"] != null && !String.IsNullOrEmpty(Request.QueryString["off"]) &&
                Request.QueryString["lisd"] != null && !String.IsNullOrEmpty(Request.QueryString["lisd"]) &&
                Request.QueryString["lid"] != null && !String.IsNullOrEmpty(Request.QueryString["lid"]) &&
                Request.QueryString["iss"] != null && !String.IsNullOrEmpty(Request.QueryString["iss"]))
            {
                hf_office.Value     = Request.QueryString["off"];
                hf_lisd.Value       = Request.QueryString["lisd"];
                hf_lid.Value        = Request.QueryString["lid"];
                hf_issue_name.Value = Request.QueryString["iss"];

                Util.MakeOfficeDropDown(dd_new_office, false, false);
                if (dd_new_office.Items.IndexOf(dd_new_office.Items.FindByText(hf_office.Value)) != -1)
                {
                    dd_new_office.SelectedIndex = dd_new_office.Items.IndexOf(dd_new_office.Items.FindByText(hf_office.Value));
                }
                if (!RoleAdapter.IsUserInRole("db_Admin") && !RoleAdapter.IsUserInRole("db_HoS"))
                {
                    dd_new_office.Enabled = false;
                }

                BindDestinationIssues(null, null);
            }
            else
            {
                Util.PageMessage(this, "An error occured, please close this window and try again.");
            }
        }
    }
Exemple #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SetTerritories();
            String territory = Util.GetUserTerritory();
            if (RoleAdapter.IsUserInRole("db_8-WeekReportTL"))
            {
                TerritoryLimit(tabstrip);
            }

            for (int i = 0; i < tabstrip.Tabs.Count; i++)
            {
                if (territory == tabstrip.Tabs[i].Text)
                {
                    tabstrip.SelectedIndex = i;
                    break;
                }
            }
            for (int i = 0; i < 61; i++)
            {
                if (i < 11)
                {
                    dd_hours.Items.Insert(i, i.ToString());
                }
                dd_minutes.Items.Insert(i, i.ToString());
            }
            SetWeeks();
        }
        lbl_mailto.Text = "This report will be sent to the following addresses:<br/>" +
                          "[email protected]<br/>This report will also be sent to any HoS for this territory.";

        BindGrids();
    }
Exemple #8
0
    private void BindDestinationTeams()
    {
        bool is_territory_limited = RoleAdapter.IsUserInRole("db_ProspectReportsTL");

        DataTable dt_offices     = Util.GetOffices(false, false);
        ArrayList pn             = new ArrayList();
        ArrayList pv             = new ArrayList();
        String    office_in_expr = String.Empty;

        for (int i = 0; i < dt_offices.Rows.Count; i++)
        {
            bool   eligable = true;
            String office   = dt_offices.Rows[i]["office"].ToString();

            if (is_territory_limited && !RoleAdapter.IsUserInRole("db_ProspectReportsTL" + office.Replace(" ", String.Empty)))
            {
                eligable = false;
            }

            if (eligable)
            {
                String param = "@o" + (pn.Count + 1);
                pn.Add(param);
                pv.Add(office);
                office_in_expr += (param + ",");
            }
        }
        if (office_in_expr == String.Empty)
        {
            office_in_expr = "''";
        }
        else if (office_in_expr.EndsWith(","))
        {
            office_in_expr = office_in_expr.Substring(0, office_in_expr.Length - 1);
        }

        String qry = "SELECT team_id, CONCAT(db_ccateams.office,' - ',db_ccateams.team_name) as 'team_name' " +
                     "FROM db_ccateams, db_dashboardoffices " +
                     "WHERE db_ccateams.office=db_dashboardoffices.office " +
                     "AND closed=0 " +
                     "AND db_ccateams.office IN (" + office_in_expr + ") " +
                     "AND db_ccateams.office != 'None' " +
                     "ORDER BY db_ccateams.office";
        DataTable dt_teams = SQL.SelectDataTable(qry, (String[])pn.ToArray(typeof(string)), (Object[])pv.ToArray(typeof(object)));

        dd_destination.DataSource     = dt_teams;
        dd_destination.DataTextField  = "team_name";
        dd_destination.DataValueField = "team_id";
        dd_destination.DataBind();

        // Make sure we select the user's default
        for (int i = 0; i < dd_destination.Items.Count; i++)
        {
            if (dd_destination.Items[i].Value == hf_team_id.Value)
            {
                dd_destination.Items[i].Selected = true;
                break;
            }
        }
    }
Exemple #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Util.AlignRadDatePicker(dp_list_out);
            if (!Util.IsBrowser(this, "IE"))
            {
                tbl_main.Style.Add("position", "relative; top:10px;");
            }
            else
            {
                rfd.Visible = false;
            }

            lb_perm_delete.Visible = RoleAdapter.IsUserInRole("db_ListDistributionDelete");

            // Set args
            if (Request.QueryString["off"] != null && !String.IsNullOrEmpty(Request.QueryString["off"]) &&
                Request.QueryString["lid"] != null && !String.IsNullOrEmpty(Request.QueryString["lid"]))
            {
                hf_office.Value  = Request.QueryString["off"];
                hf_list_id.Value = Request.QueryString["lid"];

                SetEditMode();
                BindRepNames();
                BindListInfo();
            }
            else
            {
                Util.PageMessage(this, "There was a problem getting the list information. Please close this window and retry.");
            }
        }
    }
Exemple #10
0
 protected void BindReps()
 {
     Util.MakeOfficeCCASDropDown(dd_rep, hf_office.Value, true, false, hf_team_id.Value, true);
     if (RoleAdapter.IsUserInRole("db_CCA"))
     {
         dd_rep.Enabled = false;
     }
 }
Exemple #11
0
    protected void BindData(object sender, EventArgs e)
    {
        // Get offices
        DataTable dt_offices = Util.GetOffices(false, false);

        rep_gv.DataSource = dt_offices;
        rep_gv.DataBind();

        BindGroupSummary();

        bool editable = RoleAdapter.IsUserInRole("db_Admin") || RoleAdapter.IsUserInRole("db_Finance");

        if (!editable)
        {
            List <Control> textboxes = new List <Control>();
            Util.GetAllControlsOfTypeInContainer(div_container, ref textboxes, typeof(TextBox));
            foreach (TextBox t in textboxes)
            {
                t.Enabled = false;
            }

            List <Control> buttons = new List <Control>();
            Util.GetAllControlsOfTypeInContainer(div_container, ref buttons, typeof(Button));
            foreach (Button b in buttons)
            {
                b.Enabled = false;
            }

            // Enable for HoS for their office
            bool is_hos = RoleAdapter.IsUserInRole("db_HoS");
            if (is_hos)
            {
                String         user_office = Util.GetUserTerritory();
                List <Control> gvs         = new List <Control>();
                Util.GetAllControlsOfTypeInContainer(div_container, ref gvs, typeof(GridView));
                foreach (GridView gv in gvs)
                {
                    if (gv.ToolTip == user_office)
                    {
                        textboxes = new List <Control>();
                        Util.GetAllControlsOfTypeInContainer(gv, ref textboxes, typeof(TextBox));
                        foreach (TextBox t in textboxes)
                        {
                            t.Enabled = true;
                        }

                        buttons = new List <Control>();
                        Util.GetAllControlsOfTypeInContainer(gv, ref buttons, typeof(Button));
                        foreach (Button b in buttons)
                        {
                            b.Enabled = true;
                        }
                    }
                }
            }
        }
    }
 protected void SetTeamDropDowns()
 {
     Util.MakeOfficeCCASDropDown(dd_NewRep, hf_office.Value, false, false, hf_team_id.Value, true);
     if (RoleAdapter.IsUserInRole("db_CCA"))
     {
         dd_NewRep.Items.Insert(0, new ListItem(Util.GetUserFriendlyname()));
         dd_NewRep.Enabled       = false;
         dd_NewRep.SelectedIndex = 0;
     }
 }
Exemple #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         bool has_permission = RoleAdapter.IsUserInRole("db_Admin") && User.Identity.Name == "jpickering";
         if (!has_permission)
         {
             Util.PageMessageAlertify(this, "You do not have permissions to view info on this page!", "Uh-oh");
             div_container.Visible = false;
         }
     }
 }
Exemple #14
0
        public override void OnItemsLoad(CancellationToken token)
        {
            _adapter = new RoleAdapter(Context, RoleManager);
            _adapter.IOnClickListener = this;

            ItemList.SetAdapter(_adapter);

            Task.Run(async() =>
            {
                await GetItems(token);
            }, token);
        }
Exemple #15
0
 // Other
 protected void TerritoryLimit(RadTabStrip ts)
 {
     ts.Enabled = true;
     for (int i = 0; i < ts.Tabs.Count; i++)
     {
         if (!RoleAdapter.IsUserInRole("db_8-WeekReportTL" + ts.Tabs[i].Text.Replace(" ", "")))
         {
             ts.Tabs.RemoveAt(i);
             i--;
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Util.MakeOfficeDropDown(dd_office, false, true);
            dd_office.SelectedIndex = dd_office.Items.IndexOf(dd_office.Items.FindByText(Util.GetUserTerritory()));
            dd_office.Items.Insert(0, new ListItem("Group"));

            bool AllowExport = RoleAdapter.IsUserInRole("db_FinanceSalesExport");
            btn_export.Enabled          = AllowExport;
            lbl_export_disabled.Visible = !AllowExport;
        }
    }
 protected void TerritoryLimit(DropDownList dd)
 {
     if (RoleAdapter.IsUserInRole("db_SalesBookTL"))
     {
         for (int i = 0; i < dd.Items.Count; i++)
         {
             if (!RoleAdapter.IsUserInRole("db_SalesBookTL" + dd.Items[i].Text.Replace(" ", "")))
             {
                 dd.Items.RemoveAt(i);
                 i--;
             }
         }
     }
 }
Exemple #18
0
    protected void Load()
    {
        if (RoleAdapter.IsUserInRole("db_Admin"))
        {
            tbl_bonus.Visible = true;
            BindBonusDropDowns();
        }
        else
        {
            tbl_bonus.Visible = false;
        }

        BindCompetitions();
    }
Exemple #19
0
    protected void TerritoryLimit(DropDownList dd)
    {
        String user_territory = Util.GetUserTerritory();

        for (int i = 0; i < dd_new_region.Items.Count; i++)
        {
            String this_territory = dd_new_region.Items[i].Value;
            if (this_territory.Contains("/"))
            {
                if (this_territory.Contains("Boston") && (user_territory == "Boston" || user_territory == "Canada" || user_territory.Contains("Coast"))) // For north America
                {
                    dd_new_region.SelectedIndex = i;
                }
                else if (this_territory.Contains("Africa") && Util.IsOfficeUK(user_territory)) // for Norwich
                {
                    dd_new_region.SelectedIndex = i;
                }
            }
            else if (user_territory == this_territory)
            {
                dd_new_region.SelectedIndex = i;
            }

            if (RoleAdapter.IsUserInRole("db_EditorialTrackerTL"))
            {
                if (this_territory.Contains("/"))
                {
                    if (this_territory.Contains("Boston") &&
                        !RoleAdapter.IsUserInRole("db_EditorialTrackerTLCanada") && !RoleAdapter.IsUserInRole("db_EditorialTrackerTLBoston") &&
                        !RoleAdapter.IsUserInRole("db_EditorialTrackerTLEastCoast") && !RoleAdapter.IsUserInRole("db_EditorialTrackerTLWestCoast") &&
                        !RoleAdapter.IsUserInRole("db_EditorialTrackerTLUSA"))
                    {
                        dd_new_region.Items.RemoveAt(i);
                        i--;
                    }
                    else if (this_territory.Contains("Africa") && !RoleAdapter.IsUserInRole("db_EditorialTrackerTLAfrica") &&
                             !RoleAdapter.IsUserInRole("db_EditorialTrackerTLEurope") && !RoleAdapter.IsUserInRole("db_EditorialTrackerTLMiddleEast") && !RoleAdapter.IsUserInRole("db_EditorialTrackerTLAsia"))
                    {
                        dd_new_region.Items.RemoveAt(i);
                        i--;
                    }
                }
                else if (!RoleAdapter.IsUserInRole("db_EditorialTrackerTL" + this_territory.Replace(" ", "")))
                {
                    dd_new_region.Items.RemoveAt(i);
                    i--;
                }
            }
        }
    }
Exemple #20
0
    protected void RemoveUserFromAllTemplateRoles(String username)
    {
        if (RoleAdapter.IsUserInRole(username, "db_Custom"))
        {
            RoleAdapter.RemoveUserFromRole(username, "db_Custom");
        }

        // Ensure Admin always stays admin when editing their own permissions
        if (!(RoleAdapter.IsUserInRole("db_Admin") && dd_user.SelectedItem.Text == User.Identity.Name) || User.Identity.Name == "jpickering")
        {
            if (RoleAdapter.IsUserInRole(username, "db_Admin"))
            {
                RoleAdapter.RemoveUserFromRole(username, "db_Admin");
            }
        }
        if (RoleAdapter.IsUserInRole(username, "db_HoS"))
        {
            RoleAdapter.RemoveUserFromRole(username, "db_HoS");
        }
        if (RoleAdapter.IsUserInRole(username, "db_TeamLeader"))
        {
            RoleAdapter.RemoveUserFromRole(username, "db_TeamLeader");
        }
        if (RoleAdapter.IsUserInRole(username, "db_Finance"))
        {
            RoleAdapter.RemoveUserFromRole(username, "db_Finance");
        }
        if (RoleAdapter.IsUserInRole(username, "db_GroupUser"))
        {
            RoleAdapter.RemoveUserFromRole(username, "db_GroupUser");
        }
        if (RoleAdapter.IsUserInRole(username, "db_User"))
        {
            RoleAdapter.RemoveUserFromRole(username, "db_User");
        }
        if (RoleAdapter.IsUserInRole(username, "db_CCA"))
        {
            RoleAdapter.RemoveUserFromRole(username, "db_CCA");
        }

        if (RoleAdapter.IsUserInRole(username, "db_SalesBookOfficeAdmin"))
        {
            RoleAdapter.RemoveUserFromRole(username, "db_SalesBookOfficeAdmin");
        }
        if (RoleAdapter.IsUserInRole(username, "db_SalesBookDesign"))
        {
            RoleAdapter.RemoveUserFromRole(username, "db_SalesBookDesign");
        }
    }
 // Misc
 protected void TerritoryLimit(DropDownList dd)
 {
     dd.Enabled = true;
     if (RoleAdapter.IsUserInRole("db_ProgressReportTL"))
     {
         for (int i = 0; i < dd.Items.Count; i++)
         {
             if (!RoleAdapter.IsUserInRole("db_ProgressReportTL" + dd.Items[i].Text.Replace(" ", String.Empty)))
             {
                 dd.Items.RemoveAt(i);
                 i--;
             }
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!RoleAdapter.IsUserInRole("db_CommissionFormsL3"))
     {
         btn_update_defaults.Visible = false;
     }
     else
     {
         if (!IsPostBack)
         {
             Util.MakeOfficeDropDown(dd_office, false, false);
             BindOfficeDefaultRules(String.Empty, null);
         }
     }
 }
Exemple #23
0
 protected void TerritoryLimit()
 {
     for (int i = 0; i < repeater_terHls.Items.Count; i++)
     {
         HyperLink x = repeater_terHls.Items[i].Controls[1] as HyperLink;
         if (!RoleAdapter.IsUserInRole("db_ProgressReportOutputTL" + x.Text.Replace(" ", String.Empty)))
         {
             x.Visible = false;
             if (x.Text == (String)ViewState["territory"])
             {
                 Response.Redirect("~/dashboard/homehub/homehub.aspx");
             }
         }
     }
 }
Exemple #24
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         bool has_permission = RoleAdapter.IsUserInRole("db_LeadsAnalytics");
         if (has_permission)
         {
             BindAppointments();
         }
         else
         {
             Util.PageMessageAlertify(this, "You do not have permissions to view stats on this page!", "Uh-oh");
         }
     }
 }
    protected String GetTeamTerritory(int teamID)
    {
        String    qry       = "SELECT Office FROM db_ccateams WHERE TeamID=@team_id";
        DataTable dt_office = SQL.SelectDataTable(qry, "@team_id", teamID);

        if (RoleAdapter.IsUserInRole("db_ProgressReportOutputTL") && !RoleAdapter.IsUserInRole("db_ProgressReportOutputTL" + dt_office.Rows[0]["Office"].ToString().Replace(" ", "")))
        {
            return(String.Empty);
        }
        else if (dt_office.Rows.Count > 0 && dt_office.Rows[0]["Office"] != DBNull.Value)
        {
            return(dt_office.Rows[0]["Office"].ToString());
        }

        return(String.Empty);
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (RoleAdapter.IsUserInRole("db_Admin") || RoleAdapter.IsUserInRole("db_Finance"))
         {
             BindIssues();
             BindGroupStats(null, null);
         }
         else
         {
             Util.PageMessage(this, "Sorry, you don't have permissions to view group stats.");
             Util.CloseRadWindow(this, String.Empty, false);
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         bool has_permission = RoleAdapter.IsUserInRole("db_Admin") || RoleAdapter.IsUserInRole("db_HoS");
         if (has_permission)
         {
             BindTab();
         }
         else
         {
             Util.PageMessageAlertify(this, "You do not have permissions to view info on this page!", "Uh-oh");
             div_container.Visible = false;
         }
     }
 }
Exemple #28
0
    protected void TerritoryLimit(DropDownList dd)
    {
        String user_ter      = Util.GetUserTerritory();
        bool   is_restricted = RoleAdapter.IsUserInRole("db_ListDistributionTL");

        for (int i = 0; i < dd.Items.Count; i++)
        {
            if (is_restricted && !RoleAdapter.IsUserInRole("db_ListDistributionTL" + dd.Items[i].Text.Replace(" ", "")))
            {
                dd.Items.RemoveAt(i);
                i--;
            }
            else if (dd.Items[i].Text == user_ter)
            {
                dd.Items[i].Selected = true;
            }
        }
    }
    protected void BindOffices()
    {
        div_toggle_office.Controls.Clear();
        String    qry        = "SELECT * FROM db_dashboardoffices WHERE Closed=0 AND Region=@region";
        DataTable dt_offices = SQL.SelectDataTable(qry, "@region", hf_region.Value);

        for (int i = 0; i < dt_offices.Rows.Count; i++)
        {
            if (dt_offices.Rows[i]["Region"].ToString() == hf_region.Value)
            {
                LinkButton l = new LinkButton();
                l.Enabled   = _Enabled;
                l.Click    += new EventHandler(ToggleOffice);
                l.ForeColor = System.Drawing.Color.Silver;
                l.Text      = dt_offices.Rows[i]["Office"].ToString();
                l.ID        = dt_offices.Rows[i]["Office"].ToString().Replace(" ", String.Empty);
                if (i < dt_offices.Rows.Count - 1)
                {
                    l.Attributes.Add("style", "border-right:solid 1px gray; margin-right:3px; padding-right:4px; position:relative; left:" + Left + "px; top:" + Top + "px;");
                }
                else
                {
                    l.Attributes.Add("style", "position:relative; left:" + Left + "px; top:" + Top + "px;");
                }
                div_toggle_office.Controls.Add(l);
            }
        }

        if (IncludeRegionalGroup && dt_offices.Rows.Count > 0 && (hf_region.Value == "US" || hf_region.Value == "UK") &&
            (RoleAdapter.IsUserInRole("db_Admin") || RoleAdapter.IsUserInRole("db_HoS") || RoleAdapter.IsUserInRole("db_Finance")))
        {
            LinkButton l = new LinkButton();
            l.Enabled   = _Enabled;
            l.Click    += new EventHandler(ToggleOffice);
            l.ForeColor = System.Drawing.Color.Silver;
            l.Text      = "Americas";
            if (hf_region.Value == "UK")
            {
                l.Text = "EMEA";
            }
            l.Attributes.Add("style", "border-left:solid 1px gray; margin-left:3px; padding-left:4px; position:relative; left:" + Left + "px; top:" + Top + "px;");
            div_toggle_office.Controls.Add(l);
        }
    }
    protected void TerritoryLimit(DropDownList dd)
    {
        if (RoleAdapter.IsUserInRole("db_EditorialTrackerTL"))
        {
            String user_territory = Util.GetUserTerritory();
            for (int i = 0; i < dd.Items.Count; i++)
            {
                String this_territory = dd.Items[i].Text.Substring(0, dd.Items[i].Text.IndexOf("-") - 1);
                if (this_territory == "North America") // do Boston/Canada
                {
                    if (!RoleAdapter.IsUserInRole("db_EditorialTrackerTLCanada") && !RoleAdapter.IsUserInRole("db_EditorialTrackerTLBoston") &&
                        !RoleAdapter.IsUserInRole("db_EditorialTrackerTLWestCoast") && !RoleAdapter.IsUserInRole("db_EditorialTrackerTLEastCoast") &&
                        !RoleAdapter.IsUserInRole("db_EditorialTrackerTLUSA"))
                    {
                        dd.Items.RemoveAt(i);
                        i--;
                    }
                }
                else if (this_territory == "Norwich") // do Norwich/Eur/Afr/MEast/Asia
                {
                    if (!RoleAdapter.IsUserInRole("db_EditorialTrackerTLAfrica") && !RoleAdapter.IsUserInRole("db_EditorialTrackerTLEurope") &&
                        !RoleAdapter.IsUserInRole("db_EditorialTrackerTLMiddleEast") && !RoleAdapter.IsUserInRole("db_EditorialTrackerTLAsia"))
                    {
                        dd.Items.RemoveAt(i);
                        i--;
                    }
                }
                else
                {
                    if (!RoleAdapter.IsUserInRole("db_EditorialTrackerTL" + this_territory.Replace(" ", "")))
                    {
                        dd.Items.RemoveAt(i);
                        i--;
                    }
                }
            }

            if (dd.Items.Count == 0)
            {
                Util.PageMessage(this, "No destination issues found.");
            }
        }
    }