private void BuildInstructionTypeComments(StringBuilder sbComments, eInstructionType instructionType)
        {
            switch (instructionType)
            {
            case eInstructionType.Load:
                sbComments.Append(" (COLLECT) ");
                break;

            case eInstructionType.Drop:
                sbComments.Append(" (DROP) ");
                break;

            case eInstructionType.PickupPallets:
                sbComments.Append(" (PICKUP PALLETS) ");
                break;

            case eInstructionType.DeHirePallets:
                sbComments.Append(" (DEHIRE PALLETS) ");
                break;

            case eInstructionType.LeavePallets:
                sbComments.Append(" (LEAVE PALLETS) ");
                break;
            }
        }
Exemplo n.º 2
0
 public PalletDelivery(Entities.Order palletOrder, eInstructionType palletAction, decimal charge, string destination, string pallettype)
 {
     PalletOrder  = palletOrder;
     PalletAction = palletAction;
     Charge       = charge;
     Destination  = destination;
     PalletType   = pallettype;
 }
        private Entities.Order GeneratePalletOrder(int palletTypeId, int noPallets, eInstructionType selectedPalletAction, ref string destination)
        {
            destination = string.Empty;

            int      identityId           = 0;
            bool     deliveryIsAnytime    = false;
            DateTime deliveryFromDateTime = new DateTime();
            DateTime deliveryDateTime     = new DateTime();

            if (selectedPalletAction == eInstructionType.DeHirePallets)
            {
                identityId = int.Parse(rcbDeHireOrganisation.SelectedValue);
            }
            else
            {
                identityId = Orchestrator.Globals.Configuration.IdentityId;
            }

            deliveryFromDateTime = new DateTime(dteDeliveryFromDate.SelectedDate.Value.Year, dteDeliveryFromDate.SelectedDate.Value.Month, dteDeliveryFromDate.SelectedDate.Value.Day, dteDeliveryFromTime.SelectedDate.Value.Hour, dteDeliveryFromTime.SelectedDate.Value.Minute, 0);
            deliveryDateTime     = new DateTime(dteDeliveryByDate.SelectedDate.Value.Year, dteDeliveryByDate.SelectedDate.Value.Month, dteDeliveryByDate.SelectedDate.Value.Day, dteDeliveryByTime.SelectedDate.Value.Hour, dteDeliveryByTime.SelectedDate.Value.Minute, 0);
            deliveryIsAnytime    = rdDeliveryIsAnytime.Checked;

            Entities.Order palletOrder = new Entities.Order();

            // Setting default values for the Order.
            palletOrder.Cases               = 0;
            palletOrder.Weight              = 0;
            palletOrder.GoodsTypeID         = 1; // This REALLY needs to be Pallets ( hint hint system definition ).
            palletOrder.PalletSpaceID       = (int)ePalletSize.Normal;
            palletOrder.CustomerOrderNumber = "palletHandling";
            palletOrder.DeliveryOrderNumber = "palletHandling";
            palletOrder.OrderStatus         = eOrderStatus.Approved;
            palletOrder.OrderType           = eOrderType.PalletHandling;
            palletOrder.OrderInstructionID  = 3; // Find out what this is?

            palletOrder.CustomerIdentityID = identityId;

            palletOrder.PalletTypeID = palletTypeId;
            palletOrder.NoPallets    = noPallets;
            palletOrder.PalletSpaces = palletOrder.NoPallets;

            palletOrder.PlannedForCollection = palletOrder.PlannedForDelivery = true;
            palletOrder.CollectionPointID    = palletOrder.DeliveryPointID = ucDeliveryPoint.SelectedPoint.PointId;
            destination = ucDeliveryPoint.SelectedPoint.Description;

            palletOrder.ForeignRate = palletOrder.Rate = rntPalletDeliveryCharge.Value.HasValue ? (decimal)rntPalletDeliveryCharge.Value : 0m;

            palletOrder.CollectionDateTime   = palletOrder.DeliveryFromDateTime = deliveryFromDateTime;
            palletOrder.CollectionByDateTime = palletOrder.DeliveryDateTime = deliveryDateTime;
            palletOrder.CollectionIsAnytime  = palletOrder.DeliveryIsAnytime = deliveryIsAnytime;

            palletOrder.FuelSurchargePercentage = 0m;
            palletOrder.FuelSurchargeAmount     = palletOrder.FuelSurchargeForeignAmount = 0m;

            return(palletOrder);
        }
