Example #1
0
        void btnReport_Click(object sender, EventArgs e)
        {
            btnReport.DisableServerSideValidation();

            if (Page.IsValid)
            {
                var excludeFirstLine    = false;
                var usePlannedTimes     = true;
                var showFullAddress     = false;
                var useInstructionOrder = false;

                int customerIdentityID;
                int.TryParse(cboClient.SelectedValue, out customerIdentityID);
                var startDate = dteStartDate.SelectedDate.Value.Date;
                var endDate   = dteEndDate.SelectedDate.Value.Date;

                var ds = new DataSet();
                ds.Tables.Add(ManifestGeneration.GetClientManifestReport(customerIdentityID, startDate, endDate, usePlannedTimes, excludeFirstLine, showFullAddress, useInstructionOrder));

                if (ds.Tables[0].Rows.Count > 0)
                {
                    // Configure the report settings collection
                    var reportParams = new NameValueCollection
                    {
                        { "ManifestName", "" },
                        { "ManifestID", "0" },
                        { "UsePlannedTimes", usePlannedTimes.ToString() },
                    };

                    // Configure the Session variables used to pass data to the report
                    Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = eReportType.RunSheet;
                    Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = ds;
                    Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = string.Empty;
                    Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";
                    Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;

                    // Show the user control
                    reportViewer.Visible = true;
                }
                else
                {
                    lblError.Text    = " No instructions found from " + startDate.ToString("dd/MM/yy") + " to " + endDate.ToString("dd/MM/yy") + ".";
                    lblError.Visible = true;
                }
            }
            else
            {
                reportViewer.Visible = false;
            }
        }
Example #2
0
        private void GenerateAndShowManifest(int resourceManifestID, bool excludeFirstLine, int extraRows, bool usePlannedTimes, bool includeScript, bool showFullAddress, bool useInstructionOrder)
        {
            Facade.ResourceManifest   facResourceManifest = new Orchestrator.Facade.ResourceManifest();
            Entities.ResourceManifest rm = new Orchestrator.Entities.ResourceManifest();
            rm = facResourceManifest.GetResourceManifest(resourceManifestID);

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

            manifests.Tables.Add(ManifestGeneration.GetDriverManifest(rm.ResourceManifestId, rm.ResourceId, usePlannedTimes, excludeFirstLine, showFullAddress, useInstructionOrder));

            if (manifests.Tables[0].Rows.Count > 0)
            {
                // Add blank rows if applicable
                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", rm.Description);
                reportParams.Add("ManifestID", rm.ResourceManifestId.ToString());
                reportParams.Add("UsePlannedTimes", usePlannedTimes.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
                if (includeScript)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "<script language=\"javascript\">location.href='/reports/reportviewer.aspx?wiz=true';</script>");
                }
            }
        }
Example #3
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>");
            }
        }
Example #4
0
        private void CombinePDFs()
        {
            Response.Buffer = true;
            Facade.ResourceManifest facMan      = new Facade.ResourceManifest();
            PdfDocument             combinedPDF = new PdfDocument();



            foreach (int resourceManifestID in ManifestIDs)
            {
                // Retrieve the resource manifest
                NameValueCollection reportParams = new NameValueCollection();

                var     manifest  = facMan.GetResourceManifest(resourceManifestID);
                DataSet manifests = new DataSet();

                if (manifest.SubcontractorId == null)
                {
                    manifests.Tables.Add(ManifestGeneration.GetDriverManifest(resourceManifestID, manifest.ResourceId, true, false, false, true));
                }
                else
                {
                    manifests.Tables.Add(ManifestGeneration.GetSubbyManifest(resourceManifestID, manifest.ResourceId, true, false, false, true));
                }

                if (manifests.Tables[0].Rows.Count > 0)
                {
                    // Add blank rows if applicable
                    int extraRows = 0;
                    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", manifest.Description);
                    reportParams.Add("ManifestID", manifest.ResourceManifestId.ToString());
                    reportParams.Add("UsePlannedTimes", "false");

                    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";

                    MemoryStream mem = ExecuteReport1();
                    PdfDocument  pdf = PdfReader.Open(mem, PdfDocumentOpenMode.Import);
                    foreach (PdfPage page in pdf.Pages)
                    {
                        combinedPDF.AddPage(page);
                    }
                }
            }


            //string[] pdfs = Directory.GetFiles(PDFPath);
            //foreach (string file in pdfs)
            //{
            //    PdfDocument pdf = PdfReader.Open(file, PdfDocumentOpenMode.Import);

            //    foreach (PdfPage page in pdf.Pages)
            //        combinedPDF.AddPage(page);
            //}


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



            // Combine the PDFS into a single document
            //foreach (var invoice in invoices)
            //{
            //    using (FileStream fs = File.OpenRead(Server.MapPath(invoice.PDFLocation)))
            //    {
            //        pdf = PdfReader.Open(fs, PdfDocumentOpenMode.Import);
            //    }
            //}

            // Stream this to the IFrame
            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.Buffer      = true;
            Response.ContentType = "application/pdf";

            // this makes a new window appear:
            //Response.AddHeader("content-disposition","attachment; filename=MyPDF.PDF");
            Response.AddHeader("content-disposition", "inline; filename=Manifests.PDF");

            MemoryStream binaryData = new MemoryStream();

            combinedPDF.Save(binaryData);

            Response.BinaryWrite(binaryData.ToArray());

            //Directory.Delete(PDFPath);
        }