private void btnSave_Click_1(object sender, EventArgs e) { if (!model.IsValid()) { errorProvider1.DataSource = bindingSource1; MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle); return; } bindingSource1.EndEdit(); SettingsRepository s = new SettingsRepository(); RepositoryBase r = new RepositoryBase(); int userid = ApplicationData.Instance.GetUserId(); if(model.EntityType != IndicatorEntityType.Export) if (model.EntityType == IndicatorEntityType.EcologicalZone) s.SaveEz(model, userid); if (model.EntityType == IndicatorEntityType.EvalSubDistrict) s.SaveEvalSubDistrict(model, userid); else if (model.EntityType == IndicatorEntityType.EvaluationUnit) s.SaveEu(model, userid); else if (model.EntityType == IndicatorEntityType.EvalSite) s.SaveEvalSite(model, userid); else r.Save(model, userid); OnSave(model); this.Close(); }
/// <summary> /// Runs the report with the report options and collects all the disease distribution calculation /// </summary> /// <param name="mainReportOptions">The report options</param> public void Run(ReportOptions mainReportOptions) { SettingsRepository settingsRepo = new SettingsRepository(); Report = new SavedReport(); DistributionReportGenerator gen = new DistributionReportGenerator(); Report.ReportOptions = new ReportOptions(); Report.ReportOptions.SelectedIndicators = new List<ReportIndicator>(); Report.ReportOptions.Years = Util.DeepClone(mainReportOptions.Years); Report.ReportOptions.SelectedAdminLevels = Util.DeepClone(mainReportOptions.SelectedAdminLevels); Report.ReportOptions.MonthYearStarts = 1; Report.ReportOptions.IsByLevelAggregation = true; Report.ReportOptions.IsCountryAggregation = false; Report.ReportOptions.IsNoAggregation = false; // Determine the name of the reporting admin level if (mainReportOptions.SelectedAdminLevels.Count > 0) { int levelNum = mainReportOptions.SelectedAdminLevels[0].LevelNumber; AdminLevelType adminLevelType = settingsRepo.GetAdminLevelTypeByLevel(levelNum); NameOfReportingAdminLevel = adminLevelType.DisplayName; } if (NameOfReportingAdminLevel == null) throw new ArgumentException("Could not determine reporting level"); // STH Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.STH, new KeyValuePair<string, Indicator>("DDSTHPopulationRequiringPc", new Indicator { Id = 141, DisplayName = "DDSTHPopulationRequiringPc" }))); Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.STH, new KeyValuePair<string, Indicator>("DDSTHPsacAtRisk", new Indicator { Id = 142, DisplayName = "DDSTHPsacAtRisk" }))); Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.STH, new KeyValuePair<string, Indicator>("DDSTHSacAtRisk", new Indicator { Id = 143, DisplayName = "DDSTHSacAtRisk" }))); Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.STH, new KeyValuePair<string, Indicator>("DDSTHPopulationAtRisk", new Indicator { Id = 140, DisplayName = "DDSTHPopulationAtRisk" }))); // LF Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Lf, new KeyValuePair<string, Indicator>("DDLFPopulationAtRisk", new Indicator { Id = 98, DisplayName = "DDLFPopulationAtRisk" }))); Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Lf, new KeyValuePair<string, Indicator>("DDLFPopulationRequiringPc", new Indicator { Id = 99, DisplayName = "DDLFPopulationRequiringPc" }))); // Oncho Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Oncho, new KeyValuePair<string, Indicator>("DDOnchoPopulationAtRisk", new Indicator { Id = 111, DisplayName = "DDOnchoPopulationAtRisk" }))); Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Oncho, new KeyValuePair<string, Indicator>("DDOnchoPopulationRequiringPc", new Indicator { Id = 112, DisplayName = "DDOnchoPopulationRequiringPc" }))); // Schisto Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Schisto, new KeyValuePair<string, Indicator>("DDSchistoPopulationAtRisk", new Indicator { Id = 125, DisplayName = "DDSchistoPopulationAtRisk" }))); Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Schisto, new KeyValuePair<string, Indicator>("DDSchistoPopulationRequiringPc", new Indicator { Id = 126, DisplayName = "DDSchistoPopulationRequiringPc" }))); Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Schisto, new KeyValuePair<string, Indicator>("DDSchistoSacAtRisk", new Indicator { Id = 127, DisplayName = "DDSchistoSacAtRisk" }))); // Trachoma Report.ReportOptions.SelectedIndicators.Add(ReportRepository.CreateReportIndicator((int)DiseaseType.Trachoma, new KeyValuePair<string, Indicator>("DDTraPopulationAtRisk", new Indicator { Id = 161, DisplayName = "DDTraPopulationAtRisk" }))); // Run the report Result = gen.Run(Report); }
public void DoNext() { SettingsRepository settings = new SettingsRepository(); var als = settings.GetAllAdminLevels(); var aggLevel = als.FirstOrDefault(a => a.IsAggregatingLevel); OnSwitchStep(new StepAdminLevelImport(aggLevel, this, true, demoDate, countryDemoId)); }
private void RtiExport_Load(object sender, EventArgs e) { if (!DesignMode) { Localizer.TranslateControl(this); lblRtiLanguage.SetMaxWidth(400); SettingsRepository repo = new SettingsRepository(); exporter = new RtiWorkbooksExporter(); exporter.StartDate = DateTime.Now.AddYears(-1); exporter.EndDate = DateTime.Now; var allLevelTypes = repo.GetAllAdminLevels(); var reportingType = allLevelTypes.First(); exporter.AdminLevelType = reportingType; bindingSource1.DataSource = allLevelTypes; cbTypes.SelectedIndex = allLevelTypes.IndexOf(reportingType); bindingSource2.DataSource = exporter; List<string> languages = ConfigurationManager.AppSettings["SupportedLanguages"].Split('|').ToList(); List<Language> langz = languages.Select(l => new Language { IsoCode = l.Split(';')[0], Name = l.Split(';')[1] }).ToList(); langz.RemoveAll(l => l.IsoCode == "id-ID"); bsLanguages.DataSource = langz; if (langz.FirstOrDefault(x => x.IsoCode == Thread.CurrentThread.CurrentCulture.Name) != null) cbLanguages.SelectedValue = Thread.CurrentThread.CurrentCulture.Name; else cbLanguages.SelectedValue = "en-US"; } }
private void AdminLevelMultiselect_Load(object sender, EventArgs e) { if (!DesignMode) { Localizer.TranslateControl(this); demography = new DemoRepository(); settings = new SettingsRepository(); levels = settings.GetAllAdminLevels(); bsLevels.DataSource = levels; cbLevels.SelectedItem = levels.FirstOrDefault(); LoadTrees(); treeAvailable.CanExpandGetter = model => ((AdminLevel)model). Children.Count > 0; treeAvailable.ChildrenGetter = delegate(object model) { return ((AdminLevel)model). Children; }; treeSelected.CanExpandGetter = model => ((AdminLevel)model). Children.Count > 0; treeSelected.ChildrenGetter = delegate(object model) { return ((AdminLevel)model). Children; }; cbLevels.DropDownWidth = BaseForm.GetDropdownWidth(levels.Select(a => a.DisplayName)); } }
//[TestMethod] public void CanCreateBaselineDatabase() { SettingsRepository repo = new SettingsRepository(); List<string> filesToRun = repo.GetSchemaChangeScripts(@"C:\Development\Nada\NadaNtd\Nada.UI\DatabaseScripts\Differentials\"); string result = repo.RunSchemaChangeScripts(filesToRun); Assert.IsTrue(result.Length == 0); }
public StepDdReview(DdUpdateViewModel v, IWizardStep p) : base() { vm = v; prev = p; SettingsRepository settings = new SettingsRepository(); stepTitle = Translations.UpdateDiseaseDistro + " - " + vm.Diseases[vm.DiseaseStepNumber].DisplayName; InitializeComponent(); }
public void DoUpdateDatabase() { SettingsRepository repo = new SettingsRepository(); //List<string> filesToRun = new List<string> { @"C:\Users\jed\Source\Repos\NadaNTD\Nada.UI\DatabaseScripts\ScriptDiffTest.sql" }; List<string> filesToRun = new List<string> { @"C:\Development\Nada\NadaNtd\Nada.UI\DatabaseScripts\ScriptDiffTest.sql" }; string result = repo.RunSchemaChangeScripts(filesToRun); Assert.IsTrue(result.Length == 0); }
private void CheckStatus() { var settings = new SettingsRepository(); var status = settings.GetStartUpStatus(); if (!status.ShouldShowStartup()) OnFinished(); tblTasks.Visible = false; this.SuspendLayout(); tblTasks.Controls.Clear(); int rowIndex = tblTasks.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); tblTasks.Controls.Add(CreateLabel("1. " + Translations.StartUpStepCountry, status.HasEnteredCountrySettings), 0, rowIndex); var ctrl = new H3Link { Text = status.HasEnteredCountrySettings ? Translations.EditLink : Translations.StartLink, Anchor = AnchorStyles.Bottom | AnchorStyles.Left, Margin = new Padding(3, 3, 3, 5), TextColor = Color.FromArgb(255, 255, 255) }; ctrl.ClickOverride += () => { LoadWiz(new StepCountrySettings(demo.GetCountry())); }; tblTasks.Controls.Add(ctrl, 1, rowIndex); rowIndex = tblTasks.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); tblTasks.Controls.Add(CreateLabel("2. " + Translations.StartUpStepDiseases, status.HasEnteredDiseaseDetails), 0, rowIndex); if (status.HasEnteredCountrySettings) { var ctrl2 = new H3Link { Text = status.HasEnteredDiseaseDetails ? Translations.EditLink : Translations.StartLink, Anchor = AnchorStyles.Bottom | AnchorStyles.Left, Margin = new Padding(3, 3, 3, 5), TextColor = Color.FromArgb(255, 255, 255) }; ctrl2.ClickOverride += () => { LoadWiz(new StepDiseases()); }; tblTasks.Controls.Add(ctrl2, 1, rowIndex); } bool hasFinishedPrevStep = status.HasEnteredDiseaseDetails; var countryDemo = demo.GetCountryDemoRecent(); int stepCount = 3; foreach (var al in status.AdminLevelTypes) { rowIndex = tblTasks.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); tblTasks.Controls.Add(CreateLabel(stepCount + ". " + Translations.StartUpStepAdminLevels + al.LevelName, al.HasEntered), 0, rowIndex); if(hasFinishedPrevStep) { var ctrl3 = new H3Link { Text = al.HasEntered ? Translations.EditLink : Translations.StartLink, Anchor = AnchorStyles.Bottom | AnchorStyles.Left, Margin = new Padding(3, 3, 3, 5), TextColor = Color.FromArgb(255, 255, 255) }; int levelNumber = al.Level - 1; ctrl3.ClickOverride += () => { LoadWiz(new StepAdminLevelImport(settings.GetNextLevel(levelNumber), null, countryDemo.Id)); }; tblTasks.Controls.Add(ctrl3, 1, rowIndex); hasFinishedPrevStep = al.HasEntered; } stepCount++; } if (ConfigurationManager.AppSettings["DeveloperMode"] == "QA") { rowIndex = tblTasks.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); var skipLink = new H3Link { Text = "Skip Start Up", Anchor = AnchorStyles.Bottom | AnchorStyles.Left, Margin = new Padding(3, 3, 3, 5), TextColor = Color.FromArgb(255, 255, 255) }; skipLink.ClickOverride += skipLink_ClickOverride; tblTasks.Controls.Add(skipLink, 0, rowIndex); } this.ResumeLayout(); tblTasks.Visible = true; }
public void LoadRelatedLists() { SettingsRepository settings = new SettingsRepository(); ezs = settings.GetEcologicalZones(); eus = settings.GetEvaluationUnits(); subdistricts = settings.GetEvalSubDistricts(); evalsites = settings.GetEvalSites(); IntvRepository repo = new IntvRepository(); partners = repo.GetPartners(); }
public void CanUpdate() { SettingsRepository repo = new SettingsRepository(); var admins = repo.GetAllAdminLevels(); var al = admins[0]; al.DisplayName = "update"; repo.Save(al, 26); var updated = repo.GetAllAdminLevels(); Assert.AreEqual(al.DisplayName, updated[0].DisplayName); }
public void DoFinish() { var selected = diseasePickerControl1.GetSelectedItems(); var available = diseasePickerControl1.GetUnselectedItems(); int userId = ApplicationData.Instance.GetUserId(); r.SaveSelectedDiseases(selected, true, userId); r.SaveSelectedDiseases(available, false, userId); SettingsRepository settings = new SettingsRepository(); settings.SetDiseasesReviewedStatus(); OnFinish(); }
private void AdminLevelTypesControl_Load(object sender, EventArgs e) { if (!DesignMode) { Localizer.TranslateControl(this); lblAggLevel.SetMaxWidth(550); maxLevelsAllowed = Convert.ToInt32(ConfigurationManager.AppSettings["MaxLevelsAllowed"]); r = new SettingsRepository(); RefreshList(); } }
void worker_DoWork(object sender, DoWorkEventArgs e) { try { SettingsRepository repo = new SettingsRepository(); e.Result = repo.RunSchemaChangeScripts((List<string>)e.Argument); } catch (Exception ex) { Logger log = new Logger(); log.Error("Error updating database. UpdateDb:worker_DoWork. ", ex); e.Result = new ImportResult(Translations.UnexpectedException + " " + ex.Message); } }
private void RunUpdates() { SettingsRepository repo = new SettingsRepository(); string scriptsPath = Path.Combine( System.Windows.Forms.Application.StartupPath, @"DatabaseScripts\Differentials\"); List<string> scriptsToRun = repo.GetSchemaChangeScripts(scriptsPath); if (scriptsToRun.Count > 0) { WizardForm wiz = new WizardForm(new UpdateDb(scriptsToRun, DoRestart), Translations.Updates); wiz.OnFinish += () => { if (restartNeeded) OnRestart(); }; wiz.ShowDialog(); } }
private void LoadAdminLevels() { SettingsRepository settings = new SettingsRepository(); DemoRepository repo = new DemoRepository(); var levels = settings.GetAllAdminLevels(); var t = repo.GetAdminLevelTree(levels.OrderByDescending(l => l.LevelNumber).ToArray()[1].Id, 0, true, true, levelType); treeAvailable.CanExpandGetter = m => ((AdminLevel)m).Children.Count > 0; treeAvailable.ChildrenGetter = delegate(object m) { return ((AdminLevel)m).Children; }; treeAvailable.SetObjects(t); foreach (var l in t) { treeAvailable.Expand(l); foreach (var l2 in l.Children) treeAvailable.Expand(l2); } }
private void Init(AdminLevelType type, IWizardStep step, bool demoOnly, int? cid) { countryDemoId = cid; isDemoOnly = demoOnly; locationType = type; prev = step; SettingsRepository settings = new SettingsRepository(); DemoRepository demo = new DemoRepository(); if (!isDemoOnly) demoDate = demo.GetCountryDemoRecent().DateDemographyData; if (!isSingleImport) { nextType = settings.GetNextLevel(locationType.LevelNumber); stepTitle = isDemoOnly ? Translations.UpdateDemography + " - " + locationType.DisplayName : Translations.ImportAdminLevels + locationType.DisplayName; importer = new AdminLevelDemoImporter(locationType, countryDemoId); } else stepTitle = Translations.Demography + " - " + locationType.DisplayName; updater = new AdminLevelDemoUpdater(locationType, countryDemoId); InitializeComponent(); }
private void btnSave_Click_1(object sender, EventArgs e) { if (!model.IsValid()) { MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle); return; } SettingsRepository r = new SettingsRepository(); var adminLevels = r.GetAllAdminLevels(); if (model.Id <= 0 && adminLevels.FirstOrDefault(a => a.DisplayName == model.DisplayName.Trim()) != null) { MessageBox.Show(Translations.AdminLevelNameUnique, Translations.ValidationErrorTitle); return; } bsAdminLevel.EndEdit(); int userid = ApplicationData.Instance.GetUserId(); r.Save(model, userid); // Show the warning message if this is not the start up wizard if (!IsStartUp) MessageBox.Show(Translations.AddAdminLevelNoAdminUnits, Translations.AdminLevelType); OnSave(); this.Close(); }
public void Delete(DemoDetails details, int userId) { SettingsRepository settings = new SettingsRepository(); var type = settings.GetAdminLevelTypeByLevel(adminLevel.LevelNumber); demos.Delete(details, userId); if (type.IsAggregatingLevel) demos.AggregateUp(type, details.DateReported, userId, null, null); }
private void menuMergeDistrictToolStripMenuItem_Click(object sender, EventArgs e) { SettingsRepository repo = new SettingsRepository(); DiseaseDashboard dash = new DiseaseDashboard(true); dash.ReloadView = (v) => { }; dash.LoadView = (v) => { }; dash.LoadForm = (v) => { LoadForm(v); }; dash.StatusChanged = (s) => { }; WizardForm wiz = new WizardForm(new BackupForRedistrict(new RedistrictingOptions { Dashboard = dash, SplitType = SplittingType.Merge }), Translations.SplitMergeTitle); wiz.OnFinish = import_OnSuccess; wiz.OnClose = () => { LoadDashboard(new DashboardView()); }; wiz.ShowDialog(); }
void worker_DoWork(object sender, DoWorkEventArgs e) { try { SettingsRepository settings = new SettingsRepository(); var als = settings.GetAllAdminLevels(); var aggLevel = als.FirstOrDefault(a => a.IsAggregatingLevel); int userId = ApplicationData.Instance.GetUserId(); repo.ApplyGrowthRate(vm.GrowthRate.Value, userId, aggLevel, vm.DateReported); repo.AggregateUp(aggLevel, vm.DateReported, userId, vm.GrowthRate.Value, vm.CountryDemoId); e.Result = ""; } catch (Exception ex) { Logger log = new Logger(); log.Error("Error updating demography for new year. StepDemoUpdateGrowthRate:worker_DoWork. ", ex); e.Result = Translations.UnexpectedException + " " + ex.Message; } }
private void LoadAdminLevelTypes() { adminLevelTypes = new Dictionary<int, AdminLevelType>(); SettingsRepository r = new SettingsRepository(); List<AdminLevelType> types = r.GetAllAdminLevels(); foreach (var t in types) adminLevelTypes.Add(t.LevelNumber, t); }
protected void LoadRelatedLists() { IntvRepository repo = new IntvRepository(); partners = repo.GetPartners(); months = GlobalizationUtil.GetAllMonths(); SettingsRepository settings = new SettingsRepository(); ezs = settings.GetEcologicalZones(); eus = settings.GetEvaluationUnits(); subdistricts = settings.GetEvalSubDistricts(); ess = settings.GetEvalSites(); DiseaseRepository diseases = new DiseaseRepository(); selectedDiseases = diseases.GetSelectedDiseases().Select(d => d.DisplayName).ToList(); valueParser.LoadRelatedLists(); }
void DemoWorker_DoWork(object sender, DoWorkEventArgs e) { try { var f = (IFetchActivities)e.Argument; var demo = f.GetDemography(); SettingsRepository repo = new SettingsRepository(); var adminType = repo.GetAdminLevelTypeByLevel(adminLevel.LevelNumber); bool canCrud = false; if (adminType != null) canCrud = adminType.IsDemographyAllowed; if (canCrud) { foreach (var d in demo) { d.CanViewEdit = true; d.CanDelete = true; } } e.Result = new DemoPayload { DemoList = demo, AllowAdd = canCrud }; } catch (Exception ex) { Logger log = new Logger(); log.Error("Error fetching dashboard demography. ", ex); throw; } }
public void LoadRelatedLists() { IntvRepository repo = new IntvRepository(); partners = repo.GetPartners(); months = GlobalizationUtil.GetAllMonths(); SettingsRepository settings = new SettingsRepository(); ezs = settings.GetEcologicalZones(); eus = settings.GetEvaluationUnits(); subdistricts = settings.GetEvalSubDistricts(); ess = settings.GetEvalSites(); }
private void StepOptions_Load(object sender, EventArgs e) { if (!DesignMode) { Localizer.TranslateControl(this); if (report.ReportOptions.StartDate != DateTime.MinValue) dtStart.Value = report.ReportOptions.StartDate; if (report.ReportOptions.EndDate != DateTime.MinValue) dtEnd.Value = report.ReportOptions.EndDate; var months = GlobalizationUtil.GetAllMonths(); monthItemBindingSource.DataSource = months; cbMonths.DropDownWidth = BaseForm.GetDropdownWidth(months.Select(m => m.Name)); if (report.ReportOptions.MonthYearStarts > 0) cbMonths.SelectedValue = report.ReportOptions.MonthYearStarts; else cbMonths.SelectedValue = 1; DiseaseRepository r = new DiseaseRepository(); var diseases = r.GetSelectedDiseases().Where(d => d.DiseaseType == Translations.PC).ToList(); bindingSource1.DataSource = diseases; cbDiseases.DropDownWidth = BaseForm.GetDropdownWidth(diseases.Select(m => m.DisplayName)); if (options.Diseases.Count > 0) cbDiseases.SelectedItem = diseases.FirstOrDefault(d => d.Id == options.Diseases.First().Id); else cbMonths.SelectedIndex = 0; SettingsRepository settings = new SettingsRepository(); cbEliminationType.Items.Add(Translations.Persons); cbEliminationType.Items.Add(Translations.RtiReportingLevel); if (options.IsPersons) cbEliminationType.SelectedItem = Translations.Persons; else cbEliminationType.SelectedItem = options.DistrictType.DisplayName; rbAggCountry.Checked = report.ReportOptions.IsCountryAggregation; rbAggLevel.Checked = report.ReportOptions.IsByLevelAggregation; var allLevelTypes = settings.GetAllAdminLevels(); var reportingType = allLevelTypes.First(); options.DistrictType = reportingType; bindingSource2.DataSource = allLevelTypes; bindingSource3.DataSource = options; } }
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { TaskForceApiResult result = (TaskForceApiResult)e.Result; if (!result.WasSuccessful) { MessageBox.Show(result.ErrorMsg, Translations.ErrorOccured, MessageBoxButtons.OK, MessageBoxIcon.Error); OnFinish(); return; } if (result.Units.Count == 0) { MessageBox.Show(Translations.RtiNoData, Translations.ErrorOccured, MessageBoxButtons.OK, MessageBoxIcon.Error); OnSwitchStep(this); if (TrySkip()) return; return; } var userId = ApplicationData.Instance.GetUserId(); demo.UpdateCountry(country, userId); SettingsRepository settings = new SettingsRepository(); List<AdminLevelType> levels = settings.GetAllAdminLevels(); OnSwitchStep(new TaskForceAdminLevelStep(levels, 0, result.Units)); }
private void StepOptions_Load(object sender, EventArgs e) { if (!DesignMode) { // Set up the report inputs SetupReportTypeInput(); SetupYearListBox(); // Diseases DiseaseRepository diseaseRepo = new DiseaseRepository(); var diseases = diseaseRepo.GetSelectedDiseases().Where(d => d.DiseaseType == Translations.PC).ToList(); diseaseBindingSource.DataSource = diseases; // Add the diseases to the collection of available ones options.AvailableDiseases = diseases; // Interventions IntvRepository intvRepo = new IntvRepository(); // The interventions we want to use to popualte the list List<int> interventionTypeIds = new List<int> { (int)StaticIntvType.Alb, (int)StaticIntvType.Alb2, (int)StaticIntvType.DecAlb, (int)StaticIntvType.Ivm, (int)StaticIntvType.IvmAlb, (int)StaticIntvType.IvmPzq, (int)StaticIntvType.IvmPzqAlb, (int)StaticIntvType.Mbd, (int)StaticIntvType.Pzq, (int)StaticIntvType.PzqAlb, (int)StaticIntvType.PzqMbd, (int)StaticIntvType.ZithroTeo }; List<IntvType> intvTypes = intvRepo.GetAllTypes().Where(i => interventionTypeIds.Contains(i.Id)).OrderBy(i => i.IntvTypeName).ToList(); intvTypeBindingSource.DataSource = intvTypes; // Add the interventions to the collection of available ones options.AvailableDrugPackages = intvTypes; // Admin level types SettingsRepository settingsRepo = new SettingsRepository(); var allLevelTypes = settingsRepo.GetAllAdminLevels(); adminLevelTypeBindingSource.DataSource = allLevelTypes; // Repopulate the previous report options if (options != null) RepopulateOptions(); } }
/// <summary> /// SAVE Method /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void save_Click(object sender, EventArgs e) { if (!model.IsValid() || !customIndicatorControl1.IsValid()) { MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle); return; } bsDemo.EndEdit(); int userId = ApplicationData.Instance.GetUserId(); demo.Save(model, userId); SettingsRepository settings = new SettingsRepository(); var type = settings.GetAdminLevelTypeByLevel(adminLevel.LevelNumber); var country = demo.GetCountry(); if (type.IsAggregatingLevel) { demo.AggregateUp(type, model.DateDemographyData, userId, null, null); if (originalDate != DateTime.MinValue && Util.GetYearReported(1, originalDate) != Util.GetYearReported(1, model.DateDemographyData)) demo.AggregateUp(type, originalDate, userId, null, null); } OnClose(); }