Esempio n. 1
0
        private void OpenView()
        {
            if (dgvAlerts.SelectedRows.Count > 0)
            {
                // Get the id:
                ModelRiskAlert selAlert = dgvAlerts.SelectedRows[0].Tag as ModelRiskAlert;

                if (selAlert != null)
                {
                    ModelRiskAlert alert = ModelRiskAlertHelper.Get(selAlert.IDModelRiskAlert);
                    List <ModelRiskAlertAttachment> alertAttachments =
                        ModelRiskAlertHelper.GetModelRiskAlertAttachments(alert);
                    if (alert.IDModelRiskAlert == selAlert.IDModelRiskAlert)
                    {
                        // View / Print the grid:
                        CopyAttachmentFilesToDir(alertAttachments);
                        ModelRiskAlertHelper.GenerateRARHtml(GetAlertTitle(selAlert), GetAlertText(selAlert, alertAttachments), ModelRiskAlertHelper.GetRARHtmlAlarmFile());
                        var win = new HtmlPopup(DirectoryAndFileHelper.ClientAppDataFolder + ModelRiskAlertHelper.GetRARHtmlAlarmFile())
                        {
                            ShowBackForward = false
                        };
                        win.ShowDialog();
                    }
                }
            }
        }
 private void DeleteAttachment(object sender, UpdaterEventArgs e)
 {
     if (e.Id != 0)
     {
         List <ModelRiskAlertAttachment> modelRiskAlertAttachmentList = ModelRiskAlertHelper.GetModelRiskAlertAttachments(_alert);
         foreach (ModelRiskAlertAttachment att in modelRiskAlertAttachmentList)
         {
             if (att.IDModelRiskAlertAttachment == e.Id)
             {
                 //att.Deleted = true;
                 ModelRiskAlertHelper.DeleteAttachment(att);
             }
         }
     }
     // and remove the control.
     analysisPanel.Controls.Remove((Control)sender);
     ((Control)sender).Dispose();
 }
        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);
            }
        }