Example #1
0
        private void PopulateControls()
        {
            Facade.IJobRate  facJobRate = new Facade.Job();
            Entities.JobRate jobRate    = facJobRate.GetRateForRateId(m_rateId);

            if (jobRate != null)
            {
                // Delivery point
                Facade.IPoint  facPoint = new Facade.Point();
                Entities.Point point    = facPoint.GetPointForPointId(jobRate.DeliveryPointId);
                cboDeliveryPoint.Text          = point.Description;
                cboDeliveryPoint.SelectedValue = jobRate.DeliveryPointId.ToString();
                cboDelivery.Text          = point.OrganisationName;
                cboDelivery.SelectedValue = point.IdentityId.ToString();

                // Collection point
                point = facPoint.GetPointForPointId(jobRate.CollectionPointId);
                cboCollectionPoint.Text          = point.Description;
                cboCollectionPoint.SelectedValue = jobRate.CollectionPointId.ToString();
                cboCollection.Text          = point.OrganisationName;
                cboCollection.SelectedValue = point.IdentityId.ToString();

                txtFullLoadRate.Text      = jobRate.FullLoadRate.ToString("C");
                txtMultiDropRate.Text     = jobRate.MultiDropRate.ToString("C");
                dteStartDate.SelectedDate = jobRate.StartDate;
                dteStartDate.Text         = jobRate.StartDate.ToString();
                if (!(jobRate.EndDate.ToString() == "01/01/1753 00:00:00"))
                {
                    dteEndDate.SelectedDate = jobRate.EndDate;
                    dteEndDate.Text         = jobRate.EndDate.ToString();
                }
            }
        }
Example #2
0
        void lvDuplicateAddress_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            int pointId = Convert.ToInt32(e.CommandArgument);

            Facade.IPoint  facPoint = new Facade.Point();
            Entities.Point p        = facPoint.GetPointForPointId(pointId);
            if (p != null)
            {
                if (p.PointStateId == ePointState.Deleted)
                {
                    string userId = ((Orchestrator.Entities.CustomPrincipal)Page.User).UserName;
                    p.PointStateId = ePointState.Approved;
                    Entities.FacadeResult result = facPoint.Update(p, userId);
                }

                this.SelectedPoint     = p;
                cboPoint.Text          = p.Description;
                cboPoint.SelectedValue = p.IdentityId.ToString() + "," + p.PointId.ToString();

                pnlNewPoint.Visible = false;
                pnlPoint.Visible    = true;
                this.divDuplicateAddress.Visible = false;
                inpCreateNewPointSelected.Value  = string.Empty;
            }
        }
Example #3
0
        private bool UpdatePoint()
        {
            Facade.IPoint facPoint = new Facade.Point();
            string        userName = ((Entities.CustomPrincipal)Page.User).UserName;

            // Ensure the latest traffic area id is reflected in the update.
            point.Address.TrafficArea.TrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue);

            Entities.FacadeResult retVal = facPoint.Update(point, userName);
            if (retVal.Success)
            {
                lblConfirmation.Text    = "The point has been updated.";
                lblConfirmation.Visible = true;

                point = facPoint.GetPointForPointId(point.PointId);
                cboTrafficArea.SelectedValue = point.Address.TrafficArea.TrafficAreaId.ToString();
            }
            else
            {
                infringementDisplay.Infringements = retVal.Infringements;
                infringementDisplay.DisplayInfringments();
            }

            return(retVal.Success);
        }
Example #4
0
        void cboPoint_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            // Set the identity id to use for the point filtering
            switch ((eInstructionType)m_instruction.InstructionTypeId)
            {
            case eInstructionType.Load:
                m_identityId = m_job.IdentityId;
                break;

            case eInstructionType.Drop:
                m_identityId = m_instruction.ClientsCustomerIdentityID;
                break;
            }

            if (cboPoint.SelectedValue != String.Empty)
            {
                Facade.IPoint  facPoint      = new Facade.Point();
                Entities.Point selectedPoint = facPoint.GetPointForPointId(Convert.ToInt32(cboPoint.SelectedValue));

                m_identityId = selectedPoint.IdentityId;
                m_owner      = selectedPoint.OrganisationName;
                m_pointId    = selectedPoint.PointId;
                m_point      = selectedPoint.Description;
                m_townId     = selectedPoint.PostTown.TownId;
                m_town       = selectedPoint.PostTown.TownName;

                cboTown.SelectedValue = selectedPoint.PostTown.TownId.ToString();
                cboTown.Text          = selectedPoint.PostTown.TownName;

                cboOwner.SelectedValue = selectedPoint.IdentityId.ToString();
                cboOwner.Text          = selectedPoint.OrganisationName;
            }
        }
Example #5
0
        private void PrepareOrders()
        {
            if (!IsPostBack)
            {
                OrdersCSV = PreviousPage.Orders;
            }

            Facade.IOrder facOrder = new Facade.Order();
            DataSet       dsOrders = facOrder.GetOrdersForList(OrdersCSV, true, false);

            Facade.IOrganisation  facOrg   = new Facade.Organisation();
            Entities.Organisation org      = facOrg.GetForIdentityId(Globals.Configuration.IdentityId);
            Facade.IPoint         facPoint = new Facade.Point();
            Entities.Point        deliveryRunCollectionPoint = null;
            if (org.Defaults[0].GroupageDeliveryRunCollectionPoint > 0)
            {
                deliveryRunCollectionPoint = facPoint.GetPointForPointId(org.Defaults[0].GroupageDeliveryRunCollectionPoint);
            }

            dsOrders.Tables[0].Columns.Add("CollectFromPointID", typeof(int));
            dsOrders.Tables[0].Columns.Add("CollectFromPoint", typeof(string));
            dsOrders.Tables[0].Columns.Add("CollectAtDateTime", typeof(DateTime));
            dsOrders.Tables[0].Columns.Add("CollectAtAnyTime", typeof(bool));
            dsOrders.Tables[0].Columns.Add("LoadOrder", typeof(string));
            dsOrders.Tables[0].Columns.Add("DeliveryOrder", typeof(int));

            int loadOrder = 1;

            foreach (DataRow row in dsOrders.Tables[0].Rows)
            {
                row["CollectFromPointID"] = (int)row["DeliveryRunCollectionPointID"];
                row["CollectFromPoint"]   = row["DeliveryRunCollectionPointDescription"].ToString();
                row["CollectAtDateTime"]  = (DateTime)row["DeliveryRunCollectionDateTime"];
                row["CollectAtAnyTime"]   = (bool)row["DeliveryRunCollectionIsAnyTime"];
                if (loadOrder == dsOrders.Tables[0].Rows.Count)
                {
                    row["LoadOrder"] = "L";
                }
                else
                {
                    row["LoadOrder"] = loadOrder.ToString();
                }
                loadOrder++;

                // Set the default collection point to that specified by the organisation settings
                if (row["LastPlannedOrderActionID"] == DBNull.Value)
                {
                    if (deliveryRunCollectionPoint != null)
                    {
                        row["CollectFromPointID"] = deliveryRunCollectionPoint.PointId;
                        row["CollectFromPoint"]   = deliveryRunCollectionPoint.Description;
                    }
                }
            }

            dsOrders.AcceptChanges();
            OrderData = dsOrders;
            grdOrders.Rebind();
        }
        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);
        }
Example #7
0
        private void LoadPointAuditTrail()
        {
            pnlPoint.Visible = true;

            Facade.IPoint  facPoint     = new Facade.Point();
            Entities.Point currentPoint = facPoint.GetPointForPointId(currentID);

            lblPalletBalanceType.Text = "Point Pallet Audit Trail : " + currentPoint.Description;

            Facade.IPalletBalance facPalletBalance = new Facade.Pallet();
            lvPointAudit.DataSource = facPalletBalance.GetPointAuditTrail(currentID, int.Parse(rcbPalletType.SelectedValue), rdiStartDate.SelectedDate.Value, rdiEndDate.SelectedDate.Value);
            lvPointAudit.DataBind();
        }
        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;
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int.TryParse(Request.QueryString["pointId"], out _pointID);
            int.TryParse(Request.QueryString["identityId"], out _identityID);
            _clientName = Request.QueryString["clientName"];



            btnClose.Visible = allowclose;

            if (!IsPostBack)
            {
                Facade.IPoint facPoint = new Facade.Point();
                _point = facPoint.GetPointForPointId(_pointID);
                ucPointCtl.SelectedPoint = _point;
                if (_identityID > 0)
                {
                    ucPointCtl.NewPointOwnerIdentityID  = _identityID;
                    ucPointCtl.NewPointOwnerDescription = _clientName;
                }
            }
        }
