Exemple #1
0
        private Entities.FacadeResult SubContractSpecificLegs(Entities.JobSubContractor jobSubContractor, DateTime lastUpdateDateTime, string userID)
        {
            Facade.IJobSubContractor facJobSubContractor = new Facade.Job();

            if (!m_isUpdate)
            {
                List <int> instructionIDs = new List <int>();
                foreach (GridItem gdi in grdLegs.SelectedItems)
                {
                    int instructionID = int.Parse(gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["InstructionID"].ToString());
                    instructionIDs.Add(instructionID);
                }

                if (chkUseSubContractorTrailer.Checked)
                {
                    return(facJobSubContractor.Create(m_jobId, instructionIDs, new List <int>(), jobSubContractor, lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
                else
                {
                    return(facJobSubContractor.Create(m_jobId, instructionIDs, new List <int>(), jobSubContractor, int.Parse(cboTrailer.SelectedValue), lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
            }
            else
            {
                return(GenerateValidationError("UnableToUpdate", "Unable to update sub-contracted information in this way"));
            }
        }
Exemple #2
0
        private Entities.FacadeResult SubContractWholeJob(Entities.JobSubContractor jobSubContractor, DateTime lastUpdateDateTime, string userID)
        {
            Facade.IJobSubContractor facJobSubContractor = new Facade.Job();

            if (m_isUpdate)
            {
                return(facJobSubContractor.Update(m_jobId, jobSubContractor, lastUpdateDateTime, userID));
            }
            else
            {
                if (chkUseSubContractorTrailer.Checked)
                {
                    return(facJobSubContractor.Create(m_jobId, new List <int>(), new List <int>(), jobSubContractor, lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
                else
                {
                    return(facJobSubContractor.Create(m_jobId, new List <int>(), new List <int>(), jobSubContractor, int.Parse(cboTrailer.SelectedValue), lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
            }
        }
Exemple #3
0
        private Entities.FacadeResult SubContractPerOrder(Entities.JobSubContractor jobSubContractor, DateTime lastUpdateDateTime, string userID)
        {
            Facade.IJobSubContractor facJobSubContractor = new Facade.Job();

            if (!m_isUpdate)
            {
                List <int> instructionIDs = new List <int>();
                List <int> orderIDs       = new List <int>();
                foreach (GridItem gdi in grdLegs.SelectedItems)
                {
                    Label lblOrderIDs = (Label)gdi.FindControl("lblOrderIDs");
                    if (lblOrderIDs.Text == string.Empty)
                    {
                        int instructionID = int.Parse(gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["InstructionID"].ToString());
                        instructionIDs.Add(instructionID);
                    }
                    else
                    {
                        string[] split       = new string[] { ", " };
                        string[] arrOrderIDs = lblOrderIDs.Text.Split(split, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string orderID in arrOrderIDs)
                        {
                            orderIDs.Add(int.Parse(orderID));
                        }
                    }
                }

                if (chkUseSubContractorTrailer.Checked)
                {
                    return(facJobSubContractor.Create(m_jobId, instructionIDs, orderIDs, jobSubContractor, lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
                else
                {
                    return(facJobSubContractor.Create(m_jobId, instructionIDs, orderIDs, jobSubContractor, int.Parse(cboTrailer.SelectedValue), lastUpdateDateTime, userID, chkForceRemoveResources.Checked));
                }
            }
            else
            {
                return(GenerateValidationError("UnableToUpdate", "Unable to update sub-contracted information in this way"));
            }
        }
Exemple #4
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Facade.IJobRate  facJobRate = new Facade.Job();
                Entities.JobRate jobRate    = new Entities.JobRate();
                SetEntityProperties(jobRate);

                int rateId = facJobRate.Create(jobRate, ((Entities.CustomPrincipal)Page.User).UserName);
                if (rateId > 0)
                {
                    lblConfirmation.Text    = "The rate was added successfully";
                    lblConfirmation.Visible = true;
                }
            }
        }
Exemple #5
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                m_job = (Entities.Job)Session[wizard.C_JOB];

                // Populate the job rate.
                Entities.JobRate jobRate = new Entities.JobRate();
                jobRate.IdentityId        = m_job.IdentityId;
                jobRate.CollectionPointId = m_collectionPointId;
                jobRate.DeliveryPointId   = m_deliveryPointId;
                jobRate.FullLoadRate      = Decimal.Parse(txtFullLoadRate.Text);
                jobRate.PartLoadRate      = Decimal.Parse(txtPartLoadRate.Text);
                jobRate.MultiDropRate     = Decimal.Parse(txtMultiDropRate.Text);

                jobRate.StartDate = DateTime.UtcNow;
                if (!dteEndDate.SelectedDate.HasValue)
                {
                    // Not great.
                    jobRate.EndDate = new DateTime(1753, 1, 1, 0, 0, 0);
                }
                else
                {
                    jobRate.EndDate = dteEndDate.SelectedDate.Value;
                }

                // Create the new rate.
                Facade.IJobRate facJobRate = new Facade.Job();
                int             jobRateId  = facJobRate.Create(jobRate, ((Entities.CustomPrincipal)Page.User).UserName);

                if (jobRateId > 0)
                {
                    if (m_job.JobId > 0)
                    {
                        GoToStep("PC");
                    }
                    else
                    {
                        GoToStep("JD");
                    }
                }
            }
        }
        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;

            bool newcollection = false;

            foreach (DataRow row in OrderData.Tables[0].Rows)
            {
                #region Collections
                newcollection = false;
                int      pointID             = (int)row["CollectFromPointID"];
                DateTime bookedDateTime      = (DateTime)row["CollectAtDateTime"];
                bool     collectionIsAnytime = (bool)row["CollectAtAnyTime"];

                // 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 ((bool)row["CollectAtAnytime"])
                    {
                        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();
                    newcollection         = true;
                }

                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
            }

            // Add the Drops in the Order specified
            DataView dvDrops = OrderData.Tables[0].DefaultView;
            dvDrops.Sort = "DeliveryOrder ASC";
            DataTable dtDrops = dvDrops.ToTable();
            foreach (DataRow row in dtDrops.Rows)
            {
                #region Deliveries
                bool newdelivery = false;
                newdelivery = false;
                int      deliveryPointID   = (int)row["DeliveryPointID"];
                DateTime deliveryDateTime  = (DateTime)row["DeliveryDateTime"];
                bool     deliveryIsAnyTime = (bool)row["DeliveryIsAnyTime"];

                // 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(eInstructionType.Drop, deliveryPointID, deliveryDateTime, deliveryIsAnyTime);
                }

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

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

                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();

                iDrop.CollectDrops.Add(cd);
                if (newdelivery)
                {
                    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.UpdateForDeliveryRun(cd.OrderID, iCollect.PointID, iCollect.BookedDateTime, iCollect.IsAnyTime, Page.User.Identity.Name);

                #endregion
            }



            #region Add the Instructions to the job

            if (job.Instructions == null)
            {
                job.Instructions = new Entities.InstructionCollection();
            }

            foreach (Entities.Instruction instruction in collections)
            {
                job.Instructions.Add(instruction);
            }

            // removed by t.lunken 23/08/07 as this is now manually done.
            //drops.Sort(eInstructionSortType.DropDateTime);
            foreach (Entities.Instruction instruction in drops)
            {
                job.Instructions.Add(instruction);
            }
            #endregion

            Facade.IJob facjob = new Facade.Job();
            job.JobState = eJobState.Booked;
            int jobID = facjob.Create(job, Page.User.Identity.Name);
            _jobID   = jobID;
            _openJob = true;
        }
        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;
        }