Ejemplo n.º 1
0
        private void LoadReport()
        {
            int itemIndex = Convert.ToInt32(ViewState["DataGridItemIndex"]);

            NameValueCollection reportParams = new NameValueCollection();

            reportParams.Add("LoadNo", dgJobCollections.Items[itemIndex].Cells[(int)eDataGridColumns.LoadNo].Text);
            reportParams.Add("Destination", dgJobCollections.Items[itemIndex].Cells[(int)eDataGridColumns.Destination].Text);
            reportParams.Add("Driver", dgJobCollections.Items[itemIndex].Cells[(int)eDataGridColumns.Driver].Text);
            reportParams.Add("VehicleReg", dgJobCollections.Items[itemIndex].Cells[(int)eDataGridColumns.RegNo].Text);
            reportParams.Add("TrailerRef", dgJobCollections.Items[itemIndex].Cells[(int)eDataGridColumns.TrailerRef].Text);
            reportParams.Add("DeliveryTime", dgJobCollections.Items[itemIndex].Cells[(int)eDataGridColumns.DeliveryTime].Text);
            reportParams.Add("To", txtTo.Text);
            reportParams.Add("From", txtFrom.Text);
            reportParams.Add("Ref", txtRef.Text);

            //-------------------------------------------------------------------------------------
            //									Load Report Section
            //-------------------------------------------------------------------------------------
            Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]   = eReportType.LoadReleaseFax;
            Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable] = reportParams;

            // Show the user control
            reportViewer.Visible = true;
            using (Facade.IJob facJob = new Facade.Job())
                reportViewer.IdentityId = facJob.GetJob(m_jobId).IdentityId;
        }
