public void EmailAttachment(string TOEmail,
     IIncident_Report incidentReport, IIncident_Report_Version reportVersion)
 {
     this._incidentReport = incidentReport;
     this._reportVersion = reportVersion;
     this.emailTwo = TOEmail;
     SetEmail();
 }
        public void EmailAttachment(string browserEmail, string IncidentIDString)
        {
            Edit_Incident_Handler mih = new Edit_Incident_Handler();

            this._incidentReport = APF.Searcher.Find_Incident_Report(int.Parse(IncidentIDString));
            this._reportVersion = mih.GetIncidentVersion(_incidentReport);
            this.emailOne = browserEmail;
            SetEmail();
        }
        // 10.09pm
        public void SelectIncidentVersion(int incidentID)
        {
            _selectedReport = APF.Searcher.Find_Incident_Report(incidentID);

            if (_selectedReport.IsDraft == true)
            {
                //throw exception?

            }

            int lastVersionNumber = _selectedReport.Incident_Report_Version.Count();

            _selectedVersion = _selectedReport.Incident_Report_Version[lastVersionNumber - 1];  // [index of last Version]
        }
    protected void PopulateIncidentForm(IIncident_Report _incident_Report, IIncident_Report_Version _report_Version)
    {
        this._incident_Report = _incident_Report;
        this._report_Version = _report_Version;
        SetTextBox("FileNumberTextBox", _incident_Report.File_Number.ToString());
        SetTextBox("IncidentIDNoTextBox", _incident_Report.ID.ToString());
        SetLabel("DropZoneCodeLabel", _incident_Report.Drop_Zone.Code);
        SetLabel("DropZoneNameLabel", _incident_Report.Drop_Zone.Name);

        SetTextBox("ReporterNameTextBox", _report_Version.Reporter.FullName);
        _reporterRole = APF.Searcher.Find_Role(_report_Version.Reporter_Role_ID.ToString());
        SetTextBox("ReporterTitleTextBox", _reporterRole.RoleName);
        SetTextBox("ReporterCertificateTextBox", _report_Version.Reporter.Certificate.Code);
        if (_incident_Report.Incident_Date != defaultDate)
        {
            SetTextBox("IncidentDateTextbox", _incident_Report.Incident_Date.ToString("dd/MM/yyyy"));
        }
        if (_incident_Report.Closed == true)
        {
            SetDropDownList("IncidentStatusDropDownList", 1);   // Closed
        }
        else
        {
            SetDropDownList("IncidentStatusDropDownList", 0);   // Open
        }
        SetDropDownList("SeverityLevelDropDownList", _report_Version.Severity_Level.ID);

        #region Setting Jumper Details
        if (_report_Version.InjuredParty.First_Name != "")
        {
            SetTextBox("JumperFirstNameTextBox", _report_Version.InjuredParty.First_Name);
        }
        if (_report_Version.InjuredParty.Last_Name != "")
        {
            SetTextBox("JumperLastNameTextBox", _report_Version.InjuredParty.Last_Name);
        }
        if (_report_Version.InjuredParty.Age != -1)
        {
            SetTextBox("JumperAgeTextBox", _report_Version.InjuredParty.Age.ToString());
        }
        if (_report_Version.InjuredParty.Gender.ID != 1)     // The 'Not specified yet' item
        {
            SetRadioButtonList("JumperSexRadioButtonList", _report_Version.InjuredParty.Gender.ID);
        }
        if (_report_Version.InjuredParty.Weight != -1)
        {
            SetTextBox("JumperWeightTextBox", _report_Version.InjuredParty.Weight.ToString());
        }

        SetDropDownList("JumperCertificateDropDownList", _report_Version.InjuredParty.Certificate.ID);
        ICertificate_Holder certificate_holder = APF.Searcher.Find_Certificate_Holder(_report_Version.InjuredParty.ID);
        // If the certificate is from overseas (or just isn't listed)....
        if (_report_Version.InjuredParty.Certificate.ID == int.Parse(ConfigurationManager.AppSettings.Get("OtherCertificateDDLValue")))
        {
            SetTextBox("JumperCertificateOtherTextBox", certificate_holder.Overseas_Certificate_Code);
            // and make it visible.
            TextBox tb = (TextBox)_myControls["JumperCertificateOtherTextBox"];
            tb.Visible = true;
        }

        if (certificate_holder.Previous_Jump_Date != null)
        {
            DateTime _previous_jump_date = (DateTime)certificate_holder.Previous_Jump_Date;
            SetTextBox("PrevJumpTextBox", _previous_jump_date.ToString("dd/MM/yyyy"));
        }
        else
        {
            SetTextBox("PrevJumpTextBox", ConfigurationManager.AppSettings.Get("NoPreviousJumpDateValue"));
            SetCheckBox("PrevJumpCheckBox", true);
            // Disable the Calender extender and validation
            CalendarExtender ce = (CalendarExtender)_myControls["PrevJumpTextBox_CalendarExtender"];
            ce.Enabled = false;
            RangeValidator rv = (RangeValidator)_myControls["RangeValidator_PrevJumpTextBox"];
            rv.Enabled = false;
        }

        if (certificate_holder.Jumps_Last_Month != -1)
        {
            SetTextBox("MonthJumpsTextBox", certificate_holder.Jumps_Last_Month.ToString());
        }
        if (certificate_holder.Jumps_Last_Six_Months != -1)
        {
            SetTextBox("SixMonthsJumpsTextBox", certificate_holder.Jumps_Last_Six_Months.ToString());
        }
        if (certificate_holder.Total_Jumps != -1)
        {
            SetTextBox("JumpNoTextBox", certificate_holder.Total_Jumps.ToString());
        }
        #endregion

        #region Setting TMpassenger details
        if (_report_Version.Jump_Type_ID == int.Parse(ConfigurationManager.AppSettings.Get("TandemDDLValue")))
        {
            if (_report_Version.TMPassenger.First_Name != "")
            {
                SetTextBox("PassFirstNameTextBox", _report_Version.TMPassenger.First_Name);
            }
            if (_report_Version.TMPassenger.Last_Name != "")
            {
                SetTextBox("PassLastNameTextBox", _report_Version.TMPassenger.Last_Name);
            }
            if (_report_Version.TMPassenger.Age != -1)
            {
                SetTextBox("PassAgeTextBox", _report_Version.TMPassenger.Age.ToString());
            }
            if (_report_Version.TMPassenger.Gender.ID != 1)     // The 'Not specified yet' item
            {
                SetRadioButtonList("PassSexRadioButtonList", _report_Version.TMPassenger.Gender.ID);
            }
            if (_report_Version.TMPassenger.Weight != -1)
            {
                SetTextBox("PassWeightTextBox", _report_Version.TMPassenger.Weight.ToString());
            }
        }
        #endregion

        SetDropDownList("JumpTypeDropDownList", _report_Version.Jump_Type_ID);

        SetCheckBox("HandyCamCheckBox", _report_Version.Handycam);

        if (_report_Version.Wind_Direction != "")
        {
            SetTextBox("WindDirectionTextBox", _report_Version.Wind_Direction);
        }

        if (_report_Version.Wind_Speed != -1)
        {
            SetTextBox("WindKnotsTextBox", _report_Version.Wind_Speed.ToString());
        }

        SetDropDownList("WeatherDropDownList", _report_Version.Weather_ID);
        SetDropDownList("ContainerDropDownList", _report_Version.Container__ID);
        SetDropDownList("AADTypeDropDownList", _report_Version.AAD_Type_ID);
        SetDropDownList("MainCanopyBrandDropDownList", _report_Version.Main_Canopy_ID);
        if (_report_Version.Main_Canopy_Size != -1)
        {
            SetTextBox("MainCanopySizeTextBox", _report_Version.Main_Canopy_Size.ToString());
        }

        SetDropDownList("ReserveCanopyBrandDropDownList", _report_Version.Reserve_Canopy_ID);
        if (_report_Version.Reserve_Canopy_Size != -1)
        {
            SetTextBox("ReserveCanopySizeTextBox", _report_Version.Reserve_Canopy_Size.ToString());
        }

        if (_report_Version.Suspected_Injuries == ConfigurationManager.AppSettings.Get("NoInjuryDefaultValue"))
        {
            SetCheckBox("NoInjuryCheckBox", true);
            // Disable its complementary textbox.
            TextBox tb = (TextBox)_myControls["SuspectedInjuriesTextBox"];
            tb.Enabled = false;
            tb.BackColor = Color.LightGray;
        }
        else
        {
            if (_report_Version.Suspected_Injuries != "")
            {
                SetTextBox("SuspectedInjuriesTextBox", _report_Version.Suspected_Injuries);
            }
        }

        if (_report_Version.Main_Deployment_ID != 1)
        {
            SetRadioButtonList("MainDeploymentRadioButtonList", _report_Version.Main_Deployment_ID);
        }

        if (_report_Version.Incident_Summary != "")
        {
            SetTextBox("IncidentSummaryTextBox", _report_Version.Incident_Summary);
        }

        if (_report_Version.Recurrence_Prevention != "")
        {
            SetTextBox("RecurrencePreventionTextBox", _report_Version.Recurrence_Prevention);
        }

        // Their initial values should be 1 already. Like every other 'dropdownlist attribute.'
        SetDropDownList("InjuryTypeDropDownList", _report_Version.Injury_Type_ID);
        SetDropDownList("IncidentType1DropDownList", _report_Version.Incident_Type1_ID);
        SetDropDownList("IncidentType2DropDownList", _report_Version.Incident_Type2_ID);
        SetDropDownList("IncidentType3DropDownList", _report_Version.Incident_Type3_ID);
        SetDropDownList("IncidentType4DropDownList", _report_Version.Incident_Type4_ID);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        rih = new ReportIncidentHandler();

        rih.SelectIncident(1);

            // Get the selected incident report and populate the form.
            _iIncident_Report = rih.GetIncident();

            FileNoTextBox.Text = _iIncident_Report.File_Number.ToString();
            IncidentIDNoTextBox.Text = _iIncident_Report.ID.ToString();
            DropZoneCodeLabel.Text = _iIncident_Report.Drop_Zone.Code.ToString();
            DropZoneNameLabel.Text = _iIncident_Report.Drop_Zone.Name;
            LIncidentDateTextbox.Text = _iIncident_Report.Incident_Date.ToShortDateString();

            if (_iIncident_Report.Closed == true)
            {
                LIncidentStatusTextBox.Text = "Closed";
            }
            else
            {
                LIncidentStatusTextBox.Text = "Open";
            }

            // Get its version--for now it's assumed it's 1. Need to find out how to get the latest version.
            _iReport_Version = rih.GetIncidentVersion(1);
            // Get the IDs of people involved in the incident
            IPersonsInIncident _iPersonsInIncident = rih.GetPersonsInIncident(_iReport_Version.ID);
            // Get more details of the reporter.
            IUser_Person_Link _iReporter = rih.GetReporter(_iPersonsInIncident.Reporter_ID.ToString());
            ReporterNameTextBox.Text = _iReporter.Person.First_Name + " " + _iReporter.Person.Last_Name;
            ReporterCertificateTextBox.Text = _iReporter.Person.Certificate.Code.ToString();
            // Get the full, uncrypted term of the role.
            IRole _iReporterRole = rih.GetReporterTitle(_iReport_Version.Reporter_Role_ID.ToString());
            ReporterTitleTextBox.Text = _iReporterRole.RoleName;

            // For now, the details of jumper fields and passengers are NULL!
            LJumperFirstNameTextBox.Text = "NULL";
            LJumperLastNameTextBox.Text = "NULL";
            LJumperAgeTextBox.Text = "NULL";
            LJumperSexTextBox.Text = "NULL";
            LJumperWeightTextBox.Text = "NULL";
            LJumperCertificateTextBox.Text = "NULL";

            LJumpTypeTextBox.Text = _iReport_Version.Jump_Type.Type;

            if (_iReport_Version.Handycam == true)
            {
                LHandyCamLabel.Text = "Yes";
            }
            else
            {
                LHandyCamLabel.Text = "No";
            }

            LPrevJumpTextBox.Text = "NULL";
            LMonthJumpsTextBox.Text = "NULL";
            LSixMonthsJumpsTextBox.Text = "NULL";
            LJumpNoTextBox.Text = "NULL";

            LWindDirectionTextBox.Text = _iReport_Version.Wind_Direction;
            LWindKnotsTextBox.Text = _iReport_Version.Wind_Speed;
            LContainerTextBox.Text = _iReport_Version.Container.Name;

            // Skipping ...

            LIncidentSummaryTextBox.Text = _iReport_Version.Incident_Summary;

            #region If a passenger has been previously logged as involved, the modifying area is visible
            // Change all the if statements into on later, so it can check if there is a
            // Passenger object linked to the IncidentReport object(?) for this area to be visible

            // That must mean the JumpType is a 'TANDEM JUMP'. So if the user were to modify that area, we need
            // to show a alert message box saying that the Passenger area of the form will be greyed out and erased.
            // Behind the code, the passenger object and its properties 'are gone' on the modified version of the IR.

            // Temporary code to preview.
            // There is a passenger:
            //IsPassenger = true;
            //LPassFirstNameTextBox.Text = "Maya";
            //LPassLastNameTextBox.Text = "Fey";
            //LPassAgeTextBox.Text = "19";
            //LPassSexRadioButtonList.SelectedIndex = 1;
            //LPassWeightTextBox.Text = "50";

            // There isn't a passenger:
            IsPassenger = false;
            LPassFirstNameTextBox.Text = "";
            LPassLastNameTextBox.Text = "";
            LPassAgeTextBox.Text = "";
            LPassSexRadioButtonList.SelectedIndex = -1;
            LPassWeightTextBox.Text = "";

            if (IsPassenger == true)  // Change to see if the Passenger object exists
            {
                HighlightPassengerAreaLabels();
                ShowModifiedPassengerControls();
            }
            else
            {
                HideModifiedPassengerControls();
            }
            #endregion
    }
 // Need to succeed in finding a version by Incident_Report_ID
 public IIncident_Report_Version GetIncidentVersion(int ID)
 {
     _reportVersion = APF.Searcher.Find_Incident_Report_Version(ID);
     return _reportVersion;
 }
 public void SubmitIncidentVersion(IIncident_Report_Version submittedVersion)
 {
     APF.Persist(submittedVersion);
 }