Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        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 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);
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
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.º 6
0
        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 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();
        }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
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;
            }
        }
Ejemplo n.º 10
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.º 11
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int pointId       = Convert.ToInt32(Request.QueryString["pointId"]);
            int instructionId = Convert.ToInt32(Request.QueryString["iID"]);

            Entities.Instruction instruction = null;
            Entities.Point       point       = null;

            if (instructionId > 0)
            {
                string cacheName = "_pointAddressWithNotes" + instructionId.ToString();

                if (Cache[cacheName] == null)
                {
                    Facade.IInstruction facInstruction = new Facade.Instruction();
                    instruction = facInstruction.GetInstruction(instructionId);

                    if (instruction != null)
                    {
                        Cache.Add(cacheName, instruction, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null);
                    }
                }
                else
                {
                    instruction = (Entities.Instruction)Cache[cacheName];
                }

                if (instruction != null)
                {
                    point = instruction.Point;
                }
            }

            if (pointId > 0)
            {
                string cacheName = "_pointAddress" + pointId.ToString();
                if (Cache[cacheName] == null)
                {
                    Facade.IPoint facPoint = new Facade.Point();
                    point = facPoint.GetPointForPointId(pointId);
                    if (point != null)
                    {
                        Cache.Add(cacheName, point, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null);
                    }
                }
                else
                {
                    point = (Entities.Point)Cache["_pointAddress" + pointId.ToString()];
                }
            }

            if (point != null)
            {
                // A leg has been selected for viewing so display it.
                XslCompiledTransform transformer = new XslCompiledTransform();
                transformer.Load(Server.MapPath(@"..\xsl\instructions.xsl"));

                XmlUrlResolver resolver  = new XmlUrlResolver();
                XPathNavigator navigator = point.ToXml().CreateNavigator();

                // Populate the Point.
                StringWriter sw = new StringWriter();
                transformer.Transform(navigator, null, sw);
                Response.Write(sw.GetStringBuilder().ToString());

                // If instruction notes are present, attach them to the response.
                if (instruction != null && instruction.Note.Length > 0)
                {
                    Response.Write("<br>" + instruction.Note);
                }

                Response.Write(string.Format("<br>tel: {0}", point.PhoneNumber));

                if (point.PointNotes != string.Empty)
                {
                    Response.Write("<br>" + point.PointNotes.Replace("\r\n", "</br>"));
                }

                if (Response.IsClientConnected)
                {
                    Response.Flush();
                    Response.End();
                }

                return;
            }
        }
