private void LoadRisksDataGrid()
        {
            if (EnableSearch)
            {
                // Load List:
                // Clear and create columns:
                dgvAlerts.Rows.Clear();

                _alerts = ModelRiskAlertHelper.GetWithFilter(null, new List <int> (), (rbActive.Checked) ? true : (rbInactive.Checked ? (bool?)false : null));
                //List<ModelRiskAlert> modelRiskAlertDistinctIDsList = new List<ModelRiskAlert>();
                foreach (ModelRiskAlert alert in _alerts)
                {
                    //if (IsAlertInList(alert, modelRiskAlertDistinctIDsList)) continue;

                    int           i = 0;
                    StringBuilder electoralPhase = new StringBuilder("");

                    foreach (ModelRiskAlertPhase phase in alert.ModelRiskAlertPhases)
                    {
                        if (i > 0)
                        {
                            electoralPhase.Append(", ");
                        }
                        electoralPhase.Append(phase.Phase.Title);
                        i = i + 1;
                    }

                    i = dgvAlerts.Rows.Add(alert.Code, alert.Title, alert.Model.Name, electoralPhase.ToString() != "" ? electoralPhase.ToString() : "--", alert.DateCreated, alert.DateModified, (alert.Active) ? "Active" : "Inactive", "+");
                    DataGridViewRow r = dgvAlerts.Rows[i];
                    r.Tag = alert;
                    if (electoralPhase.ToString() != "")
                    {
                        r.Cells[3].ToolTipText = electoralPhase.ToString().Replace(",", Environment.NewLine);
                    }

                    if (alert.Active)
                    {
                        r.Cells[6].Style.BackColor = Color.Red;
                        r.Cells[6].Style.ForeColor = Color.Black;
                    }
                    else
                    {
                        r.Cells[6].Style.BackColor = Color.Green;
                        r.Cells[6].Style.ForeColor = Color.White;
                    }
                }
            }
        }
Beispiel #2
0
        private void LoadRisksDataGrid()
        {
            if (_enableSearch)
            {
                Model model = ERMTSession.Instance.CurrentModel;
                if (model != null)
                {
                    // Load List:
                    // Clear and create columns:
                    dgvAlerts.Rows.Clear();

                    // Create a list of integer:
                    List <int> regionsChecked = new List <int>();
                    foreach (TreeNode checkedNode in tvRegions.Nodes)
                    {
                        GetCheckedRegions(regionsChecked, checkedNode);
                    }

                    List <ModelRiskAlert> alerts = new List <ModelRiskAlert>();
                    if (IsMasterRAR)
                    {
                        dgvAlerts.Columns["Model"].Visible = true;
                        alerts = ModelRiskAlertHelper.GetWithFilter(null, regionsChecked,
                                                                    (rbActive.Checked) ? true : (rbInactive.Checked ? (bool?)false : null));
                    }
                    else
                    {
                        dgvAlerts.Columns["Model"].Visible = false;
                        alerts = ModelRiskAlertHelper.GetWithFilter(model.IDModel, regionsChecked,
                                                                    (rbActive.Checked) ? true : (rbInactive.Checked ? (bool?)false : null));
                    }

                    if (alerts == null || alerts.Count == 0)
                    {
                        return;
                    }

                    List <ModelRiskAlert> modelRiskAlertDistinctIDsList = new List <ModelRiskAlert>();
                    foreach (ModelRiskAlert alert in alerts)
                    {
                        if (IsAlertInList(alert, modelRiskAlertDistinctIDsList))
                        {
                            continue;
                        }

                        List <ModelRiskAlertPhase> modelRiskAlertPhaseList = ModelRiskAlertHelper.GetPhases(alert);
                        int           i = 0;
                        StringBuilder electoralPhase = new StringBuilder("");

                        foreach (ModelRiskAlertPhase mrap in modelRiskAlertPhaseList)
                        {
                            if (i > 0)
                            {
                                electoralPhase.Append(" - ");
                            }
                            electoralPhase.Append(PhaseHelper.Get(mrap.IDPhase).Title);
                            i = i + 1;
                        }

                        Model alertModel = IsMasterRAR ? ModelHelper.GetModel(alert.IDModel) : ERMTSession.Instance.CurrentModel;

                        i = dgvAlerts.Rows.Add(alert.Code, alertModel.Name, alert.Title, electoralPhase.ToString() != "" ? electoralPhase.ToString() : "--", alert.DateCreated, alert.DateModified, (alert.Active) ? "Active" : "Inactive", "+");
                        DataGridViewRow r = dgvAlerts.Rows[i];
                        r.Tag = alert;
                        if (electoralPhase.ToString() != "")
                        {
                            r.Cells[2].ToolTipText = electoralPhase.ToString().Replace(",", Environment.NewLine);
                        }

                        if (alert.Active)
                        {
                            r.Cells[5].Style.BackColor = Color.Red;
                            r.Cells[5].Style.ForeColor = Color.Black;
                        }
                        else
                        {
                            r.Cells[5].Style.BackColor = Color.Green;
                            r.Cells[5].Style.ForeColor = Color.White;
                        }
                    }
                }
            }
        }