Example #10
0
        private bool AddPoint()
        {
            Facade.IPoint facPoint = new Facade.Point();
            string        userName = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.FacadeResult retVal = facPoint.Create(point, userName);

            if (retVal.Success)
            {
                lblConfirmation.Text    = "The point was added.";
                lblConfirmation.Visible = true;

                ViewState["pointId"] = retVal.ObjectId;

                point = facPoint.GetPointForPointId(retVal.ObjectId);

                ViewState["point"] = point;

                cboClient.Enabled = false;

                PopulateTrafficAreaControl();

                cboTrafficArea.Visible = true;
                lblTrafficArea.Visible = true;
                cboTrafficArea.Items.FindByValue(point.Address.TrafficArea.TrafficAreaId.ToString()).Selected = true;

                btnAdd.Text = "Update";
                m_isUpdate  = true;

                PopulateTrafficAreaControl();
            }
            else
            {
                infringementDisplay.Infringements = retVal.Infringements;
                infringementDisplay.DisplayInfringments();
            }

            return(retVal.Success);
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int pointId = Convert.ToInt32(Request.QueryString["pointId"]);

            Entities.Point point = null;

            if (pointId > 0)
            {
                string cacheName = "_pointAddress" + pointId.ToString();
                if (Cache[cacheName] == null)
                {
                    Facade.IPoint facPoint = new Facade.Point();
                    point = facPoint.GetPointForPointId(pointId);
                }
                else
                {
                    point = (Entities.Point)Cache["_pointAddress" + pointId.ToString()];
                }
            }

            if (point != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(point.Address.AddressLine1);
                sb.Append("<br>");

                if (point.Address.AddressLine2.Length > 0)
                {
                    sb.Append(point.Address.AddressLine2);
                    sb.Append("<br>");
                }
                if (point.Address.AddressLine3.Length > 0)
                {
                    sb.Append(point.Address.AddressLine3);
                    sb.Append("<br>");
                }
                if (point.Address.PostTown.Length > 0)
                {
                    sb.Append(point.Address.PostTown);
                    sb.Append("<br>");
                }
                if (point.Address.County.Length > 0)
                {
                    sb.Append(point.Address.County);
                    sb.Append("<br>");
                }
                if (point.Address.PostCode.Length > 0)
                {
                    sb.Append(point.Address.PostCode);
                    sb.Append("<br>");
                }
                if (point.Address.CountryDescription.Length > 0)
                {
                    sb.Append(point.Address.CountryDescription);
                }

                Response.Write(sb.ToString());
                Response.Flush();
                Response.End();
                return;
            }
        }
Example #12
0
        //-----------------------------------------------------------------------------------------------------------

        private void AddNewDropInstruction(Entities.Order currentOrder, Entities.Job run, List <Entities.Instruction> amendedInstructions)
        {
            Facade.IPoint facPoint = new Facade.Point();

            // Load the job's current state.
            Facade.IJob facJob = new Facade.Job();

            #region Configure the end instruction.
            Entities.Instruction endInstruction = null;
            if (amendedInstructions.Count > 0)
            {
                endInstruction = amendedInstructions[0];
            }
            else
            {
                endInstruction = run.Instructions.Find(i => i.InstructionTypeId == (int)eInstructionType.Drop && i.PointID == this.cboNewDeliveryPoint.PointID);
            }

            // Can a matching instruction be found on the job after the start instruction?
            //endInstruction = job.Instructions.Find(i => i.InstructionOrder > startInstruction.InstructionOrder && i.InstructionTypeId == (int)untetheredLocations.EndInstructionType.Value && i.PointID == untetheredLocations.EndPointID.Value && !i.HasActual);
            if (endInstruction == null)
            {
                // A new instruction is required.
                endInstruction                   = new Orchestrator.Entities.Instruction();
                endInstruction.PointID           = this.cboNewDeliveryPoint.PointID;
                endInstruction.Point             = facPoint.GetPointForPointId(this.cboNewDeliveryPoint.PointID);
                endInstruction.InstructionTypeId = (int)eInstructionType.Drop;

                if (this.dteDeliveryByDate.SelectedDate.HasValue)
                {
                    endInstruction.BookedDateTime           = this.dteDeliveryByDate.SelectedDate.Value;
                    endInstruction.PlannedArrivalDateTime   = this.dteDeliveryByDate.SelectedDate.Value;
                    endInstruction.PlannedDepartureDateTime = this.dteDeliveryByDate.SelectedDate.Value;
                }
                else
                {
                    endInstruction.BookedDateTime           = currentOrder.DeliveryDateTime;
                    endInstruction.PlannedArrivalDateTime   = currentOrder.DeliveryDateTime;
                    endInstruction.PlannedDepartureDateTime = currentOrder.DeliveryDateTime;
                }

                if (this.rdDeliveryIsAnytime.Checked)
                {
                    endInstruction.IsAnyTime = true;
                }
                else
                {
                    endInstruction.IsAnyTime = false;
                }

                endInstruction.JobId = run.JobId;
                endInstruction.ClientsCustomerIdentityID = currentOrder.CustomerIdentityID;

                // Record that this instruction has been amended.
                amendedInstructions.Add(endInstruction);
            }
            else
            if (amendedInstructions.Count == 0)
            {
                amendedInstructions.Add(endInstruction);
            }

            // Add the collect drop for this order to the instruction.
            Entities.CollectDrop endCollectDrop = new Entities.CollectDrop();
            endCollectDrop.Order     = currentOrder;
            endCollectDrop.OrderID   = currentOrder.OrderID;
            endCollectDrop.NoPallets = currentOrder.NoPallets;
            endCollectDrop.ClientsCustomerReference = currentOrder.CustomerOrderNumber;
            endCollectDrop.GoodsTypeId = currentOrder.GoodsTypeID;
            endCollectDrop.NoCases     = currentOrder.Cases;
            endCollectDrop.Weight      = currentOrder.Weight;
            endCollectDrop.Docket      = currentOrder.OrderID.ToString();

            endCollectDrop.OrderAction = eOrderAction.Default;
            endInstruction.CollectDrops.Add(endCollectDrop);

            this.UpdateOrder(currentOrder);
            #endregion
        }
        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;
            }
        }
Example #14
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;

            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;
        }
Example #15
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (cboPoint.SelectedValue == String.Empty)
                {
                    // Set the point type, organisation, town, and name for the new point
                    switch ((eInstructionType)m_instruction.InstructionTypeId)
                    {
                    case eInstructionType.Drop:
                        Session[wizard.C_POINT_TYPE] = ePointType.Deliver;
                        Session[wizard.C_POINT_FOR]  = m_instruction.ClientsCustomerIdentityID;
                        break;

                    case eInstructionType.Load:
                        Session[wizard.C_POINT_TYPE] = ePointType.Collect;
                        Session[wizard.C_POINT_FOR]  = m_job.IdentityId;
                        break;
                    }

                    Session[wizard.C_POINT_NAME] = cboPoint.Text;
                    Session[wizard.C_TOWN_ID]    = Convert.ToInt32(cboTown.SelectedValue);

                    // The point name must be unique for this client
                    bool          foundPointName = false;
                    Facade.IPoint facPoint       = new Facade.Point();
                    DataSet       pointNames     = facPoint.GetAllForOrganisation((int)Session[wizard.C_POINT_FOR], ePointType.Any, cboPoint.Text);
                    foreach (DataRow row in pointNames.Tables[0].Rows)
                    {
                        if (((string)row["Description"]) == cboPoint.Text)
                        {
                            foundPointName = true;
                        }
                    }

                    if (foundPointName)
                    {
                        pnlCreateNewPoint.Visible = true;
                    }
                    else
                    {
                        // Allow the user to create the new point
                        GoToStep("CNP");
                    }
                }
                else
                {
                    int pointId = Convert.ToInt32(cboPoint.SelectedValue);

                    if (m_isUpdate)
                    {
                        if (m_instruction.InstructionID == 0)
                        {
                            // Adding a new instruction

                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            // Altering an existing instruction
                            // Cause the first collectdrop to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }
                        }
                    }
                    else
                    {
                        if (m_isAmendment)
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                Facade.IPoint  facPoint      = new Facade.Point();
                                Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                                m_instruction.Point   = selectedPoint;
                                m_instruction.PointID = selectedPoint.PointId;
                            }

                            // Cause the first point to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                    }

                    GoToStep("PD");
                }
            }
        }
