コード例 #1
0
        void rdoSubContractMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            SubContractingMethod method = (SubContractingMethod)int.Parse(rdoSubContractMethod.SelectedValue);

            if (method == SubContractingMethod.WholeJob)
            {
                grdLegs.Visible = false;
            }
            else
            {
                grdLegs.Visible = true;
                grdLegs.Rebind();
            }
        }
コード例 #2
0
        bool ValidateSubContractLeg()
        {
            SubContractingMethod method = (SubContractingMethod)int.Parse(rdoSubContractMethod.SelectedValue);

            if (method == SubContractingMethod.SpecificLegs || method == SubContractingMethod.PerOrder)
            {
                if (grdLegs.SelectedItems.Count == 0)
                {
                    Entities.BusinessRuleInfringement bri = new Orchestrator.Entities.BusinessRuleInfringement("InvalidLegs", "You must select at least 1 Leg to sub-contract if you are not sub-contracting the whole job.");
                    infrigementDisplay.Infringements = new Orchestrator.Entities.BusinessRuleInfringementCollection();
                    infrigementDisplay.Infringements.Add(bri);
                    infrigementDisplay.DisplayInfringments();
                    return(false);
                }
            }

            return(true);
        }
コード例 #3
0
        void grdLegs_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is Telerik.Web.UI.GridDataItem)
            {
                if (!string.IsNullOrEmpty(rdoSubContractMethod.SelectedValue))
                {
                    SubContractingMethod method = (SubContractingMethod)int.Parse(rdoSubContractMethod.SelectedValue);
                    Label lblOrderIDs           = (Label)e.Item.FindControl("lblOrderIDs");

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

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

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

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

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

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

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

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

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

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

                    // Trailer
                    HtmlGenericControl spnTrailer = e.Item.FindControl("spnTrailer") as HtmlGenericControl;
                    spnTrailer.InnerText = leg.Trailer == null ? "" : leg.Trailer.TrailerRef;
                }
            }
        }
コード例 #4
0
        void btnConfirmSubContract_Click(object sender, EventArgs e)
        {
            if (Page.IsValid && ValidateSubContractLeg())
            {
                // Check whether the user is trying to subcontract instructions that have resources assigned.
                // Only applies to driver and vehicle resources.
                Entities.InstructionCollection instructions = Job.Instructions;

                // Extract the collections.
                Entities.Instruction selected = instructions.Find(
                    delegate(Entities.Instruction instruction)
                {
                    return(instruction.InstructionOrder == 0);
                });

                // No resources exist for selected instructions, so continue with save oepration.
                SubContractingMethod method = (SubContractingMethod)int.Parse(rdoSubContractMethod.SelectedValue);
                string userID = ((Entities.CustomPrincipal)Page.User).UserName;

                Entities.JobSubContractor jobSubContractor = GetJobSubContract(selected);
                DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]);

                // Set the job to be sub-contracted
                Entities.FacadeResult result = null;

                switch (method)
                {
                case SubContractingMethod.WholeJob:
                    //add something that finds if any of the other legs have been subbed out already.
                    result = SubContractWholeJob(jobSubContractor, lastUpdateDate, userID);
                    break;

                case SubContractingMethod.SpecificLegs:
                    result = SubContractSpecificLegs(jobSubContractor, lastUpdateDate, userID);
                    break;

                case SubContractingMethod.PerOrder:
                    result = SubContractPerOrder(jobSubContractor, lastUpdateDate, userID);
                    break;
                }

                if (Globals.Configuration.SubContractorCommunicationsRequired &&
                    chkShowAsCommunicated.Checked)
                {
                    CommunicateInstructionsForSubContractor(Job.JobId, jobSubContractor.ContractorIdentityId, userID);
                }

                if (result.Success)
                {
                    Cache.Remove("JobEntityForJobId" + m_jobId.ToString());
                    //InjectScript.Text = "<script>RefreshParentPage();</script>";
                    this.ReturnValue = "refresh";
                    this.Close();
                }
                else
                {
                    infrigementDisplay.Infringements = result.Infringements;
                    infrigementDisplay.DisplayInfringments();
                    infrigementDisplay.Visible = true;

                    pnlConfirmation.Visible = false;
                }
            }
        }