Ejemplo n.º 2
0
        private void BindLegs()
        {
            Facade.IJob  facJob = new Facade.Job();
            Entities.Job job    = facJob.GetJob(m_jobId, true, true);

            Entities.LegPlan lp = new Facade.Instruction().GetLegPlan(job.Instructions, false);
            repLegs.DataSource = lp.Legs();
            repLegs.DataBind();

            if (job.Instructions.Count > 0)
            {
                if (job.Instructions[0].Driver != null)
                {
                    chkLinkDriver.Text = "Link " + job.Instructions[0].Driver.Individual.FullName;
                }
                if (job.Instructions[0].Vehicle != null)
                {
                    chkLinkVehicle.Text = "Link " + job.Instructions[0].Vehicle.RegNo;
                }
                if (job.Instructions[0].Trailer != null)
                {
                    chkLinkTrailer.Text = "Link " + job.Instructions[0].Trailer.TrailerRef;
                }
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.AddEditJob, eSystemPortion.GeneralUsage);

            m_jobId = Convert.ToInt32(Request.QueryString["jobId"]);

            if (m_jobId > 0)
            {
                Facade.IJob  facJob = new Facade.Job();
                Entities.Job job    = facJob.GetJob(m_jobId);

                if (job != null)
                {
                    switch (job.JobType)
                    {
                    case eJobType.Normal:
                        pnlOpenWizard.Visible = true;
                        break;

                    case eJobType.PalletReturn:
                        Response.Redirect("addupdatepalletreturnjob.aspx?jobId=" + m_jobId.ToString());
                        break;

                    case eJobType.Return:
                        Response.Redirect("addupdategoodsreturnjob.aspx?jobId=" + m_jobId.ToString());
                        break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Retrieve the job we're working on
            try
            {
                if (Request.QueryString["pointID"] != null)
                {
                    int.TryParse(Request.QueryString["pointID"], out m_PointId);
                }

                m_jobId           = Convert.ToInt32(ViewState[C_JOB_ID_VS]);
                m_deliveryPointId = Convert.ToInt32(ViewState[C_DELIVERY_POINT_ID_VS]);

                Facade.IJob facJob = new Facade.Job();
                m_job = facJob.GetJob(m_jobId);

                Facade.IPCV facPCV = new Facade.PCV();
                m_job.PCVs = facPCV.GetForJobId(m_jobId, m_deliveryPointId);
            }
            catch {}

            if (!IsPostBack)
            {
                PopulateStaticControls();
                LoadJobs();
            }
        }
Ejemplo n.º 5
0
        private void LoadJob()
        {
            Facade.IJob facJob = new Facade.Job();
            m_job = facJob.GetJob(m_jobId);

            if (m_job != null)
            {
                if (m_job.JobState == eJobState.Cancelled)
                {
                    Response.Redirect("../../Job/job.aspx?wiz=true&jobId=" + m_job.JobId.ToString() + "&csid=" + this.CookieSessionID);
                }

                Facade.IPCV facPCV = new Facade.PCV();
                m_job.PCVs = facPCV.GetForJobId(m_jobId);

                if (m_job.JobState == eJobState.Booked)
                {
                    Response.Redirect("../jobManagement.aspx?jobId=" + m_jobId + "&csid=" + this.CookieSessionID);
                }

                // Load the various parts of the job.
                Facade.IInstruction facInstruction = new Facade.Instruction();
                m_job.Instructions = facInstruction.GetForJobId(m_jobId);

                PopulateJobInformation();
            }

            ViewState[C_JOB_VS] = m_job;
        }
Ejemplo n.º 6
0
        private bool UpdateInstruction()
        {
            Facade.IJob facJob = new Facade.Job();
            string      userId = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.FacadeResult result = null;

            if (m_instruction.InstructionID == 0)
            {
                int plannerId = ((Entities.CustomPrincipal)Page.User).IdentityId;
                result = facJob.AddInstruction(m_job, m_instruction, plannerId, userId);
            }
            else
            {
                // Update the instruction
                result = facJob.UpdateInstruction(m_job, m_instruction, userId);
            }

            if (result.Success)
            {
                if (!chkManualRateEntry.Checked)
                {
                    // Cause the rates to be recalculated for this job.
                    facJob.PriceJob(m_jobId, ((Entities.CustomPrincipal)Page.User).UserName);
                }

                m_job            = facJob.GetJob(m_jobId, true);
                m_job.Charge     = ((Facade.IJobCharge)facJob).GetForJobId(m_jobId);
                m_job.References = ((Facade.IJobReference)facJob).GetJobReferences(m_jobId);
            }

            return(result.Success);
        }
        private void LoadJob()
        {
            Facade.IJob         facJob         = new Facade.Job();
            Facade.IInstruction facInstruction = new Facade.Instruction();

            m_job = facJob.GetJob(m_jobId, true, true);
            ViewState[C_JOB_VS] = m_job;
        }
Ejemplo n.º 8
0
        public void OrderPlanChange(int orderID, int instructionTypeID, int?instructionID, int vehicleResourceID, DateTime arrivalDateTime)
        {
            using (var uow = DIContainer.CreateUnitOfWork())
            {
                if (instructionID.HasValue)
                {
                    Facade.IInstruction facInstruction = new Facade.Instruction();
                    Facade.IJob         facJob         = new Facade.Job();

                    var instructionRepo = DIContainer.CreateRepository <IInstructionRepository>(uow);
                    var jobID           = instructionRepo.Find(instructionID.Value).JobID;

                    var job         = facJob.GetJob(jobID, true, true);
                    var instruction = job.Instructions.Find(i => i.InstructionID == instructionID.Value);

                    var changeTimes   = instruction.PlannedArrivalDateTime != arrivalDateTime;
                    var changeVehicle = instruction.Vehicle.ResourceId != vehicleResourceID;

                    var userName = HttpContext.Current.User.Identity.Name;

                    if (changeVehicle)
                    {
                        var result = facInstruction.PlanInstruction(new[] { instructionID.Value }, jobID, -1, vehicleResourceID, -1, job.LastUpdateDate, userName);

                        if (!result.Success)
                        {
                            throw new ApplicationException(
                                      string.Format(
                                          "Could not update vehicle on run {0} due to the following infringements: {1}",
                                          jobID,
                                          string.Join("\n", result.Infringements.Select(i => i.Description))));
                        }
                    }

                    if (changeTimes)
                    {
                        instruction.PlannedArrivalDateTime   = arrivalDateTime;
                        instruction.PlannedDepartureDateTime = arrivalDateTime.AddMinutes(15);
                        var result = facJob.UpdatePlannedTimes(jobID, job.Instructions, job.LastUpdateDate, userName);

                        if (!result.Success)
                        {
                            throw new ApplicationException(
                                      string.Format(
                                          "Could not update planned times on run {0} due to the following infringements: {1}",
                                          jobID,
                                          string.Join("\n", result.Infringements.Select(i => i.Description))));
                        }
                    }
                }
                else
                {
                    var repo = DIContainer.CreateRepository <IOrderRepository>(uow);
                    repo.AddUpdateOrderPrePlan(orderID, (eInstructionType)instructionTypeID, vehicleResourceID, arrivalDateTime);
                    uow.SaveChanges();
                }
            }
        }
Ejemplo n.º 9
0
        private void LoadJob()
        {
            // Load the job
            Facade.IJob facJob = new Facade.Job();
            m_job = facJob.GetJob(m_jobId);

            // Store the job in the session
            Session[wizard.C_JOB] = m_job;
        }
Ejemplo n.º 10
0
 private void LoadJob()
 {
     using (Facade.IJob facJob = new Facade.Job())
     {
         m_job               = facJob.GetJob(m_jobId);
         this.JobTypeID      = (int)m_job.JobType;
         ViewState[C_JOB_VS] = m_job;
     }
 }
Ejemplo n.º 11
0
 private void ShowPCVS()
 {
     Facade.IJob  facJob = new Facade.Job();
     Entities.Job _job   = facJob.GetJob(_jobId);
     if (_job.PCVs.Count > 0)
     {
         pnlPCVS.Visible = true;
     }
     else
     {
         pnlPCVS.Visible = false;
     }
 }
        private void dgJobs_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            int    jobId         = Convert.ToInt32(e.Item.Cells[0].Text);
            string receiptNumber = ((TextBox)e.Item.Cells[2].Controls[0]).Text;

            Facade.IJob  facJob = new Facade.Job();
            Entities.Job job    = facJob.GetJob(jobId);

            job.ReturnReceiptNumber = receiptNumber;
            facJob.Update(job, ((Entities.CustomPrincipal)Page.User).UserName);

            dgJobs.EditItemIndex = -1;
            PopulateJobs();
        }
Ejemplo n.º 13
0
        private void LoadJob()
        {
            using (Facade.IJob facJob = new Facade.Job())
            {
                m_job = facJob.GetJob(m_jobId, true);

                if (m_job.JobState == eJobState.Cancelled)
                {
                    Response.Redirect("../../Job/job.aspx?wiz=true&jobId=" + m_job.JobId.ToString() + "&csid=" + this.CookieSessionID);
                }
            }

            ViewState[C_JOB_VS] = m_job;
        }
Ejemplo n.º 14
0
        private void LoadJob()
        {
            Facade.IJob  facJob = new Facade.Job();
            Entities.Job job    = facJob.GetJob(m_jobId);
            job.References = ((Facade.IJobReference)facJob).GetJobReferences(job.JobId);

            cboClient.Text          = job.Client;
            cboClient.SelectedValue = job.IdentityId.ToString();
            cboClient.SelectedValue = job.IdentityId.ToString();

            repExistingReferences.DataSource = job.References;
            repExistingReferences.DataBind();

            GetReferences(job.IdentityId);
        }
Ejemplo n.º 15
0
        private void LoadJob()
        {
            using (Facade.IJob facJob = new Facade.Job())
            {
                m_job = facJob.GetJob(m_jobId);

                if (m_job.JobState == eJobState.Cancelled)
                {
                    Response.Redirect("../../Job/job.aspx?wiz=true&jobId=" + m_job.JobId + "&csid=" + this.CookieSessionID);
                }

                Facade.IInstruction facInstruction = new Facade.Instruction();
                m_job.Instructions = facInstruction.GetForJobId(m_job.JobId);
            }

            ViewState[C_JOB_VS] = m_job;
        }
Ejemplo n.º 16
0
        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();
        }
Ejemplo n.º 17
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 18
0
        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();
        }
