コード例 #1
0
ファイル: AddPoint.ascx.cs プロジェクト: norio-soft/proteo
        protected void Page_Load(object sender, System.EventArgs e)
        {
            m_jobId = Convert.ToInt32(Request.QueryString["jobId"]);

            if (m_jobId > 0)
            {
                m_isUpdate = true;
            }

            // Retrieve the job from the session variable
            m_job = (Entities.Job)Session[wizard.C_JOB];

            if (Session[wizard.C_INSTRUCTION_INDEX] != null)
            {
                m_instructionIndex = (int)Session[wizard.C_INSTRUCTION_INDEX];

                if (!m_isUpdate && m_instructionIndex != m_job.Instructions.Count)
                {
                    m_isAmendment = true;
                }
            }

            if (Session[wizard.C_INSTRUCTION] != null)
            {
                m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];
            }

            if (!IsPostBack)
            {
                // Set the company
                Facade.IOrganisation facOrganisation = new Facade.Organisation();
                m_company = facOrganisation.GetForIdentityId((int)Session[wizard.C_POINT_FOR]).OrganisationName;

                // Set the town
                Facade.IPostTown facPostTown = new Facade.Point();
                m_town = facPostTown.GetPostTownForTownId((int)Session[wizard.C_TOWN_ID]).TownName;

                // Set the description
                m_description = Session[wizard.C_POINT_NAME].ToString();

                m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];

                btnNext.Attributes.Add("onClick", "javascript:HidePage();");
                btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE);
            }
        }
コード例 #2
0
ファイル: Refusal.aspx.cs プロジェクト: norio-soft/proteo
        /// <summary>
        /// Creates a new point based on the separate parts of the point passed as arguements.
        /// </summary>
        /// <param name="organisationId">The identity id of the organisation this point is registered to.</param>
        /// <param name="organisationName">The name of the organisation this point is registered to.</param>
        /// <param name="closestTownId">The id of the town id that is closest to this point.</param>
        /// <param name="description">The description that should be given to this point.</param>
        /// <param name="addressLine1">The first line of the address.</param>
        /// <param name="addressLine2">The second line of the address.</param>
        /// <param name="addressLine3">The third line of the address.</param>
        /// <param name="postTown">The town.</param>
        /// <param name="county">The county the point is within.</param>
        /// <param name="postCode">The post code.</param>
        /// <param name="longitude">The longitude attached to this point.</param>
        /// <param name="latitude">The latitude attached to this point.</param>
        /// <param name="trafficAreaId">The traffic area for this point.</param>
        /// <param name="userId">The id of the user creating this point.</param>
        /// <returns>The id of the new point created, or 0 if there were infringments encountered.</returns>
        private int CreateNewPoint(int organisationId, string organisationName, int closestTownId, string description, string addressLine1, string addressLine2, string addressLine3, string postTown, string county, string postCode, decimal longitude, decimal latitude, int trafficAreaId, string userId)
        {
            Entities.FacadeResult retVal = null;

            Entities.Point point = new Entities.Point();
            point.Address = new Entities.Address();
            point.Address.AddressLine1 = addressLine1;
            point.Address.AddressLine2 = addressLine2;
            point.Address.AddressLine3 = addressLine3;
            point.Address.PostTown     = postTown;
            point.Address.County       = county;
            point.Address.PostCode     = postCode;
            point.Address.Longitude    = longitude;
            point.Address.Latitude     = latitude;
            point.Address.TrafficArea  = new Entities.TrafficArea();
            point.Address.TrafficArea.TrafficAreaId = trafficAreaId;
            point.Address.AddressType = eAddressType.Point;

            point.Description      = description;
            point.IdentityId       = organisationId;
            point.Latitude         = latitude;
            point.Longitude        = longitude;
            point.OrganisationName = organisationName;
            Facade.IPostTown facPostTown = new Facade.Point();
            point.PostTown = facPostTown.GetPostTownForTownId(closestTownId);

            Facade.IPoint facPoint = new Facade.Point();
            retVal = facPoint.Create(point, userId);

            if (retVal.Success)
            {
                return(retVal.ObjectId);
            }
            else
            {
                infringementDisplay.Infringements = retVal.Infringements;
                infringementDisplay.DisplayInfringments();

                return(0);
            }
        }