Example #16
0
        private void dgGoods_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView row = (DataRowView)e.Item.DataItem;

                ////////////////////////////////////////////////////////
                int refusalId                = (int)row["RefusalId"];
                eGoodsRefusedType type       = (eGoodsRefusedType)row["RefusalTypeId"];
                HtmlAnchor        hypRefusal = (HtmlAnchor)e.Item.FindControl("hypRefusal");
                if (type == eGoodsRefusedType.Shorts || type == eGoodsRefusedType.OverAndAccepted)
                {
                    hypRefusal.HRef      = "shortage.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&instructionId=" + m_instructionId.ToString() + "&refusalId=" + refusalId + "&t=2" + "&csid=" + this.CookieSessionID;
                    hypRefusal.InnerText = refusalId.ToString();
                }
                else
                {
                    hypRefusal.HRef      = "refusal.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&instructionId=" + m_instructionId.ToString() + "&refusalId=" + refusalId + "&t=1" + this.CookieSessionID;
                    hypRefusal.InnerText = refusalId.ToString();
                }

                ///////////////////////////////////////////////////////

                int storePointId = 0;
                if (row["StorePointId"] != DBNull.Value)
                {
                    storePointId = (int)row["StorePointId"];
                }
                int returnPointId = 0;
                if (row["ReturnPointId"] != DBNull.Value)
                {
                    returnPointId = (int)row["ReturnPointId"];
                }

                if (storePointId != 0 || returnPointId != 0)
                {
                    Facade.IPoint facPoint = new Facade.Point();
                    if (storePointId != 0)
                    {
                        Label lblStoreAt = (Label)e.Item.FindControl("lblStoreAt");

                        Entities.Point storePoint = facPoint.GetPointForPointId(storePointId);
                        lblStoreAt.Text = storePoint.OrganisationName + ", " + storePoint.PostTown.TownName;

                        Uri pointAddressUri = new Uri(Request.Url, Page.ResolveUrl("~/Point/GetPointAddressHtml.aspx"));
                        lblStoreAt.Attributes.Add("onMouseOver", "ShowPoint('" + pointAddressUri.ToString() + "', '" + storePointId.ToString() + "')");
                        lblStoreAt.Attributes.Add("onMouseOut", "HidePoint()");
                    }

                    if (returnPointId != 0)
                    {
                        Label lblReturnTo = (Label)e.Item.FindControl("lblReturnTo");

                        Entities.Point returnPoint = facPoint.GetPointForPointId(returnPointId);
                        lblReturnTo.Text = returnPoint.OrganisationName + ", " + returnPoint.PostTown.TownName;

                        Uri pointAddressUri = new Uri(Request.Url, Page.ResolveUrl("~/Point/GetPointAddressHtml.aspx"));
                        lblReturnTo.Attributes.Add("onMouseOver", "ShowPoint('" + pointAddressUri.ToString() + "', '" + returnPointId.ToString() + "')");
                        lblReturnTo.Attributes.Add("onMouseOut", "HidePoint()");
                    }
                }

                // Only allow goods of status Outstanding to be edited or deleted (unless this is a return job).
                if (row["RefusalStatusId"] != DBNull.Value)
                {
                    eGoodsRefusedStatus status = (eGoodsRefusedStatus)row["RefusalStatusId"];

                    //if ((status != eGoodsRefusedStatus.Outstanding && type != eGoodsRefusedType.Shorts && type != eGoodsRefusedType.OverAndAccepted) && m_job.JobType != eJobType.Return)
                    //{
                    //    // This has been commented out following a desire by Tony to be able to view the details - instead the Update Goods button is disabled.
                    //    //((Button) e.Item.Cells[8].Controls[0]).Enabled = false;
                    //    ((Button) e.Item.Cells[8].Controls[0]).Text = "View";
                    //    ((Button) e.Item.Cells[10].Controls[0]).Enabled = false;
                    //}
                }
            }
        }
Example #17
0
        private void PrepareOrders()
        {
            Facade.IOrder facOrder = new Facade.Order();
            DataSet       dsOrders = facOrder.GetOrdersForList(OrdersCSV, false, true);

            dsOrders.Tables[0].Columns.Add(C_DeliverToPointID, typeof(int));
            dsOrders.Tables[0].Columns.Add(C_DeliverToPoint, typeof(string));
            dsOrders.Tables[0].Columns.Add(C_DeliverAtDateTime, typeof(DateTime));
            dsOrders.Tables[0].Columns.Add(C_DeliverAtAnyTime, typeof(bool));
            dsOrders.Tables[0].Columns.Add(C_OrderActionID, typeof(int));
            dsOrders.Tables[0].Columns.Add(C_LoadOder, typeof(string));

            DataSet dsDefaultDeliveryPoints = DeterminDefaultDeliveryPoint();

            int loadOrder = 1;

            foreach (DataRow row in dsOrders.Tables[0].Rows)
            {
                int       orderID = (int)row["OrderID"];
                DataRow[] drows   = dsDefaultDeliveryPoints.Tables[0].Select("OrderID = " + orderID.ToString());
                if (drows.Length == 1)
                {
                    row[C_DeliverToPointID]  = (int)drows[0]["DeliveryRunCollectionPointID"];
                    row[C_DeliverToPoint]    = (string)drows[0]["Description"];
                    row[C_DeliverAtDateTime] = (DateTime)drows[0]["DeliveryRunCollectionDateTime"];
                    row[C_DeliverAtAnyTime]  = (bool)drows[0]["DeliveryRunCollectionIsAnytime"];
                    row[C_OrderActionID]     = (int)eOrderAction.Default;
                }

                if ((bool)row["PlannedForDelivery"])
                {
                    // The order is planned for delivery so the sensible default is to cross-dock to the delivery run collection point.
                    row[C_OrderActionID] = (int)eOrderAction.Cross_Dock;
                }
                else
                {
                    // The order has not been planned for delivery so the sensible default is to deliver to the delivery point.
                    row[C_OrderActionID]     = (int)eOrderAction.Default;
                    row[C_DeliverToPointID]  = (int)row["DeliveryPointID"];
                    row[C_DeliverToPoint]    = (string)row["DeliveryPointDescription"];
                    row[C_DeliverAtDateTime] = (DateTime)row["DeliveryDateTime"];
                    row[C_DeliverAtAnyTime]  = (bool)row["DeliveryIsAnyTime"];
                }

                row[C_LoadOder] = loadOrder.ToString();
                loadOrder++;
            }

            dsOrders.AcceptChanges();

            Facade.IOrganisation  facOrganisation = new Facade.Organisation();
            Entities.Organisation owner           = facOrganisation.GetForIdentityId(Globals.Configuration.IdentityId);

            Facade.IPoint facPoint = new Facade.Point();
            if (owner.Defaults[0].GroupageCollectionRunDeliveryPoint > 0)
            {
                ucDeliveryPoint.SelectedPoint =
                    facPoint.GetPointForPointId(owner.Defaults[0].GroupageCollectionRunDeliveryPoint);
            }
            else
            {
                ucDeliveryPoint.SelectedPoint = facPoint.GetPointForPointId((int)dsOrders.Tables[0].Rows[0][C_DeliverToPointID]);
            }

            dteDeliveryDate.SelectedDate = (DateTime)dsOrders.Tables[0].Rows[0][C_DeliverAtDateTime];
            if (!(bool)dsOrders.Tables[0].Rows[0][C_DeliverAtAnyTime])
            {
                dteDeliveryTime.SelectedDate = (DateTime)dsOrders.Tables[0].Rows[0][C_DeliverAtDateTime];
            }

            OrderData = dsOrders;
        }
        private void BindPalletHandling(Entities.PalletDelivery palletDelivery)
        {
            btnGenerate.Text = "Update";

            m_isUpdateable = palletDelivery.PalletOrder.OrderStatus == eOrderStatus.Approved;

            rcbPalletHandlingAction.FindItemByValue(((int)palletDelivery.PalletAction).ToString()).Selected = true;

            if (palletDelivery.PalletAction == eInstructionType.DeHirePallets)
            {
                // Set the Customer Identity
                Facade.IOrganisation  facOrg = new Facade.Organisation();
                Entities.Organisation org    = facOrg.GetForIdentityId(palletDelivery.PalletOrder.CustomerIdentityID);

                rcbDeHireOrganisation.Text          = org.OrganisationName;
                rcbDeHireOrganisation.SelectedValue = org.IdentityId.ToString();

                deHireRow.Style.Remove("display");
            }

            Facade.IPoint facPoint = new Facade.Point();
            ucDeliveryPoint.SelectedPoint = facPoint.GetPointForPointId(palletDelivery.PalletOrder.DeliveryPointID);

            #region Delivery Date Time

            //Delivery Date
            dteDeliveryFromDate.SelectedDate = palletDelivery.PalletOrder.DeliveryFromDateTime;
            dteDeliveryByDate.SelectedDate   = palletDelivery.PalletOrder.DeliveryDateTime;
            dteDeliveryByTime.SelectedDate   = palletDelivery.PalletOrder.DeliveryDateTime;
            dteDeliveryFromTime.SelectedDate = palletDelivery.PalletOrder.DeliveryFromDateTime;

            if (palletDelivery.PalletOrder.DeliveryIsAnytime)
            {
                // Anytime
                rdDeliveryIsAnytime.Checked     = true;
                rdDeliveryTimedBooking.Checked  = false;
                rdDeliveryBookingWindow.Checked = false;

                dteDeliveryFromTime.Enabled   = false;
                hidDeliveryTimingMethod.Value = "anytime";
            }
            else if (palletDelivery.PalletOrder.DeliveryFromDateTime == palletDelivery.PalletOrder.DeliveryDateTime)
            {
                // Timed booking
                rdDeliveryIsAnytime.Checked     = false;
                rdDeliveryTimedBooking.Checked  = true;
                rdDeliveryBookingWindow.Checked = false;

                hidDeliveryTimingMethod.Value = "timed";
            }
            else
            {
                // Booking window
                rdDeliveryIsAnytime.Checked     = false;
                rdDeliveryTimedBooking.Checked  = false;
                rdDeliveryBookingWindow.Checked = true;

                hidDeliveryTimingMethod.Value = "window";
            }

            #endregion

            rntPalletDeliveryCharge.Value   = (double)palletDelivery.PalletOrder.ForeignRate;
            rntPalletDeliveryCharge.Culture = new CultureInfo(palletDelivery.PalletOrder.LCID);

            //Set Updateable flags.

            rcbPalletHandlingAction.Enabled = m_isUpdateable;
            rcbDeHireOrganisation.Enabled   = m_isUpdateable;

            ucDeliveryPoint.CanUpdatePoint = m_isUpdateable;

            dteDeliveryFromDate.Enabled = m_isUpdateable;
            dteDeliveryByDate.Enabled   = m_isUpdateable;
            dteDeliveryByTime.Enabled   = m_isUpdateable;
            dteDeliveryFromTime.Enabled = m_isUpdateable;

            rdDeliveryIsAnytime.Disabled     = !m_isUpdateable;
            rdDeliveryTimedBooking.Disabled  = !m_isUpdateable;
            rdDeliveryBookingWindow.Disabled = !m_isUpdateable;

            rntPalletDeliveryCharge.Enabled = m_isUpdateable;
        }
