Esempio n. 1
0
        public OperationResult CreateDriver(ServiceDataContracts.Driver driver)
        {
            try
            {
                var d = new Entities.Driver();
                d.FullName = driver.FullName;
                d.Phone    = driver.Phone;
                d.IsActive = driver.IsActive;

                db.Driver.Add(d);
                db.SaveChanges();

                return(new OperationResult
                {
                    Success = true,
                    CreatedObjectId = d.Id
                });
            }
            catch (Exception e)
            {
                log.Error("Error", e);
                return(new OperationResult
                {
                    Success = false,
                    ErrorMessage = e.Message
                });
            }
        }
Esempio n. 2
0
        private void PopulateRequest()
        {
            if (m_request == null)
            {
                Facade.IDriver  facDriver = new Facade.Resource();
                Entities.Driver driver    = facDriver.GetDriverForResourceId(Convert.ToInt32(cboDrivers.SelectedValue));

                m_request = new Entities.DriverRequest(driver, txtRequestText.Text, dteRequestDate.SelectedDate.Value);
            }
            else
            {
                m_request.Text      = txtRequestText.Text;
                m_request.AppliesTo = dteRequestDate.SelectedDate.Value;
            }
        }
        private Entities.Driver MapJsonDriver(int?jsonDriverId, Models.InputJson.Json inputJson)
        {
            if (jsonDriverId == null)
            {
                return(null);
            }

            Models.Driver jsonDriver = inputJson.Drivers.First(x => x.Id == jsonDriverId);

            Entities.Driver entityDriver = new Entities.Driver
            {
                Id            = jsonDriverId.Value,
                LicenseNumber = jsonDriver.LicenseNumber,
                PersonId      = jsonDriver.Person,
                Person        = MapJsonPerson(jsonDriver.Person, inputJson)
            };

            return(entityDriver);
        }
Esempio n. 4
0
        private void dgDrivers_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            switch (e.CommandName.ToLower())
            {
            case "removedriver":
                int resourceId = Convert.ToInt32(e.Item.Cells[0].Text);

                for (int driverIndex = 0; driverIndex < m_drivers.Count; driverIndex++)
                {
                    Entities.Driver thisDriver = m_drivers[driverIndex];

                    if (thisDriver.ResourceId == resourceId)
                    {
                        m_drivers.RemoveAt(driverIndex);
                        ViewState[C_DRIVER_COLLECTION] = m_drivers;
                        BindDrivers();
                    }
                }
                break;
            }
        }
        private void DisplayCommunication(int driverCommunicationId)
        {
            // Load the communication
            Entities.DriverCommunication communication = null;
            Entities.Driver driver = null;

            using (Facade.IDriver facDriver = new Facade.Resource())
            {
                communication = ((Facade.IDriverCommunication)facDriver).GetForDriverCommunicationId(driverCommunicationId);
                int driverId = facDriver.GetDriverForDriverCommunicationId(driverCommunicationId);
                driver = facDriver.GetDriverForResourceId(driverId);
            }

            if (communication != null && driver != null)
            {
                lblDriverFullName.Text          = driver.Individual.FullName;
                lblCommunicationStatus.Text     = Utilities.UnCamelCase(communication.DriverCommunicationStatus.ToString());
                lblCommunicationType.Text       = Utilities.UnCamelCase(communication.DriverCommunicationType.ToString());
                lblCommunicationComments.Text   = communication.Comments.Replace("START PLACE", "<br>START PLACE").Replace("STOP", "<br>STOP");
                lblCommunicationText.Text       = communication.Text;
                lblCommunicationNumberUsed.Text = communication.NumberUsed;
            }
        }
