Exemple #1
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;
        }
Exemple #2
0
        private void StepCategory_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                Localizer.TranslateControl(this);


                Dictionary<int, Disease> diseases = new Dictionary<int, Disease>();
                foreach (var distro in options.DistrosCm)
                    if (!diseases.ContainsKey(distro.Disease.Id))
                        diseases.Add(distro.Disease.Id, distro.Disease);
                foreach (var distro in options.DistrosPc)
                    if (!diseases.ContainsKey(distro.Disease.Id))
                        diseases.Add(distro.Disease.Id, distro.Disease);

                if (diseases.Count == 0)
                    DoNext();

                foreach (var disease in diseases.Values.OrderBy(d => d.DisplayName))
                {
                    var index = tblNewUnits.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
                    var lblName = new H3bLabel { AutoSize = true, Text = disease.DisplayName, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lblName, 0, index);

                    var lnk = new H3Link { Text = Translations.DownloadImportFile, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lnk, 1, index);
                    lnk.ClickOverride += () =>
                    {
                        List<IHaveDynamicIndicatorValues> forms = new List<IHaveDynamicIndicatorValues>();
                        if (disease.DiseaseType == "CM")
                            forms = options.DistrosCm.Where(d => d.Disease.Id == disease.Id).Cast<IHaveDynamicIndicatorValues>().ToList();
                        else
                            forms = options.DistrosPc.Where(d => d.Disease.Id == disease.Id).Cast<IHaveDynamicIndicatorValues>().ToList();
                        DistroImporter importer = new DistroImporter();
                        importer.SetType(disease.Id);
                        var payload = new WorkerPayload
                        {
                            FileName = Util.CleanFilename(disease.DisplayName) + "_" + options.SplitType.ToString() + DateTime.Now.ToString("yyyyMMdd") + ".xlsx",
                            Importer = importer,
                            Forms = forms
                        };
                        CreateDownload(payload);
                    };
                    var lnk2 = new H3Link { Text = Translations.UploadImportFile, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lnk2, 2, index);
                    lnk2.ClickOverride += () =>
                    {
                        Upload(disease);
                    };
                }
            }
        }