コード例 #3
0
        /// <summary>
        /// Populates the location object with the new information.
        /// </summary>
        private void PopulateLocation()
        {
            Entities.Point thisPoint;

            if (m_location == null)
            {
                // adding a new location, configure identity and a new address
                m_location            = new Orchestrator.Entities.OrganisationLocation();
                m_location.IdentityId = m_identityId;
                thisPoint             = new Entities.Point();
                m_location.Point      = thisPoint;
            }
            else
            {
                thisPoint = m_location.Point;
            }

            if (_individual == null)
            {
                _individual = new Orchestrator.Entities.Individual();
                _individual.IndividualType = eIndividualType.Contact;
            }

            //Set the indiviudal details;
            _individual.FirstNames = txtFirstNames.Text;
            _individual.LastName   = txtLastName.Text;
            _individual.Title      = (eTitle)Enum.Parse(typeof(eTitle), cboTitle.SelectedValue);
            if (_individual.Contacts == null)
            {
                _individual.Contacts = new Orchestrator.Entities.ContactCollection();
            }

            _individual.Contacts.Add(new Orchestrator.Entities.Contact(eContactType.Email, txtEmailAddress.Text));
            _individual.Contacts.Add(new Orchestrator.Entities.Contact(eContactType.Telephone, txtTelephone.Text));
            _individual.Contacts.Add(new Orchestrator.Entities.Contact(eContactType.Fax, txtFax.Text));


            // Update the location based on it's settings.
            // location information
            m_location.OrganisationLocationName = txtLocationName.Text;
            m_location.OrganisationLocationType = (eOrganisationLocationType)Enum.Parse(typeof(eOrganisationLocationType), cboType.SelectedValue.Replace(" ", ""), true);
            m_location.TelephoneNumber          = txtTelephone.Text;
            m_location.FaxNumber = txtFax.Text;

            // address information
            thisPoint.Description = m_organisationName + " - " + txtPostTown.Text;
            Facade.IPostTown facPostTown = new Facade.Point();
            thisPoint.PostTown = facPostTown.GetPostTownForTownId(Convert.ToInt32(cboClosestTown.SelectedValue));
            if (thisPoint.Address == null)
            {
                thisPoint.Address = new Entities.Address();
            }
            thisPoint.Address.AddressType  = eAddressType.Correspondence;
            thisPoint.Address.AddressLine1 = txtAddressLine1.Text;
            thisPoint.Address.AddressLine2 = txtAddressLine2.Text;
            thisPoint.Address.AddressLine3 = txtAddressLine3.Text;
            thisPoint.Address.PostTown     = txtPostTown.Text;
            thisPoint.Address.County       = txtCounty.Text;
            thisPoint.Address.PostCode     = txtPostCode.Text;
            thisPoint.Address.Longitude    = Decimal.Parse(txtLongitude.Text);
            thisPoint.Address.Latitude     = Decimal.Parse(txtLatitude.Text);
            if (thisPoint.Address.TrafficArea == null)
            {
                thisPoint.Address.TrafficArea = new Entities.TrafficArea();
            }

            thisPoint.Address.CountryDescription        = cboCountry.SelectedItem.Text;
            thisPoint.Address.CountryId                 = Convert.ToInt32(cboCountry.SelectedValue);
            thisPoint.Address.TrafficArea.TrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue);
            thisPoint.IdentityId       = m_identityId;
            thisPoint.Latitude         = thisPoint.Address.Latitude;
            thisPoint.Longitude        = thisPoint.Address.Longitude;
            thisPoint.OrganisationName = m_organisationName;

            Facade.IOrganisation facOrganisation            = new Facade.Organisation();
            Orchestrator.Entities.Organisation organisation = facOrganisation.GetForIdentityId(thisPoint.IdentityId);

            // set the radius if the address was changed by addressLookup
            // if the org has a default, use it, if not, use the system default.
            if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value))
            {
                if (organisation.Defaults[0].DefaultGeofenceRadius == null)
                {
                    thisPoint.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                }
                else
                {
                    thisPoint.Radius = organisation.Defaults[0].DefaultGeofenceRadius;
                }
            }
        }