Ejemplo n.º 19
0
        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.");
                }
            }
        }
Ejemplo n.º 20
0
        private void dgJobs_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "AttachPCVs":
                m_jobId           = Convert.ToInt32(e.Item.Cells[0].Text);
                m_deliveryPointId = Convert.ToInt32(e.Item.Cells[5].Text);

                ViewState[C_JOB_ID_VS]            = m_jobId;
                ViewState[C_DELIVERY_POINT_ID_VS] = m_deliveryPointId;

                Facade.IJob facJob = new Facade.Job();
                m_job = facJob.GetJob(m_jobId);
                Facade.IPCV facPCV = new Facade.PCV();
                m_job.PCVs = facPCV.GetForJobId(m_jobId, m_deliveryPointId);

                LoadJobs();
                LoadPCVs(m_jobId);
                break;
            }
        }
Ejemplo n.º 21
0
        private Entities.Job GetJobEntityFromCache()
        {
            Entities.Job job = (Entities.Job)Cache.Get("JobEntityForJobId" + m_jobID);

            if (job == null)
            {
                Facade.IJob facJob = new Facade.Job();
                Facade.IPCV facPCV = new Facade.PCV();
                Facade.IJobSubContractor facJobSubContractor = new Facade.Job();

                job                = facJob.GetJob(m_jobID, true, true);
                job.Charge         = ((Facade.IJobCharge)facJob).GetForJobId(m_jobID);
                job.Extras         = facJob.GetExtras(m_jobID, true);
                job.PCVs           = facPCV.GetForJobId(m_jobID);
                job.References     = ((Facade.IJobReference)facJob).GetJobReferences(m_jobID);
                job.SubContractors = facJobSubContractor.GetSubContractorForJobId(m_jobID);

                AddJobEntityToCache(job);
            }

            return(job);
        }
