private void btnAddNewControlArea_Click(object sender, EventArgs e) { m_controlArea = null; ViewState[C_CONTROL_AREA_VS] = m_controlArea; cboControlArea.SelectedIndex = -1; ConfigureControlAreaManipulation(eControlAreaManipulation.AddControlArea); }
/// <summary> /// The user has selected a control area to configure traffic areas for. /// </summary> private void cboControlArea_SelectedIndexChanged(object sender, EventArgs e) { int controlAreaId = Convert.ToInt32(cboControlArea.SelectedValue); using (Facade.IControlArea facControlArea = new Facade.Traffic()) { m_controlArea = facControlArea.GetForControlAreaId(controlAreaId); ViewState[C_CONTROL_AREA_VS] = m_controlArea; } ConfigureControlAreaManipulation(eControlAreaManipulation.ConfigureTrafficAreas); }
/// <summary> /// The user has selected a control area to alter - allow them to change the description and code. /// </summary> private void btnAlterControlArea_Click(object sender, EventArgs e) { btnAlterControlArea.DisableServerSideValidation(); if (Page.IsValid) { int controlAreaId = Convert.ToInt32(cboControlArea.SelectedValue); using (Facade.IControlArea facControlArea = new Facade.Traffic()) { m_controlArea = facControlArea.GetForControlAreaId(controlAreaId); ViewState[C_CONTROL_AREA_VS] = m_controlArea; } ConfigureControlAreaManipulation(eControlAreaManipulation.AddControlArea); } }
protected void Page_Load(object sender, System.EventArgs e) { Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.ControlAreaManagement); if (!IsPostBack) { ConfigureControlAreaManipulation(eControlAreaManipulation.SelectControlArea); ConfigureTrafficAreaManupulation(eTrafficAreaManipulation.SelectTrafficArea); } else { m_controlArea = (Entities.ControlArea)ViewState[C_CONTROL_AREA_VS]; m_trafficArea = (Entities.TrafficArea)ViewState[C_TRAFFIC_AREA_VS]; } lblConfirmation.Visible = false; }
private void btnActionControlArea_Click(object sender, EventArgs e) { btnActionControlArea.DisableServerSideValidation(); if (Page.IsValid) { if (m_controlArea == null) { m_controlArea = new Entities.ControlArea(); } m_controlArea.ControlAreaName = txtControlAreaDescription.Text; bool success = false; using (Facade.IControlArea facControlArea = new Facade.Traffic()) { if (m_controlArea.ControlAreaId == 0) { m_controlArea.ControlAreaId = facControlArea.Create(m_controlArea, ((Entities.CustomPrincipal)Page.User).UserName); success = m_controlArea.ControlAreaId > 0; } else { success = facControlArea.Update(m_controlArea, ((Entities.CustomPrincipal)Page.User).UserName); } } if (success) { lblConfirmation.Text = "The control area has been stored."; ConfigureControlAreaManipulation(eControlAreaManipulation.SelectControlArea); } else { lblConfirmation.Text = "The control area has not been stored."; } lblConfirmation.Visible = true; } }
/// <summary> /// Load Trailer /// </summary> private void LoadTrailer() { if (ViewState["trailer"] == null) { Facade.ITrailer facTrailer = new Facade.Resource(); trailer = facTrailer.GetForTrailerId(m_resourceId, true); ViewState["trailer"] = trailer; } else { trailer = (Entities.Trailer)ViewState["trailer"]; } if (trailer != null) { txtTrailerRef.Text = trailer.TrailerRef; cboTrailerType.Items.FindByValue(trailer.TrailerTypeId.ToString()).Selected = true; cboTrailerManufacturer.Items.FindByValue(trailer.TrailerManufacturerId.ToString()).Selected = true; Facade.IPoint facPoint = new Facade.Point(); Entities.Point point = facPoint.GetPointForPointId(trailer.HomePointId); cboOrganisation.Text = point.OrganisationName; cboOrganisation.SelectedValue = point.IdentityId.ToString(); m_organisationId = point.IdentityId; m_startTown = point.PostTown.TownName; m_startTownId = point.PostTown.TownId; if (trailer.VehicleResourceID.HasValue) { lblVehicle.Text = trailer.VehicleResource; } txtGPSUnitID.Text = trailer.GPSUnitID; cboPoint.Text = point.Description; cboPoint.SelectedValue = point.PointId.ToString(); m_pointId = point.PointId; cboTrailerDescription.SelectedIndex = trailer.TrailerDescriptionId + 1; if (trailer.ResourceStatus == eResourceStatus.Deleted) { chkDelete.Checked = true; } Entities.ControlArea ca = null; Entities.TrafficArea ta = null; using (Facade.IResource facResource = new Facade.Resource()) facResource.GetControllerForResourceId(trailer.ResourceId, ref ca, ref ta); if (ca != null && ta != null) { cboControlArea.ClearSelection(); cboControlArea.Items.FindByValue(ca.ControlAreaId.ToString()).Selected = true; cboTrafficArea.ClearSelection(); cboTrafficArea.Items.FindByValue(ta.TrafficAreaId.ToString()).Selected = true; } chkDelete.Visible = true; pnlTrailerDeleted.Visible = true; txtThirdPartyIntegrationID.Text = (trailer.ThirdPartyIntegrationID.HasValue) ? trailer.ThirdPartyIntegrationID.ToString() : string.Empty; } btnAdd.Text = "Update"; }
private void ConfigureControlAreaManipulation(eControlAreaManipulation manipulation) { pnlConfigureControlAreasTrafficAreas.Visible = false; pnlAddTrafficAreaToControlArea.Visible = false; pnlConfigureControlArea.Visible = false; // Configure the manipulation panels switch (manipulation) { case eControlAreaManipulation.ConfigureTrafficAreas: pnlConfigureControlAreasTrafficAreas.Visible = true; cboControlAreaTrafficAreas.SelectedIndex = -1; using (Facade.ITrafficArea facTrafficArea = new Facade.Traffic()) cboControlAreaTrafficAreas.DataSource = facTrafficArea.GetForControlAreaId(m_controlArea.ControlAreaId); cboControlAreaTrafficAreas.DataTextField = "Description"; cboControlAreaTrafficAreas.DataValueField = "TrafficAreaId"; cboControlAreaTrafficAreas.DataBind(); break; case eControlAreaManipulation.AddTrafficArea: pnlConfigureControlAreasTrafficAreas.Visible = true; pnlAddTrafficAreaToControlArea.Visible = true; cboAddTrafficArea.SelectedIndex = -1; using (Facade.ITrafficArea facTrafficArea = new Facade.Traffic()) cboAddTrafficArea.DataSource = facTrafficArea.GetAll(); cboAddTrafficArea.DataTextField = "Description"; cboAddTrafficArea.DataValueField = "TrafficAreaId"; cboAddTrafficArea.DataBind(); break; case eControlAreaManipulation.AddControlArea: pnlConfigureControlArea.Visible = true; if (m_controlArea != null) { txtControlAreaDescription.Text = m_controlArea.ControlAreaName; btnActionControlArea.Text = "Update"; } else { txtControlAreaDescription.Text = String.Empty; btnActionControlArea.Text = "Add"; } break; case eControlAreaManipulation.SelectControlArea: // Set the control area m_controlArea = null; ViewState[C_CONTROL_AREA_VS] = m_controlArea; // Set the drop down list cboControlArea.SelectedIndex = -1; using (Facade.IControlArea facControlArea = new Facade.Traffic()) cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataTextField = "Description"; cboControlArea.DataValueField = "ControlAreaId"; cboControlArea.DataBind(); cboControlArea.Items.Insert(0, new ListItem("-- Select a Control Area -- ", "-1")); break; } }
/// <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"; }
/// <summary> /// Load Vehicle /// </summary> private void LoadVehicle() { if (ViewState["vehicle"] == null) { Facade.IVehicle facVehicle = new Facade.Resource(); vehicle = facVehicle.GetForVehicleId(m_resourceId); ViewState["vehicle"] = vehicle; } else { vehicle = (Entities.Vehicle)ViewState["vehicle"]; } if (vehicle != null) { txtRegistrationNo.Text = vehicle.RegNo; vehicleRegistrationNo = vehicle.RegNo; txtChassisNo.Text = vehicle.ChassisNo; txtTelephoneNumber.Text = vehicle.CabPhoneNumber; cboClass.SelectedIndex = -1; dteMOTExpiry.SelectedDate = vehicle.MOTExpiry; dteServiceDate.SelectedDate = vehicle.VehicleServiceDueDate; cboManufacturer.ClearSelection(); cboClass.Items.FindByValue(vehicle.VehicleClassId.ToString()).Selected = true; cboManufacturer.Items.FindByValue(vehicle.VehicleManufacturerId.ToString()).Selected = true; chkIsFixedUnit.Checked = vehicle.IsFixedUnit; pnlTrailerDetails.Visible = !vehicle.IsFixedUnit; if (pnlTrailerDetails.Visible && vehicle.TrailerResourceID.HasValue) { lblTrailer.Text = vehicle.TrailerResource; } cboVehicleType.ClearSelection(); if (vehicle.VehicleTypeID > 0) { cboVehicleType.Items.FindByValue(vehicle.VehicleTypeID.ToString()).Selected = true; } if (telematicsOption.Visible) { cboTelematicsSolution.ClearSelection(); if (vehicle.TelematicsSolution.HasValue) { cboTelematicsSolution.Items.FindByText(vehicle.TelematicsSolution.ToString()).Selected = true; } } // Need to load model after manufacturer has loaded and then loaded // model dropdown with the relevant results cboManufacturer_SelectedIndexChanged(cboManufacturer, EventArgs.Empty); cboModel.Items.FindByValue(vehicle.VehicleModelId.ToString()).Selected = true; // Need to load model after manufacturer has loaded and then loaded // model dropdown with the relevant results cboManufacturer_SelectedIndexChanged(cboManufacturer, EventArgs.Empty); cboModel.Items.FindByValue(vehicle.VehicleModelId.ToString()).Selected = true; Facade.IPoint facPoint = new Facade.Point(); Entities.Point point = facPoint.GetPointForPointId(vehicle.HomePointId); 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; // Set the nominal code if (vehicle.NominalCodeId > 0) { cboNominalCode.Items.FindByValue(vehicle.NominalCodeId.ToString()).Selected = true; } PopulateKeys(); if (vehicle.ResourceStatus == eResourceStatus.Deleted) { chkDelete.Checked = true; } Entities.ControlArea ca = null; Entities.TrafficArea ta = null; using (Facade.IResource facResource = new Facade.Resource()) facResource.GetControllerForResourceId(vehicle.ResourceId, ref ca, ref ta); cboDepot.ClearSelection(); if (vehicle.DepotId > 0) { cboDepot.Items.FindByValue(vehicle.DepotId.ToString()).Selected = true; } if (ca != null && ta != null) { cboControlArea.ClearSelection(); cboControlArea.Items.FindByValue(ca.ControlAreaId.ToString()).Selected = true; cboTrafficArea.ClearSelection(); cboTrafficArea.Items.FindByValue(ta.TrafficAreaId.ToString()).Selected = true; } cboDedicatedToClient.SelectedValue = vehicle.DedicatedToClientIdentityID.ToString(); if (vehicle.DedicatedToClientIdentityID.HasValue) { using (var uow = DIContainer.CreateUnitOfWork()) { var repo = DIContainer.CreateRepository <IOrganisationRepository>(uow); var client = repo.Find(vehicle.DedicatedToClientIdentityID.Value); cboDedicatedToClient.Text = client.OrganisationName; } } else { cboDedicatedToClient.Text = "- none -"; } chkDelete.Visible = true; pnlVehicleDeleted.Visible = true; txtGPSUnitID.Text = vehicle.GPSUnitID; txtGPSUnitID.Text = txtGPSUnitID.Text.ToUpper(); txtThirdPartyIntegrationID.Text = (vehicle.ThirdPartyIntegrationID.HasValue) ? vehicle.ThirdPartyIntegrationID.ToString() : string.Empty; //Find all tree nodes that correspond to the org units var treeNodesToCheck = m_orgUnitTreeNodes.Where(x => vehicle.OrgUnitIDs.Contains(x.OrgUnitId.Value)); foreach (var treeNode in treeNodesToCheck) { treeNode.Checked = true; } } btnAdd.Text = "Update"; }