Esempio n. 6
0
        private void btnSelectDriver_Click(object sender, EventArgs e)
        {
            btnSelectDriver.DisableServerSideValidation();

            if (Page.IsValid)
            {
                int  resourceId      = Convert.ToInt32(cboDriver.SelectedValue);
                bool alreadySelected = false;

                // Make sure each driver is only present once
                foreach (Entities.Driver thisDriver in m_drivers)
                {
                    if (thisDriver.ResourceId == resourceId)
                    {
                        alreadySelected = true;
                    }
                }

                if (!alreadySelected)
                {
                    // Retrieve the driver
                    Facade.IDriver  facDriver = new Facade.Resource();
                    Entities.Driver driver    = facDriver.GetDriverForResourceId(resourceId);

                    // Add the driver to the collection and refresh the viewstate
                    m_drivers.Add(driver);
                    ViewState[C_DRIVER_COLLECTION] = m_drivers;
                }

                // Reset the dbcombo
                cboDriver.Text          = "";
                cboDriver.SelectedValue = "";

                // Rebind the drivers
                BindDrivers();
            }
        }
        void cboVehicle_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            ((Telerik.Web.UI.RadComboBox)sender).Items.Clear();
            Telerik.Web.UI.RadComboBoxItem rcItem = new Telerik.Web.UI.RadComboBoxItem();

            DataSet ds = null;

            string[] clientArgs = e.Context["FilterString"].ToString().Split(':');
            if (e.Context["FilterString"] != null)
            {
                if (clientArgs[0] == "true")
                {
                    // Get the Drivers usual vehicle
                    Facade.IDriver  facDriver = new Facade.Resource();
                    Entities.Driver driver    = facDriver.GetDriverForResourceId(int.Parse(clientArgs[1]));

                    Entities.Vehicle vehicle = ((Facade.IVehicle)facDriver).GetForVehicleId(driver.AssignedVehicleId);
                    if (vehicle != null)
                    {
                        rcItem.Text     = vehicle.RegNo;
                        rcItem.Value    = vehicle.ResourceId.ToString();
                        rcItem.Selected = true;
                        ((Telerik.Web.UI.RadComboBox)sender).Items.Add(rcItem);
                    }
                }
                else
                {
                    int   controlAreaId = 0;
                    int[] trafficAreas  = new int[clientArgs.Length - 1];
                    controlAreaId = int.Parse(clientArgs[0]);

                    for (int i = 1; i < clientArgs.Length; i++)
                    {
                        trafficAreas[i - 1] = int.Parse(clientArgs[i]);
                    }

                    Facade.IResource facResource = new Facade.Resource();
                    ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, controlAreaId, trafficAreas, true);
                }
            }
            else
            {
                Facade.IResource facResource = new Facade.Resource();
                ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, false);
            }

            if (ds != null)
            {
                int itemsPerRequest = 20;
                int itemOffset      = e.NumberOfItems;
                int endOffset       = itemOffset + itemsPerRequest;
                if (endOffset > ds.Tables[0].Rows.Count)
                {
                    endOffset = ds.Tables[0].Rows.Count;
                }

                DataTable dt = ds.Tables[0];
                for (int i = itemOffset; i < endOffset; i++)
                {
                    rcItem       = new Telerik.Web.UI.RadComboBoxItem();
                    rcItem.Text  = dt.Rows[i]["Description"].ToString();
                    rcItem.Value = dt.Rows[i]["ResourceId"].ToString();
                    ((Telerik.Web.UI.RadComboBox)sender).Items.Add(rcItem);
                }

                if (dt.Rows.Count > 0)
                {
                    e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dt.Rows.Count.ToString());
                }
            }
        }