Ejemplo n.º 22
0
        private void StoreActual()
        {
            Entities.FacadeResult result = null;
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.InstructionActual ia = null;
            Facade.IJob facJob            = new Facade.Job();
            string      errMessage        = "<div style=\"background-color:white; color:red; border:solid 1pt black; padding:5px;\"> One or nore of the Call Ins that you wanted to create could not be done as there are either earlier debriefs to be processed first or they are on the same job as others that are for Customers that have been marked as to require the capture of Debrief information : <br/>{0}</div>";
            string      jobLink           = "<a href=\"job.aspx?jobId={0}&csid=xx\" target=\"_blank\">{0}</a>";
            string      jobLinks          = string.Empty;
            string      jobIds            = string.Empty;

            int i = 0;

            foreach (Telerik.Web.UI.GridDataItem gdi in grdCallIns.SelectedItems)
            {
                if (i > 100)
                {
                    break;
                }
                m_instructionId = (int)gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["InstructionId"];
                m_jobID         = (int)gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["JobId"];
                m_job           = facJob.GetJob(m_jobID, true);
                ia     = PopulateInstructionActual();
                result = CreateInstructionActual(ia, userId);
                if (result.Success == false)
                {
                    jobIds += string.Format(jobLink, m_jobID.ToString()) + "<br/>";
                }
                i++;
            }

            if (jobIds.Length > 0)
            {
                litError.Text    = string.Format(errMessage, jobIds);
                litError.Visible = true;
            }
        }
Ejemplo n.º 23
0
        private bool LoadJob()
        {
            bool isJobLoaded = false;

            try
            {
                // Retrieve the Job Id
                m_jobId = Int32.Parse(Request.QueryString["jobId"]);

                // Load the Job
                Facade.IJob facJob = new Facade.Job();
                m_job = facJob.GetJob(m_jobId);

                // Check that the job has been loaded
                if (m_job != null)
                {
                    isJobLoaded = true;
                }
            }
            catch {}

            return(isJobLoaded);
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            if (m_isUpdate)
            {
                // Reload the job.

                Facade.IJob facJob = new Facade.Job();
                m_job = facJob.GetJob(m_jobId);

                Facade.IInstruction facInstruction = new Facade.Instruction();

                if (m_job.JobType == eJobType.Normal)
                {
                    m_job.Charge       = ((Facade.IJobCharge)facJob).GetForJobId(m_jobId);
                    m_job.Instructions = facInstruction.GetForJobId(m_job.JobId);
                    m_job.References   = ((Facade.IJobReference)facJob).GetJobReferences(m_jobId);

                    Session[wizard.C_JOB] = m_job;
                }
                else
                {
                    switch (m_job.JobType)
                    {
                    case eJobType.PalletReturn:
                        GoToStep("PR");
                        break;

                    case eJobType.Return:
                        GoToStep("GR");
                        break;
                    }
                }
            }

            GoToStep("JD");
        }
Ejemplo n.º 26
0
        private void LoadJob()
        {
            Facade.IJob  facJob = new Facade.Job();
            Entities.Job job    = facJob.GetJob(m_jobId);

            bool canBeMarkedForCancellation = job.JobState == eJobState.Booked || job.JobState == eJobState.Planned || job.JobState == eJobState.InProgress;

            // Set the checkbox status and the cancellation reason.
            chkMarkforCancellation.Checked = job.ForCancellation;
            if (job.ForCancellation)
            {
                txtCancellationReason.Text = job.ForCancellationReason;
            }

            if (!canBeMarkedForCancellation || job.ForCancellation)
            {
                // Only allow the display of the cancellation information.
                chkMarkforCancellation.Enabled = false;
                txtCancellationReason.Enabled  = false;

                // This job is too advanced to be cancelled, or has already been marked for cancellation.
                btnCancelJob.Enabled = false;
            }
        }
