예제 #1
0
 private void lbCurrentProjects_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (bFirstTimeThisFormIsLoaded == true)
     {
         lbCurrentProjects.SelectedIndex = -1;           // don't make any selection, this will make loading faster
         bFirstTimeThisFormIsLoaded      = false;
         setEnableFlagOnAllAscxControls(false);          // disable all ascx controls
     }
     else
     {
         if (true == ascxFindings.axAuthentic_Findings.Modified)
         {
             if (bProjectSelectedIndexChanged)           // this only happens if the user clicks on the current item, or after the lbFindingsInCurrentTarget.SelectedIndex has been corrected in the case bellow
             {
                 bProjectSelectedIndexChanged = false;
                 return;
             }
             // We might want to change this question for usability purposes since the user is usually used to answer Yes to the 'Unsaved data' question)
             if (MessageBox.Show("Current Findings contains unsaved data!" + Environment.NewLine + Environment.NewLine +
                                 "are you sure you to continue?", "Confirmation Message", MessageBoxButtons.YesNo) == DialogResult.No)
             {
                 bProjectSelectedIndexChanged    = true;
                 lbCurrentProjects.SelectedIndex = iCurrentProjectSelectedIndex;
                 return;
             }
             else
             {
                 ascxFindings.axAuthentic_Findings.SetUnmodified();
             }
         }
         setEnableFlagOnAllAscxControls(false);      // Disable all tabs so that the user can't click anywhere
         lbCurrentProjects.Enabled = false;          // disable it so that the user doesn't click on it before this method is full processed
         Application.DoEvents();                     // this will allow the redraw of the disabled list box (better user experience)
         // comment the following lines to disable autoloading of autentic pages
         ascxProjects.loadProjectData(lbCurrentProjects.Text);
         ascxTargets.loadProjectData(lbCurrentProjects.Text);
         ascxFindings.loadProjectData(lbCurrentProjects.Text);
         ascxExecutiveSummary.loadProjectData(lbCurrentProjects.Text);
         ascxReportPdf.loadProjectData(lbCurrentProjects.Text);
         iCurrentProjectSelectedIndex = lbCurrentProjects.SelectedIndex;
         setEnableFlagOnAllAscxControls(true);    // enable all ascx controls
         lbCurrentProjects.Enabled = true;        // Now the user can select another Target
     }
 }