private void btnAddNewTrafficArea_Click(object sender, EventArgs e) { m_trafficArea = null; ViewState[C_TRAFFIC_AREA_VS] = m_trafficArea; cboTrafficArea.ClearSelection(); ConfigureTrafficAreaManupulation(eTrafficAreaManipulation.AddTrafficArea); }
private void btnSelectTrafficArea_Click(object sender, EventArgs e) { btnSelectTrafficArea.DisableServerSideValidation(); if (Page.IsValid) { // Add this traffic area to this control area. int trafficAreaId = Convert.ToInt32(cboAddTrafficArea.SelectedValue); bool success = false; using (Facade.ITrafficArea facTrafficArea = new Facade.Traffic()) { Entities.TrafficArea trafficArea = facTrafficArea.GetForTrafficAreaId(trafficAreaId); trafficArea.ControlAreaId = m_controlArea.ControlAreaId; success = facTrafficArea.Update(trafficArea, ((Entities.CustomPrincipal)Page.User).UserName); } if (success) { lblConfirmation.Text = "The traffic area has been added."; ConfigureControlAreaManipulation(eControlAreaManipulation.ConfigureTrafficAreas); } else { lblConfirmation.Text = "The traffic area has not been added."; } lblConfirmation.Visible = true; } }
private void cboTrafficArea_SelectedIndexChanged(object sender, EventArgs e) { int trafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue); using (Facade.ITrafficArea facTrafficArea = new Facade.Traffic()) { m_trafficArea = facTrafficArea.GetForTrafficAreaId(trafficAreaId); ViewState[C_TRAFFIC_AREA_VS] = m_trafficArea; } ConfigureTrafficAreaManupulation(eTrafficAreaManipulation.ConfigurePlanners); }
private void btnAlterTrafficArea_Click(object sender, EventArgs e) { btnAlterTrafficArea.DisableServerSideValidation(); if (Page.IsValid) { int trafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue); using (Facade.ITrafficArea facTrafficArea = new Facade.Traffic()) { m_trafficArea = facTrafficArea.GetForTrafficAreaId(trafficAreaId); ViewState[C_TRAFFIC_AREA_VS] = m_trafficArea; } ConfigureTrafficAreaManupulation(eTrafficAreaManipulation.AddTrafficArea); } }
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 btnActionTrafficArea_Click(object sender, EventArgs e) { btnActionTrafficArea.DisableServerSideValidation(); if (Page.IsValid) { if (m_trafficArea == null) { m_trafficArea = new Entities.TrafficArea(); } m_trafficArea.TrafficAreaName = txtTrafficAreaDescription.Text; m_trafficArea.ControlAreaId = Convert.ToInt32(cboControlAreaForNewTrafficArea.SelectedValue); bool success = false; using (Facade.ITrafficArea facTrafficArea = new Facade.Traffic()) { if (m_trafficArea.TrafficAreaId == 0) { m_trafficArea.TrafficAreaId = facTrafficArea.Create(m_trafficArea, ((Entities.CustomPrincipal)Page.User).UserName); success = m_trafficArea.TrafficAreaId > 0; } else { success = facTrafficArea.Update(m_trafficArea, ((Entities.CustomPrincipal)Page.User).UserName); } } if (success) { lblConfirmation.Text = "The traffic area has been stored."; ConfigureTrafficAreaManupulation(eTrafficAreaManipulation.SelectTrafficArea); } else { lblConfirmation.Text = "The traffic 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"; }
/// <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"; }