Example #19
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;
        }
Example #20
0
        //private void MessageBox(string msg)
        //{
        //    Label lbl = new Label();
        //    lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "')</script>";
        //    Page.Controls.Add(lbl);
        //}

        private void btnConfirmDropConversion_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var facPoint = new Facade.Point();

                // Get the point to trunk to.
                var trunkPoint = facPoint.GetPointForPointId(ucPoint.PointID);;

                // Configure the instructions.
                var dropInstruction = GetInstruction();
                Entities.Instruction trunkInstruction = new Entities.Instruction(eInstructionType.Trunk, dropInstruction.JobId, String.Empty);
                trunkInstruction.BookedDateTime            = dropInstruction.BookedDateTime;
                trunkInstruction.IsAnyTime                 = dropInstruction.IsAnyTime;
                trunkInstruction.PointID                   = trunkPoint.PointId;
                trunkInstruction.Point                     = trunkPoint;
                trunkInstruction.CollectDrops              = new Entities.CollectDropCollection();
                trunkInstruction.ClientsCustomerIdentityID = trunkPoint.IdentityId;

                // Process the collect drops.
                for (int collectDropIndex = 0; collectDropIndex < dropInstruction.CollectDrops.Count; collectDropIndex++)
                {
                    var cd = dropInstruction.CollectDrops[collectDropIndex];

                    // If the order can be moved from the drop to the trunk do so.
                    if (CanBeRemovedFromDrop(dropInstruction, cd.Order))
                    {
                        cd.CollectDropId = 0;
                        cd.InstructionID = trunkInstruction.InstructionID;
                        cd.OrderAction   = eOrderAction.Cross_Dock;
                        trunkInstruction.CollectDrops.Add(cd);
                        dropInstruction.CollectDrops.RemoveAt(collectDropIndex);
                        collectDropIndex--;
                    }
                }

                if (trunkInstruction.CollectDrops.Count > 0)
                {
                    // Alter the job.
                    Facade.IJob facJob       = new Facade.Job();
                    var         job          = facJob.GetJob(dropInstruction.JobId, true, true);
                    var         instructions = new List <Entities.Instruction>()
                    {
                        dropInstruction, trunkInstruction
                    };
                    Entities.CustomPrincipal user = Page.User as Entities.CustomPrincipal;
                    var result = facJob.AmendInstructions(job, instructions, eLegTimeAlterationMode.Minimal, user.UserName);

                    if (result.Success)
                    {
                        // Close this window and refresh the parent window.
                        this.ReturnValue = "refresh";
                        this.Close();
                    }
                }
                else
                {
                    // No action to take - close this window.
                    if (String.IsNullOrEmpty(errorMessage))
                    {
                        this.ReturnValue = "refresh";
                        this.Close();
                    }
                    else
                    {
                        //System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Please see the Message in the " +
                        //"Table for more information", "Error",
                        //    System.Windows.Forms.MessageBoxButtons.OK);
                        ClientScript.RegisterStartupScript(GetType(), "Error", "alert('Please see the message in the Table for more information');", true);
                    }
                }
            }
        }
Example #21
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                #region Create the new point

                Entities.Point newPoint = new Entities.Point();

                Facade.IPostTown  facPostTown = new Facade.Point();
                Entities.PostTown town        = facPostTown.GetPostTownForTownId((int)Session[wizard.C_TOWN_ID]);

                // Set the point owner and description
                newPoint.IdentityId  = (int)Session[wizard.C_POINT_FOR];
                newPoint.Description = Session[wizard.C_POINT_NAME].ToString();

                // Get the point type
                switch ((ePointType)Session[wizard.C_POINT_TYPE])
                {
                case ePointType.Collect:
                    newPoint.Collect = true;
                    break;

                case ePointType.Deliver:
                    newPoint.Deliver = true;
                    break;

                case ePointType.Any:
                    newPoint.Collect = true;
                    newPoint.Deliver = true;
                    break;
                }

                // set the address
                Entities.Address address = new Entities.Address();
                address.AddressLine1 = txtAddressLine1.Text;
                address.AddressLine2 = txtAddressLine2.Text;
                address.AddressLine3 = txtAddressLine3.Text;
                address.AddressType  = eAddressType.Point;
                address.County       = txtCounty.Text;
                address.IdentityId   = newPoint.IdentityId;
                address.Latitude     = Decimal.Parse(txtLatitude.Text);
                address.Longitude    = Decimal.Parse(txtLongitude.Text);
                address.PostCode     = txtPostCode.Text;
                address.PostTown     = txtPostTown.Text;
                if (address.TrafficArea == null)
                {
                    address.TrafficArea = new Orchestrator.Entities.TrafficArea();
                }

                address.TrafficArea.TrafficAreaId = Convert.ToInt32(hidTrafficArea.Value);
                newPoint.Address   = address;
                newPoint.Longitude = address.Longitude;
                newPoint.Latitude  = address.Latitude;

                Facade.IOrganisation facOrganisation            = new Facade.Organisation();
                Orchestrator.Entities.Organisation organisation = facOrganisation.GetForIdentityId(newPoint.IdentityId);

                // set the radius if the address was changed by addressLookup
                // if the org has a default, use it, if not, use the system default.
                if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value))
                {
                    if (organisation.Defaults[0].DefaultGeofenceRadius == null)
                    {
                        newPoint.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                    }
                    else
                    {
                        newPoint.Radius = organisation.Defaults[0].DefaultGeofenceRadius;
                    }
                }

                newPoint.PostTown   = town;
                newPoint.PointNotes = txtPointNotes.Text;

                string userId = ((Entities.CustomPrincipal)Page.User).UserName;

                // Create the new point
                Facade.IPoint         facPoint = new Facade.Point();
                Entities.FacadeResult result   = facPoint.Create(newPoint, userId);

                int pointId = facPoint.Create(newPoint, userId).ObjectId;

                #endregion

                if (pointId == 0)
                {
                    // This customer already has a point with this name
                    // Try to locate the point
                    Entities.PointCollection points = facPoint.GetClientPointsForName(newPoint.IdentityId, newPoint.Description);
                    if (points.Count == 1)
                    {
                        // The point id has been found!
                        pointId = points[0].PointId;
                    }
                    else
                    {
                        // Clear the session variables used to help add the new point
                        Session[wizard.C_POINT_TYPE] = null;
                        Session[wizard.C_POINT_FOR]  = null;
                        Session[wizard.C_POINT_NAME] = null;
                        Session[wizard.C_TOWN_ID]    = null;

                        GoToStep("P");
                    }
                }

                if (pointId > 0)
                {
                    // Reload the point to ensure we have all the ancillary entities
                    Entities.Point createdPoint = facPoint.GetPointForPointId(pointId);

                    if (m_isUpdate)
                    {
                        // Add the collect drop point information
                        if (m_instruction == null)
                        {
                            m_instruction = new Entities.Instruction();

                            m_instruction.JobId = m_jobId;
                            switch ((ePointType)(int)Session[wizard.C_POINT_TYPE])
                            {
                            case ePointType.Collect:
                                m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                                break;

                            case ePointType.Deliver:
                                m_instruction.InstructionTypeId = (int)eInstructionType.Drop;
                                break;
                            }
                        }

                        m_instruction.Point         = createdPoint;
                        m_instruction.PointID       = createdPoint.PointId;
                        m_instruction.InstructionID = m_instruction.InstructionID;

                        if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop)
                        {
                            m_instruction.ClientsCustomerIdentityID = createdPoint.IdentityId;
                        }

                        // Cause the first docket to be displayed.
                        if (m_instruction.CollectDrops.Count > 0)
                        {
                            Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                            Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                        }

                        Session[wizard.C_INSTRUCTION] = m_instruction;
                    }
                    else
                    {
                        if (m_isAmendment)
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                m_instruction.Point   = createdPoint;
                                m_instruction.PointID = createdPoint.PointId;
                            }

                            // Cause the first docket to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            // Add the collect drop point information
                            if (m_instruction == null)
                            {
                                m_instruction = new Entities.Instruction();

                                m_instruction.JobId = m_jobId;
                                switch ((ePointType)(int)Session[wizard.C_POINT_TYPE])
                                {
                                case ePointType.Collect:
                                    m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                                    break;

                                case ePointType.Deliver:
                                    m_instruction.InstructionTypeId = (int)eInstructionType.Drop;
                                    break;
                                }
                            }

                            m_instruction.Point         = createdPoint;
                            m_instruction.PointID       = createdPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop)
                            {
                                m_instruction.ClientsCustomerIdentityID = createdPoint.IdentityId;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                    }

                    GoToStep("PD");
                }
            }
        }
