public void UpdateInstruction(WhatYouGotLibrary.Models.Instruction instruction) { Entities.Instruction currentInstruction = _context.Instruction.Find(instruction.Id); Entities.Instruction newInstruction = Mapper.Map(instruction); _context.Entry(currentInstruction).CurrentValues.SetValues(newInstruction); }
private void InitialisePage() { // Retrieve the instruction. Facade.IInstruction facInstruction = new Facade.Instruction(); m_instruction = facInstruction.GetInstruction(m_instructionID); ViewState[C_Instruction_VS] = m_instruction; // Populate the control and traffic area dropdowns. Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataBind(); cboTrafficArea.DataSource = ((Facade.ITrafficArea)facControlArea).GetAll(); cboTrafficArea.DataBind(); // Select the current control and traffic area assigned to the leg. cboControlArea.Items.FindByValue(m_instruction.ControlAreaId.ToString()).Selected = true; cboTrafficArea.Items.FindByValue(m_instruction.TrafficAreaId.ToString()).Selected = true; // Enable the checkbox if this is not the last leg in the job. Facade.IJob facJob = new Facade.Job(); Entities.InstructionCollection instructions = facInstruction.GetForJobId(m_instruction.JobId); if (instructions.Count == m_instruction.InstructionOrder + 1) { chkApplyToAllFollowingInstructions.Enabled = false; } else { chkApplyToAllFollowingInstructions.Enabled = true; } }
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]; m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION]; if (!IsPostBack) { btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE); switch ((eInstructionType)m_instruction.InstructionTypeId) { case eInstructionType.Load: lblCollection.Visible = true; lblDelivery.Visible = false; break; case eInstructionType.Drop: lblCollection.Visible = false; lblDelivery.Visible = true; break; } } }
private bool CanBeRemovedFromDrop(Entities.Instruction dropInstruction, Entities.Order order, out string message) { var messageFragments = new List <string>(); // This order can only be removed from this delivery and placed on a trunk if: // * This would not result in the breaking of the chain - to test this the order's collection run delivery point must match the delivery run collection point. // * No refusals have been logged against this instruction - it is possible to remove the call-in but keep the refusal. if (order.CollectionRunDeliveryPointID != order.DeliveryRunCollectionPointID) { messageFragments.Add("The Order's Collection Point does not match the Collection Point on the Run."); } var facGoodsRefusal = new Facade.GoodsRefusal(); var dsGoodsRefusal = facGoodsRefusal.GetRefusalsForInstructionIdAndOrderId(dropInstruction.InstructionID, order.OrderID); if (dsGoodsRefusal.Tables[0].Rows.Count > 0) { messageFragments.Add("Refusals Logged"); } if (messageFragments.Count > 0) { message = String.Format("This Order cannot be Converted - {0}", String.Join(", ", messageFragments.ToArray())); grdOrdersOnDrop.ItemStyle.BackColor = System.Drawing.Color.FromName("FireBrick"); grdOrdersOnDrop.ItemStyle.ForeColor = System.Drawing.Color.White; } else { message = String.Empty; } errorMessage = message; return(messageFragments.Count == 0); }
//----------------------------------------------------------------------------------------------------------- private void ChangeExistingInstruction(Entities.Instruction instruction, Entities.Job run, List <int> orderIds) { Facade.IInstruction facInstruction = new Facade.Instruction(); // no need to create a new instruction. Entities.FacadeResult retVal = new Entities.FacadeResult(); Orchestrator.Facade.IOrder facOrder = new Orchestrator.Facade.Order(); Facade.Job facJob = new Facade.Job(); Entities.CollectDropCollection collectDrops = new Orchestrator.Entities.CollectDropCollection(); // Update the Order and the relevant instructions foreach (int ordId in orderIds) { DataSet dsOrders = facOrder.GetLegsForOrder(ordId); // Get the last job id from the dataset int jobId = -1; if (dsOrders.Tables[0].Rows.Count > 0) { jobId = Convert.ToInt32(dsOrders.Tables[0].Rows[dsOrders.Tables[0].Rows.Count - 1]["JobID"].ToString()); } Entities.Order currentOrder = facOrder.GetForOrderID(ordId); if (instruction.CollectDrops.GetForOrderID(currentOrder.OrderID) != null) { facInstruction.UpdatePointID(instruction.InstructionID, this.cboNewDeliveryPoint.PointID, this.Page.User.Identity.Name); instruction.PointID = this.cboNewDeliveryPoint.PointID; this.UpdateOrder(currentOrder); instruction.BookedDateTime = currentOrder.DeliveryDateTime; instruction.PlannedArrivalDateTime = currentOrder.DeliveryDateTime; instruction.PlannedDepartureDateTime = currentOrder.DeliveryDateTime; } } }
private string GetTrunkConversionMessage(Entities.Instruction loadInstruction, Entities.Instruction trunkInstruction, Entities.Order order) { string message = String.Empty; CanBeRemovedFromTrunk(trunkInstruction, order, out message); return(message); }
private void BindInstruction() { Entities.Instruction instruction = null; // Get the instruction to work with. using (Facade.IInstruction facInstruction = new Facade.Instruction()) { if (m_instructionId == 0) { // Get the job's next instruction. instruction = facInstruction.GetNextInstruction(m_jobId); } else { // Get the specific instruction. instruction = facInstruction.GetInstruction(m_instructionId); } } if (instruction != null) { m_pointId = instruction.PointID; ViewState[C_POINT_ID_VS] = m_pointId; } }
private string GetAssignedResource(Entities.Job job, Entities.Instruction instruction, Entities.Order order) { if (instruction.Driver != null) { return(instruction.Driver.Individual.FullName); } else { // May be sub-contracted. var jobSubContracts = job.SubContractors.Cast <Entities.JobSubContractor>(); var facOrganisation = new Facade.Organisation(); if (jobSubContracts.Any(jsc => jsc.SubContractWholeJob)) { // Whole job sub-contracted out. return(facOrganisation.GetNameForIdentityId(jobSubContracts.First(jsc => jsc.SubContractWholeJob).ContractorIdentityId)); } else if (jobSubContracts.Any(jsc => jsc.JobSubContractID == instruction.JobSubContractID)) { // Per-instruction sub-contracted out. return(facOrganisation.GetNameForIdentityId(jobSubContracts.First(jsc => jsc.JobSubContractID == instruction.JobSubContractID).ContractorIdentityId)); } else if (instruction.InstructionTypeId == (int)eInstructionType.Drop && jobSubContracts.Any(jsc => jsc.JobSubContractID == order.JobSubContractID)) { // Sub-contracted for delivery. return(facOrganisation.GetNameForIdentityId(jobSubContracts.First(jsc => jsc.JobSubContractID == order.JobSubContractID).ContractorIdentityId)); } } // No resource assigned. return(String.Empty); }
private string GetDropConversionMessage(Entities.Instruction loadInstruction, Entities.Instruction dropInstruction, Entities.Order order) { string message = String.Empty; CanBeRemovedFromDrop(dropInstruction, order, out message); return(message); }
private void ConfigureDisplay() { int jobId, instructionId = 0; if (JobId == -1 && !string.IsNullOrEmpty(Request.QueryString["jId"])) { if (int.TryParse(Request.QueryString["jId"], out jobId)) { JobId = jobId; } } if (InstructionId == -1 && !string.IsNullOrEmpty(Request.QueryString["iId"])) { if (int.TryParse(Request.QueryString["iId"], out instructionId)) { InstructionId = instructionId; } } // Bind the options for redelivery reasons, collection options only. cboRedeliveryReason.DataSource = EF.DataContext.Current.RedeliveryReasonSet.Where(rr => rr.IsEnabled == true && rr.IsCollection == true).OrderBy(rr => rr.Description); cboRedeliveryReason.DataBind(); // Bind the extra types (remove any invalid options). Facade.ExtraType facExtraType = new Facade.ExtraType(); bool? getActiveExtraTypes = true; List <Entities.ExtraType> extraTypes = facExtraType.GetForIsEnabled(getActiveExtraTypes); extraTypes.RemoveAll(o => (eExtraType)(o.ExtraTypeId) == eExtraType.Custom || (eExtraType)(o.ExtraTypeId) == eExtraType.Demurrage || (eExtraType)(o.ExtraTypeId) == eExtraType.DemurrageExtra); cboExtraType.DataSource = extraTypes; cboExtraType.DataValueField = "ExtraTypeId"; cboExtraType.DataTextField = "Description"; cboExtraType.DataBind(); // Bind the extra states (remove any invalid options). List <string> extraStates = new List <string>(Utilities.UnCamelCase(Enum.GetNames(typeof(eExtraState)))); extraStates.Remove(Utilities.UnCamelCase(Enum.GetName(typeof(eExtraState), eExtraState.Invoiced))); cboExtraState.DataSource = extraStates; cboExtraState.DataBind(); // Get Instruction Details Facade.IInstruction facIns = new Facade.Instruction(); Facade.IPoint facPoint = new Facade.Point(); Entities.Instruction currentIns = facIns.GetInstruction(InstructionId); Entities.Point loadPoint = facPoint.GetPointForPointId(currentIns.PointID); txtExtraCustomReason.Text = string.Format("Attempted Collection from {0}", loadPoint.Description); }
private void InitialisePage() { // Populate the control and traffic area dropdowns. Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataBind(); cboTrafficArea.DataSource = ((Facade.ITrafficArea)facControlArea).GetAll(); cboTrafficArea.DataBind(); if (m_instructionId != 0) { Facade.IInstruction facInstruction = new Facade.Instruction(); Entities.Instruction instruction = facInstruction.GetInstruction(m_instructionId); if (instruction.Driver != null) { tdDriver.InnerText = instruction.Driver.Individual.FullName; } if (instruction.Vehicle != null) { tdVehicle.InnerText = instruction.Vehicle.RegNo; } if (instruction.Trailer != null) { tdTrailer.InnerText = instruction.Trailer.TrailerRef; } // Select the current control and traffic area assigned to the leg. cboControlArea.Items.FindByValue(instruction.ControlAreaId.ToString()).Selected = true; cboTrafficArea.Items.FindByValue(instruction.TrafficAreaId.ToString()).Selected = true; } if (m_driverResourceId != 0) { tdDriver.InnerText = m_fullName; // Select the current control and traffic area assigned to the leg. if (m_controlAreaId > 0) { cboControlArea.Items.FindByValue(m_controlAreaId.ToString()).Selected = true; } if (m_trafficAreaId > 0) { cboTrafficArea.Items.FindByValue(m_trafficAreaId.ToString()).Selected = true; } } if (m_vehicleResourceId != 0) { tdVehicle.InnerText = m_regNo; } if (m_trailerResourceId != 0) { tdTrailer.InnerText = m_trailerRef; } }
protected void Page_Load(object sender, EventArgs e) { m_instructionID = Convert.ToInt32(Request.QueryString["InstructionID"]); m_lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]); if (!IsPostBack) { InitialisePage(); } else { m_instruction = (Entities.Instruction)ViewState[C_Instruction_VS]; } }
public void Populate() { GetSessionIDFromQueryString(); rtsCallIn.Tabs.Clear(); m_jobId = Convert.ToInt32(Request.QueryString["jobId"]); m_instructionId = Convert.ToInt32(Request.QueryString["instructionId"]); // Get the instruction to work with. if (m_instructionId == 0) { using (Facade.IInstruction facInstruction = new Facade.Instruction()) { Entities.Instruction instruction = facInstruction.GetNextInstruction(m_jobId); if (instruction != null) { m_instructionId = instruction.InstructionID; } } } rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[0], "CallIn", 0)); var instructionType = (from i in EF.DataContext.Current.InstructionSet where i.InstructionId == m_instructionId select i.InstructionType.InstructionTypeId).FirstOrDefault(); if (instructionType == 2) { rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[1], "Refusal", 1)); rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[2], "Shortage", 2)); } rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[3], "tabReturns", 3)); if (!((Entities.CustomPrincipal) this.Page.User).IsInRole(((int)eUserRole.SubConPortal).ToString())) { rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[4], "tabPCVS", 4)); rtsCallIn.Tabs.Add(CreateTab(m_tabTexts[5], "tabProgress", 5)); } int selectedTabID = 0; int.TryParse(Request.QueryString["t"], out selectedTabID); if (selectedTabID > -1 && rtsCallIn.Tabs.FindTabByText(m_tabTexts[selectedTabID]) != null) { rtsCallIn.Tabs.FindTabByText(m_tabTexts[selectedTabID]).Selected = true; } }
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); } }
private void BindTrunkInstruction(Entities.Instruction instruction) { // The instruction to convert is currently a trunk instruction so will // either be converted to a drop instruction or the point will be changed // so that the orders involved will be taken to a different location. // In the case when instruction will be converted to a drop instruction, // this is only possible for the orders that have not already been planned // for delivery. // In the case of changing the trunk location, this can only be done for the // end of the collection run, otherwise the order's collection chain will be broken. mvConvertInstruction.SetActiveView(vwConvertTrunk); var facJob = new Facade.Job(); var facOrganisation = new Facade.Organisation(); var job = facJob.GetJob(instruction.JobId, true, true); grdOrdersOnTrunk.DataSource = from o in instruction.CollectDrops.Cast <Entities.CollectDrop>().Select(cd => cd.Order) let ci = (from i in job.Instructions where i.InstructionTypeId == (int)eInstructionType.Load && i.CollectDrops.Cast <Entities.CollectDrop>().FirstOrDefault(cd => cd.OrderID == o.OrderID) != null select i).Single() let client = facOrganisation.GetForIdentityId(o.CustomerIdentityID) select new ConvertInstructionOrderData() { OrderID = o.OrderID, CustomerOrganisationName = client.OrganisationName, BusinessTypeDescription = GetBusinessTypeDescription(o.BusinessTypeID), OrderServiceLevel = o.OrderServiceLevel, CustomerOrderNumber = o.CustomerOrderNumber, DeliveryOrderNumber = o.DeliveryOrderNumber, Message = GetTrunkConversionMessage(ci, instruction, o), CollectionPointID = ci.PointID, CollectionPointDescription = ci.Point.Description, CollectionDateTime = ci.BookedDateTime, CollectionIsAnyTime = ci.IsAnyTime, DeliveryPointID = instruction.PointID, DeliveryPointDescription = instruction.Point.Description, DeliveryDateTime = instruction.BookedDateTime, DeliveryIsAnyTime = instruction.IsAnyTime, DeliveringResource = GetAssignedResource(job, instruction, o), LCID = o.LCID, ForeignRate = o.ForeignRate }; grdOrdersOnDrop.DataBind(); }
private void GetJobAndInstructions() { // Get the job. using (Facade.IInstruction facInstruction = new Facade.Instruction()) { _endInstruction = facInstruction.GetInstruction(_instructionId); // Try and get the job from the cache _job = (Entities.Job)Cache.Get("JobEntityForJobId" + _jobId.ToString()); if (_job == null) { Facade.IJob facJob = new Facade.Job(); _job = facJob.GetJob(_jobId); // Job was not in the cache thus get the instruction collection from the db _instructions = new Facade.Instruction().GetForJobId(_jobId); // Get the previous instruction _startInstruction = _instructions.GetPreviousInstruction(_instructionId); } else { // Job is in the cache, check for instructions if (_job.Instructions != null) { // We have instructions _instructions = _job.Instructions; // use the instruction collection from the cached job _startInstruction = _instructions.GetPreviousInstruction(_instructionId); } else { // otherwise get a fresh instruction collection _instructions = new Facade.Instruction().GetForJobId(_jobId); // Get the previous instruction _startInstruction = _instructions.GetPreviousInstruction(_instructionId); } } } }
private void ConfigurePage() { int instructionId = Convert.ToInt32(Request.QueryString["instructionId"]); Entities.Instruction instruction = null; using (Facade.IInstruction facInstruction = new Facade.Instruction()) { instruction = facInstruction.GetInstruction(instructionId); } // Display the resource information if (instruction.Driver != null) { tdDriver.InnerText = instruction.Driver.Individual.FullName; } if (instruction.Vehicle != null) { tdVehicle.InnerText = instruction.Vehicle.RegNo; } if (instruction.Trailer != null) { tdTrailer.InnerText = instruction.Trailer.TrailerRef; } // Display the point information XslCompiledTransform transformer = new XslCompiledTransform(); transformer.Load(Server.MapPath(@"..\xsl\instructions.xsl")); XsltArgumentList args = new XsltArgumentList(); args.AddParam("webserver", "", Orchestrator.Globals.Configuration.WebServer); args.AddParam("showShortAddress", "", "false"); XmlUrlResolver resolver = new XmlUrlResolver(); XPathNavigator navigator = instruction.Point.ToXml().CreateNavigator(); // Populate the Point. StringWriter sw = new StringWriter(); transformer.Transform(navigator, args, sw); tdPoint.InnerHtml = sw.GetStringBuilder().ToString(); }
void btnConfirm_Click(object sender, EventArgs e) { Facade.IResource facResource = new Facade.Resource(); int controlAreaId = int.Parse(cboControlArea.SelectedValue); int trafficAreaId = int.Parse(cboTrafficArea.SelectedValue); if (m_instructionId != 0) { Facade.IInstruction facInstruction = new Facade.Instruction(); Entities.Instruction instruction = facInstruction.GetInstruction(m_instructionId); if (instruction.Driver != null) { facResource.AssignToArea(controlAreaId, trafficAreaId, instruction.Driver.ResourceId, "Driver was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName); } if (instruction.Vehicle != null) { facResource.AssignToArea(controlAreaId, trafficAreaId, instruction.Vehicle.ResourceId, "Vehicle was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName); } if (instruction.Trailer != null) { facResource.AssignToArea(controlAreaId, trafficAreaId, instruction.Trailer.ResourceId, "Trailer was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName); } } else { if (m_driverResourceId != 0) { facResource.AssignToArea(controlAreaId, trafficAreaId, m_driverResourceId, "Driver was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName); } if (m_vehicleResourceId != 0) { facResource.AssignToArea(controlAreaId, trafficAreaId, m_vehicleResourceId, "Vehicle was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName); } if (m_trailerResourceId != 0) { facResource.AssignToArea(controlAreaId, trafficAreaId, m_trailerResourceId, "Trailer was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName); } } mwhelper.CausePostBack = false; mwhelper.CloseForm = true; }
private void BindDropInstruction(Entities.Instruction instruction) { // The instruction to convert is currently a drop instruction so will be // converted to a trunk instruction (most likely for cross-docking). // Performing this action is only permissable if the new movement represented // by each order's involvement on the run can sensibly be attached to end of the // collection run for the order. This is so that the chain for each order is maintained. mvConvertInstruction.SetActiveView(vwConvertDrop); var facJob = new Facade.Job(); var facOrganisation = new Facade.Organisation(); var job = facJob.GetJob(instruction.JobId, true, true); grdOrdersOnDrop.DataSource = from o in instruction.CollectDrops.Cast <Entities.CollectDrop>().Select(cd => cd.Order) let ci = (from i in job.Instructions where i.InstructionTypeId == (int)eInstructionType.Load && i.CollectDrops.Cast <Entities.CollectDrop>().FirstOrDefault(cd => cd.OrderID == o.OrderID) != null select i).Single() let client = facOrganisation.GetForIdentityId(o.CustomerIdentityID) select new ConvertInstructionOrderData() { OrderID = o.OrderID, CustomerOrganisationName = client.OrganisationName, BusinessTypeDescription = GetBusinessTypeDescription(o.BusinessTypeID), OrderServiceLevel = o.OrderServiceLevel, CustomerOrderNumber = o.CustomerOrderNumber, DeliveryOrderNumber = o.DeliveryOrderNumber, Message = GetDropConversionMessage(ci, instruction, o), CollectionPointID = ci.PointID, CollectionPointDescription = ci.Point.Description, CollectionDateTime = ci.BookedDateTime, CollectionIsAnyTime = ci.IsAnyTime, DeliveryPointID = instruction.PointID, DeliveryPointDescription = instruction.Point.Description, DeliveryDateTime = instruction.BookedDateTime, DeliveryIsAnyTime = instruction.IsAnyTime, DeliveringResource = GetAssignedResource(job, instruction, o), LCID = o.LCID, ForeignRate = o.ForeignRate }; grdOrdersOnDrop.DataBind(); }
private void GetJobAndInstructions() { // Get the job. using (Facade.IInstruction facInstruction = new Facade.Instruction()) { // Try and get the job from the cache _job = (Entities.Job)Cache.Get("JobEntityForJobId" + _jobId.ToString()); if (_job == null) { Facade.IJob facJob = new Facade.Job(); _job = facJob.GetJob(_jobId); // Job was not in the cache thus get the instruction collection from the db _instructions = new Facade.Instruction().GetForJobId(_jobId); } else { // Job is in the cache, check for instructions if (_job.Instructions != null) { // We have instructions _instructions = _job.Instructions; } else { // otherwise get a fresh instruction collection _instructions = new Facade.Instruction().GetForJobId(_jobId); } } // Get the end instruction _endInstruction = _instructions.Find(instruc => instruc.InstructionOrder == _instructions.Count - 1); if (_endInstruction == null) { throw new ApplicationException("Cannot find last instruction."); } } }
private void PopulateStaticControls() { btnAddDestination.Visible = false; lblMessage.Text = "This job has been cancelled or invoiced and you are not able to add a destination at this time."; pnlAddDestination.Visible = false; int jobId = 0; if (int.TryParse(Request.QueryString["jobId"], out jobId)) { JobId = jobId; // If the job is invoiced or cancelled we can not add a destination. if (CurrentJob.JobState != eJobState.Invoiced && CurrentJob.JobState != eJobState.Cancelled) { Entities.Instruction endInstruction = CurrentJob.Instructions[CurrentJob.Instructions.Count - 1]; //rdiArrivalTime.MinDate = endInstruction.PlannedDepartureDateTime.Add(new TimeSpan(0, 15, 0)); _minDate = endInstruction.PlannedDepartureDateTime; chkDriver.Enabled = endInstruction.Driver != null; chkVehicle.Enabled = endInstruction.Vehicle != null; chkTrailer.Enabled = endInstruction.Trailer != null; if (endInstruction.Driver != null) { chkDriver.Text = endInstruction.Driver.Individual.FullName; } if (endInstruction.Vehicle != null) { chkVehicle.Text = endInstruction.Vehicle.RegNo; } if (endInstruction.Trailer != null) { chkTrailer.Text = endInstruction.Trailer.TrailerRef; } lblMessage.Text = "Please specify the destination point and arrival time, you may also supply the resources that will be assigned to the destination."; pnlAddDestination.Visible = true; btnAddDestination.Visible = true; } } }
private string BuildLoadComments(int driverId, Entities.InstructionCollection instructionCollection) { StringBuilder loadComments = new StringBuilder(); ArrayList collectedDockets = new ArrayList(); // Build the list of dockets being collected. foreach (Entities.Instruction instruction in instructionCollection) { if (instruction.InstructionTypeId == (int)eInstructionType.Load) { foreach (Entities.CollectDrop collection in instruction.CollectDrops) { collectedDockets.Add(collection.Docket); } } } Entities.Instruction instruc = null; // Display the dockets in the reverse order they are being delivered. for (int instructionIndex = instructionCollection.Count - 1; instructionIndex >= 0; instructionIndex--) { instruc = instructionCollection[instructionIndex]; if (instruc.InstructionTypeId == (int)eInstructionType.Drop) { foreach (Entities.CollectDrop delivery in instruc.CollectDrops) { if (collectedDockets.Contains(delivery.Docket)) { loadComments.Append(string.Format("{0} ({1})", delivery.Docket, instruc.Point.PostTown.TownName)); loadComments.Append("<br>"); } } } } return(loadComments.ToString()); }
private void PopulateForm() { Facade.IInstruction facInstruction = new Facade.Instruction(); m_instruction = facInstruction.GetInstruction(m_instructionID); bool canRemoveTrunkPoint = false; if (m_instruction != null) { if (m_instruction.InstructionTypeId == (int)eInstructionType.Trunk && (m_instruction.CollectDrops.Count == 0 || m_instruction.CollectDrops[0].OrderID == 0)) { canRemoveTrunkPoint = true; // This instruction is either a trunk or a trunk that has zero orders. } // Get the previous instruction. Entities.InstructionCollection instructions = facInstruction.GetForJobId(m_instruction.JobId); m_previousInstruction = instructions.GetPreviousInstruction(m_instruction.InstructionID); } pnlConfirmation.Visible = canRemoveTrunkPoint; pnlCannotRemoveTrunk.Visible = !canRemoveTrunkPoint; btnRemoveTrunk.Visible = canRemoveTrunkPoint; }
Entities.JobSubContractor GetJobSubContract(Entities.Instruction selected) { Facade.IExchangeRates facER = new Facade.ExchangeRates(); decimal rate = Decimal.Parse(rntSubContractRate.Text, System.Globalization.NumberStyles.Currency); Entities.JobSubContractor jobSubContract = new Entities.JobSubContractor(int.Parse(cboSubContractor.SelectedValue), rate, chkUseSubContractorTrailer.Checked); jobSubContract.LCID = rntSubContractRate.Culture.LCID; CultureInfo culture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture); if (jobSubContract.LCID != culture.LCID) // Default { jobSubContract.ExchangeRateID = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(jobSubContract.LCID), selected.PlannedArrivalDateTime); jobSubContract.Rate = facER.GetConvertedRate((int)jobSubContract.ExchangeRateID, jobSubContract.ForeignRate); } else { jobSubContract.Rate = decimal.Round(jobSubContract.ForeignRate, 4, MidpointRounding.AwayFromZero); } return(jobSubContract); }
private bool CanBeRemovedFromTrunk(Entities.Instruction trunkInstruction, Entities.Order order, out string message) { var messageFragments = new List <string>(); // This order can only be removed from this trunk and placed on a delivery if: // * The order hasn't already been planned for delivery on another job. if (order.PlannedForDelivery) { messageFragments.Add("Already planned for delivery"); } if (messageFragments.Count > 0) { message = String.Format("Excluded - {0}", String.Join(", ", messageFragments.ToArray())); } else { message = String.Empty; } return(messageFragments.Count == 0); }
private void GetDocketNumbers(int instructionId) { using (Facade.IInstruction facInstruction = new Facade.Instruction()) { Entities.Instruction selected = facInstruction.GetInstruction(instructionId); string docketCollection = string.Empty; if (selected != null) { foreach (Entities.CollectDrop cd in selected.CollectDrops) { if (docketCollection.Length > 0) { docketCollection += "/"; } docketCollection += cd.Docket; } } txtRef.Text = docketCollection; } }
private bool AddGoodsRefused() { Facade.IGoodsRefusal facGoods = new Facade.GoodsRefusal(); bool retVal = false; string userName = ((Entities.CustomPrincipal)Page.User).UserName; eJobType jobType = eJobType.Normal; using (Facade.IInstruction facInstruction = new Facade.Instruction()) { Entities.Instruction instruction = facInstruction.GetInstruction(_instructionId); using (Facade.IJob facJob = new Facade.Job()) { Entities.Job job = facJob.GetJob(instruction.JobId); jobType = job.JobType; } } retVal = facGoods.Create(_goodsRefused, jobType, _instructionId, userName); if (!retVal) { lblConfirmation.Text = "There was an error adding the Goods Refused, please try again."; lblConfirmation.Visible = true; lblConfirmation.ForeColor = Color.Red; retVal = false; } else { btnAdd.Text = "Update Goods Refused"; this.ReturnValue = "Refresh_Redeliveries_And_Refusals"; this.Close(); } return(retVal); }
private Entities.InstructionActual PopulateInstructionActual() { Facade.IInstruction facInstruction = new Facade.Instruction(); Entities.InstructionActual instructionActual = ((Facade.IInstructionActual)facInstruction).GetEntityForInstructionId(m_instructionId); if (instructionActual == null) { instructionActual = new Entities.InstructionActual(); instructionActual.InstructionId = m_instructionId; instructionActual.CollectDropActuals = new Entities.CollectDropActualCollection(); } Entities.Instruction i = facInstruction.GetInstruction(m_instructionId); // Populate the main data about a call-in. instructionActual.Discrepancies = ""; instructionActual.DriversNotes = ""; instructionActual.ArrivalDateTime = i.BookedDateTime; instructionActual.CollectDropDateTime = i.BookedDateTime; instructionActual.LeaveDateTime = i.BookedDateTime; // Populate the collect drop information. eInstructionType instructionType = (eInstructionType)i.InstructionTypeId; #region Instruction Type Specific Loadings switch (instructionType) { case eInstructionType.Load: // The collect drop dockets are specified by the drop recording process - we just need to create dummy actuals (we only do this for the initial create). if (instructionActual.InstructionActualId == 0) { Entities.Instruction instruction = facInstruction.GetInstruction(m_instructionId); foreach (Entities.CollectDrop loadDocket in instruction.CollectDrops) { Entities.CollectDropActual loadDocketDummyActual = new Entities.CollectDropActual(); loadDocketDummyActual.CollectDropId = loadDocket.CollectDropId; loadDocketDummyActual.NumberOfCases = 0; loadDocketDummyActual.NumberOfPallets = 0; loadDocketDummyActual.Weight = 0; instructionActual.CollectDropActuals.Add(loadDocketDummyActual); } } break; case eInstructionType.Trunk: // The collect drop dockets are specified by the drop recording process - we just need to create dummy actuals (we only do this for the initial create). if (instructionActual.InstructionActualId == 0) { Entities.Instruction instruction = i; foreach (Entities.CollectDrop loadDocket in instruction.CollectDrops) { Entities.CollectDropActual loadDocketDummyActual = new Entities.CollectDropActual(); loadDocketDummyActual.CollectDropId = loadDocket.CollectDropId; loadDocketDummyActual.NumberOfCases = 0; loadDocketDummyActual.NumberOfPallets = 0; loadDocketDummyActual.Weight = 0; instructionActual.CollectDropActuals.Add(loadDocketDummyActual); } } break; case eInstructionType.Drop: if (m_job.JobType == eJobType.Normal || m_job.JobType == eJobType.Groupage) { //create a collectdropactual for each collectdrop Entities.CollectDropActual cda = new Orchestrator.Entities.CollectDropActual(); foreach (Entities.CollectDrop cd in i.CollectDrops) { cda = new Orchestrator.Entities.CollectDropActual(); cda.NumberOfCases = cd.NoCases; cda.NumberOfPallets = cd.NoPallets; cda.NumberOfPalletsReturned = cd.NoPallets; cda.CollectDropId = cd.CollectDropId; cda.Weight = cd.Weight; } instructionActual.CollectDropActuals.Add(cda); } break; } #endregion return(instructionActual); }
private Entities.InstructionCollection PopulateInstructions() { foreach (RepeaterItem item in repLegs.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { int instructionID = int.Parse(((HtmlInputHidden)item.FindControl("hidInstructionID")).Value); RadDatePicker dteSDate = item.FindControl("dteSDate") as RadDatePicker; RadTimePicker dteSTime = item.FindControl("dteSTime") as RadTimePicker; RadDatePicker dteEDate = item.FindControl("dteEDate") as RadDatePicker; RadTimePicker dteETime = item.FindControl("dteETime") as RadTimePicker; // Configure the new date and time values. DateTime startDateTime = dteSDate.SelectedDate.Value; startDateTime = startDateTime.Subtract(startDateTime.TimeOfDay); startDateTime = startDateTime.Add(dteSTime.SelectedDate.Value.TimeOfDay); DateTime endDateTime = dteEDate.SelectedDate.Value; endDateTime = endDateTime.Subtract(endDateTime.TimeOfDay); endDateTime = endDateTime.Add(dteETime.SelectedDate.Value.TimeOfDay); // Locate the instruction(s) to alter. Entities.Instruction instruction = Instructions.GetForInstructionId(instructionID); if (Instructions.Count == 1) { // First (and only) instruction on the job, set the arrival and departure date time. instruction.PlannedArrivalDateTime = startDateTime; instruction.PlannedDepartureDateTime = endDateTime; } else { // Get the previous instruction. Entities.Instruction previousInstruction = Instructions.GetPreviousInstruction(instruction); Facade.IJob facJob = new Facade.Job(); if (previousInstruction != null) { if (previousInstruction.InstructionOrder == 0) { previousInstruction.PlannedArrivalDateTime = startDateTime; var expectedTurnaroundTime = facJob.GetExpectedTurnaroundTimeForInstruction(previousInstruction); previousInstruction.PlannedDepartureDateTime = previousInstruction.PlannedArrivalDateTime.Add(expectedTurnaroundTime); } else { previousInstruction.PlannedDepartureDateTime = startDateTime; } } // Set the arrival date time for this instruction. instruction.PlannedArrivalDateTime = endDateTime; bool isLastInstruction = Instructions.IsLastInstruction(instruction); if (isLastInstruction) { var expectedTurnaroundTime = facJob.GetExpectedTurnaroundTimeForInstruction(instruction); instruction.PlannedDepartureDateTime = instruction.PlannedArrivalDateTime.Add(expectedTurnaroundTime); } } } } return(Instructions); }
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 (!IsPostBack) { Facade.IOrganisation facOrganisation = new Facade.Organisation(); btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE); if (Session[wizard.C_INSTRUCTION] != null) { m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION]; switch ((eInstructionType)m_instruction.InstructionTypeId) { case eInstructionType.Load: // Allow the user to collect from any location if this is a stock movement job. if (m_job.IsStockMovement) { m_identityId = 0; } else { m_identityId = m_job.IdentityId; } lblCollection.Visible = true; lblCollectFrom.Visible = true; lblDelivery.Visible = false; lblDeliverTo.Visible = false; lblCollectDrop.Text = "Collection Details"; break; case eInstructionType.Drop: m_identityId = m_instruction.ClientsCustomerIdentityID; lblCollection.Visible = false; lblCollectFrom.Visible = false; lblDelivery.Visible = true; lblDeliverTo.Visible = true; lblCollectDrop.Text = "Delivery Details"; m_owner = facOrganisation.GetNameForIdentityId(m_identityId); cboOwner.Text = m_owner; cboOwner.SelectedValue = m_identityId.ToString(); cboOwner.Visible = false; lblOwner.Visible = true; lblOwner.Text = m_owner; break; } } else { m_instruction = new Entities.Instruction(); m_instruction.JobId = m_jobId; if (m_job.Instructions == null) { m_job.Instructions = new Entities.InstructionCollection(); } switch ((ePointType)Session[wizard.C_POINT_TYPE]) { case ePointType.Collect: // Allow the user to collect from any location if this is a stock movement job. if (m_job.IsStockMovement) { m_identityId = 0; } else { m_identityId = m_job.IdentityId; } m_owner = facOrganisation.GetNameForIdentityId(m_job.IdentityId); cboOwner.Text = m_owner; cboOwner.SelectedValue = m_identityId.ToString(); m_instruction.InstructionTypeId = (int)eInstructionType.Load; lblCollection.Visible = true; lblCollectFrom.Visible = true; lblDelivery.Visible = false; lblDeliverTo.Visible = false; lblCollectDrop.Text = "Collection Details"; #region Load the Default Collection Point try { Entities.Organisation client = facOrganisation.GetForIdentityId(m_job.IdentityId); Facade.IPoint facPoint = new Facade.Point(); Entities.Point defaultPoint = facPoint.GetPointForPointId(client.Defaults[0].DefaultCollectionPointId); cboTown.SelectedValue = defaultPoint.PostTown.TownId.ToString(); cboTown.Text = defaultPoint.PostTown.TownName; cboPoint.SelectedValue = defaultPoint.PointId.ToString(); cboPoint.Text = defaultPoint.Description; m_identityId = defaultPoint.IdentityId; m_owner = defaultPoint.OrganisationName; m_pointId = defaultPoint.PointId; m_point = defaultPoint.Description; m_townId = defaultPoint.PostTown.TownId; m_town = defaultPoint.PostTown.TownName; cboOwner.Text = m_owner; cboOwner.SelectedValue = m_identityId.ToString(); } catch { } #endregion break; } Session[wizard.C_INSTRUCTION] = m_instruction; if (!m_isUpdate) { Session[wizard.C_INSTRUCTION_INDEX] = m_job.Instructions.Count; } } if (m_instruction != null && m_instruction.Point != null) { cboOwner.SelectedValue = m_instruction.Point.IdentityId.ToString(); cboOwner.Text = m_instruction.Point.OrganisationName; cboPoint.SelectedValue = m_instruction.PointID.ToString(); cboPoint.Text = m_instruction.Point.Description; cboTown.SelectedValue = m_instruction.Point.PostTown.TownId.ToString(); cboTown.Text = m_instruction.Point.PostTown.TownName; } } else { m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION]; } pnlCreateNewPoint.Visible = false; }