Exemple #3
0
        private void StepCategory_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                Localizer.TranslateControl(this);

                Dictionary<int, IntvType> types = new Dictionary<int, IntvType>();
                foreach (var form in options.Intvs)
                    if (!types.ContainsKey(form.IntvType.Id))
                        types.Add(form.IntvType.Id, form.IntvType);

                if (types.Count == 0)
                    DoNext();

                foreach (var t in types.Values)
                {
                    var index = tblNewUnits.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
                    var lblName = new H3bLabel { AutoSize = true, Text = t.IntvTypeName, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lblName, 0, index);

                    var lnk = new H3Link { Text = Translations.DownloadImportFile, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lnk, 1, index); 
                    lnk.ClickOverride += () =>
                    {
                        List<IHaveDynamicIndicatorValues> forms = options.Intvs.Where(s => s.IntvType.Id == t.Id).Cast<IHaveDynamicIndicatorValues>().ToList();
                        IntvImporter importer = new IntvImporter();
                        importer.SetType(t.Id);
                        var payload = new SplitDistro.WorkerPayload
                        {
                            FileName = Util.CleanFilename(t.IntvTypeName) + "_" + options.SplitType.ToString() + DateTime.Now.ToString("yyyyMMdd") + ".xlsx",
                            Importer = importer,
                            Forms = forms
                        };
                        SplitDistro.CreateDownload(payload);
                    };
                    var lnk2 = new H3Link { Text = Translations.UploadImportFile, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lnk2, 2, index);
                    lnk2.ClickOverride += () =>
                    {
                        Upload(t);
                    };
                }
            }
        }
        private static Control AddNewValLink(Control cntrl, Indicator indicator, IndicatorEntityType entityType)
        {
            cntrl.Margin = new Padding(0, 5, 20, 0);
            TableLayoutPanel tblContainer = new TableLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, AutoScroll = true };
            tblContainer.RowStyles.Clear();
            tblContainer.ColumnStyles.Clear();
            int cRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
            tblContainer.Controls.Add(cntrl, 0, cRow);
            int lRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
            var lnk = new H3Link { Text = Translations.AddNewItemLink, Margin = new Padding(0, 5, 3, bottomPadding) };
            lnk.ClickOverride += () =>
            {
                IndicatorValueItemAdd form = new IndicatorValueItemAdd(new IndicatorDropdownValue { IndicatorId = indicator.Id, EntityType = entityType }, indicator);
                form.OnSave += (v) =>
                {
                    v.TranslationKey = v.DisplayName;
                    if (cntrl is ListBox)
                        (cntrl as ListBox).Items.Add(v);
                    else if (cntrl is ComboBox)
                        (cntrl as ComboBox).Items.Add(v);
                };
                form.ShowDialog();
            };
            tblContainer.Controls.Add(lnk, 0, lRow);

            return tblContainer;
        }
        public static Control CreatePartners(Indicator indicator, string val, ErrorProvider indicatorErrors, List<DynamicContainer> controlList)
        {
            var container = new DynamicContainer { Indicator = indicator };
            var cntrl = new ListBox { Name = "dynamicPartners" + indicator.Id.ToString(), Width = 220, Height = 100, Margin = new Padding(0, 5, 20, bottomPadding), SelectionMode = SelectionMode.MultiExtended };

            List<Partner> partners = GetAndLoadPartners(cntrl);
            cntrl.ValueMember = "Id";
            cntrl.DisplayMember = "DisplayName";
            if (!string.IsNullOrEmpty(val))
            {
                string[] vals = val.Split('|');
                cntrl.ClearSelected();
                foreach (var av in partners.Where(v => vals.Contains(v.Id.ToString())))
                    cntrl.SelectedItems.Add(av);
            }

            container.GetValue = () =>
            {
                List<string> selected = new List<string>();
                foreach (var i in cntrl.SelectedItems)
                    selected.Add((i as Partner).Id.ToString());
                return string.Join("|", selected.ToArray());
            };

            container.IsValid = () =>
            {
                if (indicator.IsRequired && indicatorErrors != null)
                {
                    if (string.IsNullOrEmpty(container.GetValue()))
                    {
                        indicatorErrors.SetError(cntrl, Translations.Required);
                        return false;
                    }
                    else
                        indicatorErrors.SetError(cntrl, "");
                }
                return true;
            };
            cntrl.Validating += (s, e) => { container.IsValid(); };

            // Add table container and link
            controlList.Add(container);
            cntrl.Margin = new Padding(0, 5, 20, 0);
            TableLayoutPanel tblContainer = new TableLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, AutoScroll = true };
            tblContainer.RowStyles.Clear();
            tblContainer.ColumnStyles.Clear();
            int cRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
            tblContainer.Controls.Add(cntrl, 0, cRow);
            int lRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
            var lnk = new H3Link { Text = Translations.AddNewItemLink, Margin = new Padding(0, 0, 3, bottomPadding) };
            lnk.ClickOverride += () =>
            {
                PartnerList list = new PartnerList();
                list.OnSave += () =>
                {
                    partners = GetAndLoadPartners(cntrl);
                };
                list.ShowDialog();
            };
            tblContainer.Controls.Add(lnk, 0, lRow);

            return tblContainer;
        }
        public Control CreateListBox(Indicator indicator, Action<ListBox, List<IndicatorDropdownValue>> addValues, 
            Action<ListBox, Indicator, IndicatorEntityType> onAddValue, IndicatorEntityType entityType, List<IndicatorDropdownValue> values,
            string displayMember)
        {
            var cntrl = new ListBox { Name = "dynamicMulti" + indicator.Id.ToString(), Width = 220, Height = 100, Margin = new Padding(0, 5, 20, bottomPadding), 
                SelectionMode = SelectionMode.None };
            addValues(cntrl, values);
            cntrl.ValueMember = "Id";
            cntrl.DisplayMember = displayMember;

            cntrl.Margin = new Padding(0, 5, 20, 0);
            TableLayoutPanel tblContainer = new TableLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, AutoScroll = true };
            tblContainer.RowStyles.Clear();
            tblContainer.ColumnStyles.Clear();
            int cRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
            tblContainer.Controls.Add(cntrl, 0, cRow);
            int lRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
            var lnk = new H3Link { Text = Translations.AddNewItemLink, Margin = new Padding(0, 5, 3, bottomPadding) };
            lnk.ClickOverride += () =>
            {
                onAddValue(cntrl, indicator, entityType);
            };
            tblContainer.Controls.Add(lnk, 0, lRow);

            return tblContainer;
        }
 public Control CreateSentinelSitePicker(KeyValuePair<string, SurveyUnitsAndSentinelSite> survey)
 {
     var cntrl = new ComboBox { Name = "dynamicMulti" + survey.Key, Width = 220, Height = 100, Margin = new Padding(0, 5, 20, bottomPadding) };
     List<SentinelSite> sites = surveys.GetSitesForAdminLevel(survey.Value.Units.Select(a => a.Id.ToString()));
     foreach (var v in sites)
         cntrl.Items.Add(v);
     cntrl.ValueMember = "Id";
     cntrl.DisplayMember = "SiteName";
     if (sites.Count > 0)
         cntrl.SelectedIndex = 0;
     cntrl.Tag = survey;
     cntrl.Margin = new Padding(0, 5, 20, 0);
     TableLayoutPanel tblContainer = new TableLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, AutoScroll = true };
     tblContainer.RowStyles.Clear();
     tblContainer.ColumnStyles.Clear();
     int cRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
     tblContainer.Controls.Add(cntrl, 0, cRow);
     int lRow = tblContainer.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
     var lnk = new H3Link { Text = Translations.AddNewItemLink, Margin = new Padding(0, 5, 3, bottomPadding) };
     lnk.ClickOverride += () =>
     {
         AddSentinelSite(cntrl, survey);
     };
     tblContainer.Controls.Add(lnk, 0, lRow);
     
     sitePickers.Add(cntrl);
     return tblContainer;
 }
        private void LoadSavedReports()
        {
            ReportRepository repo = new ReportRepository();
            var reports = repo.GetCustomReports();
            tblReportBuilder.Visible = false;
            this.SuspendLayout();
            tblReportBuilder.Controls.Clear();
            int rowIndex = tblReportBuilder.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
            var tblNew = new TableLayoutPanel { AutoSize = true, AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink };
            tblNew.RowStyles.Clear();
            tblNew.ColumnStyles.Clear();
            tblNew.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize });
            tblNew.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize });
            tblNew.RowStyles.Add(new RowStyle { SizeType = System.Windows.Forms.SizeType.AutoSize });
            var name2 = new H3bLabel { Text = Translations.CustomReport, Name = "rpt_cr", AutoSize = true, };
            name2.SetMaxWidth(400);
            var edit2 = new H3Link { Text = Translations.NewLink, Margin = new Padding(0, 2, 0, 0) };
            edit2.ClickOverride += () =>
            {
                WizardForm wiz = new WizardForm(new StepCategory(), Translations.CustomReportBuilder);
                wiz.Height = 695;
                wiz.OnRunReport = RunCustomReport;
                wiz.Show();
            };
            tblNew.Controls.Add(name2, 0, 0);
            tblNew.Controls.Add(edit2, 1, 0);
            tblReportBuilder.Controls.Add(tblNew, 0, rowIndex);

            foreach (var report in reports)
            {
                rowIndex = tblReportBuilder.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
                var tbl = new TableLayoutPanel { AutoSize = true, AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink };
                tbl.RowStyles.Clear();
                tbl.ColumnStyles.Clear();
                tbl.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize });
                tbl.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize });
                tbl.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize });
                tbl.RowStyles.Add(new RowStyle { SizeType = System.Windows.Forms.SizeType.AutoSize });
                var name = new H3bLabel { Text = report.DisplayName, Name = "rpt_" + report.DisplayName, AutoSize = true, };
                name.SetMaxWidth(400);
                var edit = new H3Link { Text = Translations.Edit + "...", Margin = new Padding(0, 2, 0, 0) };
                edit.ClickOverride += () =>
                {
                    WizardForm wiz = new WizardForm(new StepIndicators(report), Translations.CustomReportBuilder);
                    wiz.Height = 695;
                    wiz.OnRunReport = RunCustomReport;
                    wiz.Show();
                };
                var delete = new H3Link { Text = Translations.Delete + "...", Margin = new Padding(0, 2, 0, 0) };
                delete.ClickOverride += () => 
                {
                    DeleteConfirm confirm = new DeleteConfirm(Translations.Delete, Translations.DeleteConfirmMessage);
                    if (confirm.ShowDialog() == DialogResult.OK)
                    {
                        repo.DeleteCustomReport(report, ApplicationData.Instance.GetUserId());
                        LoadSavedReports();
                    }
                };
                tbl.Controls.Add(name, 0, 0);
                tbl.Controls.Add(edit, 1, 0);
                tbl.Controls.Add(delete, 2, 0);
                tblReportBuilder.Controls.Add(tbl, 0, rowIndex);
            }
            this.ResumeLayout();
            tblReportBuilder.Visible = true;
        }
        private void StepCategory_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                Localizer.TranslateControl(this);


                Dictionary<int, SurveyType> surveys = new Dictionary<int, SurveyType>();
                foreach (var survey in options.Surveys)
                    if (!surveys.ContainsKey(survey.TypeOfSurvey.Id))
                        surveys.Add(survey.TypeOfSurvey.Id, survey.TypeOfSurvey);

                if (surveys.Count == 0 || options.SplitType == SplittingType.Merge)
                {
                    DoNext();
                    return;
                }

                MessageBox.Show(Translations.SplittingSurveyWarning, Translations.ValidationErrorTitle);

                foreach (var t in surveys.Values)
                {
                    var index = tblNewUnits.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
                    var lblName = new H3bLabel { AutoSize = true, Text = t.SurveyTypeName, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lblName, 0, index);

                    var lnk = new H3Link { Text = Translations.DownloadImportFile, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lnk, 1, index);
                    lnk.ClickOverride += () =>
                    {
                        List<IHaveDynamicIndicatorValues> forms = options.Surveys.Where(s => s.TypeOfSurvey.Id == t.Id).Cast<IHaveDynamicIndicatorValues>().ToList();
                        SurveyImporter importer = new SurveyImporter();
                        importer.SetType(t.Id);
                        var payload = new SplitDistro.WorkerPayload
                        {
                            FileName = Util.CleanFilename(t.SurveyTypeName) + "_" + options.SplitType.ToString() + DateTime.Now.ToString("yyyyMMdd") + ".xlsx",
                            Importer = importer,
                            Forms = forms
                        };
                        SplitDistro.CreateDownload(payload);
                    };

                    var lnk2 = new H3Link { Text = Translations.UploadImportFile, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lnk2, 2, index);
                    lnk2.ClickOverride += () =>
                    {
                        Upload(t);
                    };
                }
            }
        }