Example #22
0
        ///	<summary>
        /// Load PCV
        ///	</summary>
        private void LoadPCV()
        {
            // May be required to be  shown if PCV's are allowed to be deleted once created
            //chkDelete.Visible = true;
            //pnlPCVDeleted.Visible = true;

            if (ViewState["pcv"] == null)
            {
                Facade.IPCV facPCV = new Facade.PCV();
                pcv = facPCV.GetForPCVId(m_PCVId);

                ViewState["pcv"] = pcv;
            }
            else
            {
                pcv = (Entities.PCV)ViewState["pcv"];
            }


            if (m_isUpdate)
            {
                txtJobPCVId.Text = pcv.PCVId.ToString();
            }
            else
            {
                txtJobPCVId.Text = m_jobId.ToString();
            }

            txtVoucherNo.Text           = pcv.VoucherNo.ToString();
            txtNoOfPallets.Text         = pcv.NoOfPalletsReceived.ToString();
            dteDateOfIssue.SelectedDate = pcv.DateOfIssue;
            txtDepotId.Text             = pcv.DepotId.ToString();
            cboPCVStatus.Items.FindByValue(pcv.PCVStatusId.ToString()).Selected = true;
            cboPCVRedemptionStatus.Items.FindByValue(pcv.PCVRedemptionStatusId.ToString()).Selected = true;

            // Load dgDeliveryPoints with the relevant fields and markers
            int deliveryPointId = pcv.DeliverPointId;

            // Get point and mark it checked in the grid
            Facade.IPoint facPoint = new Facade.Point();
            DataSet       ds       = facPoint.GetPointForPointId(deliveryPointId, "DataSet");

            dgDeliveryPoint.DataSource = ds;
            dgDeliveryPoint.DataBind();

            foreach (DataGridItem dgItem in dgDeliveryPoint.Items)
            {
                // Get RdoBtnGrouper object
                RdoBtnGrouper selectRadioButton = dgItem.FindControl("selectRadioButton") as RdoBtnGrouper;

                // Make the row highlight the radiobutton
                selectRadioButton.Checked = true;
            }

            txtSignings.Text = pcv.NoOfSignings.ToString();

            //if (pcv.PCVStatus == ePCVStatus.NotApplicable)
            //	chkDelete.Checked = true;

            Header1.Title    = "Update PCV";
            Header1.subTitle = "Please make any changes neccessary.";
            btnAdd.Text      = "Update";
        }
Example #23
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (cboPoint.SelectedValue == String.Empty)
                {
                    int ownerID = 0;

                    if (cboOwner.SelectedValue == string.Empty)
                    {
                        // Create a new client customer for the point owner (this can be upgraded to client in the future).
                        Entities.Organisation organisation = new Entities.Organisation();
                        organisation.OrganisationName = cboOwner.Text;
                        organisation.OrganisationType = eOrganisationType.ClientCustomer;
                        Facade.IOrganisation  facOrganisation = new Facade.Organisation();
                        Entities.FacadeResult result          = facOrganisation.Create(organisation, ((Entities.CustomPrincipal)Page.User).UserName);
                        if (result.Success)
                        {
                            ownerID = result.ObjectId;
                        }
                        else
                        {
                            // Organisation has already been created by someone else between validation and this call (unlikely)
                            ownerID = facOrganisation.GetForName(cboOwner.Text).IdentityId;
                        }
                    }
                    else
                    {
                        ownerID = int.Parse(cboOwner.SelectedValue);
                    }

                    // Set the point type, organisation, town, and name for the new point
                    switch ((eInstructionType)m_instruction.InstructionTypeId)
                    {
                    case eInstructionType.Drop:
                        Session[wizard.C_POINT_TYPE] = ePointType.Deliver;
                        Session[wizard.C_POINT_FOR]  = m_instruction.ClientsCustomerIdentityID;
                        break;

                    case eInstructionType.Load:
                        Session[wizard.C_POINT_TYPE] = ePointType.Collect;
                        Session[wizard.C_POINT_FOR]  = ownerID;
                        break;
                    }

                    Session[wizard.C_INSTRUCTION_INDEX] = m_instructionIndex;
                    Session[wizard.C_POINT_NAME]        = cboPoint.Text;
                    Session[wizard.C_TOWN_ID]           = Convert.ToInt32(cboTown.SelectedValue);

                    // The point name must be unique for this client
                    bool          foundPointName = false;
                    Facade.IPoint facPoint       = new Facade.Point();
                    DataSet       pointNames     = facPoint.GetAllForOrganisation((int)Session[wizard.C_POINT_FOR], ePointType.Any, cboPoint.Text);
                    foreach (DataRow row in pointNames.Tables[0].Rows)
                    {
                        if (((string)row["Description"]) == cboPoint.Text)
                        {
                            foundPointName = true;
                        }
                    }

                    if (foundPointName)
                    {
                        pnlCreateNewPoint.Visible = true;
                    }
                    else
                    {
                        // Allow the user to create the new point
                        GoToStep("CNP");
                    }
                }
                else
                {
                    int pointId = Convert.ToInt32(cboPoint.SelectedValue);

                    if (m_isUpdate)
                    {
                        if (m_instruction.InstructionID == 0)
                        {
                            // Adding a new instruction

                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                Facade.IPoint  facPoint      = new Facade.Point();
                                Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                                m_instruction.Point   = selectedPoint;
                                m_instruction.PointID = selectedPoint.PointId;
                            }

                            // Altering an existing instruction
                            // Cause the first collectdrop to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }
                        }
                    }
                    else
                    {
                        if (m_isAmendment)
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                Facade.IPoint  facPoint      = new Facade.Point();
                                Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                                m_instruction.Point   = selectedPoint;
                                m_instruction.PointID = selectedPoint.PointId;
                            }

                            // Cause the first point to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                    }

                    GoToStep("PD");
                }
            }
        }
