public void DoNext()
 {
     DiseaseRepository diseases = new DiseaseRepository();
     vm.Diseases = diseases.GetSelectedDiseases();
     vm.DiseaseStepNumber = 0;
     OnSwitchStep(new StepDdReview(vm, this));
 }
 public void LoadAvailable(bool filterPc)
 {
     r = new DiseaseRepository();
     diseases = r.GetSelectedDiseases();
     if(filterPc)
         diseases = diseases.Where(d => d.DiseaseType == Translations.PC).ToList();
     diseaseBindingSource.DataSource = diseases;
 }
 private void lnkDistro_ClickOverride()
 {
     ReportRepository repo = new ReportRepository();
     opts.EntityType = Model.IndicatorEntityType.DiseaseDistribution;
     opts.AvailableIndicators = repo.GetDiseaseDistroIndicators();
     DiseaseRepository typeRepo = new DiseaseRepository();
     var types = typeRepo.GetSelectedDiseases();
     opts.FormTypes = types.Select(t => t.DisplayName).OrderBy(t => t).ToList();
     OnSwitchStep(new IndStepIndicators(opts));
 }
 private void IndicatorControl_Load(object sender, EventArgs e)
 {
     if (!DesignMode)
     {
         Localizer.TranslateControl(this);
         dtStart.Value = start;
         dtEnd.Value = end;
         tblMetaData.Visible = false;
         tblTopControls.Visible = false;
         DiseaseRepository diseases = new DiseaseRepository();
         selectedDiseases = diseases.GetSelectedDiseases().Select(d => d.DisplayName).ToList();
     }
 }
 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();
 }
        private List<KeyValuePair<string, int>> GetFormTypes(DataRow dr)
        {
            var result = new List<KeyValuePair<string, int>>();
            if (!string.IsNullOrEmpty(dr["Type ID"].ToString()))
            {
                var entityType = (IndicatorEntityType)Convert.ToInt32(dr["Type ID"]);

                switch (entityType)
                {
                    case IndicatorEntityType.DiseaseDistribution:
                        DiseaseRepository typeRepo = new DiseaseRepository();
                        result = typeRepo.GetSelectedDiseases().Select(d => new KeyValuePair<string, int>(d.DisplayName, d.Id)).ToList();
                        break;
                    case IndicatorEntityType.Intervention:
                        IntvRepository intv = new IntvRepository();
                        result = intv.GetAllTypes().Select(d => new KeyValuePair<string, int>(d.IntvTypeName, d.Id)).ToList();
                        break;
                    case IndicatorEntityType.Survey:
                        SurveyRepository sRepo = new SurveyRepository();
                        result = sRepo.GetSurveyTypes().Select(d => new KeyValuePair<string, int>(d.SurveyTypeName, d.Id)).ToList();
                        break;
                    case IndicatorEntityType.Process:
                        ProcessRepository pRepo = new ProcessRepository();
                        result = pRepo.GetProcessTypes().Select(d => new KeyValuePair<string, int>(d.TypeName, d.Id)).ToList();
                        break;
                }        
            }
            return result;
        }
        public List<ReportIndicator> GetDiseaseDistroIndicators()
        {
            List<ReportIndicator> indicators = new List<ReportIndicator>();
            DiseaseRepository repo = new DiseaseRepository();
            var types = repo.GetSelectedDiseases();
            var pc = new ReportIndicator { Name = TranslationLookup.GetValue("PcNtds"), IsCategory = true };
            var cm = new ReportIndicator { Name = TranslationLookup.GetValue("OtherNtds"), IsCategory = true };
            indicators.Add(pc);
            indicators.Add(cm);
            foreach (var t in types.Where(i => i.DiseaseType == TranslationLookup.GetValue("PC")).OrderBy(t => t.DisplayName))
            {
                var cat = new ReportIndicator { Name = t.DisplayName, IsCategory = true };
                DiseaseDistroPc dd = repo.Create((DiseaseType)t.Id);
                foreach (var i in dd.Indicators)
                    cat.Children.Add(CreateReportIndicator(t.Id, i, t.DisplayName, t.DisplayNameKey));
                cat.Children = cat.Children.OrderBy(c => c.Name).ToList();
                pc.Children.Add(cat);
            }
            foreach (var t in types.Where(i => i.DiseaseType == TranslationLookup.GetValue("CM")).OrderBy(t => t.DisplayName))
            {
                var cat = new ReportIndicator { Name = t.DisplayName, IsCategory = true };
                DiseaseDistroCm dd = repo.CreateCm((DiseaseType)t.Id);
                foreach (var i in dd.Indicators)
                    cat.Children.Add(CreateReportIndicator(t.Id, i, t.DisplayName, t.DisplayNameKey));
                cat.Children = cat.Children.OrderBy(c => c.Name).ToList();
                cm.Children.Add(cat);
            }

            return indicators;
        }
        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();
            }
        }
        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;
            }
        }