Esempio n. 8
0
        private void LoadCommunication()
        {
            Facade.IInstruction facInstrucion = new Facade.Instruction();
            var jobInstructions = facInstrucion.GetForJobId(_jobId);
            var instruction     = jobInstructions.Single(i => i.InstructionID == _instructionID);

            // Get the driver.
            Facade.IDriver  facDriver = new Facade.Resource();
            Entities.Driver driver    = facDriver.GetDriverForResourceId(_driverId);

            var communicationTypes = Utilities.GetEnumPairs <eDriverCommunicationType>();

            // We don't offer the option to communicate by Tough Touch if the driver doesn't have a passcode or the vehicle doesn't have a Tough Touch installed.
            if (string.IsNullOrWhiteSpace(driver.Passcode) || instruction.Vehicle == null || !instruction.Vehicle.IsTTInstalled)
            {
                communicationTypes.Remove((int)eDriverCommunicationType.ToughTouch);
            }

            cboCommunicationType.DataSource = communicationTypes;
            cboCommunicationType.DataBind();
            cboCommunicationType.Items.Insert(0, new ListItem("-- Select a communication type --", ""));
            cboCommunicationType.Attributes.Add("onchange", "cboCommunicationTypeIndex_Changed();");

            cboCommunicationStatus.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eDriverCommunicationStatus)));
            cboCommunicationStatus.DataBind();

            RadioButton rb = null;

            Entities.ContactCollection contacts = new Entities.ContactCollection();

            if (driver != null && driver.Individual.Contacts != null)
            {
                contacts = driver.Individual.Contacts;
            }

            // Get the vehicle the driver is currently assigned to.
            Facade.IJourney  facJourney     = new Facade.Journey();
            Entities.Vehicle currentVehicle = facJourney.GetCurrentVehicleForDriver(_driverId);

            if (currentVehicle != null)
            {
                contacts.Add(new Entities.Contact(eContactType.MobilePhone, currentVehicle.CabPhoneNumber));
            }

            Entities.ContactCollection cs = new Orchestrator.Entities.ContactCollection();
            rb = new RadioButton();

            bool numberSelected = false;

            foreach (Entities.Contact contact in contacts)
            {
                if (contact.ContactDetail.Length > 0)
                {
                    rb           = new RadioButton();
                    rb.GroupName = "rblNumbers";
                    rb.Text      = contact.ContactDetail;
                    rb.Attributes.Add("onclick", "setNumberUsed('" + contact.ContactDetail + "');");

                    if (contact.ContactType == eContactType.MobilePhone || contact.ContactType == eContactType.PersonalMobile ||
                        contact.ContactType == eContactType.Telephone)
                    {
                        if (!numberSelected)
                        {
                            rb.Checked     = true;
                            txtNumber.Text = contact.ContactDetail;
                            numberSelected = true;
                        }
                    }

                    plcNumbers.Controls.Add(rb);
                    plcNumbers.Controls.Add(new LiteralControl("<br/>"));
                }
            }

            rb           = new RadioButton();
            rb.Text      = "Other";
            rb.GroupName = "rblNumbers";
            rb.Attributes.Add("onclick", "enableOtherTextBox();");
            plcNumbers.Controls.Add(rb);

            bool isInvolvedInLoad = false;

            foreach (Entities.Instruction i in jobInstructions)
            {
                if (i.Driver != null && i.Driver.ResourceId == _driverId)
                {
                    if ((eInstructionType)i.InstructionTypeId == eInstructionType.Load)
                    {
                        isInvolvedInLoad = true;
                    }
                }
            }

            trLoadOrder.Visible = isInvolvedInLoad;

            if (isInvolvedInLoad)
            {
                var loadComments = BuildLoadComments(_driverId, jobInstructions);
                lblLoadOrder.Text   = loadComments;
                trLoadOrder.Visible = !string.IsNullOrWhiteSpace(loadComments);
            }

            var legPlan = new Facade.Instruction().GetLegPlan(jobInstructions, false);

            txtComments.Text = GetComments(legPlan, eDriverCommunicationType.Phone);
            txtSMSText.Text  = GetComments(legPlan, eDriverCommunicationType.Text);

            var defaultCommunicationTypeID = driver.DefaultCommunicationTypeID == 0 ? (int)eDriverCommunicationType.Phone : driver.DefaultCommunicationTypeID;

            //lookup the communication type in the drop down, dont select if it doesnt exist - this should only happen if the driver whos default method of communitication
            // is tough touch but has now moved into a vechicial without one being installed
            if (cboCommunicationType.Items.FindByValue(defaultCommunicationTypeID.ToString()) != null)
            {
                cboCommunicationType.Items.FindByValue(defaultCommunicationTypeID.ToString()).Selected = true;
            }

            Facade.IControlArea facControlArea = new Facade.Traffic();
            cboControlArea.DataSource = facControlArea.GetAll();
            cboControlArea.DataBind();

            for (int instructionIndex = jobInstructions.Count - 1; instructionIndex >= 0; instructionIndex--)
            {
                if (jobInstructions[instructionIndex].Driver != null && jobInstructions[instructionIndex].Driver.ResourceId == _driverId)
                {
                    hidLastInstructionInvolvedWith.Value = jobInstructions[instructionIndex].InstructionOrder.ToString();

                    cboControlArea.ClearSelection();
                    cboControlArea.Items.FindByValue(jobInstructions[instructionIndex].Point.Address.TrafficArea.ControlAreaId.ToString()).Selected = true;
                    BindTrafficAreas(Convert.ToInt32(cboControlArea.SelectedValue), jobInstructions[instructionIndex].Point.Address.TrafficArea.TrafficAreaId);
                    break;
                }
            }

            ShowPCVS();
        }