コード例 #4
0
ファイル: AddPoint.ascx.cs プロジェクト: norio-soft/proteo
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                #region Create the new point

                Entities.Point newPoint = new Entities.Point();

                Facade.IPostTown  facPostTown = new Facade.Point();
                Entities.PostTown town        = facPostTown.GetPostTownForTownId((int)Session[wizard.C_TOWN_ID]);

                // Set the point owner and description
                newPoint.IdentityId  = (int)Session[wizard.C_POINT_FOR];
                newPoint.Description = Session[wizard.C_POINT_NAME].ToString();

                // Get the point type
                switch ((ePointType)Session[wizard.C_POINT_TYPE])
                {
                case ePointType.Collect:
                    newPoint.Collect = true;
                    break;

                case ePointType.Deliver:
                    newPoint.Deliver = true;
                    break;

                case ePointType.Any:
                    newPoint.Collect = true;
                    newPoint.Deliver = true;
                    break;
                }

                // set the address
                Entities.Address address = new Entities.Address();
                address.AddressLine1 = txtAddressLine1.Text;
                address.AddressLine2 = txtAddressLine2.Text;
                address.AddressLine3 = txtAddressLine3.Text;
                address.AddressType  = eAddressType.Point;
                address.County       = txtCounty.Text;
                address.IdentityId   = newPoint.IdentityId;
                address.Latitude     = Decimal.Parse(txtLatitude.Text);
                address.Longitude    = Decimal.Parse(txtLongitude.Text);
                address.PostCode     = txtPostCode.Text;
                address.PostTown     = txtPostTown.Text;
                if (address.TrafficArea == null)
                {
                    address.TrafficArea = new Orchestrator.Entities.TrafficArea();
                }

                address.TrafficArea.TrafficAreaId = Convert.ToInt32(hidTrafficArea.Value);
                newPoint.Address   = address;
                newPoint.Longitude = address.Longitude;
                newPoint.Latitude  = address.Latitude;

                Facade.IOrganisation facOrganisation            = new Facade.Organisation();
                Orchestrator.Entities.Organisation organisation = facOrganisation.GetForIdentityId(newPoint.IdentityId);

                // set the radius if the address was changed by addressLookup
                // if the org has a default, use it, if not, use the system default.
                if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value))
                {
                    if (organisation.Defaults[0].DefaultGeofenceRadius == null)
                    {
                        newPoint.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                    }
                    else
                    {
                        newPoint.Radius = organisation.Defaults[0].DefaultGeofenceRadius;
                    }
                }

                newPoint.PostTown   = town;
                newPoint.PointNotes = txtPointNotes.Text;

                string userId = ((Entities.CustomPrincipal)Page.User).UserName;

                // Create the new point
                Facade.IPoint         facPoint = new Facade.Point();
                Entities.FacadeResult result   = facPoint.Create(newPoint, userId);

                int pointId = facPoint.Create(newPoint, userId).ObjectId;

                #endregion

                if (pointId == 0)
                {
                    // This customer already has a point with this name
                    // Try to locate the point
                    Entities.PointCollection points = facPoint.GetClientPointsForName(newPoint.IdentityId, newPoint.Description);
                    if (points.Count == 1)
                    {
                        // The point id has been found!
                        pointId = points[0].PointId;
                    }
                    else
                    {
                        // Clear the session variables used to help add the new point
                        Session[wizard.C_POINT_TYPE] = null;
                        Session[wizard.C_POINT_FOR]  = null;
                        Session[wizard.C_POINT_NAME] = null;
                        Session[wizard.C_TOWN_ID]    = null;

                        GoToStep("P");
                    }
                }

                if (pointId > 0)
                {
                    // Reload the point to ensure we have all the ancillary entities
                    Entities.Point createdPoint = facPoint.GetPointForPointId(pointId);

                    if (m_isUpdate)
                    {
                        // Add the collect drop point information
                        if (m_instruction == null)
                        {
                            m_instruction = new Entities.Instruction();

                            m_instruction.JobId = m_jobId;
                            switch ((ePointType)(int)Session[wizard.C_POINT_TYPE])
                            {
                            case ePointType.Collect:
                                m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                                break;

                            case ePointType.Deliver:
                                m_instruction.InstructionTypeId = (int)eInstructionType.Drop;
                                break;
                            }
                        }

                        m_instruction.Point         = createdPoint;
                        m_instruction.PointID       = createdPoint.PointId;
                        m_instruction.InstructionID = m_instruction.InstructionID;

                        if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop)
                        {
                            m_instruction.ClientsCustomerIdentityID = createdPoint.IdentityId;
                        }

                        // Cause the first docket to be displayed.
                        if (m_instruction.CollectDrops.Count > 0)
                        {
                            Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                            Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                        }

                        Session[wizard.C_INSTRUCTION] = m_instruction;
                    }
                    else
                    {
                        if (m_isAmendment)
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                m_instruction.Point   = createdPoint;
                                m_instruction.PointID = createdPoint.PointId;
                            }

                            // Cause the first docket to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            // Add the collect drop point information
                            if (m_instruction == null)
                            {
                                m_instruction = new Entities.Instruction();

                                m_instruction.JobId = m_jobId;
                                switch ((ePointType)(int)Session[wizard.C_POINT_TYPE])
                                {
                                case ePointType.Collect:
                                    m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                                    break;

                                case ePointType.Deliver:
                                    m_instruction.InstructionTypeId = (int)eInstructionType.Drop;
                                    break;
                                }
                            }

                            m_instruction.Point         = createdPoint;
                            m_instruction.PointID       = createdPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop)
                            {
                                m_instruction.ClientsCustomerIdentityID = createdPoint.IdentityId;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                    }

                    GoToStep("PD");
                }
            }
        }
