Ejemplo n.º 1
0
        private void CountChargeableLegs()
        {
            ReadOnlyCollection <Entities.LegView> legs = new Facade.Instruction().GetLegPlan(m_job.Instructions, false).Legs();

            m_chargeableLegs = 0;

            Entities.LegView leg           = null;
            bool             legChargeable = false;

            for (int i = 0; i < legs.Count; i++)
            {
                legChargeable = false;
                leg           = legs[i];

                // Does the Leg Have a trailer
                if (leg.Trailer != null || m_job.HasBeenSubContracted || leg.Vehicle.IsFixedUnit)
                {
                    //if there is a delivery on this leg then it is chargeable
                    if ((leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.Drop) ||
                        (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.LeaveGoods) ||
                        ((m_job.JobType == eJobType.PalletReturn) && (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.DeHirePallets))
                        )
                    {
                        legChargeable = true;
                        //J.Steele 05/06/08
                        //Shouldn't break here - this was causing a Divide by zero error
                        //break;
                    }

                    // Is there a delivery on any future leg
                    if (!legChargeable)
                    {
                        for (int x = i + 1; x < legs.Count; x++)
                        {
                            leg = legs[i];

                            if (
                                (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.Drop) ||
                                (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.LeaveGoods) ||
                                ((m_job.JobType == eJobType.PalletReturn) && (leg.EndLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.DeHirePallets))
                                )
                            {
                                legChargeable = true;
                                break;
                            }
                        }
                    }

                    if (legChargeable)
                    {
                        m_chargeableLegs++;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void repLegs_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Entities.LegView leg = (Entities.LegView)e.Item.DataItem;

                RadDatePicker dteSDate = e.Item.FindControl("dteSDate") as RadDatePicker;
                RadTimePicker dteSTime = e.Item.FindControl("dteSTime") as RadTimePicker;

                RadDatePicker dteEDate = e.Item.FindControl("dteEDate") as RadDatePicker;
                RadTimePicker dteETime = e.Item.FindControl("dteETime") as RadTimePicker;

                DateTime startDateTime = leg.StartLegPoint.PlannedDateTime;
                DateTime endDateTime   = leg.EndLegPoint.PlannedDateTime;

                dteSDate.SelectedDate = startDateTime;
                dteSTime.SelectedDate = startDateTime;

                dteEDate.SelectedDate = endDateTime;
                dteETime.SelectedDate = endDateTime;
            }
        }
Ejemplo n.º 3
0
        private void GetChargeableLegs()
        {
            ReadOnlyCollection <Entities.LegView> legs = new Facade.Instruction().GetLegPlan(m_job.Instructions, false).Legs();

            // Get first leg point which is chargeable.
            for (int i = 0; i < legs.Count; i++)
            {
                Entities.LegView leg = legs[i];

                Entities.LegPoint startLegPoint = leg.StartLegPoint;
                Entities.LegPoint endLegPoint   = leg.EndLegPoint;

                // If start leg point of leg has an instruction of type load,
                // current leg is chargeable.
                if (startLegPoint.Instruction != null && startLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.Load)
                {
                    m_chargeableLegStart = i;
                    m_chargeableLegs++;
                }

                // Otherwise, if end leg point of leg has an instruction of type load,
                // next leg is chargeable.
                else if (endLegPoint.Instruction != null && (endLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.Load || (m_job.JobType == eJobType.PalletReturn && endLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.PickupPallets)))
                {
                    m_chargeableLegStart = i + 1;
                    m_chargeableLegs++;
                }

                if (m_chargeableLegStart != 0)
                {
                    break;
                }
            }

            // Get last leg point which is chargeable.
            for (int i = legs.Count - 1; i >= 0; i--)
            {
                Entities.LegView leg = legs[i];

                Entities.LegPoint startLegPoint = leg.StartLegPoint;
                Entities.LegPoint endLegPoint   = leg.EndLegPoint;

                // If end leg point of instruction has a drop, this leg is chargeable.
                if (endLegPoint.Instruction != null && (endLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.Drop || (m_job.JobType == eJobType.PalletReturn && endLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.DeHirePallets)))
                {
                    m_chargeableLegEnd = i;
                    m_chargeableLegs++;
                }

                // Otherwise if start leg point of leg has an instruction type of drop, previous
                // leg is chargeable.
                else if (startLegPoint.Instruction != null && (startLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.Drop || (m_job.JobType == eJobType.PalletReturn && startLegPoint.Instruction.InstructionTypeId == (int)eInstructionType.DeHirePallets)))
                {
                    m_chargeableLegEnd = i - 1;
                }

                if (m_chargeableLegEnd != 0)
                {
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        void gvLegs_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ((TextBox)e.Row.FindControl("txtCost")).Attributes.Add("onblur", "updateCost(this);");
                ((TextBox)e.Row.FindControl("txtCharge")).Attributes.Add("onblur", "updateCharge(this);");
                e.Row.Attributes.Add("__key", ((Entities.LegView)(e.Row.DataItem)).InstructionID.ToString());
            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Entities.LegView  leg   = (Entities.LegView)e.Row.DataItem;
                Entities.LegPoint start = leg.StartLegPoint;
                Entities.LegPoint end   = leg.EndLegPoint;

                Facade.IOrganisation facOrganisation = new Facade.Organisation();
                bool legsHaveCharges = false;

                Facade.IInstruction facInstruc = new Facade.Instruction();
                Entities.LegPlan    legPlan    = facInstruc.GetLegPlan(m_job.Instructions, false);

                foreach (Entities.LegView legVw in legPlan.Legs())
                {
                    if (legVw.EndLegPoint.Instruction.Charge > 0)
                    {
                        legsHaveCharges = true;
                        break;
                    }
                }
                TextBox txtCost   = (TextBox)e.Row.FindControl("txtCost");
                TextBox txtCharge = (TextBox)e.Row.FindControl("txtCharge");

                bool aLegPointHasInstruction = false;
                if (!legsHaveCharges)
                {
                    #region Populate the configured rates


                    if ((m_job.JobType != eJobType.Groupage) && m_job.Charge.JobChargeType == eJobChargeType.FreeOfCharge || m_job.Charge.JobChargeType == eJobChargeType.FreeOfChargeInvoicing)
                    {
                        decimal zero = 0;

                        txtCost.Text   = zero.ToString("C");
                        txtCharge.Text = zero.ToString("C");

                        txtCost.Enabled   = false;
                        txtCharge.Enabled = false;
                    }
                    else
                    {
                        if (m_job.Charge.JobChargeType == eJobChargeType.PerPallet)
                        {
                            // No action
                        }
                    }

                    #endregion

                    // Hide the inner repeater unless it can have actuals/demurrages
                    aLegPointHasInstruction = ((start.Instruction != null) || (end.Instruction != null));

                    // Set leg cost
                    if (m_job.HasBeenSubContracted && m_job.SubContractors[0].Rate > 0)
                    {
                        try
                        {
                            decimal subContractorRate = 0, legCount = 0;
                            subContractorRate = m_job.SubContractors[0].Rate;
                            legCount          = Convert.ToDecimal(new Facade.Instruction().GetLegPlan(m_job.Instructions, false).Legs().Count);

                            txtCost.Text = (subContractorRate / legCount).ToString("C");
                        }
                        catch
                        {
                            txtCost.Text = "0";
                        }
                    }

                    try
                    {
                        if (end.Instruction.InstructionTypeId == (int)eInstructionType.Drop || end.Instruction.InstructionTypeId == (int)eInstructionType.LeaveGoods || (m_job.JobType == eJobType.PalletReturn && end.Instruction.InstructionTypeId == (int)eInstructionType.DeHirePallets) || (m_job.JobType == eJobType.Groupage && end.Instruction.InstructionTypeId == (int)eInstructionType.Trunk))
                        {
                            decimal instructionTotal = 0;
                            //this leg is chargeable

                            if (m_job.Rate != null)
                            {
                                if (end.Point.PointId == m_job.Rate.DeliveryPointId)
                                {
                                    if (end.Instruction.TotalPallets >= Orchestrator.Globals.Configuration.PartLoadThreshold)
                                    {
                                        instructionTotal += m_job.Rate.FullLoadRate;
                                    }
                                    else
                                    {
                                        instructionTotal += m_job.Rate.PartLoadRate;
                                    }
                                }
                                else
                                {
                                    instructionTotal += m_job.Rate.MultiDropRate;
                                }
                            }
                            else
                            {
                                instructionTotal += m_job.Charge.JobChargeAmount / m_chargeableLegs;
                            }

                            txtCharge.Text = instructionTotal.ToString("C");
                        }
                        else
                        {
                            txtCharge.Visible = false;
                            txtCharge.Text    = "0";
                        }
                    }
                    catch
                    {
                        txtCharge.Text = "0";
                    }
                }
                else
                {
                    if (!(end.Instruction.InstructionTypeId == (int)eInstructionType.Drop) && !(end.Instruction.InstructionTypeId == (int)eInstructionType.LeaveGoods) && !(m_job.JobType == eJobType.PalletReturn && end.Instruction.InstructionTypeId == (int)eInstructionType.DeHirePallets))
                    {
                        if (leg.EndLegPoint.Instruction.Charge == 0)
                        {
                            txtCharge.Visible = false;
                        }
                    }
                }

                if (m_job.JobState == eJobState.Invoiced)
                {
                    ((TextBox)e.Row.FindControl("txtCost")).Enabled   = false;
                    ((TextBox)e.Row.FindControl("txtCharge")).Enabled = false;
                }

                if (m_job.JobType == eJobType.Return && aLegPointHasInstruction)
                {
                    decimal lc = m_job.Charge.JobChargeAmount / m_chargeableLegs;
                    ((TextBox)e.Row.FindControl("txtCharge")).Text = lc.ToString("C");
                }

                // Running cost & charge total calculation
                m_runningCostTotal += Decimal.Parse(((TextBox)e.Row.FindControl("txtCost")).Text, System.Globalization.NumberStyles.Currency);
                if (((TextBox)e.Row.FindControl("txtCharge")).Visible)
                {
                    m_runningChargeTotal += Decimal.Parse(((TextBox)e.Row.FindControl("txtCharge")).Text, System.Globalization.NumberStyles.Currency);
                }
            }
            else if (e.Row.RowType == DataControlRowType.Footer)
            {
                ((Label)e.Row.FindControl("lblTotalCost")).Text   = m_runningCostTotal.ToString("C");
                ((Label)e.Row.FindControl("lblTotalCharge")).Text = m_runningChargeTotal.ToString("C");
            }
        }
Ejemplo n.º 5
0
        void grdLegs_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is Telerik.Web.UI.GridDataItem)
            {
                if (!string.IsNullOrEmpty(rdoSubContractMethod.SelectedValue))
                {
                    SubContractingMethod method = (SubContractingMethod)int.Parse(rdoSubContractMethod.SelectedValue);
                    Label lblOrderIDs           = (Label)e.Item.FindControl("lblOrderIDs");

                    // Default the order ids to none (this will cause the rate to be added to the leg).
                    lblOrderIDs.Text = string.Empty;

                    if (method == SubContractingMethod.PerOrder)
                    {
                        Entities.Instruction instruction = null;
                        using (Facade.IInstruction facInstruction = new Facade.Instruction())
                        {
                            instruction = (e.Item.DataItem as Entities.LegView).Instruction;
                        }

                        if (instruction.InstructionTypeId == (int)eInstructionType.Drop && instruction.CollectDrops.Count > 0 && instruction.CollectDrops[0].OrderID > 0)
                        {
                            // This is a delivery instruction with an order - add all the orders to the hidden field.
                            StringBuilder orderIDs = new StringBuilder();
                            foreach (Entities.CollectDrop collectDrop in instruction.CollectDrops)
                            {
                                if (collectDrop.OrderID > 0)
                                {
                                    if (orderIDs.Length > 0)
                                    {
                                        orderIDs.Append(", ");
                                    }
                                    orderIDs.Append(collectDrop.OrderID.ToString());
                                }
                            }

                            lblOrderIDs.Text = orderIDs.ToString();
                        }
                    }

                    ///////////////////////////////////////////////////////////
                    Entities.LegView leg = e.Item.DataItem as Entities.LegView;

                    // InstructionId
                    HiddenField hidInstructionId = e.Item.FindControl("hidInstructionId") as HiddenField;
                    hidInstructionId.Value = leg.InstructionID.ToString();

                    // Collection Point
                    HtmlGenericControl spnCollectionPoint = e.Item.FindControl("spnCollectionPoint") as HtmlGenericControl;
                    spnCollectionPoint.Attributes.Add("class", "orchestratorLink");
                    spnCollectionPoint.InnerText = leg.StartLegPoint.Point.Description;

                    // Destination Point
                    HtmlGenericControl spnDestinationPoint = e.Item.FindControl("spnDestinationPoint") as HtmlGenericControl;
                    spnDestinationPoint.Attributes.Add("class", "orchestratorLink");
                    spnDestinationPoint.InnerText = leg.EndLegPoint.Point.Description;

                    // Driver
                    HtmlGenericControl spnDriver = e.Item.FindControl("spnDriver") as HtmlGenericControl;
                    spnDriver.Attributes.Add("class", "orchestratorLink");

                    if (leg.SubContractorForDisplay != null && leg.Driver == null)
                    {
                        // The driver is a subby. Pass the Organisation IdentityId.
                        spnDriver.InnerText = leg.SubContractorForDisplay.OrganisationDisplayName;
                    }
                    else if (leg.SubContractorForDisplay == null && leg.Driver != null)
                    {
                        // The driver is an inhouse resource. Pass Individual IdentityId.
                        // The driver is a subby. Pass the Organisation IdentityId.
                        spnDriver.InnerText = leg.Driver.Individual.FullName;
                    }

                    // Trailer
                    HtmlGenericControl spnTrailer = e.Item.FindControl("spnTrailer") as HtmlGenericControl;
                    spnTrailer.InnerText = leg.Trailer == null ? "" : leg.Trailer.TrailerRef;
                }
            }
        }
Ejemplo n.º 6
0
 public bool FilterLegs(Entities.LegView leg)
 {
     return(leg.State != Entities.LegView.eLegState.InProgress && leg.State != Entities.LegView.eLegState.Completed);
 }
Ejemplo n.º 7
0
        private void BuildStartComments(eDriverCommunicationType communicationType, StringBuilder sbComments, Entities.LegView leg)
        {
            switch (communicationType)
            {
            case eDriverCommunicationType.Phone:
                sbComments.Append("START TIME: ");
                break;

            case eDriverCommunicationType.Text:
                sbComments.Append("ST: ");
                break;
            }
            sbComments.Append(leg.StartLegPoint.PlannedDateTime.ToString("dd/MM/yy HH:mm"));
            sbComments.Append(". ");

            switch (communicationType)
            {
            case eDriverCommunicationType.Phone:
                sbComments.Append("START PLACE: ");
                break;

            case eDriverCommunicationType.Text:
                sbComments.Append("SP: ");
                break;
            }

            sbComments.Append(string.Format("{0}.", leg.StartLegPoint.Point.PostTown.TownName));
        }