Ejemplo n.º 27
0
        private void JobId_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = P1TP.Components.Common.SimpleValidation.ValidateNumericValue(args.Value, 1, true);

            if (args.IsValid)
            {
                try
                {
                    int jobId = Convert.ToInt32(args.Value);

                    using (Facade.IJob facJob = new Facade.Job())
                    {
                        if (facJob.GetJob(jobId) == null)
                        {
                            args.IsValid = false;
                        }
                    }
                }
                catch
                {
                    args.IsValid = false;
                }
            }
        }
Ejemplo n.º 28
0
        //-----------------------------------------------------------------------------------------------------------

        protected void btnUpdateOrders_Click(object sender, EventArgs e)
        {
            // Find out if we need to create a new instruction, if all the orders have been selected then we can
            // change the instructions point and all the orders delivery points without adding a new instruction.

            // if some orders are left on the existing instruction then we need to remove the selected orders from
            // the current instruction and create a new instruction based on the new delivery details.
            // Then add the selected orders to the newly created instruction.

            // Ensure that all points are created.

            if (this.cboNewDeliveryPoint.PointID < 1)
            {
                this.lblError.Text = "Please select a Point.";
            }
            else
            {
                this.lblError.Text = String.Empty;
                Facade.IOrder        facorder       = new Facade.Order();
                Facade.IInstruction  facInstruction = new Facade.Instruction();
                Entities.Instruction instruction    = null;

                List <int> orderIds      = new List <int>();
                int        instructionId = -1;
                int        runId         = -1;

                foreach (GridDataItem item in grdOrders.Items)
                {
                    if (instructionId == -1)
                    {
                        Label lblInstruction = (Label)item.FindControl("lblInstructionId");
                        int.TryParse(lblInstruction.Text, out instructionId);
                    }
                    if (runId == -1)
                    {
                        HyperLink hypRun = (HyperLink)item.FindControl("hypRun");
                        int.TryParse(hypRun.Text, out runId);
                    }

                    CheckBox chkOrderId = (CheckBox)item.FindControl("chkSelectOrder");
                    int      orderId;
                    int.TryParse(chkOrderId.Attributes["OrderID"].ToString(), out orderId);

                    if (chkOrderId.Checked)
                    {
                        orderIds.Add(int.Parse(chkOrderId.Attributes["OrderID"].ToString()));
                    }
                }

                instruction = facInstruction.GetInstruction(instructionId);

                if (instruction != null)
                {
                    Facade.IJob  facJob = new Facade.Job();
                    Entities.Job run    = facJob.GetJob(runId, true);

                    if (orderIds.Count == this.grdOrders.Items.Count)
                    {
                        ChangeExistingInstruction(instruction, run, orderIds);

                        List <Entities.Instruction> amendedInstructions = new List <Orchestrator.Entities.Instruction>();
                        amendedInstructions.Add(instruction);
                        // Commit the action.
                        Entities.FacadeResult    retVal = null;
                        Entities.CustomPrincipal user   = (Entities.CustomPrincipal)Page.User;

                        retVal = facJob.AmendInstructions(run, amendedInstructions, eLegTimeAlterationMode.Enforce_Booked_Times, user.Name);
                    }
                    else
                    {
                        List <Entities.Instruction> amendedInstructions = new List <Orchestrator.Entities.Instruction>();

                        Facade.IOrder facOrder = new Facade.Order();
                        BusinessLogicLayer.ICollectDrop busCollectDrop = new BusinessLogicLayer.CollectDrop();

                        using (TransactionScope tran = new TransactionScope())
                        {
                            foreach (int ordId in orderIds)
                            {
                                Entities.Order currentOrder = facOrder.GetForOrderID(ordId);

                                Entities.CollectDrop collectDrop = instruction.CollectDrops.Find(i => i.OrderID == currentOrder.OrderID);
                                busCollectDrop.Delete(collectDrop, this.Page.User.Identity.Name);

                                this.AddNewDropInstruction(currentOrder, run, amendedInstructions);
                            }

                            // Commit the action.
                            Entities.FacadeResult    retVal = null;
                            Entities.CustomPrincipal user   = (Entities.CustomPrincipal)Page.User;

                            retVal = facJob.AmendInstructions(run, amendedInstructions, eLegTimeAlterationMode.Enforce_Booked_Times, user.Name);
                            if (retVal.Success)
                            {
                                tran.Complete();
                            }
                        }
                    }
                }

                this.grdOrders.DataSource = null;
                this.grdOrders.Rebind();
            }
        }
