Пример #1
0
 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);
 }
Пример #2
0
 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";
           
     }
 }
 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 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));

            }
        }
Пример #5
0
        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);
            }
        }
Пример #6
0
        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();
        }
Пример #7
0
 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;
     }
 }
Пример #8
0
        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();
            }
        }
Пример #10
0
        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;
            }
        }
Пример #11
0
 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);
 }