private void BuildStartComments(eDriverCommunicationType communicationType, StringBuilder sbComments, Entities.Instruction instruction)
        {
            switch (communicationType)
            {
            case eDriverCommunicationType.Phone:
                sbComments.Append("START TIME: ");
                break;

            case eDriverCommunicationType.Text:
                sbComments.Append("ST: ");
                break;
            }
            sbComments.Append(instruction.PlannedDepartureDateTime.ToString("dd/MM/yy HH:mm"));
            sbComments.Append(". ");

            switch (communicationType)
            {
            case eDriverCommunicationType.Phone:
                sbComments.Append("START PLACE: ");
                break;

            case eDriverCommunicationType.Text:
                sbComments.Append("SP: ");
                break;
            }
            sbComments.Append(string.Format("{0}.", instruction.Point.PostTown.TownName));
        }
        protected void cboEditCommunicationType_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList           cboEditCommunicationType = (DropDownList)sender;
            RequiredFieldValidator rfvEditText = (RequiredFieldValidator)cboEditCommunicationType.Parent.Parent.FindControl("rfvEditText");
            CustomValidator        cfvEditText = (CustomValidator)cboEditCommunicationType.Parent.Parent.FindControl("cfvEditText");
            CheckBox chkResendText             = (CheckBox)cboEditCommunicationType.Parent.Parent.FindControl("chkResendText");

            eDriverCommunicationType communicationType = (eDriverCommunicationType)Enum.Parse(typeof(eDriverCommunicationType), cboEditCommunicationType.SelectedValue.Replace(" ", ""));

            switch (communicationType)
            {
            case eDriverCommunicationType.Phone:
                rfvEditText.Enabled   = false;
                cfvEditText.Enabled   = false;
                chkResendText.Visible = false;
                break;

            case eDriverCommunicationType.Text:
                rfvEditText.Enabled   = true;
                cfvEditText.Enabled   = true;
                chkResendText.Visible = true;
                break;

            case eDriverCommunicationType.InPerson:
                rfvEditText.Enabled   = false;
                cfvEditText.Enabled   = false;
                chkResendText.Visible = false;
                break;
            }
        }
        private string GetComments(Entities.LegPlan legPlan, eDriverCommunicationType communicationType)
        {
            bool doneFirstLeg = false;
            int  lastLorry    = 0;
            int  lastTrailer  = 0;

            StringBuilder sb = new StringBuilder();

            foreach (Entities.LegView leg in legPlan.Legs())
            {
                if (leg.Driver != null && leg.Driver.ResourceId == _driverId)
                {
                    if (!doneFirstLeg)
                    {
                        BuildStartComments(communicationType, sb, leg);
                        doneFirstLeg = true;
                    }

                    if (leg.Vehicle != null && leg.Vehicle.ResourceId != lastLorry)
                    {
                        BuildVehicleComments(communicationType, sb, leg.Vehicle);
                        lastLorry = leg.Vehicle.ResourceId;
                    }

                    if (leg.Trailer != null && leg.Trailer.ResourceId != lastTrailer)
                    {
                        BuildTrailerComments(communicationType, sb, leg.Trailer);
                        lastTrailer = leg.Trailer.ResourceId;
                    }

                    // We should display information about this leg point.
                    BuildLegPointComments(communicationType, sb, leg.EndLegPoint);

                    // Display any instruction information.
                    if ((leg.StartLegPoint != null && leg.EndLegPoint != null) && leg.StartLegPoint.Instruction != null)
                    {
                        BuildInstructionTypeComments(sb, (eInstructionType)leg.StartLegPoint.Instruction.InstructionTypeId);

                        // Display the timing information.
                        sb.Append(" " + leg.StartLegPoint.PlannedDateTime.ToString("dd/MM/yy HH:mm"));
                        sb.Append(" " + leg.EndLegPoint.PlannedDateTime.ToString("dd/MM/yy HH:mm"));
                        sb.Append(". ");
                    }
                    else
                    {
                        // Display the timing information.
                        sb.Append(" " + leg.EndLegPoint.PlannedDateTime.ToString("dd/MM/yy HH:mm"));
                        sb.Append(". ");
                    }
                }
            }

            return(sb.ToString());
        }
        private void BuildTrailerComments(eDriverCommunicationType communicationType, StringBuilder sbComments, Entities.Trailer trailer)
        {
            switch (communicationType)
            {
            case eDriverCommunicationType.Phone:
                sbComments.Append("TRAILER: ");
                break;

            case eDriverCommunicationType.Text:
                sbComments.Append("T: ");
                break;
            }
            sbComments.Append(trailer.TrailerRef);
            sbComments.Append(". ");
        }
        private int BuildVehicleComments(eDriverCommunicationType communicationType, StringBuilder sbComments, Entities.Vehicle vehicle)
        {
            switch (communicationType)
            {
            case eDriverCommunicationType.Phone:
                sbComments.Append("LORRY: ");
                break;

            case eDriverCommunicationType.Text:
                sbComments.Append("V: ");
                break;
            }
            sbComments.Append(vehicle.RegNo);
            sbComments.Append(". ");

            int lastLorry = vehicle.ResourceId;

            return(lastLorry);
        }
        private void BuildLegPointComments(eDriverCommunicationType communicationType, StringBuilder sbComments, Entities.LegPoint legPoint)
        {
            // We should display information about this leg point.
            switch (communicationType)
            {
            case eDriverCommunicationType.Phone:
                sbComments.Append("STOP: ");
                break;

            case eDriverCommunicationType.Text:
                sbComments.Append("S: ");
                break;
            }

            // Display the point information.
            sbComments.Append(legPoint.Point.OrganisationName);
            sbComments.Append(", ");
            sbComments.Append(legPoint.Point.Description);
            sbComments.Append(", ");
            sbComments.Append(legPoint.Point.PostTown.TownName);
        }