Ejemplo n.º 29
0
        private void TrunkLeg()
        {
            Entities.CustomPrincipal user   = (Entities.CustomPrincipal)Page.User;
            Entities.FacadeResult    result = null;

            int pointId = ucPoint.PointID;// int.Parse(cboPoint.SelectedValue);

            if (!IsUpdate)
            {
                #region Create New Trunk
                Entities.Instruction instruction = null;
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                {
                    instruction = facInstruction.GetInstruction(m_instructionId);
                }

                // We've trunked the leg.
                DateTime arriveAtTrunkPoint;
                DateTime leaveTrunkPoint;

                // Get the arrival time.
                //arriveAtTrunkPoint = timeStartDate.xDateTime;
                arriveAtTrunkPoint = new DateTime(rdiStartDate.SelectedDate.Value.Year, rdiStartDate.SelectedDate.Value.Month, rdiStartDate.SelectedDate.Value.Day, rdiStartTime.SelectedDate.Value.Hour, rdiStartTime.SelectedDate.Value.Minute, 0);

                // Get the departure time.
                //leaveTrunkPoint = timeEndDate.xDateTime;
                leaveTrunkPoint = new DateTime(rdiEndDate.SelectedDate.Value.Year, rdiEndDate.SelectedDate.Value.Month, rdiEndDate.SelectedDate.Value.Day, rdiEndTime.SelectedDate.Value.Hour, rdiEndTime.SelectedDate.Value.Minute, 0);

                DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]);

                // Create the new trunk instruction
                Entities.Instruction trunkInstruction = new Orchestrator.Entities.Instruction();
                trunkInstruction.InstructionTypeId        = (int)eInstructionType.Trunk;
                trunkInstruction.JobId                    = instruction.JobId;
                trunkInstruction.PointID                  = pointId;
                trunkInstruction.PlannedDepartureDateTime = leaveTrunkPoint;
                trunkInstruction.PlannedArrivalDateTime   = arriveAtTrunkPoint;
                trunkInstruction.Trailer                  = instruction.Trailer;

                // Set the booked datetime of the trunk to the trunks planned arrival time. This could produce a situation
                // where the booked times do not flow, however, the trunks booked time is irrelevant so if this happens, it shouldn't matter.
                // Failing to set a booked time for the trunk here would cause an error when attempting to save the instruction.
                trunkInstruction.BookedDateTime = arriveAtTrunkPoint;

                // Note: Always get the driver and the vehicle.
                trunkInstruction.Driver  = instruction.Driver;
                trunkInstruction.Vehicle = instruction.Vehicle;

                // Add the trunk to the job.
                using (Facade.IJob facJob = new Facade.Job())
                {
                    Entities.Job job = facJob.GetJob(instruction.JobId);
                    result = facJob.Trunk(trunkInstruction, instruction, job.IdentityId, user.UserName, job.LastUpdateDate, chkDriver.Checked, chkVehicle.Checked);
                }

                #endregion
            }
            else
            {
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                {
                    facInstruction.UpdatePointID(m_instructionId, pointId, user.UserName);
                    result = new Orchestrator.Entities.FacadeResult(true);
                }
            }

            if (result.Success)
            {
                this.ReturnValue = "refresh";
                this.Close();
            }
            else
            {
                infringementDisplay.Infringements = result.Infringements;
                infringementDisplay.DisplayInfringments();
            }
        }
        void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Entities.FacadeResult success = new Orchestrator.Entities.FacadeResult(false);

                if (rdOrderAction_NotCollected.Checked)
                {
                    #region Get Page details
                    int rReasonId = 0;
                    int.TryParse(cboRedeliveryReason.SelectedValue, out rReasonId);

                    int      nCPointId = 0, nDPointId = 0, dayDifference = 0;
                    bool     nCIsAnytime = false, nDIsAnyTime = false;
                    DateTime nCDateTime = new DateTime(), nCByDateTime = new DateTime(), nDDateTime = new DateTime(), nDFromDateTime = new DateTime(), dateDiff = new DateTime();

                    nCDateTime = dteCollectionFromDate.SelectedDate.Value;
                    nCDateTime = nCDateTime.Add(new TimeSpan(dteCollectionFromTime.SelectedDate.Value.Hour, dteCollectionFromTime.SelectedDate.Value.Minute, 0));

                    nCByDateTime = nCDateTime;

                    if (rdCollectionBookingWindow.Checked)
                    {
                        nCByDateTime = dteCollectionByDate.SelectedDate.Value;
                        nCByDateTime = nCByDateTime.Add(new TimeSpan(dteCollectionByTime.SelectedDate.Value.Hour, dteCollectionByTime.SelectedDate.Value.Minute, 0));
                    }

                    nCIsAnytime = rdCollectionIsAnytime.Checked;

                    if (chkChangeDeliveryDate.Checked)
                    {
                        nDFromDateTime = dteDeliveryFromDate.SelectedDate.Value;
                        nDFromDateTime = nDFromDateTime.Add(new TimeSpan(dteDeliveryFromTime.SelectedDate.Value.Hour, dteDeliveryFromTime.SelectedDate.Value.Minute, 0));

                        nDDateTime = nDFromDateTime;

                        if (rdDeliveryBookingWindow.Checked)
                        {
                            nDDateTime = dteDeliveryByDate.SelectedDate.Value;
                            nDDateTime = nDDateTime.Add(new TimeSpan(dteDeliveryByTime.SelectedDate.Value.Hour, dteDeliveryByTime.SelectedDate.Value.Minute, 0));
                        }

                        nDIsAnyTime = rdDeliveryIsAnytime.Checked;
                    }

                    if (chkCollectGoodsElsewhere.Checked && ucNewCollectionPoint.SelectedPoint != null)
                    {
                        nCPointId = ucNewCollectionPoint.SelectedPoint.PointId;
                    }

                    if (chkDeliverGoodsElsewhere.Checked && ucNewDeliveryPoint.SelectedPoint != null)
                    {
                        nDPointId = ucNewDeliveryPoint.SelectedPoint.PointId;
                    }

                    Entities.Extra extra = null;

                    // If Updates processed sucessfully, log the extra against the highest value order.
                    if (chkCharging.Checked)
                    {
                        // Build an extra to cover the redelivery.
                        extra               = new Entities.Extra();
                        extra.ExtraType     = (eExtraType)int.Parse(cboExtraType.SelectedValue);
                        extra.ForeignAmount = (decimal)txtExtraAmount.Value;

                        extra.ExtraState        = Utilities.SelectedEnumValue <eExtraState>(cboExtraState.SelectedValue);;
                        extra.CustomDescription = txtExtraCustomReason.Text;

                        if (!string.IsNullOrEmpty(txtClientContact.Text))
                        {
                            extra.ClientContact = txtClientContact.Text;
                        }
                    }
                    #endregion

                    Facade.IAttemptedCollection facAC = new Facade.AttemptedCollection();
                    success = facAC.Create(JobId, InstructionId, rdResolutionMethod_AttemptLater.Checked, rReasonId, txtAttemptedCollectionReference.Text, txtAttemptedClientContact.Text, nCDateTime, nCByDateTime, nCIsAnytime, nCPointId, chkChangeDeliveryDate.Checked, nDFromDateTime, nDDateTime, nDIsAnyTime, nDPointId, chkCreateOnwardRun.Checked, extra, Page.User.Identity.Name);
                }

                #region Display Results
                if (success != null && success.Success)
                {
                    if (success.ObjectId > 0)
                    {
                        Facade.IJob  facJob = new Facade.Job();
                        Entities.Job eJob   = facJob.GetJob(JobId);

                        // If the existing run has been cancelled, then re-direct to the new run.
                        if (eJob == null)
                        {
                            JobId         = success.ObjectId;
                            InstructionId = -1;
                        }
                        else
                        {
                            dlgOrder.Open(string.Format("jobId={0}", success.ObjectId));
                        }
                    }

                    btnCancel_Click(null, null);
                }
                else
                {
                    if (success != null)
                    {
                        idErrors.Infringements = success.Infringements;
                    }

                    idErrors.DisplayInfringments();
                    idErrors.Visible = true;
                }
                #endregion
            }
        }