Esempio n. 9
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;
        }
Esempio n. 10
0
        ///	<summary>
        /// Load Driver
        ///	</summary>
        private void LoadDriver()
        {
            if (ViewState["driver"] == null)
            {
                IDriver facDriver = new Facade.Resource();
                _driver = facDriver.GetDriverForIdentityId(_identityId);

                ViewState["driver"] = _driver;
            }
            else
            {
                _driver = (Entities.Driver)ViewState["driver"];
            }

            if (_driver != null)
            {
                hypAddNewVehicle.Visible = true;
                cboTitle.SelectedValue   = Utilities.UnCamelCase(_driver.Individual.Title.ToString());
                txtFirstNames.Text       = _driver.Individual.FirstNames;
                txtLastName.Text         = _driver.Individual.LastName;
                txtPasscode.Text         = _driver.Passcode;

                dteDOB.SelectedDate = _driver.Individual.DOB;

                if (_driver.Individual.Contacts != null && _driver.Individual.Contacts.Count > 0)
                {
                    Entities.Contact telephone      = _driver.Individual.Contacts.GetForContactType(eContactType.Telephone);
                    Entities.Contact mobile         = _driver.Individual.Contacts.GetForContactType(eContactType.MobilePhone);
                    Entities.Contact personalMobile = _driver.Individual.Contacts.GetForContactType(eContactType.PersonalMobile);

                    if (telephone != null)
                    {
                        txtTelephone.Text = telephone.ContactDetail;
                    }
                    if (mobile != null)
                    {
                        txtMobilePhone.Text = mobile.ContactDetail;
                    }
                    if (personalMobile != null)
                    {
                        txtPersonalMobile.Text = personalMobile.ContactDetail;
                    }
                }

                if (_driver.Individual.Address != null)
                {
                    txtAddressLine1.Text = _driver.Individual.Address.AddressLine1;
                    txtAddressLine2.Text = _driver.Individual.Address.AddressLine2;
                    txtAddressLine3.Text = _driver.Individual.Address.AddressLine3;

                    txtPostTown.Text = _driver.Individual.Address.PostTown;
                    txtCounty.Text   = _driver.Individual.Address.County;
                    txtPostCode.Text = _driver.Individual.Address.PostCode;

                    if (_driver.Individual.Address.TrafficArea != null)
                    {
                        hidTrafficArea.Value = _driver.Individual.Address.TrafficArea.TrafficAreaId.ToString();
                    }
                }

                foreach (Entities.Contact contact in _driver.Individual.Contacts)
                {
                    if (contact.ContactType == eContactType.Telephone)
                    {
                        txtTelephone.Text = contact.ContactDetail;
                    }
                    if (contact.ContactType == eContactType.MobilePhone)
                    {
                        txtMobilePhone.Text = contact.ContactDetail;
                    }
                    if (contact.ContactType == eContactType.PersonalMobile)
                    {
                        txtPersonalMobile.Text = contact.ContactDetail;
                    }
                }

                Facade.IPoint  facPoint = new Facade.Point();
                Entities.Point point    = facPoint.GetPointForPointId(_driver.HomePointId);

                if (point != null && point.PointId > 0)
                {
                    cboOrganisation.Text          = point.OrganisationName;
                    cboOrganisation.SelectedValue = point.IdentityId.ToString();
                    m_organisationId = point.IdentityId;

                    m_startTown   = point.PostTown.TownName;
                    m_startTownId = point.PostTown.TownId;

                    cboPoint.Text          = point.Description;
                    cboPoint.SelectedValue = point.PointId.ToString();
                    m_pointId = point.PointId;
                }

                cboDriverType.Items.FindByValue(_driver.DriverType.DriverTypeID.ToString()).Selected = true;

                cboVehicle.ClearSelection();
                if (_driver.AssignedVehicleId != 0)
                {
                    ListItem vehicle = cboVehicle.Items.FindByValue(_driver.AssignedVehicleId.ToString());
                    if (vehicle != null)
                    {
                        vehicle.Selected = true;
                    }
                }

                txtDigitalTachoCardId.Text = _driver.DigitalTachoCardId;
                chkAgencyDriver.Checked    = _driver.IsAgencyDriver;

                if (_driver.Individual.IdentityStatus == eIdentityStatus.Deleted)
                {
                    chkDelete.Checked = true;
                }

                if (_driver.Point != null)
                {
                    txtLatitude.Text      = _driver.Point.Latitude.ToString();
                    txtLongitude.Text     = _driver.Point.Longitude.ToString();
                    cboTown.SelectedValue = _driver.Point.PostTown.TownId.ToString();
                    cboTown.Text          = _driver.Point.PostTown.TownName;
                }

                Entities.ControlArea ca = null;
                Entities.TrafficArea ta = null;

                using (Facade.IResource facResource = new Facade.Resource())
                    facResource.GetControllerForResourceId(_driver.ResourceId, ref ca, ref ta);

                cboDepot.ClearSelection();
                if (_driver.DepotId > 0)
                {
                    cboDepot.FindItemByValue(_driver.DepotId.ToString()).Selected = true;
                }

                if (ca != null && ta != null)
                {
                    cboControlArea.ClearSelection();
                    cboControlArea.FindItemByValue(ca.ControlAreaId.ToString()).Selected = true;
                    cboTrafficArea.ClearSelection();
                    cboTrafficArea.FindItemByValue(ta.TrafficAreaId.ToString()).Selected = true;
                }

                chkDelete.Visible        = true;
                pnlDriverDeleted.Visible = true;

                if (_driver.DefaultCommunicationTypeID == 0)
                {
                    rblDefaultCommunicationType.Items.FindByText("None").Selected = true;
                }
                else
                {
                    rblDefaultCommunicationType.Items.FindByText(((eDriverCommunicationType)_driver.DefaultCommunicationTypeID).ToString()).Selected = true;
                }
                txtPayrollNo.Text  = _driver.PayrollNo;
                dteSD.SelectedDate = _driver.StartDate;

                if (telematicsOption.Visible)
                {
                    cboTelematicsSolution.ClearSelection();
                    if (_driver.TelematicsSolution.HasValue)
                    {
                        cboTelematicsSolution.Items.FindByText(_driver.TelematicsSolution.ToString()).Selected = true;
                    }
                }

                //Find all tree nodes that correspond to the org units
                var treeNodesToCheck = m_orgUnitTreeNodes.Where(x => _driver.OrgUnitIDs.Contains(x.OrgUnitId.Value));
                foreach (var treeNode in treeNodesToCheck)
                {
                    treeNode.Checked = true;
                }

                if (_driver.PlannerIdentityID != null)
                {
                    cboDriverPlanner.ClearSelection();
                    cboDriverPlanner.FindItemByValue(_driver.PlannerIdentityID.ToString()).Selected = true;
                }

                if (_driver.AgencyId != null)
                {
                    cboAgency.ClearSelection();
                    cboAgency.FindItemByValue(_driver.AgencyId.ToString()).Selected = true;
                }
            }

            btnAdd.Text = "Update";
        }