private void GeneratePDFReport()
        {
            string Grade = string.Empty; ;
            string Subject = string.Empty; ;
            string Course = string.Empty; ;
            string StudentId = string.Empty; ;

            if (Request.QueryString["Grade"] != null)
            { Grade = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["Grade"].ToString()); }

            if (Request.QueryString["Subject"] != null)
            { Subject = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["Subject"].ToString()); }

            if (Request.QueryString["Course"] != null)
            { Course = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["Course"].ToString()); }

            if (Request.QueryString["StudentId"] != null)
            { StudentId = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["StudentId"]); }

            var DParms = DistrictParms.LoadDistrictParms();
            string ClientID = DParms.ClientID;
            string Year = DParms.Year;

            Microsoft.Reporting.WebForms.ReportViewer rptViewer = new Microsoft.Reporting.WebForms.ReportViewer();
            rptViewer.ProcessingMode = ProcessingMode.Remote;


            rptViewer.ServerReport.ReportServerCredentials = new CustomReportCredentials(reportUsername.Value, reportPassword.Value, reportDomain.Value);
            rptViewer.ServerReport.ReportServerUrl = new Uri(reportServerUrl.Value);
            rptViewer.ServerReport.ReportPath = reportPath.Value;

            rptViewer.ShowParameterPrompts = false;

            var reportParameterCollection = new ReportParameterCollection();
            reportParameterCollection.Add(new ReportParameter("ClientID", ClientID));
            reportParameterCollection.Add(new ReportParameter("Year", Year));
            reportParameterCollection.Add(new ReportParameter("Grade", Grade));
            reportParameterCollection.Add(new ReportParameter("Subject", Subject));
            reportParameterCollection.Add(new ReportParameter("Course", Course));
            reportParameterCollection.Add(new ReportParameter("StudentTGID", StudentId));

            rptViewer.ServerReport.SetParameters(reportParameterCollection);
            rptViewer.ServerReport.Refresh();

            Warning[] warnings;
            string[] streamids;
            string mimeType, encoding, extension;

            byte[] bytes = rptViewer.ServerReport.Render("PDF", string.Empty, out mimeType, out encoding, out extension, out streamids, out warnings);

            using (MemoryStream memoryStream = new MemoryStream(bytes))
            {
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "inline; filename=AssessmentReportCard.pdf");
                Response.AddHeader("content-length", bytes.Length.ToString());
                Response.BinaryWrite(memoryStream.ToArray());
                Response.Flush();
                Response.End();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer();
            rview.ServerReport.ReportServerUrl = new Uri(WebConfigurationManager.AppSettings["ReportServer"]);

            System.Collections.Generic.List<Microsoft.Reporting.WebForms.ReportParameter> paramList = new System.Collections.Generic.List<ReportParameter>();
            paramList.Add(new Microsoft.Reporting.WebForms.ReportParameter("Param1", "Value1"));
            paramList.Add(new Microsoft.Reporting.WebForms.ReportParameter("Param2", "Value2"));

            rview.ServerReport.ReportPath = "/FlamingoSSRSReports/CustomerwiseInquiryReport";
            rview.ServerReport.SetParameters(paramList);

            string mimeType, encoding, extension, deviceInfo;
            string[] streamids;
            Microsoft.Reporting.WebForms.Warning[] warnings;

            string format = "Excel";

            deviceInfo = "<DeviceInfo>" + "<Head1>True</Head1>" + "</DeviceInfo>";
            byte[] bytes = rview.ServerReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
            Response.Clear();

            Response.ContentType = "application/excel";
            Response.AddHeader("Content-disposition", "filename=output.xls");

            Response.OutputStream.Write(bytes, 0, bytes.Length);
            Response.OutputStream.Flush();
            Response.OutputStream.Close();
            Response.Flush();
            Response.Close();
        }
        public FileResult File()
        {
            ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer();
            rv.ProcessingMode = ProcessingMode.Local;
            rv.LocalReport.ReportPath = Server.MapPath("~/AuditingLogs2/AuditReport.rdlc");
            rv.LocalReport.Refresh();

            byte[] streamBytes = null;
            string mimeType = "";
            string encoding = "";
            string filenameExtension = "";
            string[] streamids = null;
            Warning[] warnings = null;

            streamBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

            return File(streamBytes, mimeType, "AuditReport.pdf");
        }
        private void LoadReportSourceData(string value)
        {
            try
            {
                DataSet CompanyList = new DataSet();
                Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer();
                switch (value)
                {
                    case "Voucher":
                        {
                            String orgKey = "1";//(String)Session["OrgKey"];
                            String voucherNo = (String)Session["VoucherNo"];
                            if (orgKey.IsNotNullOrEmpty())
                            {
                                ReportManager manager = new ReportManager();
                                CompanyList = manager.GetCompany(orgKey);
                                ReportDataSources = manager.GetVoucherDataSources(voucherNo);
                            }
                            rview.LocalReport.ReportPath = Report.ReportPath;
                            ReportDataSource companyDatasource = new ReportDataSource("Company", CompanyList.Tables["spGetCompany"]);
                            ReportDataSource masterDatasource = new ReportDataSource("Voucher", ReportDataSources.Tables["spPreviewVoucher"]); rpViewer.LocalReport.DataSources.Add(companyDatasource);
                            rview.LocalReport.DataSources.Add(companyDatasource);
                            rview.LocalReport.DataSources.Add(masterDatasource);
                            SetReportParameters(value, rview);
                            OpenReportInPDF(rview);
                            //rview.LocalReport.Refresh();

                            break;
                        }//Transaction
                    case "PO":
                        {
                            String poID = (String)Session["POID"];

                            ReportManager manager = new ReportManager();
                            ReportDataSources = manager.GetPODataSources(poID);
                            rview.LocalReport.ReportPath = Report.ReportPath;
                            ReportDataSource masterDatasource = new ReportDataSource("PurchaseOrder", ReportDataSources.Tables["sprptPurchaseOrder"]);
                            rview.LocalReport.DataSources.Add(masterDatasource);
                            SetReportParameters(value, rview);
                            OpenReportInPDF(rview);
                            //rview.LocalReport.Refresh();

                            break;
                        }
                    case "Transaction":
                        {
                            String StockTransID = (String)Session["StockTransID"];

                            ReportManager manager = new ReportManager();
                            ReportDataSources = manager.GetAllTransactionDataSources(StockTransID);
                            rview.LocalReport.ReportPath = Report.ReportPath;
                            ReportDataSource masterDatasource = new ReportDataSource("DataSet1", ReportDataSources.Tables["sprptStorckTransactionAll"]);
                            rview.LocalReport.DataSources.Add(masterDatasource);
                            SetReportParameters(value, rview);
                            OpenReportInPDF(rview);
                            //rview.LocalReport.Refresh();

                            break;
                        }
                    case "Requisition":
                        {
                            String RequisitionID = (String)Session["RequisitionID"];

                            ReportManager manager = new ReportManager();
                            ReportDataSources = manager.GetAllRequisitionDataSources(RequisitionID);
                            rview.LocalReport.ReportPath = Report.ReportPath;
                            ReportDataSource masterDatasource = new ReportDataSource("Requisition", ReportDataSources.Tables["sprptRequisitionAll"]);
                            rview.LocalReport.DataSources.Add(masterDatasource);
                            SetReportParameters(value, rview);
                            OpenReportInPDF(rview);
                            //rview.LocalReport.Refresh();

                            break;
                        }
                }
            }
            catch (Exception ex)
            {
                //Message.ShowErrorMessage("Error: <br>" + ex.Message + "<br>Call Stack: <br>" + ex.StackTrace);
            }
        }