private string GetPhaseValueText(ModelRiskAlert alert) { StringBuilder returnText = new StringBuilder(); List <ModelRiskAlertPhase> modelRiskAlertPhases = ModelRiskAlertHelper.GetPhases(alert); foreach (var modelRiskAlertPhase in modelRiskAlertPhases) { Phase phase = PhaseHelper.Get(modelRiskAlertPhase.IDPhase); returnText.Append(phase.Title + "<br/>"); } return(returnText.ToString()); }
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; } } } } }