protected void ButtonRemoveMultiCountyDistricts_OnClick(object sender, EventArgs e) { switch (RemoveMultiCountyDistrictsReloading.Value) { case "reloading": { RemoveMultiCountyDistrictsReloading.Value = Empty; _RemoveMultiCountyDistrictsTabInfo.ClearValidationErrors(); var items = FormatMultiCountyLocalsList(LocalDistricts.GetLocalsForRemove(StateCode, CountyCode)); PopulateDistrictsToRemoveDropdown(items); _RemoveMultiCountyDistrictsTabInfo.LoadControls(); FeedbackRemoveMultiCountyDistricts.AddInfo("Remove Multi-County Districts settings loaded."); } break; case "": { try { // normal update _RemoveMultiCountyDistrictsTabInfo.ClearValidationErrors(); var localKey = ControlRemoveMultiCountyDistrictsLocalKey.GetValue(); if (IsNullOrWhiteSpace(localKey)) { throw new VoteException("No district was selected"); } var lic = LocalIdsCodes.GetDataByStateCodeLocalKey(StateCode, localKey); if (lic.Count != 1) { throw new VoteException("Missing LocalIdsCodes row"); } if (lic[0].LocalType != LocalIdsCodes.LocalTypeVote) { throw new VoteException("Invalid LocalType"); } TigerPlacesCounties.DeleteByStateCodeCountyCodeTigerCodeTigerType(StateCode, CountyCode, lic[0].LocalId, lic[0].LocalType); _RemoveMultiCountyDistrictsTabInfo.ClearValidationErrors(); var items = FormatMultiCountyLocalsList(LocalDistricts.GetLocalsForRemove(StateCode, CountyCode)); PopulateDistrictsToRemoveDropdown(items); _RemoveMultiCountyDistrictsTabInfo.LoadControls(); NavigateJurisdictionUpdatePanel.Update(); NavigateJurisdiction.Initialize(); FeedbackRemoveMultiCountyDistricts.AddInfo("Multi-County District removed."); } catch (Exception ex) { FeedbackRemoveMultiCountyDistricts.HandleException(ex); } } break; default: throw new VoteException($"Unknown reloading option: '{RemoveMultiCountyDistrictsReloading.Value}'"); } }
protected void ButtonTigerSettings_OnClick(object sender, EventArgs e) { switch (TigerSettingsReloading.Value) { case "reloading": { TigerSettingsReloading.Value = Empty; _TigerSettingsTabInfo.ClearValidationErrors(); LoadTigerControlsForTigerSettings(); FeedbackTigerSettings.AddInfo("Tiger settings loaded."); } break; case "": { try { // normal update _TigerSettingsTabInfo.ClearValidationErrors(); var tigerData = LocalIdsCodes.GetLocalData(StateCode, LocalKey).Rows.Cast <DataRow>().ToList(); PopulateTigerDistrictsForTigerSettings(tigerData, true); // phase 2 checks if (TigerChecks(out var localType, out var localIds, ControlTigerSettingsEntireCounty, ControlTigerSettingsTigerDistrict, ControlTigerSettingsTigerPlace, ControlTigerSettingsSchoolDistrict, ControlTigerSettingsCouncilDistrict, ControlTigerSettingsSupervisorsDistrict, FeedbackTigerSettings)) { return; } // delete TigerPlacesCounties row if type Vote -- these are not intrinsically tied // to county(s) var localIdsCodes = LocalIdsCodes.GetDataByStateCodeLocalKey(StateCode, LocalKey); Debug.Assert(localIdsCodes.Count == 1); if (localIdsCodes[0].LocalType == LocalIdsCodes.LocalTypeVote) { TigerPlacesCounties.DeleteByStateCodeCountyCodeTigerCodeTigerType(StateCode, CountyCode, localIdsCodes[0].LocalId, LocalIdsCodes.LocalTypeVote); } // delete existing LocalIdsCodes.DeleteByStateCodeLocalKey(StateCode, LocalKey); // add new foreach (var localId in localIds) { LocalIdsCodes.Insert(StateCode, localType, localId, LocalKey); if (localType == LocalIdsCodes.LocalTypeVote) { TigerPlacesCounties.Insert(StateCode, CountyCode, localId, TigerPlacesCounties.TigerTypeVote); } } LoadTigerControlsForTigerSettings(); FeedbackTigerSettings.AddInfo("Tiger Settings changed."); } catch (Exception ex) { FeedbackTigerSettings.HandleException(ex); } } break; default: throw new VoteException($"Unknown reloading option: '{TigerSettingsReloading.Value}'"); } }