Example #24
0
        protected void CreatePoint()
        {
            if (Page.IsValid)
            {
                string userID = ((Orchestrator.Entities.CustomPrincipal)Page.User).UserName;

                var ownerIdentityID = string.IsNullOrWhiteSpace(cboNewPointOwner.SelectedValue) ? (int?)null : int.Parse(cboNewPointOwner.SelectedValue);
                var closestTownID   = int.Parse(cboClosestTown.SelectedValue);
                var countryID       = int.Parse(cboCountry.SelectedValue);
                var trafficAreaID   = int.Parse(cboTrafficArea.SelectedValue);

                decimal latitude  = 0;
                decimal longitude = 0;
                decimal.TryParse(hidLat.Value, out latitude);
                decimal.TryParse(hidLon.Value, out longitude);

                Facade.IPoint facPoint = new Facade.Point();

                var result = facPoint.Create(
                    ownerIdentityID,
                    cboNewPointOwner.Text,
                    txtDescription.Text,
                    closestTownID,
                    txtAddressLine1.Text,
                    txtAddressLine2.Text,
                    txtAddressLine3.Text,
                    txtPostTown.Text,
                    txtCounty.Text,
                    txtPostCode.Text.ToUpper(),
                    countryID,
                    latitude,
                    longitude,
                    this.PointType,
                    txtPointCode.Text,
                    txtPointNotes.Text,
                    txtPhoneNumber.Text,
                    trafficAreaID,
                    this.ClientUserOrganisationIdentityID,
                    userID);

                if (!result.Success)
                {
                    if (result.Infringements.Any(bri => bri.Key == typeof(Orchestrator.BusinessRules.eBRPoint).FullName + "." + BusinessRules.eBRPoint.PointNameAlreadyExistsForClient.ToString()))
                    {
                        lblError.Text          = "The Description must be unique for this organisation.";
                        lblError.ForeColor     = Color.Red;
                        lblError.Visible       = true;
                        pnlPoint.Visible       = false;
                        pnlNewPoint.Visible    = true;
                        pnlFullAddress.Visible = false;
                    }
                }
                else if (result.ObjectId > 0)
                {
                    // get the Point with all parts populated.
                    var newPoint = facPoint.GetPointForPointId(result.ObjectId);
                    this.SelectedPoint     = newPoint;
                    cboPoint.Text          = newPoint.Description;
                    cboPoint.SelectedValue = newPoint.IdentityId.ToString() + "," + newPoint.PointId.ToString();

                    if (SelectedPointChanged != null)
                    {
                        SelectedPointChanged(this, new SelectedPointChangedEventArgs(this.SelectedPoint));
                    }

                    this.lnkPointGeography.OnClientClick = "javascript:" + this.ClientID + "_UpdateGeography(" + this.SelectedPoint.PointId + "); return false;";

                    pnlNewPoint.Visible             = false;
                    pnlPoint.Visible                = true;
                    inpCreateNewPointSelected.Value = string.Empty;

                    txtDescription.Text = newPoint.Description;
                }
            }
        }
Example #25
0
        private void LoadPoint()
        {
            if (ViewState["point"] == null)
            {
                Facade.IPoint facPoint = new Facade.Point();
                point = facPoint.GetPointForPointId(m_pointId);
                ViewState["point"] = point;
            }
            else
            {
                point = (Entities.Point)ViewState["point"];
            }

            if (point != null)
            {
                using (var uow = DIContainer.CreateUnitOfWork())
                {
                    var userRepo = DIContainer.CreateRepository <IUserRepository>(uow);
                    var user     = userRepo.FindByName(point.CreatorUserId);
                    if (user != null)
                    {
                        txtCreatedBy.Text = user.FullName;
                    }
                    else
                    {
                        txtCreatedBy.Text = point.CreatorUserId;
                    }

                    if (!string.IsNullOrEmpty(point.LastUpdaterUserId))
                    {
                        user = userRepo.FindByName(point.LastUpdaterUserId);
                        if (user != null)
                        {
                            txtLastModifiedBy.Text = user.FullName;
                        }
                        else
                        {
                            txtLastModifiedBy.Text = point.LastUpdaterUserId;
                        }
                    }
                }
                txtCreationDate.Text = point.CreationDate.ToLongDateString();
                if (point.LastUpdateDate != null)
                {
                    txtLastModificationDate.Text = point.LastUpdateDate.Value.ToLongDateString();
                }

                txtDescription.Text = point.Description;

                RadComboBoxItem rcbItem = new RadComboBoxItem(point.OrganisationName, point.IdentityId.ToString());
                cboClient.Items.Add(rcbItem);
                cboClient.SelectedValue = point.IdentityId.ToString();

                cboTown.SelectedValue  = point.PostTown.TownId.ToString();
                cboTown.Text           = point.PostTown.TownName;
                txtLongitude.Text      = point.Longitude.ToString();
                txtLatitude.Text       = point.Latitude.ToString();
                this.txtPointCode.Text = point.PointCode;

                // Added for existing Points whose Addresses have Latitude and Longitude values,
                // but their containing Points do not.
                if (txtLongitude.Text == "0" && txtLatitude.Text == "0" && point.Address != null)
                {
                    txtLongitude.Text = point.Address.Longitude.ToString();
                    txtLatitude.Text  = point.Address.Latitude.ToString();
                }

                if (point.IdentityId > 0)
                {
                    if (point.Address != null)
                    {
                        txtAddressLine1.Text              = point.Address.AddressLine1;
                        txtAddressLine2.Text              = point.Address.AddressLine2;
                        txtAddressLine3.Text              = point.Address.AddressLine3;
                        txtPostTown.Text                  = point.Address.PostTown;
                        txtCounty.Text                    = point.Address.County;
                        txtPostCode.Text                  = point.Address.PostCode;
                        this.cboCountry.SelectedValue     = point.Address.CountryId.ToString();
                        this.cboTrafficArea.SelectedValue = point.Address.TrafficArea.TrafficAreaId.ToString();
                    }
                }


                txtPointNotes.Text = point.PointNotes;

                hidTrafficArea.Value = point.Address.TrafficArea.TrafficAreaId.ToString();

                // get the delivery point for saving
                this.cboDeliveryPeriod.SelectedValue = point.DeliveryMatrix.ToString();
            }

            btnAdd.Text = "Update";
        }
        private void AddOrderToRun(int orderId, int runId)
        {
            CustomPrincipal customPrincipal = (Entities.CustomPrincipal)Page.User;
            string          userName        = customPrincipal.UserName;

            Facade.IJob  facJob = new Facade.Job();
            Entities.Job job    = new Orchestrator.Entities.Job();
            job = facJob.GetJob(runId, true, true);

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

            Entities.InstructionCollection deliveries          = new Orchestrator.Entities.InstructionCollection();
            Entities.Instruction           deliveryInstruction = null;

            Facade.IPoint  facPoint = new Facade.Point();
            Facade.IOrder  facOrder = new Facade.Order();
            Entities.Point point;
            Entities.Order order = facOrder.GetForOrderID(orderId);

            int      pointID             = order.CollectionPointID;
            DateTime bookedDateTime      = order.CollectionDateTime;
            bool     collectionIsAnyTime = order.CollectionIsAnytime;

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

            if (collectionInstruction == null)
            {
                collectionInstruction = new Orchestrator.Entities.Instruction();
                collectionInstruction.InstructionTypeId = (int)eInstructionType.Load;
                collectionInstruction.BookedDateTime    = bookedDateTime;
                if (collectionIsAnyTime)
                {
                    collectionInstruction.IsAnyTime = true;
                }
                point = facPoint.GetPointForPointId(pointID);
                collectionInstruction.PointID = pointID;
                collectionInstruction.Point   = point;
                collectionInstruction.ClientsCustomerIdentityID = point.IdentityId;
                collectionInstruction.CollectDrops     = new Orchestrator.Entities.CollectDropCollection();
                collectionInstruction.InstructionOrder = 0;
            }

            cd = new Orchestrator.Entities.CollectDrop();
            cd.PalletTypeID             = order.PalletTypeID;
            cd.NoPallets                = order.NoPallets;
            cd.NoCases                  = order.Cases;
            cd.GoodsTypeId              = order.GoodsTypeID;
            cd.OrderID                  = order.OrderID;
            cd.OrderAction              = eOrderAction.Default;
            cd.Weight                   = order.Weight;
            cd.ClientsCustomerReference = order.DeliveryOrderNumber;
            cd.Docket                   = order.OrderID.ToString();

            collectionInstruction.CollectDrops.Add(cd);
            collections.Add(collectionInstruction);

            eOrderAction orderAction       = eOrderAction.Default;
            int          deliveryPointID   = order.DeliveryPointID;
            DateTime     deliveryDateTime  = order.DeliveryDateTime;
            bool         deliveryIsAnyTime = order.DeliveryIsAnytime;

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

            if (deliveryInstruction == null)
            {
                deliveryInstruction = new Orchestrator.Entities.Instruction();
                deliveryInstruction.InstructionTypeId = (int)eInstructionType.Drop;
                deliveryInstruction.BookedDateTime    = deliveryDateTime;
                if (deliveryIsAnyTime)
                {
                    deliveryInstruction.IsAnyTime = true;
                }
                point = facPoint.GetPointForPointId(deliveryPointID);
                deliveryInstruction.ClientsCustomerIdentityID = point.IdentityId;
                deliveryInstruction.PointID = deliveryPointID;
                deliveryInstruction.Point   = point;

                deliveryInstruction.CollectDrops     = new Orchestrator.Entities.CollectDropCollection();
                deliveryInstruction.InstructionOrder = 0;
            }

            cd = new Orchestrator.Entities.CollectDrop();
            cd.PalletTypeID             = order.PalletTypeID;
            cd.NoPallets                = order.NoPallets;
            cd.NoCases                  = order.Cases;
            cd.GoodsTypeId              = order.GoodsTypeID;
            cd.OrderID                  = order.OrderID;
            cd.Weight                   = order.Weight;
            cd.ClientsCustomerReference = order.DeliveryOrderNumber;
            cd.Docket                   = order.OrderID.ToString();
            cd.OrderAction              = orderAction;

            deliveryInstruction.CollectDrops.Add(cd);
            deliveries.Add(deliveryInstruction);

            facOrder.UpdateForCollectionRun(cd.OrderID, deliveryInstruction.PointID, deliveryInstruction.BookedDateTime, deliveryInstruction.IsAnyTime, cd.OrderAction, userName);

            List <Instruction> instructions = new List <Instruction>();

            Entities.CollectDropCollection orderedCollectDrops = new CollectDropCollection();

            for (int i = 0; i < collections.Count; i++)
            {
                orderedCollectDrops = new CollectDropCollection();
                int pos = 0;
                foreach (Entities.CollectDrop orderedCD in collections[i].CollectDrops)
                {
                    if (orderedCollectDrops.Count == 0)
                    {
                        orderedCollectDrops.Add(orderedCD);
                    }
                    else
                    {
                        for (int x = 0; x < orderedCollectDrops.Count; x++)
                        {
                            if (orderedCD.OrderID > orderedCollectDrops[x].OrderID)
                            {
                                pos = x + 1;
                            }
                        }
                        orderedCollectDrops.Insert(pos, orderedCD);
                    }
                }
                collections[i].CollectDrops = orderedCollectDrops;
                instructions.Add(collections[i]);
            }

            Entities.InstructionCollection orderedInstructions = new InstructionCollection();
            for (int i = 0; i < deliveries.Count; i++)
            {
                int pos = 0;
                if (orderedInstructions.Count == 0)
                {
                    orderedInstructions.Add(deliveries[i]);
                }
                else
                {
                    for (int y = 0; y < orderedInstructions.Count; y++)
                    {
                        if (deliveries[i].CollectDrops[0].OrderID > orderedInstructions[y].CollectDrops[0].OrderID)
                        {
                            pos = y + 1;
                        }
                    }
                    orderedInstructions.Insert(pos, deliveries[i]);
                }
            }

            foreach (Entities.Instruction ins in orderedInstructions)
            {
                instructions.Add(ins);
            }

            facJob.AmendInstructions(job, instructions, eLegTimeAlterationMode.Minimal, userName);
        }