コード例 #5
0
        private void PopulatePoint()
        {
            if (ViewState["point"] == null)
            {
                point         = new Entities.Point();
                point.Address = new Entities.Address();
            }
            else
            {
                point = (Entities.Point)ViewState["point"];
            }

            point.Description = txtDescription.Text;
            point.PointCode   = this.txtPointCode.Text;

            //Always make a Point both Collection and Delivery
            point.Collect = true;
            point.Deliver = true;

            point.IdentityId = int.Parse(cboClient.SelectedValue);

            // Get the town object for the town
            point.PostTown = new Entities.PostTown();
            Facade.IPostTown facPostTown = new Facade.Point();
            point.PostTown = facPostTown.GetPostTownForTownId(Convert.ToInt32(cboTown.SelectedValue));

            point.Address.AddressLine1       = txtAddressLine1.Text;
            point.Address.AddressLine2       = txtAddressLine2.Text;
            point.Address.AddressLine3       = txtAddressLine3.Text;
            point.Address.AddressType        = eAddressType.Point;
            point.Address.PostTown           = txtPostTown.Text;
            point.Address.County             = txtCounty.Text;
            point.Address.PostCode           = txtPostCode.Text;
            point.Address.CountryDescription = this.cboCountry.Text;
            point.Address.CountryId          = Convert.ToInt32(this.cboCountry.SelectedValue);

            if (txtLongitude.Text.Length > 0 && txtLatitude.Text.Length > 0)
            {
                point.Longitude = point.Address.Longitude = Decimal.Parse(txtLongitude.Text);
                point.Latitude  = point.Address.Latitude = Decimal.Parse(txtLatitude.Text);
            }

            Facade.IOrganisation facOrganisation            = new Facade.Organisation();
            Orchestrator.Entities.Organisation organisation = facOrganisation.GetForIdentityId(point.IdentityId);

            // set the radius if the address was changed by addressLookup
            // if the org has a default, use it, if not, use the system default.
            if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value))
            {
                if (organisation.Defaults.Count == 0 || organisation.Defaults[0].DefaultGeofenceRadius == null)
                {
                    point.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                }
                else
                {
                    point.Radius = organisation.Defaults[0].DefaultGeofenceRadius;
                }
            }

            if (point.Address.TrafficArea == null)
            {
                point.Address.TrafficArea = new Entities.TrafficArea();
            }

            if (m_isUpdate)
            {
                point.Address.TrafficArea.TrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue);
            }
            else
            {
                point.Address.TrafficArea.TrafficAreaId = 0; //Convert.ToInt32(hidTrafficArea.Value);
            }
            point.PointNotes = txtPointNotes.Text;

            // get the delivery point for saving
            point.DeliveryMatrix = Convert.ToInt32(this.cboDeliveryPeriod.SelectedValue);
        }