Ejemplo n.º 12
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.º 13
0
        private void PopulateForm()
        {
            if (Request.QueryString["Driver"] != "")
            {
                m_driver       = Request.QueryString["Driver"];
                chkDriver.Text = m_driver;
            }
            else
            {
                chkDriver.Enabled = false;
            }

            if (Request.QueryString["RegNo"] != "")
            {
                m_vehicle       = Request.QueryString["RegNo"];
                chkVehicle.Text = m_vehicle;
            }
            else
            {
                chkVehicle.Enabled = false;
            }

            if (!string.IsNullOrEmpty(Request.QueryString["IsUpdate"]))
            {
                IsUpdate = bool.Parse(Request.QueryString["IsUpdate"]);
            }

            Entities.Instruction previousInstruction = null;
            using (Facade.IInstruction facInstruction = new Facade.Instruction())
            {
                Entities.Instruction instruction = facInstruction.GetInstruction(m_instructionId);
                Entities.Job         job         = null;

                // Try and get the job from the cache
                job = (Entities.Job)Cache.Get("JobEntityForJobId" + instruction.JobId.ToString());

                DateTime trunkStart = DateTime.Now;
                DateTime trunkEnd   = DateTime.Now;

                if (IsUpdate)
                {
                    lblTrunk.Text = "Update Trunk Leg";
                    btnTrunk.Text = "Update";

                    #region Update Trunk

                    this.ucPoint.SelectedPoint = instruction.Point;

                    rdiStartDate.SelectedDate = instruction.PlannedArrivalDateTime;
                    rdiStartTime.SelectedDate = instruction.PlannedArrivalDateTime;

                    rdiEndDate.SelectedDate   = instruction.PlannedDepartureDateTime;
                    rdiStartTime.SelectedDate = instruction.PlannedDepartureDateTime;

                    trResources.Visible  = false;
                    rdiStartDate.Enabled = rdiStartTime.Enabled = false;
                    rdiEndDate.Enabled   = rdiEndTime.Enabled = false;
                    #endregion
                }
                else
                {
                    #region New Trunk
                    if (job == null)
                    {
                        // Job was not in the cache thus get the instruction collection from the db
                        Entities.InstructionCollection instructions = new Facade.Instruction().GetForJobId(instruction.JobId, true);

                        // Get the previous instruction
                        previousInstruction = instructions.GetPreviousInstruction(instruction.InstructionID);
                    }
                    else
                    {
                        // Job is in the cache, check for instructions

                        if (job.Instructions != null)
                        {
                            // We have instructions

                            // use the instruction collection from the cached job
                            previousInstruction = job.Instructions.GetPreviousInstruction(instruction.InstructionID);
                        }
                        else
                        {
                            // otherwise get a fresh instruction collection
                            Entities.InstructionCollection instructions = new Facade.Instruction().GetForJobId(instruction.JobId, true);

                            // Get the previous instruction
                            previousInstruction = instructions.GetPreviousInstruction(instruction.InstructionID);
                        }
                    }

                    if (previousInstruction == null)
                    {
                        previousInstruction = instruction;
                    }

                    previousInstruction.PlannedDepartureDateTime = previousInstruction.PlannedDepartureDateTime.Subtract(new TimeSpan(0, 0, 0, previousInstruction.PlannedDepartureDateTime.Second, previousInstruction.PlannedDepartureDateTime.Millisecond));
                    instruction.PlannedArrivalDateTime           = instruction.PlannedArrivalDateTime.Subtract(new TimeSpan(0, 0, 0, instruction.PlannedArrivalDateTime.Second, instruction.PlannedDepartureDateTime.Millisecond));

                    if (previousInstruction == instruction)
                    {
                        trunkStart = instruction.PlannedArrivalDateTime.AddHours(2);
                        trunkEnd   = instruction.PlannedDepartureDateTime.Subtract(new TimeSpan(0, 2, 0, 0, 0));
                    }
                    else
                    {
                        trunkStart = previousInstruction.PlannedDepartureDateTime.AddHours(2);
                        trunkEnd   = instruction.PlannedArrivalDateTime.Subtract(new TimeSpan(0, 2, 0, 0, 0));
                    }

                    trunkStart = trunkStart.AddSeconds(-trunkStart.Second);
                    trunkEnd   = trunkEnd.AddSeconds(-trunkEnd.Second);

                    if (trunkStart >= trunkEnd)
                    {
                        if (previousInstruction == instruction)
                        {
                            trunkStart = instruction.PlannedArrivalDateTime.AddMinutes(15);
                            trunkEnd   = instruction.PlannedDepartureDateTime.AddMinutes(-15);
                        }
                        else
                        {
                            trunkStart = previousInstruction.PlannedDepartureDateTime.AddMinutes(15);
                            trunkEnd   = instruction.PlannedArrivalDateTime.AddMinutes(-15);
                        }

                        if (trunkStart >= trunkEnd)
                        {
                            if (previousInstruction == instruction)
                            {
                                trunkStart = instruction.PlannedArrivalDateTime.AddMinutes(1);
                                trunkEnd   = instruction.PlannedDepartureDateTime.AddMinutes(-1);
                            }
                            else
                            {
                                trunkStart = previousInstruction.PlannedDepartureDateTime.AddMinutes(1);
                                trunkEnd   = instruction.PlannedArrivalDateTime.AddMinutes(-1);
                            }
                        }
                    }

                    if (trunkStart == trunkEnd)
                    {
                        if (previousInstruction == instruction)
                        {
                            trunkStart = instruction.PlannedArrivalDateTime.AddMinutes(60);
                            trunkEnd   = instruction.PlannedDepartureDateTime.AddMinutes(-60);
                        }
                        else
                        {
                            trunkStart = previousInstruction.PlannedDepartureDateTime.AddMinutes(60);
                            trunkEnd   = instruction.PlannedArrivalDateTime.AddMinutes(-60);
                        }
                    }
                    #endregion
                }

                rdiStartDate.SelectedDate = trunkStart;
                rdiStartTime.SelectedDate = trunkStart;
                rdiEndDate.SelectedDate   = trunkEnd;
                rdiEndTime.SelectedDate   = trunkEnd;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Populates the details about the refused/returned goods.
        /// </summary>
        /// <returns>The populated object.</returns>
        private Entities.GoodsRefusal PopulateGoodsRefusal()
        {
            Entities.GoodsRefusal goodsRefusal = new Entities.GoodsRefusal();

            goodsRefusal.Docket          = cboOrder.SelectedValue;
            goodsRefusal.OriginalOrderId = int.Parse(cboOrder.SelectedValue);

            // Populate the goods refusal object.
            goodsRefusal.RefusalId            = Convert.ToInt32(hidRefusalId.Value);
            goodsRefusal.RefusalReceiptNumber = txtReceiptNumber.Text;

            // Set the return point.
            //if (cboGoodsReturnPoint.Text != String.Empty)
            //{
            // Configure the return point.
            int returnPoint = 0;

            //	if (cboGoodsReturnPoint.Value == String.Empty)
            //	{
            // A new return point has been specified.
            //returnPoint = CreateNewPoint(Convert.ToInt32(cboGoodsReturnOrganisation.Value), cboGoodsReturnOrganisation.Text, Convert.ToInt32(cboGoodsReturnTown.Value), cboGoodsReturnPoint.Text, txtGoodsReturnAddressLine1.Text, txtGoodsReturnAddressLine2.Text, txtGoodsReturnAddressLine3.Text, txtGoodsReturnPostTown.Text, txtGoodsReturnCounty.Text, txtGoodsReturnPostCode.Text, Convert.ToDecimal(txtGoodsReturnLongitude.Text), Convert.ToDecimal(txtGoodsReturnLatitude.Text), Convert.ToInt32(hidGoodsReturnTrafficArea.Value), ((Entities.CustomPrincipal) Page.User).UserName);
            //	}
            //	else

            returnPoint = ucReturnedToPoint.PointID;

            if (returnPoint > 0)
            {
                Facade.IPoint facPoint = new Facade.Point();
                goodsRefusal.ReturnPoint = facPoint.GetPointForPointId(returnPoint);
            }
            //}

            eGoodsRefusedType refusedType = (eGoodsRefusedType)Enum.Parse(typeof(eGoodsRefusedType), cboGoodsReasonRefused.SelectedValue.Replace(" ", ""));

            // Set the store point.
            int storePoint = 0;

            //if (cboGoodsStorePoint.Value == String.Empty)
            //{
            //if (cboGoodsStorePoint.Text != String.Empty)
            //{
            // A new store point has been specified.
            //storePoint = CreateNewPoint(Convert.ToInt32(cboGoodsStoreOrganisation.Value), cboGoodsStoreOrganisation.Text, Convert.ToInt32(cboGoodsStoreTown.Value), cboGoodsStorePoint.Text, txtGoodsStoreAddressLine1.Text, txtGoodsStoreAddressLine2.Text, txtGoodsStoreAddressLine3.Text, txtGoodsStorePostTown.Text, txtGoodsStoreCounty.Text, txtGoodsStorePostCode.Text, Convert.ToDecimal(txtGoodsStoreLongitude.Text), Convert.ToDecimal(txtGoodsStoreLatitude.Text), Convert.ToInt32(hidGoodsStoreTrafficArea.Value), ((Entities.CustomPrincipal) Page.User).UserName);
            //}
            //}
            //else

            storePoint = ucStoredAtPoint.PointID;

            if (storePoint > 0)
            {
                Facade.IPoint facPoint = new Facade.Point();
                goodsRefusal.StorePoint = facPoint.GetPointForPointId(storePoint);
            }

            goodsRefusal.RefusalLocation = (eGoodsRefusedLocation)Enum.Parse(typeof(eGoodsRefusedLocation), cboLocation.SelectedValue.Replace(" ", ""));
            goodsRefusal.ProductCode     = txtProductCode.Text;
            goodsRefusal.PackSize        = txtPackSize.Text;
            goodsRefusal.ProductName     = txtProductName.Text;
            goodsRefusal.QuantityOrdered = (txtQuantityOrdered.Text == String.Empty) ? 0 : Convert.ToInt32(txtQuantityOrdered.Text);
            goodsRefusal.QuantityRefused = (txtQuantityReturned.Text == String.Empty) ? 0 : Convert.ToInt32(txtQuantityReturned.Text);
            goodsRefusal.RefusalNotes    = txtGoodsNotes.Text;
            goodsRefusal.TimeFrame       = rdiReturnDate.SelectedDate.HasValue ? rdiReturnDate.SelectedDate.Value : DateTime.Now.AddDays(Orchestrator.Globals.Configuration.RefusalNoOfDaysToReturnGoods);
            goodsRefusal.InstructionId   = Convert.ToInt32(hidInstructionId.Value);

            goodsRefusal.NoPallets      = Convert.ToInt32(rntNoPallets.Value.Value);
            goodsRefusal.NoPalletSpaces = Convert.ToDecimal(rntNoPalletSpaces.Value.Value);

            goodsRefusal.RefusalType   = Convert.ToInt32(cboGoodsReasonRefused.SelectedItem.Value);
            goodsRefusal.RefusalStatus = (eGoodsRefusedStatus)Enum.Parse(typeof(eGoodsRefusedStatus), cboGoodsStatus.SelectedValue.Replace(" ", ""));

            Facade.IInstruction  facInstruction = new Facade.Instruction();
            Entities.Instruction instruction    = facInstruction.GetInstruction(m_instructionId);

            int deviationReasonId;

            int.TryParse(this.cboDeviationReason.SelectedValue, out deviationReasonId);

            if (deviationReasonId == 0)
            {
                goodsRefusal.DeviationReasonId = -1;
            }
            else
            {
                goodsRefusal.DeviationReasonId = deviationReasonId;
            }

            goodsRefusal.RefusedFromPointId = instruction.PointID;

            return(goodsRefusal);
        }
Ejemplo n.º 15
0
 private Entities.Instruction GetInstruction(int instructionID)
 {
     Facade.Instruction facInstruction = new Facade.Instruction();
     return(facInstruction.GetInstruction(instructionID));
 }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int instructionId = Convert.ToInt32(Request.QueryString["iID"]);

            if (!Page.IsPostBack)
            {
                using (Facade.Instruction facInstruction = new Facade.Instruction())
                {
                    Entities.Instruction affectedInstruction = null;
                    Entities.Job         job = null;
                    int jobId = 0;
                    Entities.InstructionCollection instructions = null;

                    if (int.TryParse(Request.QueryString["jobId"], out jobId))
                    {
                        if (instructionId != 0)
                        {
                            affectedInstruction = facInstruction.GetInstruction(instructionId);

                            // Get the job.
                            job = (Entities.Job)Cache.Get("JobEntityForJobId" + jobId.ToString());

                            // Try and get the job from the cache
                            if (job == null)
                            {
                                Facade.IJob facJob = new Facade.Job();
                                job = facJob.GetJob(jobId);
                            }
                        }
                        else
                        {
                            // We have no instruction id - this means that ascx is being used for adding
                            // multiple destinations. We should use the last instruction on the job.

                            // Get the job.
                            job = (Entities.Job)Cache.Get("JobEntityForJobId" + jobId.ToString());

                            // Try and get the job from the cache
                            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 end instruction
                                Entities.Instruction endInstruction = null;
                                endInstruction = instructions.Find(instruc => instruc.InstructionOrder == instructions.Count - 1);

                                if (endInstruction == null)
                                {
                                    throw new ApplicationException("Cannot find last instruction.");
                                }

                                affectedInstruction = endInstruction;
                            }
                            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
                                Entities.Instruction endInstruction = null;
                                endInstruction = instructions.Find(instruc => instruc.InstructionOrder == instructions.Count - 1);

                                if (endInstruction == null)
                                {
                                    throw new ApplicationException("Cannot find last instruction.");
                                }

                                affectedInstruction = endInstruction;
                            }
                        }
                    }

                    if (job.JobState != eJobState.Invoiced && job.JobState != eJobState.Cancelled)
                    {
                        if (affectedInstruction.Driver != null)
                        {
                            chkDriver.Text = affectedInstruction.Driver.Individual.FullName;
                        }
                        else
                        {
                            chkDriver.Enabled = false;
                        }

                        if (affectedInstruction.Vehicle != null)
                        {
                            chkVehicle.Text = affectedInstruction.Vehicle.RegNo;
                        }
                        else
                        {
                            chkVehicle.Enabled = false;
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
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();
            }
        }