Example #27
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            m_jobId = Convert.ToInt32(Request.QueryString["jobId"]);

            if (m_jobId > 0)
            {
                m_isUpdate = true;
            }

            // Retrieve the job from the session variable
            m_job = (Entities.Job)Session[wizard.C_JOB];

            if (Session[wizard.C_INSTRUCTION_INDEX] != null)
            {
                m_instructionIndex = (int)Session[wizard.C_INSTRUCTION_INDEX];

                if (!m_isUpdate && m_instructionIndex != m_job.Instructions.Count)
                {
                    m_isAmendment = true;
                }
            }

            if (!IsPostBack)
            {
                Facade.IOrganisation facOrganisation = new Facade.Organisation();
                btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE);

                if (Session[wizard.C_INSTRUCTION] != null)
                {
                    m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];

                    switch ((eInstructionType)m_instruction.InstructionTypeId)
                    {
                    case eInstructionType.Load:
                        // Allow the user to collect from any location if this is a stock movement job.
                        if (m_job.IsStockMovement)
                        {
                            m_identityId = 0;
                        }
                        else
                        {
                            m_identityId = m_job.IdentityId;
                        }
                        lblCollection.Visible  = true;
                        lblCollectFrom.Visible = true;
                        lblDelivery.Visible    = false;
                        lblDeliverTo.Visible   = false;
                        lblCollectDrop.Text    = "Collection Details";
                        break;

                    case eInstructionType.Drop:
                        m_identityId           = m_instruction.ClientsCustomerIdentityID;
                        lblCollection.Visible  = false;
                        lblCollectFrom.Visible = false;
                        lblDelivery.Visible    = true;
                        lblDeliverTo.Visible   = true;
                        lblCollectDrop.Text    = "Delivery Details";

                        m_owner                = facOrganisation.GetNameForIdentityId(m_identityId);
                        cboOwner.Text          = m_owner;
                        cboOwner.SelectedValue = m_identityId.ToString();
                        cboOwner.Visible       = false;
                        lblOwner.Visible       = true;
                        lblOwner.Text          = m_owner;
                        break;
                    }
                }
                else
                {
                    m_instruction       = new Entities.Instruction();
                    m_instruction.JobId = m_jobId;

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

                    switch ((ePointType)Session[wizard.C_POINT_TYPE])
                    {
                    case ePointType.Collect:
                        // Allow the user to collect from any location if this is a stock movement job.
                        if (m_job.IsStockMovement)
                        {
                            m_identityId = 0;
                        }
                        else
                        {
                            m_identityId = m_job.IdentityId;
                        }

                        m_owner                = facOrganisation.GetNameForIdentityId(m_job.IdentityId);
                        cboOwner.Text          = m_owner;
                        cboOwner.SelectedValue = m_identityId.ToString();

                        m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                        lblCollection.Visible           = true;
                        lblCollectFrom.Visible          = true;
                        lblDelivery.Visible             = false;
                        lblDeliverTo.Visible            = false;
                        lblCollectDrop.Text             = "Collection Details";

                        #region Load the Default Collection Point

                        try
                        {
                            Entities.Organisation client       = facOrganisation.GetForIdentityId(m_job.IdentityId);
                            Facade.IPoint         facPoint     = new Facade.Point();
                            Entities.Point        defaultPoint = facPoint.GetPointForPointId(client.Defaults[0].DefaultCollectionPointId);
                            cboTown.SelectedValue  = defaultPoint.PostTown.TownId.ToString();
                            cboTown.Text           = defaultPoint.PostTown.TownName;
                            cboPoint.SelectedValue = defaultPoint.PointId.ToString();
                            cboPoint.Text          = defaultPoint.Description;

                            m_identityId = defaultPoint.IdentityId;
                            m_owner      = defaultPoint.OrganisationName;
                            m_pointId    = defaultPoint.PointId;
                            m_point      = defaultPoint.Description;
                            m_townId     = defaultPoint.PostTown.TownId;
                            m_town       = defaultPoint.PostTown.TownName;

                            cboOwner.Text          = m_owner;
                            cboOwner.SelectedValue = m_identityId.ToString();
                        }
                        catch { }

                        #endregion
                        break;
                    }

                    Session[wizard.C_INSTRUCTION] = m_instruction;

                    if (!m_isUpdate)
                    {
                        Session[wizard.C_INSTRUCTION_INDEX] = m_job.Instructions.Count;
                    }
                }

                if (m_instruction != null && m_instruction.Point != null)
                {
                    cboOwner.SelectedValue = m_instruction.Point.IdentityId.ToString();
                    cboOwner.Text          = m_instruction.Point.OrganisationName;

                    cboPoint.SelectedValue = m_instruction.PointID.ToString();
                    cboPoint.Text          = m_instruction.Point.Description;

                    cboTown.SelectedValue = m_instruction.Point.PostTown.TownId.ToString();
                    cboTown.Text          = m_instruction.Point.PostTown.TownName;
                }
            }
            else
            {
                m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];
            }

            pnlCreateNewPoint.Visible = false;
        }
Example #28
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);
        }