コード例 #6
0
        ///	<summary>
        /// Populate Driver
        ///	</summary>
        private void populateDriver()
        {
            if (ViewState["driver"] == null)
            {
                _driver = new Entities.Driver();
            }
            else
            {
                _driver = (Entities.Driver)ViewState["driver"];
            }

            _driver.ResourceType = eResourceType.Driver;
            if (_driver.Individual == null)
            {
                _driver.Individual = new Entities.Individual();
            }

            _driver.Individual.Title      = (eTitle)Enum.Parse(typeof(eTitle), cboTitle.SelectedValue.Replace(" ", ""));
            _driver.Individual.FirstNames = txtFirstNames.Text;
            _driver.Individual.LastName   = txtLastName.Text;
            if (dteDOB.SelectedDate != null)
            {
                _driver.Individual.DOB = dteDOB.SelectedDate.Value;
            }
            else
            {
                _driver.Individual.DOB = DateTime.MinValue;
            }
            _driver.Individual.IndividualType = eIndividualType.Driver;
            _driver.Passcode = txtPasscode.Text;

            if (_driver.Individual.Address == null)
            {
                _driver.Individual.Addresses = new Entities.AddressCollection();
                _driver.Individual.Addresses.Add(new Entities.Address());
            }

            _driver.Individual.Address.AddressLine1 = txtAddressLine1.Text;
            _driver.Individual.Address.AddressLine2 = txtAddressLine2.Text;
            _driver.Individual.Address.AddressLine3 = txtAddressLine3.Text;
            _driver.Individual.Address.PostTown     = txtPostTown.Text;
            _driver.Individual.Address.County       = txtCounty.Text;
            _driver.Individual.Address.PostCode     = txtPostCode.Text;

            if (_driver.Individual.Address.TrafficArea == null)
            {
                _driver.Individual.Address.TrafficArea = new Orchestrator.Entities.TrafficArea();
            }
            if (hidTrafficArea.Value != "")
            {
                _driver.Individual.Address.TrafficArea.TrafficAreaId = Convert.ToInt32(hidTrafficArea.Value);
            }

            if (_driver.Individual.Contacts == null)
            {
                _driver.Individual.Contacts = new Entities.ContactCollection();
            }

            Entities.Contact contact = _driver.Individual.Contacts.GetForContactType(eContactType.Telephone);
            if (null == contact)
            {
                contact             = new Entities.Contact();
                contact.ContactType = eContactType.Telephone;
                _driver.Individual.Contacts.Add(contact);
            }

            contact.ContactDetail = txtTelephone.Text;

            contact = _driver.Individual.Contacts.GetForContactType(eContactType.MobilePhone);
            if (null == contact)
            {
                contact             = new Entities.Contact();
                contact.ContactType = eContactType.MobilePhone;
                _driver.Individual.Contacts.Add(contact);
            }

            contact.ContactDetail = txtMobilePhone.Text;

            contact = _driver.Individual.Contacts.GetForContactType(eContactType.PersonalMobile);

            if (contact == null)
            {
                contact             = new Entities.Contact();
                contact.ContactType = eContactType.PersonalMobile;
                _driver.Individual.Contacts.Add(contact);
            }

            contact.ContactDetail = txtPersonalMobile.Text;

            // Retrieve the organisation and place it in viewstate
            Facade.IOrganisation          facOrganisation             = new Facade.Organisation();
            Entities.Organisation         m_organisation              = facOrganisation.GetForIdentityId(Orchestrator.Globals.Configuration.IdentityId);
            Entities.OrganisationLocation currentOrganisationLocation = null;
            Entities.Point   currentPoint   = null;
            Entities.Address currentAddress = null;
            if (m_organisation != null && m_organisation.Locations.Count > 0)
            {
                currentOrganisationLocation = m_organisation.Locations.GetHeadOffice();
                currentPoint   = currentOrganisationLocation.Point;
                currentAddress = currentPoint.Address;
            }

            if (cboPoint.SelectedValue != "")
            {
                _driver.HomePointId = Convert.ToInt32(cboPoint.SelectedValue);
            }
            else
            {
                _driver.HomePointId = currentPoint.PointId;
            }
            if (Convert.ToInt32(cboVehicle.SelectedValue) > 0)
            {
                _driver.AssignedVehicleId = Convert.ToInt32(cboVehicle.SelectedValue);
            }
            else
            {
                _driver.AssignedVehicleId = 0;
            }

            if (chkDelete.Checked)
            {
                _driver.Individual.IdentityStatus = eIdentityStatus.Deleted;
                _driver.ResourceStatus            = eResourceStatus.Deleted;
            }
            else
            {
                _driver.Individual.IdentityStatus = eIdentityStatus.Active;
                _driver.ResourceStatus            = eResourceStatus.Active;
            }

            if (_driver.Point == null && cboTown.SelectedValue != "")
            {
                _driver.Point = new Entities.Point();
            }

            if (cboDepot.SelectedValue != "")
            {
                _driver.DepotId = Convert.ToInt32(cboDepot.SelectedValue);
            }
            else
            {
                _driver.DepotId = currentOrganisationLocation.OrganisationLocationId;
            }

            if (_driver.Point != null)
            {
                decimal dLatitude = 0;
                decimal.TryParse(txtLatitude.Text, out dLatitude);
                decimal dLongtitude = 0;
                decimal.TryParse(txtLongitude.Text, out dLongtitude);

                _driver.Individual.Address.Latitude  = dLatitude;
                _driver.Individual.Address.Longitude = dLongtitude;
                _driver.Point.PostTown = new Entities.PostTown();
                Facade.IPostTown facPostTown = new Facade.Point();
                _driver.Point.IdentityId  = 0;
                _driver.Point.PostTown    = facPostTown.GetPostTownForTownId(Convert.ToInt32(cboTown.SelectedValue));
                _driver.Point.Address     = _driver.Individual.Address;
                _driver.Point.Latitude    = dLatitude;
                _driver.Point.Longitude   = dLongtitude;
                _driver.Point.Description = _driver.Individual.FirstNames + " " + _driver.Individual.LastName + " - Home";
                // We must try to set the radius of the point so that a new geofence
                // can be generated as we have just changed the point location through the address lookup.
                // not sure that this is neccessary for drivers though
                if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value))
                {
                    _driver.Point.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                }
            }

            if (cboDriverType.SelectedValue != "")
            {
                _driver.DriverType.DriverTypeID = int.Parse(cboDriverType.SelectedValue);
            }
            else
            {
                _driver.DriverType.DriverTypeID = 1;
            }

            _driver.DigitalTachoCardId = txtDigitalTachoCardId.Text;
            _driver.IsAgencyDriver     = chkAgencyDriver.Checked;
            if (dteSD.SelectedDate != null)
            {
                _driver.StartDate = dteSD.SelectedDate.Value;
            }
            else
            {
                _driver.StartDate = null;
            }
            _driver.PayrollNo = txtPayrollNo.Text;

            string selectedCommunicationType = rblDefaultCommunicationType.SelectedValue;

            if (selectedCommunicationType == "None")
            {
                _driver.DefaultCommunicationTypeID = 0;
            }
            else
            {
                _driver.DefaultCommunicationTypeID = (int)Enum.Parse(typeof(eDriverCommunicationType), rblDefaultCommunicationType.SelectedValue);
            }

            _driver.OrgUnitIDs = trvResourceGrouping.CheckedNodes.Select(x => Int32.Parse(x.Attributes["OrgUnitID"])).ToList();

            // if the telematics option is visible use the selected solution (validation enforces a non-null selection)
            if (telematicsOption.Visible)
            {
                _driver.TelematicsSolution = (eTelematicsSolution?)Enum.Parse(typeof(eTelematicsSolution), cboTelematicsSolution.SelectedValue);
            }
            else
            {
                // if telematics option is not visible and we're creating, use the default
                if (!_isUpdate && ViewState["defaultTelematicsSolution"] != null)
                {
                    _driver.TelematicsSolution = (eTelematicsSolution)ViewState["defaultTelematicsSolution"];
                }
                //otherwise leave the telematics solution as it is
            }

            if (!string.IsNullOrEmpty(cboDriverPlanner.SelectedValue))
            {
                _driver.PlannerIdentityID = Convert.ToInt32(cboDriverPlanner.SelectedValue);
            }
            else
            {
                _driver.PlannerIdentityID = null;   //PROT-6452 - un-allocating a driver from its planner
            }

            if (chkAgencyDriver.Checked)
            {
                if (cboAgency.SelectedIndex == -1)
                {
                    var agency = new Agency()
                    {
                        Name = cboAgency.Text
                    };

                    using (var uow = DIContainer.CreateUnitOfWork())
                    {
                        var agenciesRepo = DIContainer.CreateRepository <IAgencyRepository>(uow);
                        agenciesRepo.Add(agency);
                        uow.SaveChanges();
                    }
                    _driver.AgencyId = agency.AgencyId;
                }
                else
                {
                    _driver.AgencyId = int.Parse(cboAgency.SelectedItem.Value);
                }
            }
            else
            {
                _driver.AgencyId = null;
            }


            ViewState["driver"] = _driver;
        }