Exemplo n.º 1
0
        private void EditRiskAndAction_Load(object sender, EventArgs e)
        {
            //TREEVIEW
            Model model = ERMTSession.Instance.CurrentModel;

            if (model != null)
            {
                tvRegions.Nodes.Clear();
                Region        current = RegionHelper.Get(model.IDRegion);
                List <Region> regions = new List <Region>();
                regions.Add(RegionHelper.Get(1));
                if (current.IDParent.HasValue && current.IDParent != 1)
                {
                    regions.Add(RegionHelper.Get(current.IDParent.Value));
                }
                regions.Add(current);
                regions.AddRange(RegionHelper.GetAllChilds(current.IDRegion));

                TreeNode node = new TreeNode()
                {
                    Text = current.RegionName, Name = current.IDRegion.ToString(), Tag = current
                };
                int mainRegionLevel = RegionHelper.GetLevel(current.IDRegion);

                tvRegions.Nodes.Add(node);
                AddChildRegions(tvRegions.Nodes[0], regions, mainRegionLevel);
                tvRegions.SelectedNode = tvRegions.Nodes[0];
                tvRegions.ExpandAll();
            }

            //Electoral Phase
            cbElectoralPhases.Items.Add(new ComboBoxItemFace(null));
            cbElectoralPhases.Items.AddRange(PhaseHelper.GetAll().Select(p => new ComboBoxItemFace(p)).ToArray());
            cbElectoralPhases.SelectedIndex = 0;

            // Add data from alert:
            if (_alert.IDModel != 0)
            {
                tbCode.Text              = _alert.Code;
                tbTitle.Text             = _alert.Title;
                dtpDateFrom.Value        = _alert.DateFrom;
                dtpDateTo.Value          = _alert.DateTo;
                tbDescription.Text       = _alert.RiskDescription;
                tbAction.Text            = _alert.Action;
                tbResult.Text            = _alert.Result;
                rbStatusActive.Checked   = _alert.Active;
                rbStatusInactive.Checked = !_alert.Active;

                // Phases:
                List <ModelRiskAlertPhase> modelRiskAlertPhaseList = ModelRiskAlertHelper.GetPhases(_alert);
                foreach (ModelRiskAlertPhase mrap in modelRiskAlertPhaseList)
                {
                    foreach (var cboPhase in cbElectoralPhases.Items)
                    {
                        if (((ComboBoxItemFace)cboPhase).IFase != null)
                        {
                            if (((ComboBoxItemFace)cboPhase).IFase.IDPhase == mrap.IDPhase)
                            {
                                lbElectoralPhases.Items.Add(cboPhase);
                            }
                        }
                    }
                }

                // Regions:
                List <ModelRiskAlertRegion> modelRiskAlertRegionList = ModelRiskAlertHelper.GetModelRiskAlertRegions(_alert);
                foreach (ModelRiskAlertRegion region in modelRiskAlertRegionList)
                {
                    foreach (TreeNode node in tvRegions.Nodes)
                    {
                        CheckRegion(node, region);
                    }
                }

                // Add analysis:
                List <ModelRiskAlertAttachment> modelRiskAlertAttachment = ModelRiskAlertHelper.GetModelRiskAlertAttachments(_alert);
                foreach (ModelRiskAlertAttachment att in modelRiskAlertAttachment)
                {
                    addUpdater(att);
                }

                // And a last button to add more:
                addUpdater();
            }
            else
            {
                Label newLabel = new Label
                {
                    Text      = ResourceHelper.GetResourceText("RiskAndActionSaveWarning"),
                    ForeColor = Color.Red,
                    Width     = 500
                };
                analysisPanel.Controls.Add(newLabel);
            }
        }
 private void LoadCombo()
 {
     cbPhases.DisplayMember = "Title";
     cbPhases.ValueMember   = "IDPhase";
     cbPhases.DataSource    = PhaseHelper.GetAll();
 }