예제 #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;
        }
예제 #2
0
        protected void btnDisplayManifest_Click(object sender, EventArgs e)
        {
            // Save the new job order (if its been changed)
            if (hidManifestChanged.Value.ToLower() == "true")
            {
                Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();

                // Save the job order
                foreach (GridItem row in grdResourceManifestJobs.Items)
                {
                    if (row.ItemType == GridItemType.AlternatingItem || row.ItemType == GridItemType.Item)
                    {
                        HtmlInputHidden hidJobId    = row.FindControl("hidJobId") as HtmlInputHidden;
                        HtmlInputHidden hidJobOrder = row.FindControl("hidJobOrder") as HtmlInputHidden;
                        HtmlInputHidden hidResourceManifestJobId = row.FindControl("hidResourceManifestJobId") as HtmlInputHidden;
                        CheckBox        chkDriverManifest        = row.FindControl("chkDriverManifest") as CheckBox;

                        //Entities.ResourceManifestJob rmj = this.SavedResourceManifest.ResourceManifestJobs.Find(o => o.JobId == Convert.ToInt32(hidJobId.Value));
                        Entities.ResourceManifestJob rmj = this.SavedResourceManifest.ResourceManifestJobs.Find(o => o.ResourceManifestJobId == Convert.ToInt32(hidResourceManifestJobId.Value));
                        rmj.JobOrder = Convert.ToInt32(hidJobOrder.Value);

                        // Also identify whether the user has removed the job from the manifest.
                        rmj.Removed = !chkDriverManifest.Checked;
                    }
                }

                this.SavedResourceManifest.Description  = txtManifestName.Text;
                this.SavedResourceManifest.ManifestDate = dteManifestDate.SelectedDate.Value;

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

                this.SavedResourceManifest = facResourceManifest.GetResourceManifest(this.ResourceManifestId);
            }

            grdResourceManifestJobs.Rebind();

            // Retrieve the resource manifest
            NameValueCollection reportParams = new NameValueCollection();
            DataSet             manifests    = new DataSet();

            manifests.Tables.Add(ManifestGeneration.GetDriverManifest(this.SavedResourceManifest.ResourceManifestId, this.SavedResourceManifest.ResourceId, chkUsePlannedTimes.Checked, chkExcludeFirstRow.Checked, chkShowFullAddress.Checked, true));

            if (manifests.Tables[0].Rows.Count > 0)
            {
                // Add blank rows if applicable
                int extraRows = int.Parse(txtExtraRowCount.Text);
                if (extraRows > 0)
                {
                    for (int i = 0; i < extraRows; i++)
                    {
                        DataRow newRow = manifests.Tables[0].NewRow();
                        manifests.Tables[0].Rows.Add(newRow);
                    }
                }

                //-------------------------------------------------------------------------------------
                //									Load Report Section
                //-------------------------------------------------------------------------------------
                reportParams.Add("ManifestName", this.txtManifestName.Text);
                reportParams.Add("ManifestID", this.lblManifestNumber.Text);
                reportParams.Add("UsePlannedTimes", chkUsePlannedTimes.Checked.ToString());

                Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = eReportType.RunSheet;
                Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;
                Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = manifests;
                Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = "";
                Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";

                // Show the user control
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "<script language=\"javascript\">window.open('" + Page.ResolveClientUrl("../reports/reportviewer.aspx?wiz=true") + "');</script>");
            }
        }