Example #1
0
        void btnAddSelectedJob_Click(object sender, EventArgs e)
        {
            Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();

            int highestJobOrder = 0;

            // Find the highest job order and simply add it to the end
            foreach (Entities.ResourceManifestJob rmj in this.SavedResourceManifest.ResourceManifestJobs)
            {
                if (rmj.JobOrder > highestJobOrder)
                {
                    highestJobOrder = rmj.JobOrder;
                }
            }

            foreach (GridItem row in grdResourceManifestAddJobs.Items)
            {
                if (row.ItemType == GridItemType.AlternatingItem || row.ItemType == GridItemType.Item)
                {
                    HtmlInputHidden hidJobId          = row.FindControl("hidJobId") as HtmlInputHidden;
                    HtmlInputHidden hidJobOrder       = row.FindControl("hidJobOrder") as HtmlInputHidden;
                    CheckBox        chkDriverManifest = row.FindControl("chkDriverManifest") as CheckBox;
                    if (chkDriverManifest.Checked)
                    {
                        int jobId = int.Parse(hidJobId.Value);

                        // Double check to make sure the rmj isn't already on the manifest.
                        Entities.ResourceManifestJob rmj = this.SavedResourceManifest.ResourceManifestJobs.Find(o => o.JobId == Convert.ToInt32(hidJobId.Value));
                        if (rmj != null)
                        {
                            // The rmj is already on the manifest, simply change its removed flag
                            if (rmj.Removed == true)
                            {
                                rmj.Removed = false;
                            }
                        }
                        else
                        {
                            //Get Instructions Resourced
                            Facade.Instruction facInstruction = new Facade.Instruction();
                            List <int>         instructionIDs = facInstruction.GetInstructionIDsForDriverResource(jobId, this.SavedResourceManifest.ResourceId, true);

                            foreach (int instructionID in instructionIDs)
                            {
                                // create a new rmj to add to the manifest
                                Entities.ResourceManifestJob newRmj = new Orchestrator.Entities.ResourceManifestJob();
                                newRmj.JobOrder           = ++highestJobOrder;
                                newRmj.ResourceManifestId = this.SavedResourceManifest.ResourceManifestId;
                                newRmj.JobId         = Convert.ToInt32(hidJobId.Value);
                                newRmj.InstructionId = instructionID;
                                this.SavedResourceManifest.ResourceManifestJobs.Add(newRmj);
                            }
                        }
                    }
                }
            }

            facResourceManifest.UpdateResourceManifest(this.SavedResourceManifest, this.Page.User.Identity.Name);
            this.SavedResourceManifest = facResourceManifest.GetResourceManifest(this.ResourceManifestId);

            grdResourceManifestJobs.Rebind();

            // Clear the add jobs grid.
            grdResourceManifestAddJobs.DataSource = null;
            grdResourceManifestAddJobs.DataBind();
            pnlAddJobs.Visible          = false;
            pnlExistingManifest.Visible = true;
        }
Example #2
0
        void btnDriverManifests_Click(object sender, EventArgs e)
        {
            Session[Orchestrator.Globals.Constants.SubbyManifestListFromDate] = dteStartdate.SelectedDate;
            Session[Orchestrator.Globals.Constants.SubbyManifestListToDate]   = dteEndDate.SelectedDate;
            Session[Orchestrator.Globals.Constants.SubbyManifestDate]         = dteManifestDate.SelectedDate;

            CheckBox    chkManifest    = null;
            HiddenField hidResourceIds = null;

            int runningJobOrder = 0;

            Entities.ResourceManifest resourceManifest = new Orchestrator.Entities.ResourceManifest();
            resourceManifest.ManifestDate         = dteManifestDate.SelectedDate.Value;
            resourceManifest.Description          = txtManifestName.Text;
            resourceManifest.ResourceManifestJobs = new List <Entities.ResourceManifestJob>();

            Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();
            Facade.Instruction      facInstruction      = new Orchestrator.Facade.Instruction();

            foreach (Telerik.Web.UI.GridDataItem gdi in grdManifests.Items)
            {
                chkManifest = gdi.FindControl("chkDriverManifest") as CheckBox;
                if (chkManifest != null && chkManifest.Checked)
                {
                    if (gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["JobID"] != DBNull.Value)
                    {
                        hidResourceIds = gdi.FindControl("hidResourceId") as HiddenField;

                        // Save ResourceManifestJob rows here
                        int subContractorID = Convert.ToInt32(hidResourceIds.Value);
                        int jobId           = Convert.ToInt32(gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["JobID"]);

                        if (resourceManifest.SubcontractorId == null || resourceManifest.SubcontractorId == 0)
                        {
                            resourceManifest.SubcontractorId = subContractorID;
                        }

                        //Get Instructions Resourced
                        List <int> instructionIDs = facInstruction.GetInstructionIDsForSubContractor(jobId, subContractorID, true);

                        foreach (int instructionID in instructionIDs)
                        {
                            // Create new resource manifest jobs rows
                            Entities.ResourceManifestJob rmj = new Orchestrator.Entities.ResourceManifestJob();
                            rmj.JobId         = jobId;
                            rmj.InstructionId = instructionID;
                            rmj.JobOrder      = ++runningJobOrder;

                            // Add the resource manifest job to the collection.
                            resourceManifest.ResourceManifestJobs.Add(rmj);
                        }
                    }
                }
            }

            // Create the new resource manifest.
            this.ResourceManifestId = facResourceManifest.CreateResourceManifest(resourceManifest, this.Page.User.Identity.Name);

            // Redirect to the drivers ResourceManifestJob edit page.
            Response.Redirect("SubbyResourceManifest.aspx?rmID=" + this.ResourceManifestId.ToString());
        }