Beispiel #1
0
        private void PopulateRegionsBranchesAndExecutives()
        {
            var biz  = new bizBranchRegion();
            var user = (bizUser.enGageUser)Session["USER"];

            //#region OBS

            //if (user == null)
            //{
            //    user = new bizUser.enGageUser
            //    {
            //        Branch = "Testing",
            //        DisplayName = "Test User",
            //        Region = "Testing",
            //        Role = 0,
            //        UserName = "******"
            //    };
            //}

            //#endregion OBS

            ddlRegion.Items.Clear();
            ddlBranch.Items.Clear();
            ddlExecutive.Items.Clear();

            switch (user.Role)
            {
            case (int)Enums.enUserRole.Executive:
                ddlRegion.Items.Add(new ListItem(user.Region, user.Region));
                ddlBranch.Items.Add(new ListItem(user.Branch, user.Branch));
                if (DisableExecutives == false)
                {
                    ddlExecutive.Items.Add(new ListItem(user.DisplayName, user.UserName));
                }
                else
                {
                    ddlExecutive.Items.Add(new ListItem("Executives (All)", "(All)"));
                }
                break;

            case (int)Enums.enUserRole.Branch:
                ddlRegion.Items.Add(new ListItem(user.Region, user.Region));
                ddlBranch.Items.Add(new ListItem(user.Branch, user.Branch));
                if (DisableExecutives == false)
                {
                    var bizS  = new bizSetting();
                    var execs = bizActiveDirectory.ListAccountExecutivesByBranchForDropDown(ddlBranch.SelectedValue);
                    if (execs == null)
                    {
                        return;
                    }
                    foreach (string exec in execs)
                    {
                        ddlExecutive.Items.Add(new ListItem(exec, execs[exec]));
                    }
                    SortDropDownList(ref ddlExecutive);
                }
                ddlExecutive.Items.Insert(0, new ListItem("Executives (All)", "(All)"));
                break;

            case (int)Enums.enUserRole.Region:
                ddlRegion.Items.Add(new ListItem(user.Region, user.Region));
                var bs = biz.ListBranchesByRegion(ddlRegion.SelectedValue);
                if (bs == null)
                {
                    return;
                }
                ddlBranch.Items.Add(new ListItem("Branches (All)", "(All)"));
                foreach (var b in bs)
                {
                    ddlBranch.Items.Add(new ListItem(b, b));
                }
                ddlExecutive.Items.Add(new ListItem("Executives (All)", "(All)"));
                break;

            case (int)Enums.enUserRole.Company:
            case (int)Enums.enUserRole.Administrator:
                var rs = biz.ListRegions();
                if (rs == null)
                {
                    return;
                }
                ddlRegion.Items.Add(new ListItem("Regions (All)", "(All)"));
                foreach (var r in rs)
                {
                    ddlRegion.Items.Add(new ListItem(r, r));
                }
                ddlBranch.Items.Add(new ListItem("Branches (All)", "(All)"));
                ddlExecutive.Items.Add(new ListItem("Executives (All)", "(All)"));
                break;
            }
        }
Beispiel #2
0
        public static void PopulateRegionsBranchesAndExecutives(bizUser.enGageUser user, DropDownList ddlRegion, DropDownList ddlBranch, DropDownList ddlExecutive, bool DisableExecutives, bool overrideDefaultRegion)
        {
            bizBranchRegion biz = new bizBranchRegion();

            ddlRegion.Items.Clear();
            ddlBranch.Items.Clear();
            ddlExecutive.Items.Clear();

            switch (user.Role)
            {
            case (int)Enums.enUserRole.Executive:
                ddlRegion.Items.Add(new ListItem(user.Region, user.Region));
                ddlBranch.Items.Add(new ListItem(user.Branch, user.Branch));
                if (DisableExecutives == false)
                {
                    ddlExecutive.Items.Add(new ListItem(user.DisplayName, user.UserName));
                }
                else
                {
                    ddlExecutive.Items.Add(new ListItem("Executives (All)", "(All)"));
                }
                break;

            case (int)Enums.enUserRole.Branch:
                ddlRegion.Items.Add(new ListItem(user.Region, user.Region));
                ddlBranch.Items.Add(new ListItem(user.Branch, user.Branch));
                if (DisableExecutives == false)
                {
                    using (Timeline.Capture("bizActiveDirectory.ListAccountExecutivesByBranchForDropDown", "AD"))
                    {
                        bizSetting          bizS  = new bizSetting();
                        NameValueCollection execs = bizActiveDirectory.ListAccountExecutivesByBranchForDropDown(ddlBranch.SelectedValue);
                        if (execs == null)
                        {
                            return;
                        }
                        foreach (String exec in execs)
                        {
                            ddlExecutive.Items.Add(new ListItem(exec, execs[exec]));
                        }
                        SortDropDownList(ref ddlExecutive);
                    }
                }

                ddlExecutive.Items.Insert(0, new ListItem("Executives (All)", "(All)"));
                break;

            case (int)Enums.enUserRole.Region:
                ddlRegion.Items.Add(new ListItem(user.Region, user.Region));
                List <String> bs = biz.ListBranchesByRegion(ddlRegion.SelectedValue);
                if (bs == null)
                {
                    return;
                }
                ddlBranch.Items.Add(new ListItem("Branches (All)", "(All)"));
                foreach (String b in bs)
                {
                    ddlBranch.Items.Add(new ListItem(b, b));
                }
                ddlExecutive.Items.Add(new ListItem("Executives (All)", "(All)"));
                break;

            case (int)Enums.enUserRole.Company:
            case (int)Enums.enUserRole.Administrator:
                List <String> rs = biz.ListRegions();
                if (rs == null)
                {
                    return;
                }
                ddlRegion.Items.Add(new ListItem("Regions (All)", "(All)"));
                foreach (String r in rs)
                {
                    ddlRegion.Items.Add(new ListItem(r, r));
                }
                ddlBranch.Items.Add(new ListItem("Branches (All)", "(All)"));
                ddlExecutive.Items.Add(new ListItem("Executives (All)", "(All)"));

                if (overrideDefaultRegion)
                {
                    ddlRegion.SelectedValue = user.Region;
                    ddlRegion.Items.RemoveAt(0);
                }

                break;
            }
        }