Example #29
0
        ///	<summary>
        /// Load Trailer
        ///	</summary>
        private void LoadTrailer()
        {
            if (ViewState["trailer"] == null)
            {
                Facade.ITrailer facTrailer = new Facade.Resource();
                trailer = facTrailer.GetForTrailerId(m_resourceId, true);
                ViewState["trailer"] = trailer;
            }
            else
            {
                trailer = (Entities.Trailer)ViewState["trailer"];
            }

            if (trailer != null)
            {
                txtTrailerRef.Text = trailer.TrailerRef;

                cboTrailerType.Items.FindByValue(trailer.TrailerTypeId.ToString()).Selected = true;
                cboTrailerManufacturer.Items.FindByValue(trailer.TrailerManufacturerId.ToString()).Selected = true;

                Facade.IPoint  facPoint = new Facade.Point();
                Entities.Point point    = facPoint.GetPointForPointId(trailer.HomePointId);

                cboOrganisation.Text          = point.OrganisationName;
                cboOrganisation.SelectedValue = point.IdentityId.ToString();

                m_organisationId = point.IdentityId;

                m_startTown   = point.PostTown.TownName;
                m_startTownId = point.PostTown.TownId;

                if (trailer.VehicleResourceID.HasValue)
                {
                    lblVehicle.Text = trailer.VehicleResource;
                }

                txtGPSUnitID.Text      = trailer.GPSUnitID;
                cboPoint.Text          = point.Description;
                cboPoint.SelectedValue = point.PointId.ToString();
                m_pointId = point.PointId;

                cboTrailerDescription.SelectedIndex = trailer.TrailerDescriptionId + 1;

                if (trailer.ResourceStatus == eResourceStatus.Deleted)
                {
                    chkDelete.Checked = true;
                }

                Entities.ControlArea ca = null;
                Entities.TrafficArea ta = null;

                using (Facade.IResource facResource = new Facade.Resource())
                    facResource.GetControllerForResourceId(trailer.ResourceId, ref ca, ref ta);

                if (ca != null && ta != null)
                {
                    cboControlArea.ClearSelection();
                    cboControlArea.Items.FindByValue(ca.ControlAreaId.ToString()).Selected = true;
                    cboTrafficArea.ClearSelection();
                    cboTrafficArea.Items.FindByValue(ta.TrafficAreaId.ToString()).Selected = true;
                }

                chkDelete.Visible         = true;
                pnlTrailerDeleted.Visible = true;

                txtThirdPartyIntegrationID.Text = (trailer.ThirdPartyIntegrationID.HasValue) ? trailer.ThirdPartyIntegrationID.ToString() : string.Empty;
            }

            btnAdd.Text = "Update";
        }
Example #30
0
        ///	<summary>
        /// Load Driver
        ///	</summary>
        private void LoadDriver()
        {
            if (ViewState["driver"] == null)
            {
                IDriver facDriver = new Facade.Resource();
                _driver = facDriver.GetDriverForIdentityId(_identityId);

                ViewState["driver"] = _driver;
            }
            else
            {
                _driver = (Entities.Driver)ViewState["driver"];
            }

            if (_driver != null)
            {
                hypAddNewVehicle.Visible = true;
                cboTitle.SelectedValue   = Utilities.UnCamelCase(_driver.Individual.Title.ToString());
                txtFirstNames.Text       = _driver.Individual.FirstNames;
                txtLastName.Text         = _driver.Individual.LastName;
                txtPasscode.Text         = _driver.Passcode;

                dteDOB.SelectedDate = _driver.Individual.DOB;

                if (_driver.Individual.Contacts != null && _driver.Individual.Contacts.Count > 0)
                {
                    Entities.Contact telephone      = _driver.Individual.Contacts.GetForContactType(eContactType.Telephone);
                    Entities.Contact mobile         = _driver.Individual.Contacts.GetForContactType(eContactType.MobilePhone);
                    Entities.Contact personalMobile = _driver.Individual.Contacts.GetForContactType(eContactType.PersonalMobile);

                    if (telephone != null)
                    {
                        txtTelephone.Text = telephone.ContactDetail;
                    }
                    if (mobile != null)
                    {
                        txtMobilePhone.Text = mobile.ContactDetail;
                    }
                    if (personalMobile != null)
                    {
                        txtPersonalMobile.Text = personalMobile.ContactDetail;
                    }
                }

                if (_driver.Individual.Address != null)
                {
                    txtAddressLine1.Text = _driver.Individual.Address.AddressLine1;
                    txtAddressLine2.Text = _driver.Individual.Address.AddressLine2;
                    txtAddressLine3.Text = _driver.Individual.Address.AddressLine3;

                    txtPostTown.Text = _driver.Individual.Address.PostTown;
                    txtCounty.Text   = _driver.Individual.Address.County;
                    txtPostCode.Text = _driver.Individual.Address.PostCode;

                    if (_driver.Individual.Address.TrafficArea != null)
                    {
                        hidTrafficArea.Value = _driver.Individual.Address.TrafficArea.TrafficAreaId.ToString();
                    }
                }

                foreach (Entities.Contact contact in _driver.Individual.Contacts)
                {
                    if (contact.ContactType == eContactType.Telephone)
                    {
                        txtTelephone.Text = contact.ContactDetail;
                    }
                    if (contact.ContactType == eContactType.MobilePhone)
                    {
                        txtMobilePhone.Text = contact.ContactDetail;
                    }
                    if (contact.ContactType == eContactType.PersonalMobile)
                    {
                        txtPersonalMobile.Text = contact.ContactDetail;
                    }
                }

                Facade.IPoint  facPoint = new Facade.Point();
                Entities.Point point    = facPoint.GetPointForPointId(_driver.HomePointId);

                if (point != null && point.PointId > 0)
                {
                    cboOrganisation.Text          = point.OrganisationName;
                    cboOrganisation.SelectedValue = point.IdentityId.ToString();
                    m_organisationId = point.IdentityId;

                    m_startTown   = point.PostTown.TownName;
                    m_startTownId = point.PostTown.TownId;

                    cboPoint.Text          = point.Description;
                    cboPoint.SelectedValue = point.PointId.ToString();
                    m_pointId = point.PointId;
                }

                cboDriverType.Items.FindByValue(_driver.DriverType.DriverTypeID.ToString()).Selected = true;

                cboVehicle.ClearSelection();
                if (_driver.AssignedVehicleId != 0)
                {
                    ListItem vehicle = cboVehicle.Items.FindByValue(_driver.AssignedVehicleId.ToString());
                    if (vehicle != null)
                    {
                        vehicle.Selected = true;
                    }
                }

                txtDigitalTachoCardId.Text = _driver.DigitalTachoCardId;
                chkAgencyDriver.Checked    = _driver.IsAgencyDriver;

                if (_driver.Individual.IdentityStatus == eIdentityStatus.Deleted)
                {
                    chkDelete.Checked = true;
                }

                if (_driver.Point != null)
                {
                    txtLatitude.Text      = _driver.Point.Latitude.ToString();
                    txtLongitude.Text     = _driver.Point.Longitude.ToString();
                    cboTown.SelectedValue = _driver.Point.PostTown.TownId.ToString();
                    cboTown.Text          = _driver.Point.PostTown.TownName;
                }

                Entities.ControlArea ca = null;
                Entities.TrafficArea ta = null;

                using (Facade.IResource facResource = new Facade.Resource())
                    facResource.GetControllerForResourceId(_driver.ResourceId, ref ca, ref ta);

                cboDepot.ClearSelection();
                if (_driver.DepotId > 0)
                {
                    cboDepot.FindItemByValue(_driver.DepotId.ToString()).Selected = true;
                }

                if (ca != null && ta != null)
                {
                    cboControlArea.ClearSelection();
                    cboControlArea.FindItemByValue(ca.ControlAreaId.ToString()).Selected = true;
                    cboTrafficArea.ClearSelection();
                    cboTrafficArea.FindItemByValue(ta.TrafficAreaId.ToString()).Selected = true;
                }

                chkDelete.Visible        = true;
                pnlDriverDeleted.Visible = true;

                if (_driver.DefaultCommunicationTypeID == 0)
                {
                    rblDefaultCommunicationType.Items.FindByText("None").Selected = true;
                }
                else
                {
                    rblDefaultCommunicationType.Items.FindByText(((eDriverCommunicationType)_driver.DefaultCommunicationTypeID).ToString()).Selected = true;
                }
                txtPayrollNo.Text  = _driver.PayrollNo;
                dteSD.SelectedDate = _driver.StartDate;

                if (telematicsOption.Visible)
                {
                    cboTelematicsSolution.ClearSelection();
                    if (_driver.TelematicsSolution.HasValue)
                    {
                        cboTelematicsSolution.Items.FindByText(_driver.TelematicsSolution.ToString()).Selected = true;
                    }
                }

                //Find all tree nodes that correspond to the org units
                var treeNodesToCheck = m_orgUnitTreeNodes.Where(x => _driver.OrgUnitIDs.Contains(x.OrgUnitId.Value));
                foreach (var treeNode in treeNodesToCheck)
                {
                    treeNode.Checked = true;
                }

                if (_driver.PlannerIdentityID != null)
                {
                    cboDriverPlanner.ClearSelection();
                    cboDriverPlanner.FindItemByValue(_driver.PlannerIdentityID.ToString()).Selected = true;
                }

                if (_driver.AgencyId != null)
                {
                    cboAgency.ClearSelection();
                    cboAgency.FindItemByValue(_driver.AgencyId.ToString()).Selected = true;
                }
            }

            btnAdd.Text = "Update";
        }