Exemplo n.º 4
0
        private void AddGlyph(GridView grid, GridViewRow item, int col, eInstructionType instructionType)
        {
            Label glyph = new Label();

            glyph.EnableTheming = false;
            glyph.Font.Name     = "webdings";
            glyph.Font.Size     = FontUnit.XSmall;
            glyph.Text          = instructionType == eInstructionType.Load ? "C" : "D";

            item.Cells[col].Controls.Add(glyph);
        }
        void btnGenerateUpdate_Click(object sender, EventArgs e)
        {
            eInstructionType selectedPalletAction = (eInstructionType)int.Parse(rcbPalletHandlingAction.SelectedValue);

            if (selectedPalletAction == eInstructionType.LeavePallets)
            {
                rfvDeHireOrganisation.Enabled = false;
            }

            if (Page.IsValid)
            {
                GetSelectedPallets();
                btnUpdate_Click(null, null);
            }
        }
        private void GetQueryStringVariables()
        {
            m_PointId = int.Parse(Request.QueryString["PointId"]);

            if (Request.QueryString["InstructionId"] != "" && Request.QueryString["InstructionId"] != null)
            {
                m_instructionId   = int.Parse(Request.QueryString["InstructionId"]);
                m_instructionType = (eInstructionType)(int.Parse(Request.QueryString["InstructionTypeId"]));
                m_bookedDateTime  = DateTime.Parse(Request.QueryString["BookedTime"]);
                m_isAnyTime       = (int.Parse(Request.QueryString["IsAnyTime"])) == 1 ? true : false;
                m_hasInstruction  = true;
            }

            m_plannedStartDateTime = DateTime.Parse(Request.QueryString["LegPlannedStart"]);
            m_plannedEndDateTime   = DateTime.Parse(Request.QueryString["LegPlannedEnd"]);

            Facade.IPoint facPoint = new Facade.Point();
            m_point = facPoint.GetPointForPointId(m_PointId);

            string addressString = "<b>" + m_point.Description + "</b> <br/>";

            addressString += m_point.Address.ToString().Replace(Environment.NewLine, "<br/>");

            lblAddress.Text = addressString;

            string instructionType = string.Empty;
            string bookedTimes     = string.Empty;
            string plannedTimes    = string.Empty;

            if (m_hasInstruction)
            {
                instructionType         = "<b>Instruction Type :: " + Utilities.UnCamelCase(m_instructionType.ToString()) + "</b>";
                lblInstructionType.Text = instructionType;
                bookedTimes             = "<b>Booked : </b>" + m_bookedDateTime.ToString("dd/MM HH:mm");
            }
            else
            {
                instructionType         = "<span style=\"color:blue;\">This is a Trunk Leg.</span>";
                lblInstructionType.Text = instructionType;
            }

            plannedTimes           = "<b>Planned Start : </b>" + m_plannedStartDateTime.ToString("dd/MM HH:mm") + "<br/>";
            plannedTimes          += "<b>Planned End : </b>" + m_plannedEndDateTime.ToString("dd/MM HH:mm") + "<br/>";
            lblBookedDateTime.Text = bookedTimes;
            lblPlannedTimes.Text   = plannedTimes;
        }
