public Incident_Report_Page_Builder GetBuilder(Page irp, string dropZoneID, string incidentReportID, string stringRole)
 {
     if (incidentReportID != "")
     {
         IIncident_Report incidentReport = APF.Searcher.Find_Incident_Report(int.Parse(incidentReportID));
         if (stringRole == "Submitter" && incidentReport.IsDraft == true)
         {
             _builder = new Submit_Incident_Report_Builder(irp, dropZoneID, incidentReport, stringRole);
             return _builder;
         }
         else if (stringRole == "Browser" && incidentReport.IsDraft == false)
         {
             _builder = new Browse_Report_Page_Builder(irp, dropZoneID, incidentReport, stringRole);
             return _builder;
         }
         else if (stringRole == "Modifier" && incidentReport.IsDraft == false)
         {
             _builder = new Edit_Report_Page_Builder(irp, dropZoneID, incidentReport, stringRole);
             return _builder;
         }
         else return null;
     }
     else if (stringRole == "Submitter")
     {
         _builder = new Submit_Incident_Report_Builder(irp, dropZoneID, incidentReportID, stringRole);
         return _builder;
     }
     else return null;
 }
 public Incident_Report_Page_Builder ReloadBuilder(string stringRole)
 {
     if (stringRole == "Submitter")
     {
         _builder = new Submit_Incident_Report_Builder();
         return _builder;
     }
     else if (stringRole == "Browser")
     {
         _builder = new Browse_Report_Page_Builder();
         return _builder;
     }
     else if (stringRole == "Modifier")
     {
         _builder = new Edit_Report_Page_Builder();
         return _builder;
     }
     else return null;
 }
    //// Test method.
    //protected void DateButton_Click(object sender, EventArgs e)
    //{
    //    DateLabel.Text = "InjuryTypeDropDownList.SelectedValue = " + InjuryTypeDropDownList.SelectedValue;
    //    DateLabel.Text += "<BR/>IncidentType1DropDownList.SelectedValue = " + IncidentType1DropDownList.SelectedValue;
    //    DateLabel.Text += "<BR/>IncidentType2DropDownList.SelectedValue = " + IncidentType2DropDownList.SelectedValue;
    //    DateLabel.Text += "<BR/>IncidentType3DropDownList.SelectedValue = " + IncidentType3DropDownList.SelectedValue;
    //    DateLabel.Text += "<BR/>IncidentType4DropDownList.SelectedValue = " + IncidentType4DropDownList.SelectedValue;
    //}
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        Page.Validate("submit");
        Page.Validate("draft");

        if (Page.IsValid)
        {
            Table2.Visible = false;
            // Report has been validated and ready to persist to the database.
            irpb = new Director().ReloadBuilder(Profile.Role);
            irpb.SubmitReport(this);
            // Clear the profile.
            Profile.IncidentReportID = "";
            Profile.DropZoneID = "";
            Response.Redirect("Admin_Home.aspx");
        }
        else
        {
            // Else they'll stay on the page and have to fix their errors.
            ValidationSummary_Incident_Report_Submission.HeaderText = "<b>Oops! You've forgotten to fill:</b>";
            ValidationSummary_Incident_Report.HeaderText = "<b>Error(s) have also been sighted:</b>";
            Table2.Visible = true;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Response.Cache.SetNoStore();    // Don't cache this page!

            // If someone wanted to go to the Incident_Report page directly
            // (read: didn't go through the Incident_List page first)....
            if (Request.UrlReferrer == null)
            {
                Response.Redirect("CustomError.aspx");
            }
            // If someone wanted to go to the Incident_Report page directly when they are initially not logged in.
            else if (Request.UrlReferrer.LocalPath == "/Website/Login.aspx")
            {
                Response.Redirect("Admin_Home.aspx");
            }

            // If someone wanted to go back to the Incident_Report page using the back button after they
            // have left it, they cannot view the Incident Report they were using.
            if (Profile.IncidentReportID == "" && Profile.DropZoneID == "")
            {
                Response.Redirect("CustomError.aspx");
            }

            // Else they can proceed. ^_^

            Director myDirector = new Director();

            irpb = myDirector.GetBuilder(this, Profile.DropZoneID, Profile.IncidentReportID, Profile.Role);
            if (irpb == null)
            {
                Page.Response.Redirect("CustomError.aspx");
                Profile.IncidentReportID = "";
                Profile.DropZoneID = "";
                Profile.Role = "";
            }
            if (Profile.Role != "Browser")
            {
                JumpTypeDropDownList_SelectedIndexChanged(sender, e);
                JumperCertificateDropDownList_SelectedIndexChanged(sender, e);
            }

            // Make these textboxes have this javascript attribute so user can't focus on them:
            IncidentDateTextbox.Attributes.Add("onfocus", "this.blur()");
            PrevJumpTextBox.Attributes.Add("onfocus", "this.blur()");

            // Make these linkbuttons have this javascript attribute so the user can see a pop-up window when they are clicked.
            Injury_Type_ListLinkButton.Attributes.Add("onclick", "window.open('Pop_Up.aspx?id=injury','popup','width=500,height=500,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false");
            Incident_Type_ListLinkButton.Attributes.Add("onclick", "window.open('Pop_Up.aspx?id=incident','popup','width=500,height=500,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false");

            // Set the text of the PrevJumpCheckBox
            PrevJumpCheckBox.Text = ConfigurationManager.AppSettings.Get("NoPreviousJumpDateValue");

            #region Validators Properties
            RangeValidator_IncidentDateTextbox.Type = ValidationDataType.Date;
            RangeValidator_IncidentDateTextbox.MaximumValue = DateTime.Now.ToString("dd/MM/yyyy");
            RangeValidator_IncidentDateTextbox.MinimumValue = "01/01/1960"; // Before APF was made.

            RangeValidator_PrevJumpTextBox.Type = ValidationDataType.Date;
            RangeValidator_PrevJumpTextBox.MaximumValue = DateTime.Now.ToString("dd/MM/yyyy");
            RangeValidator_PrevJumpTextBox.MinimumValue = "01/01/1960"; // Before APF was made.

            #endregion
        }
    }