Esempio n. 1
0
        protected void CheckBoxListOfficeClassAllIdentified_SelectedIndexChanged(
            object sender, EventArgs e)
        {
            try
            {
                // Get all OfficesAllIdentified rows for the jurisdiction and make a
                // dictionary of only the true values
                var dictionary = OfficesAllIdentified.GetDataByStateCode(StateCode,
                                                                         CountyCode, LocalCode)
                                 .Where(row => row.IsOfficesAllIdentified)
                                 .ToDictionary(row => row.OfficeLevel.ToOfficeClass(),
                                               row => null as object);

                // now get any items that don't match the dictionary
                var items = CheckBoxListOfficeClassAllIdentified.Items.OfType <ListItem>()
                            .Where(
                    item =>
                    dictionary.ContainsKey(Offices.GetValidatedOfficeClass(item.Value)) !=
                    item.Selected);

                // should only be one item, but we'll loop just in case...
                Msg.Text = string.Empty;
                var regenerateReport = GetSelectedOfficeClass() == OfficeClass.All;
                foreach (var item in items)
                {
                    var officeClass = Offices.GetValidatedOfficeClass(item.Value);
                    if (OfficesAllIdentified.StateCodeOfficeLevelCountyCodeLocalCodeExists(
                            StateCode, officeClass.ToInt(), CountyCode, LocalCode))
                    {
                        OfficesAllIdentified.UpdateIsOfficesAllIdentified(item.Selected,
                                                                          StateCode, officeClass.ToInt(), CountyCode, LocalCode);
                    }
                    else if (item.Selected)
                    {
                        OfficesAllIdentified.Insert(StateCode, CountyCode, LocalCode,
                                                    officeClass.ToInt(), true);
                    }
                    var officeDesc = GetOfficeClassDescription(officeClass, true);
                    Msg.Text += item.Selected
            ? Ok(officeDesc +
                 " was changed to PROHIBIT the addition of offices.")
            : Ok(officeDesc + " was changed to ALLOW the addition of offices.");
                    if (officeClass == GetSelectedOfficeClass())
                    {
                        regenerateReport = true;
                    }
                }
                if (regenerateReport)
                {
                    GenerateReport();
                    UpdatePanel.Update();
                }
            }
            catch (Exception ex)
            {
                Msg.Text = Fail(ex.Message);
                LogException("CheckBoxListOfficeClassAllIdentified_SelectedIndexChanged",
                             ex);
            }
        }
Esempio n. 2
0
        private void UpdateLockedClasses()
        {
            // Get all OfficesAllIdentified rows for the state and make a dictionary of
            // only the true values
            var dictionary = OfficesAllIdentified.GetDataByStateCode(StateCode)
                             .Where(row => row.IsOfficesAllIdentified)
                             .ToDictionary(row => row.OfficeLevel.ToOfficeClass(),
                                           row => null as object);

            // now get any items that don't match the dictionary
            var items = ControlMasterOnlyClassesToLock.Items.OfType <ListItem>()
                        .Where(
                item =>
                dictionary.ContainsKey(Offices.GetValidatedOfficeClass(item.Value)) !=
                item.Selected);

            foreach (var item in items)
            {
                var officeClass = Offices.GetValidatedOfficeClass(item.Value);
                OfficesAllIdentified.UpdateIsOfficesAllIdentified(item.Selected, StateCode,
                                                                  officeClass.ToInt());
            }

            FeedbackMasterOnly.AddInfo("The locked office classes were updated");
        }
Esempio n. 3
0
        public void GetData(OfficesAdminReportViewOptions options)
        {
            DataTable = OfficesAdminReportView.GetData(options);

            // Get the OfficesAllIdentified row(s) and make a dictionary of
            // only the true values
            var table = options.OfficeClass == OfficeClass.All
        ? OfficesAllIdentified.GetDataByStateCode(options.StateCode)
        : OfficesAllIdentified.GetData(options.StateCode, options.OfficeClass.ToInt());

            _AllIdentifiedDictionary = table.Where(row => row.IsOfficesAllIdentified)
                                       .ToDictionary(row => row.OfficeLevel.ToOfficeClass(), row => null as object);
        }