Exemplo n.º 7
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);
        }
        private void GetSelectedPallets()
        {
            Entities.Instruction palletHandlingInstruction = new Entities.Instruction();

            eInstructionType selectedPalletAction = (eInstructionType)int.Parse(rcbPalletHandlingAction.SelectedValue);

            foreach (ListViewDataItem lvdi in lvEmptyPallets.Items)
            {
                CheckBox chkResourceSelected = lvdi.FindControl("chkResourceSelected") as CheckBox;

                if (chkResourceSelected != null && chkResourceSelected.Checked)
                {
                    HiddenField hdnResource    = lvdi.FindControl("hdnResource") as HiddenField;
                    HiddenField hidResourceID  = lvdi.FindControl("hidResourceID") as HiddenField;
                    HiddenField hidIsFixedUnit = lvdi.FindControl("hidIsFixedUnit") as HiddenField;
                    ListView    lvItems        = lvdi.FindControl("lvItems") as ListView;

                    int resourceID = 0;
                    int.TryParse(hidResourceID.Value, out resourceID);

                    bool isFixedUnit      = false;
                    int  isFixedUnitValue = 0;
                    int.TryParse(hidIsFixedUnit.Value, out isFixedUnitValue);
                    isFixedUnit = isFixedUnitValue > 0;

                    foreach (ListViewDataItem ilvdi in lvItems.Items)
                    {
                        #region Generate Pallet Orders

                        RadNumericTextBox rntNoOfPallets = ilvdi.FindControl("rntNoOfPallets") as RadNumericTextBox;

                        if (rntNoOfPallets != null && rntNoOfPallets.Value.Value > 0)
                        {
                            HiddenField hdnPalletTypeID = ilvdi.FindControl("hdnPalletTypeID") as HiddenField;
                            HiddenField hdnPalletType   = ilvdi.FindControl("hdnPalletType") as HiddenField;
                            HiddenField hdnIdentifier   = ilvdi.FindControl("hdnIdentifier") as HiddenField;

                            string                  destination    = string.Empty;
                            Entities.Order          palletDelivery = null;
                            Entities.PalletDelivery pd             = null;

                            if (hdnIdentifier != null && hdnIdentifier.Value != string.Empty)
                            {
                                #region Update Order
                                pd = SelectedPalletDelivery;

                                if (pd.PalletOrder.OrderID > 0)
                                {
                                    Entities.PalletDelivery updatedDelivery = null;

                                    if (UpdatedPalletDeliveries.Count > 0)
                                    {
                                        updatedDelivery = UpdatedPalletDeliveries.Find(upd => upd.PalletOrder.OrderID == pd.PalletOrder.OrderID);
                                    }

                                    if (updatedDelivery == null)
                                    {
                                        updatedDelivery = new Entities.PalletDelivery();
                                    }
                                    else
                                    {
                                        UpdatedPalletDeliveries.Remove(updatedDelivery);
                                    }

                                    if (updatedDelivery.PalletOrder == null || updatedDelivery.PalletOrder.OrderID < 1)
                                    {
                                        updatedDelivery.PalletOrder         = GeneratePalletOrder(int.Parse(hdnPalletTypeID.Value), (int)rntNoOfPallets.Value.Value, selectedPalletAction, ref destination);
                                        updatedDelivery.PalletOrder.OrderID = pd.PalletOrder.OrderID;
                                    }
                                    else
                                    {
                                        updatedDelivery.PalletOrder.NoPallets = (int)rntNoOfPallets.Value.Value;
                                    }

                                    updatedDelivery.PalletAction            = selectedPalletAction;
                                    updatedDelivery.PalletActionDescription = Utilities.UnCamelCase(selectedPalletAction.ToString());
                                    updatedDelivery.ResourceID  = resourceID;
                                    updatedDelivery.IsFixedUnit = isFixedUnit;

                                    updatedDelivery.PalletType  = hdnPalletType.Value;
                                    updatedDelivery.Resource    = hdnResource.Value;
                                    updatedDelivery.Destination = destination;

                                    updatedDelivery.UpdatedNoPallets = updatedDelivery.PalletOrder.NoPallets;
                                    //pd.UpdatedNoPallets = updatedDelivery.PalletOrder.NoPallets;
                                    updatedDelivery.IsDirty = true;

                                    UpdatedPalletDeliveries.Add(updatedDelivery);
                                }

                                //pd.PalletOrder.NoPallets = (int)rntNoOfPallets.Value.Value;
                                pd.UpdatedNoPallets = (int)rntNoOfPallets.Value.Value;
                                pd.IsDirty          = true;

                                #endregion
                            }
                            else
                            {
                                #region Generate Order

                                palletDelivery = GeneratePalletOrder(int.Parse(hdnPalletTypeID.Value), (int)rntNoOfPallets.Value.Value, selectedPalletAction, ref destination);

                                pd = new Entities.PalletDelivery();

                                pd.PalletOrder = palletDelivery;

                                pd.PalletAction            = selectedPalletAction;
                                pd.PalletActionDescription = Utilities.UnCamelCase(selectedPalletAction.ToString());
                                pd.ResourceID  = resourceID;
                                pd.IsFixedUnit = isFixedUnit;

                                pd.PalletType  = hdnPalletType.Value;
                                pd.Resource    = hdnResource.Value;
                                pd.Destination = destination;

                                #endregion
                            }

                            PalletDeliveries.Add(pd);
                        }

                        #endregion
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void PopulateEntities()
        {
            Entities.Job job = new Orchestrator.Entities.Job();
            job.Instructions           = new Orchestrator.Entities.InstructionCollection();
            job.JobType                = eJobType.Groupage;
            job.BusinessTypeID         = int.Parse(cboBusinessType.SelectedValue);
            job.IdentityId             = Globals.Configuration.IdentityId;
            job.LoadNumber             = "GRP" + Environment.TickCount.ToString().Substring(0, 3);
            job.Charge                 = new Orchestrator.Entities.JobCharge();
            job.Charge.JobChargeAmount = 0;
            job.Charge.JobChargeType   = eJobChargeType.FreeOfCharge;

            Entities.InstructionCollection collections = new Orchestrator.Entities.InstructionCollection();
            Entities.Instruction           iCollect    = null;
            Entities.CollectDrop           cd          = null;

            Entities.InstructionCollection drops = new Orchestrator.Entities.InstructionCollection();
            Entities.Instruction           iDrop = null;

            Facade.IPoint  facPoint = new Facade.Point();
            Facade.IOrder  facOrder = new Facade.Order();
            Entities.Point point    = null;

            int  collectSequence = 1;
            bool newcollection   = false;

            foreach (DataRow row in OrderData.Tables[0].Rows)
            {
                #region Collections
                newcollection = false;
                int      pointID             = (int)row["CollectionRunDeliveryPointID"];
                DateTime bookedDateTime      = (DateTime)row["CollectionRunDeliveryDateTime"];
                bool     collectionIsAnyTime = (bool)row["CollectionRunDeliveryIsAnyTime"];

                // if this setting is true then we want to create a new instruction for the order.
                if (Globals.Configuration.OneDropAndLoadInstructionPerOrder)
                {
                    iCollect = null;
                }
                else
                {
                    iCollect = collections.GetForInstructionTypeAndPointID(eInstructionType.Load, pointID, bookedDateTime, collectionIsAnyTime);
                }

                if (iCollect == null)
                {
                    iCollect = new Orchestrator.Entities.Instruction();
                    iCollect.InstructionTypeId = (int)eInstructionType.Load;
                    iCollect.BookedDateTime    = bookedDateTime;
                    if (collectionIsAnyTime)
                    {
                        iCollect.IsAnyTime = true;
                    }
                    point            = facPoint.GetPointForPointId(pointID);
                    iCollect.PointID = pointID;
                    iCollect.Point   = point;
                    iCollect.ClientsCustomerIdentityID = point.IdentityId; //Steve is this correct
                    iCollect.CollectDrops     = new Orchestrator.Entities.CollectDropCollection();
                    iCollect.InstructionOrder = collectSequence;
                    newcollection             = true;
                    collectSequence++;
                }

                cd             = new Orchestrator.Entities.CollectDrop();
                cd.NoPallets   = (int)row["NoPallets"];
                cd.NoCases     = (int)row["Cases"];
                cd.GoodsTypeId = (int)row["GoodsTypeID"];
                cd.OrderID     = (int)row["OrderID"];
                cd.Weight      = (decimal)row["Weight"];
                cd.ClientsCustomerReference = row["DeliveryOrderNumber"].ToString();
                cd.Docket = row["OrderID"].ToString();

                iCollect.CollectDrops.Add(cd);
                if (newcollection)
                {
                    collections.Add(iCollect);
                }

                #endregion

                #region Deliveries
                eOrderAction orderAction  = (eOrderAction)(int)row[C_OrderActionID];
                int          dropSequence = 1;
                bool         newdelivery  = false;
                newdelivery = false;
                int      deliveryPointID   = (int)row[C_DeliverToPointID];
                DateTime deliveryDateTime  = (DateTime)row[C_DeliverAtDateTime];
                bool     deliveryIsAnyTime = (bool)row[C_DeliverAtAnyTime];
                // If the user has selected Default (i.e. Deliver) a drop instruction will be created, otherwise a trunk instruction will be
                // created.
                eInstructionType instructionType = orderAction == eOrderAction.Default ? eInstructionType.Drop : eInstructionType.Trunk;

                // if this setting is true then we want to create a new instruction for the order.
                if (Globals.Configuration.OneDropAndLoadInstructionPerOrder)
                {
                    iDrop = null;
                }
                else
                {
                    iDrop = drops.GetForInstructionTypeAndPointID(instructionType, deliveryPointID, deliveryDateTime, deliveryIsAnyTime);
                }

                if (iDrop == null)
                {
                    iDrop = new Orchestrator.Entities.Instruction();
                    iDrop.InstructionTypeId = (int)instructionType;
                    iDrop.BookedDateTime    = deliveryDateTime;
                    if ((bool)row[C_DeliverAtAnyTime])
                    {
                        iDrop.IsAnyTime = true;
                    }
                    point = facPoint.GetPointForPointId(deliveryPointID);
                    iDrop.ClientsCustomerIdentityID = point.IdentityId;
                    iDrop.PointID = deliveryPointID;
                    iDrop.Point   = point;

                    iDrop.CollectDrops     = new Orchestrator.Entities.CollectDropCollection();
                    iDrop.InstructionOrder = dropSequence;
                    newdelivery            = true;
                    dropSequence++;
                }

                cd             = new Orchestrator.Entities.CollectDrop();
                cd.NoPallets   = (int)row["NoPallets"];
                cd.NoCases     = (int)row["Cases"];
                cd.GoodsTypeId = (int)row["GoodsTypeID"];
                cd.OrderID     = (int)row["OrderID"];
                cd.Weight      = (decimal)row["Weight"];
                cd.ClientsCustomerReference = row["DeliveryOrderNumber"].ToString();
                cd.Docket      = row["OrderID"].ToString();
                cd.OrderAction = orderAction;

                iDrop.CollectDrops.Add(cd);
                if (newdelivery)
                {
                    drops.Insert(0, iDrop);
                }
                //drops.Add(iDrop); Stephen Newman 23/04/07 Changed to insert the drop to the front of the list as the sort processed later seems to swap objects if equal.

                facOrder.UpdateForCollectionRun(cd.OrderID, iDrop.PointID, iDrop.BookedDateTime, iDrop.IsAnyTime, cd.OrderAction, Page.User.Identity.Name);
                #endregion
            }

            #region Add the Instructions to the job
            foreach (Entities.Instruction instruction in collections)
            {
                job.Instructions.Add(instruction);
            }

            drops.Sort(eInstructionSortType.DropDateTime);
            foreach (Entities.Instruction instruction in drops)
            {
                job.Instructions.Add(instruction);
            }
            #endregion

            job.JobState = eJobState.Booked;

            Facade.IJob facjob = new Facade.Job();
            _jobID   = facjob.Create(job, Page.User.Identity.Name);
            _openJob = true;
        }