コード例 #1
0
        public ActionResult Print(int comp = 0, int mstCode = 0, int msttype = 0)//170826
        {
            clsSubmitModel oSubmit = new clsSubmitModel();

            DataTable dt = oSubmit.GetVoucher(msttype, comp, mstCode);

            Session["Voucher"] = dt;
            return(View("~/Views/Shared/Report.aspx"));
        }
コード例 #2
0
        private void Voucher_PDF(int dCode, string Type)
        {
            // Variables
            Warning[] warnings;
            string[]  streamIds;
            string    mimeType  = string.Empty;
            string    encoding  = string.Empty;
            string    extension = string.Empty;

            string fileName = "Voucher"; string rPath = Server.MapPath("~/Report/PAYMENT.rdlc");

            ReportViewer viewer = new ReportViewer();

            viewer.ProcessingMode = ProcessingMode.Local;

            viewer.LocalReport.ReportPath             = Server.MapPath("~/Report/PAYMENT.rdlc");
            viewer.LocalReport.ReportEmbeddedResource = rPath;

            viewer.LocalReport.DataSources.Clear();

            clsSubmitModel oSubmit = new clsSubmitModel();
            //DataSet ds = oSubmit.GetDataSet("sp_GetSalesBill @mstcode=" + dCode + ",@compcode=" + Convert.ToInt32(Request.QueryString["comp"]) + ",@msttype=" + Convert.ToInt32(Request.QueryString["msttype"]), true);

            DataTable dt = oSubmit.GetVoucher(Convert.ToInt16(Type), SessionMaster.CompCode, dCode);

            ReportDataSource datasource = new ReportDataSource("DataSet1", dt);

            viewer.LocalReport.DataSources.Add(datasource);

            viewer.LocalReport.EnableExternalImages = true;

            string imagePath = "";

            imagePath = "~/img/" + SessionMaster.CompCode + ".png";
            imagePath = new Uri(Server.MapPath(imagePath)).AbsoluteUri;
            ReportParameter p32 = new ReportParameter("ImgPath", imagePath);

            viewer.LocalReport.SetParameters(new ReportParameter[] { p32 });

            viewer.LocalReport.EnableHyperlinks = true;
            viewer.LocalReport.Refresh();

            byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);


            // Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
            Response.Buffer = true;
            Response.Clear();
            Response.ContentType = mimeType;
            Response.AddHeader("content-disposition", "inline; filename=" + fileName + "." + extension);
            Response.BinaryWrite(bytes); // create the file
            Response.Flush();            // send it to the client to download
        }