Esempio n. 4
0
        private void PopulateAddOfficeSelectOfficeClass()
        {
            // initial office class selection is from Query String as string ordinal
            var initialOfficeClass =
                Offices.GetValidatedOfficeClass(GetQueryString("class"));

            // iterator options
            var iteratorOptions = GetOfficeClassesOptions.None;

            switch (AdminPageLevel)
            {
            case AdminPageLevel.State:
                iteratorOptions |= GetOfficeClassesOptions.IncludeCongress |
                                   GetOfficeClassesOptions.IncludeState;
                break;

            case AdminPageLevel.County:
                iteratorOptions |= GetOfficeClassesOptions.IncludeCounty;
                break;

            case AdminPageLevel.Local:
                iteratorOptions |= GetOfficeClassesOptions.IncludeLocal;
                break;
            }

            // create an entry for each OfficeClass returned by the iterator
            AddOfficeSelectOfficeClass.Items.Clear();
            AddOfficeSelectOfficeClass.Items.Add(new ListItem
            {
                Value = string.Empty,
                Text  = "<select an office class>"
            });
            foreach (var officeClass in Offices.GetOfficeClasses(iteratorOptions))
            {
                var listItem = new ListItem
                {
                    Value    = officeClass.ToInt().ToString(CultureInfo.InvariantCulture),
                    Text     = Offices.GetOfficeClassDescription(officeClass, StateCode),
                    Selected = officeClass == initialOfficeClass
                };
                if (OfficesAllIdentified.GetIsOfficesAllIdentified(StateCode,
                                                                   officeClass.ToInt(), CountyCode, LocalCode))
                {
                    listItem.Attributes.Add("disabled", "disabled");
                }
                AddOfficeSelectOfficeClass.Items.Add(listItem);
            }
        }
Esempio n. 5
0
        private void UpdateMasterOnlyControls()
        {
            ConsolidateTable.Visible           = false;
            AddOfficeTable.Visible             = false;
            AddOfficeTableInstructions.Visible = false;

            if (!IsSuperUser)
            {
                return;
            }

            ConsolidateTable.Visible = true;

            var officeClass = GetSelectedOfficeClass();

            if ((officeClass == OfficeClass.All) || (officeClass == OfficeClass.Undefined))
            {
                return;
            }

            string formatString;

            if (
                !OfficesAllIdentified.GetIsOfficesAllIdentified(StateCode,
                                                                officeClass.ToInt(), CountyCode, LocalCode))
            {
                HyperLinkAddOffice.NavigateUrl = GetOfficePageUrl(StateCode, officeClass);
                formatString = "Add {0} Offices";
                AddOfficeTableInstructions.Visible = true;
            }
            else
            {
                HyperLinkAddOffice.NavigateUrl = string.Empty;
                formatString = "Offices can not be added for {0} Offices";
            }
            HyperLinkAddOffice.Text = string.Format(formatString,
                                                    GetOfficeClassDescription(officeClass));

            AddOfficeTable.Visible = true;
        }
Esempio n. 6
0
        private void CreateLockedOfficeClassCheckBoxes()
        {
            ControlMasterOnlyClassesToLock.Items.Clear();
            var options = StateCode == "US"
        ? GetOfficeClassesOptions.IncludeUSPresident
        : GetOfficeClassesOptions.IncludeUSHouse |
                          GetOfficeClassesOptions.IncludeState |
                          GetOfficeClassesOptions.IncludeCounty |
                          GetOfficeClassesOptions.IncludeLocal;

            foreach (var officeClass in
                     Offices.GetOfficeClasses(options))
            {
                var listItem = new ListItem();
                ControlMasterOnlyClassesToLock.Items.Add(listItem);
                var allIdentified = OfficesAllIdentified.GetIsOfficesAllIdentified(
                    StateCode, officeClass.ToInt(), CountyCode, LocalCode);
                listItem.Text  = GetOfficeClassDescription(officeClass);
                listItem.Value = officeClass.ToInt()
                                 .ToString(CultureInfo.InvariantCulture);
                listItem.Selected = allIdentified;
            }
        }
Esempio n. 7
0
        private void CreateOfficeClassAllIdentifiedCheckBoxes()
        {
            CheckBoxListOfficeClassAllIdentified.Items.Clear();

            var options = GetOfficeClassesOptions.None;

            switch (AdminPageLevel)
            {
            case AdminPageLevel.State:
                options = GetOfficeClassesOptions.IncludeUSSenate |
                          GetOfficeClassesOptions.IncludeUSHouse |
                          GetOfficeClassesOptions.IncludeState;
                break;

            case AdminPageLevel.County:
                options = GetOfficeClassesOptions.IncludeCounty;
                break;

            case AdminPageLevel.Local:
                options = GetOfficeClassesOptions.IncludeLocal;
                break;
            }

            foreach (var officeClass in
                     Offices.GetOfficeClasses(options))
            {
                var listItem = new ListItem();
                CheckBoxListOfficeClassAllIdentified.Items.Add(listItem);
                var allIdentified = OfficesAllIdentified.GetIsOfficesAllIdentified(
                    StateCode, officeClass.ToInt(), CountyCode, LocalCode);
                listItem.Text = GetOfficeClassLinkOrText(StateCode, officeClass,
                                                         allIdentified, CountyCode, LocalCode);
                listItem.Value = officeClass.ToInt()
                                 .ToString(CultureInfo.InvariantCulture);
                listItem.Selected = allIdentified;
            }
        }