private void PopulateFilter() { Facade.Resource facResource = new Facade.Resource(); Facade.IOrganisationLocation facOrganiastionLocation = new Facade.Organisation(); //resource types var resourceTypes = facResource.GetAllResourceTypes(); cboResourceTypes.DataSource = resourceTypes.Tables[0]; cboResourceTypes.DataTextField = "Description"; cboResourceTypes.DataValueField = "ResourceTypeId"; cboResourceTypes.DataBind(); string driverTypeName = Enum.GetName(typeof(eResourceType), eResourceType.Driver); cboResourceTypes.Items.FindByText(driverTypeName).Selected = true; //driver types var driverTypes = facResource.GetAllDriverTypes(); cboDriverTypes.DataSource = driverTypes.Tables[0]; cboDriverTypes.DataTextField = "Description"; cboDriverTypes.DataValueField = "DriverTypeID"; cboDriverTypes.DataBind(); cboDriverTypes.Items.Insert(0, new ListItem("-- all --", "0")); //depots cboDepots.DataSource = facOrganiastionLocation.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId); cboDepots.DataValueField = "OrganisationLocationId"; cboDepots.DataTextField = "OrganisationLocationName"; cboDepots.DataBind(); cboDepots.Items.Insert(0, new ListItem("-- all --", "0")); }
private void cboDepot_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) { cboDepot.Items.Clear(); Facade.IOrganisationLocation facOrgLoc = new Facade.Organisation(); DataSet ds = facOrgLoc.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId); DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItem rcItem = null; rcItem = new Telerik.Web.UI.RadComboBoxItem(); rcItem.Text = "All"; rcItem.Value = "0"; cboDepot.Items.Add(rcItem); List <Telerik.Web.UI.RadComboBoxItem> comboItems = new List <Telerik.Web.UI.RadComboBoxItem>(); dt.Rows.Cast <DataRow>().ToList().ForEach(row => comboItems.Add( new Telerik.Web.UI.RadComboBoxItem { Text = row["OrganisationLocationName"].ToString(), Value = row["OrganisationLocationId"].ToString() })); comboItems.Sort((item1, item2) => item1.Text.CompareTo(item2.Text)); cboDepot.Items.AddRange(comboItems); }
private void PopulateStaticControls() { var lastWeekStart = Entities.Utilities.GetWeekStartDate((DayOfWeek)this.WeekStartDay).AddDays(-7); this.dteStartDate.SelectedDate = lastWeekStart; this.dteEndDate.SelectedDate = lastWeekStart.AddDays(6); Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation(); this.lbAvailableDepots.DataSource = facOrganisationLocation.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId); this.lbAvailableDepots.DataBind(); var orgFacade = new Facade.Organisation(); var orgs = orgFacade.GetAllForType((int)eOrganisationType.Client); this.lbAvailableClients.DataSource = orgs.Tables[0]; this.lbAvailableClients.DataBind(); }
private void PopulateStaticControls() { #region // Populate Control Areas Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataBind(); cboControlArea.Items[0].Selected = true; #endregion #region // Populate Traffic Areas Facade.ITrafficArea facTrafficArea = (Facade.ITrafficArea)facControlArea; cboTrafficAreas.DataSource = facTrafficArea.GetAll(); cboTrafficAreas.DataBind(); #endregion #region // Populate Depots Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation(); cboDepot.DataSource = facOrganisationLocation.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId); cboDepot.DataBind(); cboDepot.Items.Insert(0, new ListItem("Use Control Area and Traffic Areas to determine resource pool", "0")); #endregion #region // Populate Filters for this user PopulateFilterList(); #endregion #region // Configure the default dates. // Default dates are from the start of today until: // 1) On a Saturday, until the end of Monday. // 2) On any other day, until the end of tomorrow. DateTime startOfToday = DateTime.Now; startOfToday = startOfToday.Subtract(startOfToday.TimeOfDay); DateTime endOfTomorrow = startOfToday.Add(new TimeSpan(1, 23, 59, 59)); DateTime startDate = startOfToday; DateTime endDate = endOfTomorrow; if (startOfToday.DayOfWeek == DayOfWeek.Saturday) { DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59)); endDate = endOfMonday; } #endregion #region // Cause the job states to be displayed chkJobStates.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eJobState))); chkJobStates.DataBind(); #endregion #region // Load the Job Types Facade.IBusinessType facBusinessType = new Facade.BusinessType(); cblBusinessType.DataSource = facBusinessType.GetAll(); cblBusinessType.DataTextField = "Description"; cblBusinessType.DataValueField = "BusinessTypeID"; cblBusinessType.DataBind(); #endregion #region React to supplied values bool haveReacted = false; try { Entities.TrafficSheetFilter m_trafficSheetFilter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); if (m_trafficSheetFilter == null) { m_trafficSheetFilter = GetDefaultFilter(); m_trafficSheetFilter.FilterStartDate = startDate; m_trafficSheetFilter.FilterEnddate = endDate; } cboControlArea.ClearSelection(); SelectItem(cboControlArea.Items, m_trafficSheetFilter.ControlAreaId); haveReacted = true; foreach (var taid in m_trafficSheetFilter.TrafficAreaIDs) { SelectItem(cboTrafficAreas.Items, taid); } for (int i = 0; i < m_trafficSheetFilter.JobStates.Count; i++) { chkJobStates.Items.FindByValue(Utilities.UnCamelCase(Enum.Parse(typeof(eJobState), m_trafficSheetFilter.JobStates[i].ToString()).ToString())).Selected = true; } cboDepot.ClearSelection(); cboDepot.Items.FindByValue(m_trafficSheetFilter.DepotId.ToString()).Selected = true; dteStartDate.SelectedDate = m_trafficSheetFilter.FilterStartDate; dteEndDate.SelectedDate = m_trafficSheetFilter.FilterEnddate; cblBusinessType.ClearSelection(); foreach (int i in m_trafficSheetFilter.BusinessTypes) { cblBusinessType.Items.FindByValue(i.ToString()).Selected = true; } } catch (Exception eX) { Entities.TrafficSheetFilter ts = GetDefaultFilter(); ts.FilterStartDate = startDate; dteStartDate.SelectedDate = startDate; ts.FilterEnddate = endDate; dteEndDate.SelectedDate = endDate; if (Request.Cookies[this.CookieSessionID] == null) { SetCookie(ts); } BindDefaultFilter(); } finally { // Apply the dates. } #endregion }
private void PopulateStaticControls() { #region // Configure the min and max dates. dteStartDate.MinDate = new DateTime(2000, 1, 1); dteEndDate.MaxDate = new DateTime(2036, 12, 31); #endregion #region // Populate Control Areas Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataBind(); cboControlArea.Items[0].Selected = true; #endregion #region // Populate Traffic Areas Facade.ITrafficArea facTrafficArea = (Facade.ITrafficArea)facControlArea; cboTrafficAreas.DataSource = facTrafficArea.GetAll(); cboTrafficAreas.DataBind(); if (cboTrafficAreas.Items.Count > 8) { divTrafficAreas.Attributes.Add("class", "overflowHandler"); divTrafficAreas.Attributes.Add("style", "height:100px;"); } #endregion #region // Populate Depots Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation(); cboDepot.DataSource = facOrganisationLocation.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId); cboDepot.DataBind(); cboDepot.Items.Insert(0, new ListItem("Use Control Area and Traffic Areas to determine resource pool", "0")); #endregion #region // Populate Filters for this user PopulateFilterList(); #endregion #region // Configure the default dates. // Default dates are from the start of today until: // 1) On a Saturday, until the end of Monday. // 2) On any other day, until the end of tomorrow. DateTime startOfToday = DateTime.Now; startOfToday = startOfToday.Subtract(startOfToday.TimeOfDay); DateTime endOfTomorrow = startOfToday.Add(new TimeSpan(1, 23, 59, 59)); DateTime startDate = startOfToday; DateTime endDate = endOfTomorrow; if (startOfToday.DayOfWeek == DayOfWeek.Saturday) { DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59)); endDate = endOfMonday; } #endregion #region // Populate the Business Types Facade.IBusinessType facBusinessType = new Facade.BusinessType(); cblBusinessType.DataSource = facBusinessType.GetAll(); cblBusinessType.DataTextField = "Description"; cblBusinessType.DataValueField = "BusinessTypeID"; cblBusinessType.DataBind(); #endregion #region // Populate the Instruction States cblInstructionStates.DataSource = Enum.GetNames(typeof(eInstructionState)); cblInstructionStates.DataBind(); #endregion #region // Populate the In Progress Sub-States cblInProgressSubStates.DataSource = this.InProgressSubStateDescriptions.ToDictionary(kvp => (int)kvp.Key, kvp => kvp.Value); cblInProgressSubStates.DataBind(); #endregion #region // Populate the Planning Categories Types cblPlanningCategory.DataSource = DataContext.PlanningCategorySet.OrderBy(pc => pc.DisplayShort); cblPlanningCategory.DataBind(); var liAll = new ListItem("All", "-1") { Selected = true }; cblPlanningCategory.Items.Add(liAll); #endregion #region // Populate the Instruction Types cblInstructionType.Items.Clear(); var liMWF = new ListItem("MWF", "1"); liMWF.Attributes.Add("onclick", "onInstructionTypeChecked();"); var liNonMWF = new ListItem("Non-MWF", "2"); liNonMWF.Attributes.Add("onclick", "onInstructionTypeChecked();"); cblInstructionType.Items.Add(liMWF); cblInstructionType.Items.Add(liNonMWF); #endregion #region // Populate the MWF Comms Status var list = Enum.GetValues(typeof(MWFCommunicationStatusForTrafficSheetEnum)).Cast <object>().ToDictionary(v => (int)v, v => MWF_Instruction.GetCommunicationStatusForTrafficSheetDescription((int)v)); cblMWFCommsStates.DataSource = list; cblMWFCommsStates.DataBind(); #endregion #region // Populate the MWF Instruction States // Only adding the states that we use for now var list2 = new Dictionary <int, string> { { (int)MWFStatusEnum.Drive, "Drive" }, { (int)MWFStatusEnum.OnSite, "On Site" }, { (int)MWFStatusEnum.Suspend, "Suspend" }, { (int)MWFStatusEnum.Resume, "Resume" }, { (int)MWFStatusEnum.Complete, "Complete" } }; cblMWFInstructionStates.DataSource = list2; cblMWFInstructionStates.DataBind(); #endregion if (Filter == null) { Filter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); } if (Filter == null) { Filter = GetDefaultFilter(); // Configure the default dates. // Default dates are from the start of today until: // 1) On a Saturday, until the end of Monday. // 2) On any other day, until the end of tomorrow. Filter.FilterStartDate = startOfToday; if (startOfToday.DayOfWeek == DayOfWeek.Saturday) { DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59)); Filter.FilterEnddate = endOfMonday; } else { Filter.FilterEnddate = endOfTomorrow; } } cboControlArea.ClearSelection(); SelectItem(cboControlArea.Items, Filter.ControlAreaId); foreach (var taid in Filter.TrafficAreaIDs) { SelectItem(cboTrafficAreas.Items, taid); } startDate = Filter.FilterStartDate; endDate = Filter.FilterEnddate; chkShowPlanned.Checked = Filter.ShowPlannedLegs; chkShowStockMovementJobs.Checked = Filter.ShowStockMovementJobs; cboDepot.ClearSelection(); cboDepot.Items.FindByValue(Filter.DepotId.ToString()).Selected = true; foreach (var i in Filter.BusinessTypes) { try { // P1 use if we try to work on different client's version of Orchestrator // the same cookie is used (domain). cblBusinessType.Items.FindByValue(i.ToString()).Selected = true; } catch { } } foreach (int i in this.Filter.InstructionStates) { cblInstructionStates.Items.FindByValue(((eInstructionState)i).ToString()).Selected = true; } foreach (var ipss in this.Filter.InProgressSubStates) { cblInProgressSubStates.Items.FindByValue(((int)ipss).ToString()).Selected = true; } if (this.Filter.PlanningCategories.Count > 0) { foreach (ListItem li in cblPlanningCategory.Items) { li.Selected = this.Filter.PlanningCategories.Contains(int.Parse(li.Value)); } } this.chkSortbyEvent.Checked = Filter.SortbyEvent; this.chkCollapseRuns.Checked = this.Filter.CollapseRuns; liMWF.Selected = Filter.IncludeMWFInstructions; liNonMWF.Selected = Filter.IncludeNonMWFInstructions; chkSelectAllInstructionTypes.Checked = (liMWF.Selected && liNonMWF.Selected); bool allSelected = false; if (Filter.MWFCommsStates.Count > 0) { allSelected = true; foreach (ListItem li in cblMWFCommsStates.Items) { li.Selected = Filter.MWFCommsStates.Contains(int.Parse(li.Value)); if (!li.Selected) { allSelected = false; } } } chkSelectAllMWFCommsStates.Checked = allSelected; var selected = false; if (Filter.MWFInstructionStates.Count > 0) { selected = true; foreach (ListItem li in cblMWFInstructionStates.Items) { li.Selected = Filter.MWFInstructionStates.Contains(int.Parse(li.Value)); if (!li.Selected) { selected = false; } } } chkSelectAllMWFInstructionStates.Checked = selected; #region // Apply the dates. dteStartDate.SelectedDate = startDate; dteEndDate.SelectedDate = endDate; #endregion }
/// <summary> /// Populate Static Controls /// </summary> private void PopulateStaticControls() { if (Orchestrator.Globals.Configuration.FleetMetrikInstance) { OnlyEnableFleetMetrikFields(); } cboTitle.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eTitle))); cboTitle.DataBind(); IDriver facDriver = new Facade.Resource(); cboDriverType.DataSource = facDriver.GetAllDriverTypes(); cboDriverType.DataTextField = "Description"; cboDriverType.DataValueField = "DriverTypeID"; cboDriverType.DataBind(); cboDriverType.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "")); // Configure the attributes for the address target textboxes. txtAddressLine1.Attributes.Add("onfocus", "this.blur();" + txtPostCode.ClientID + ".focus();"); txtAddressLine2.Attributes.Add("onfocus", "this.blur();" + txtPostCode.ClientID + ".focus();"); txtAddressLine3.Attributes.Add("onfocus", "this.blur();" + txtPostCode.ClientID + ".focus();"); txtPostTown.Attributes.Add("onfocus", "this.blur();" + txtPostCode.ClientID + ".focus();"); txtCounty.Attributes.Add("onfocus", "this.blur();" + txtPostCode.ClientID + ".focus();"); IVehicle facVehicle = new Facade.Resource(); var dsVehicles = facVehicle.GetAllVehicles(); cboVehicle.DataSource = dsVehicles; cboVehicle.DataTextField = "RegNo"; cboVehicle.DataValueField = "ResourceId"; cboVehicle.DataBind(); cboVehicle.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "-1")); IOrganisationLocation facOrganiastionLocation = new Facade.Organisation(); cboDepot.DataSource = facOrganiastionLocation.GetAllDepots(Configuration.IdentityId); cboDepot.DataValueField = "OrganisationLocationId"; cboDepot.DataTextField = "OrganisationLocationName"; cboDepot.DataBind(); cboDepot.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("--- [ Please Select ] ---")); IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataTextField = "Description"; cboControlArea.DataValueField = "ControlAreaId"; cboControlArea.DataBind(); cboControlArea.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("--- [ Please Select ] ---")); var facTrafficArea = (ITrafficArea)facControlArea; cboTrafficArea.DataSource = facTrafficArea.GetAll(); cboTrafficArea.DataTextField = "Description"; cboTrafficArea.DataValueField = "TrafficAreaId"; cboTrafficArea.DataBind(); cboTrafficArea.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("--- [ Please Select ] ---")); this.dteDOB.MinDate = new DateTime(1900, 1, 1); IUser facUser = new Facade.User(); cboDriverPlanner.DataSource = facUser.GetAllUsersInRole(eUserRole.Planner); cboDriverPlanner.DataValueField = "IdentityID"; cboDriverPlanner.DataTextField = "FullName"; cboDriverPlanner.DataBind(); cboDriverPlanner.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("--- [ Please Select ] ---")); //Load Agencies using (var uow = DIContainer.CreateUnitOfWork()) { var agenciesRepo = DIContainer.CreateRepository <IAgencyRepository>(uow); var agencies = agenciesRepo.GetAgencies(); foreach (var ag in agencies) { var rcItem = new Telerik.Web.UI.RadComboBoxItem(); rcItem.Text = ag.Name; rcItem.Value = ag.AgencyId.ToString(); cboAgency.Items.Add(rcItem); } } InitialiseTelematicsSolution(); BindDriverCommunicationTypes(); }
/// <summary> /// Populate Static Controls /// </summary> private void PopulateStaticControls() { if (Orchestrator.Globals.Configuration.FleetMetrikInstance) { OnlyEnableFleetMetrikFields(); } if (!Orchestrator.Globals.Configuration.ShowVehicleDepot) { vehicleDepot.Style.Add("display", "none"); cboTrafficArea.Visible = false; rfvDepot.Enabled = false; } // Load the Classes Dropdown Facade.IVehicle facResource = new Facade.Resource(); DataSet dsVehicleClasses = facResource.GetAllVehicleClasses(); cboClass.DataSource = dsVehicleClasses; cboClass.DataTextField = "Description"; cboClass.DataValueField = "VehicleClassId"; cboClass.DataBind(); cboClass.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "")); // load the vehicle Types cboVehicleType.DataSource = facResource.GetAllVehicleTypes(); cboVehicleType.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "")); cboVehicleType.DataBind(); // Can this system support fixed units? chkIsFixedUnit.Enabled = Configuration.InstallationSupportsFixedUnits; // Load the Manufacturers Dropdown Facade.IVehicle facVehicleMan = new Facade.Resource(); DataSet dsVehicleManufacturers = facVehicleMan.GetAllVehicleManufacturers(); cboManufacturer.DataSource = dsVehicleManufacturers; cboManufacturer.DataTextField = "Description"; cboManufacturer.DataValueField = "VehicleManufacturerId"; cboManufacturer.DataBind(); cboManufacturer.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "")); cboVehicleType.DataSource = facResource.GetAllVehicleTypes(); cboVehicleType.DataBind(); cboVehicleType.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "0")); // Load the Model Dropdown with relevant fields cboManufacturer_SelectedIndexChanged(cboManufacturer, EventArgs.Empty); Facade.IOrganisationLocation facOrganiastionLocation = new Facade.Organisation(); cboDepot.DataSource = facOrganiastionLocation.GetAllDepots(Configuration.IdentityId); cboDepot.DataValueField = "OrganisationLocationId"; cboDepot.DataTextField = "OrganisationLocationName"; cboDepot.DataBind(); cboDepot.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "")); Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataTextField = "Description"; cboControlArea.DataValueField = "ControlAreaId"; cboControlArea.DataBind(); cboControlArea.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "")); Facade.ITrafficArea facTrafficArea = (Facade.ITrafficArea)facControlArea; cboTrafficArea.DataSource = facTrafficArea.GetAll(); cboTrafficArea.DataTextField = "Description"; cboTrafficArea.DataValueField = "TrafficAreaId"; cboTrafficArea.DataBind(); cboTrafficArea.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "")); // Get the nominal codes Facade.INominalCode facNominalCode = new Orchestrator.Facade.NominalCode(); DataSet dsNominalCodes = facNominalCode.GetAllActive(); cboNominalCode.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "0")); foreach (DataRow row in dsNominalCodes.Tables[0].Rows) { ListItem item = new ListItem(); item.Value = row["NominalCodeId"].ToString(); item.Text = row["NominalCode"].ToString() + " - " + row["Description"].ToString(); cboNominalCode.Items.Add(item); } InitialiseTelematicsSolution(); }