try
{
LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/Reports/ApplicantsAdmitCard.rdlc");
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "DataSet1";
List<RPT_OnlineApplicantSummary_Result> datas = db.RPT_OnlineApplicantSummary(obj.StudentCode, obj.MobileNo).ToList();
reportDataSource.Value = datas;
//reportDataSource.Value = db.OnlineApplications.Where(x => x.StudentCode == "2019-Three-001").FirstOrDefault();
localReport.DataSources.Add(reportDataSource);
string ReportType = "pdf";
string reportType = ReportType;
String mimeType = string.Empty;
String encoding = string.Empty;
String extension = ReportType == "Excel" ? "xlsx" : "pdf";
Warning[] warnings = null;
string[] streamids = null;
Byte[] bytes = null;
bytes = localReport.Render(reportType, "", out mimeType, out encoding, out extension, out streamids, out warnings);
//Response.AddHeader("content-disposotion", "attachment; filename=Urls." + extension);
//return File(bytes, extension);
string PDFPath = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("~/")) + "PDF\\";
string fileName = "sAdmitCard" + DateTime.Now.ToFileTime() + ".pdf";
bool IsExitsPDF = System.IO.File.Exists(PDFPath + fileName);
FileStream fs = new FileStream(PDFPath + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
byte[] data = new byte[fs.Length];
fs.Write(bytes, 0, bytes.Length);
fs.Close();
string PdfLocation = "/PDF/" + fileName;
ViewBag.PdfLocation = PdfLocation;
}
catch (Exception ex)
{
ex.Message.ToString();
}
<embed src="@ViewBag.PdfLocation" id="report" style="width: 100%;" height="550" name="whatever" type='application/pdf' />
=iif(RowNumber(Nothing) mod 3 = 1, false, true)
=iif(RowNumber(Nothing) mod 3 = 2, false, true)
=iif(RowNumber(Nothing) mod 3 = 0, false, true)
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="98%" ShowPrintButton="true" Visible="false"></rsweb:ReportViewer>
<embed runat="server" id="report" style="width: 98%;" height="550" name="Gurdian ID Card" type='application/pdf' />
string PDFPath = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/")) + "PDF\\";
string FilePath;
string Sign;
string sstudentID = "";
int examid = 0;
if (!string.IsNullOrEmpty(hdID.Value))
{
sstudentID = hdID.Value;
}
ReportViewer1.Reset();
DataTable dt = getdata(sstudentID);
ReportDataSource rds = new ReportDataSource("DataSet1", dt);
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.EnableExternalImages = true;
if (DivisionID == 2)
{
FilePath = @"file:\" + Server.MapPath("\\ExternalFiles\\InstituteRptLogo\\LogoHigh.png");
Sign = @"file:\" + Server.MapPath("\\ExternalFiles\\InstituteRptLogo\\PrincipalSirSign.png");
}
else
{
FilePath = @"file:\" + Server.MapPath("\\ExternalFiles\\InstituteRptLogo\\LogoPrimary.png");
Sign = @"file:\" + Server.MapPath("\\ExternalFiles\\InstituteRptLogo\\HeadSirSign.png");
}
ReportParameter[] parameter = new ReportParameter[]
{
new ReportParameter("ImagePath", FilePath),
new ReportParameter("Sign", Sign)
};
this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("../Controls/") + "GurdianIDCard.rdlc";
ReportViewer1.LocalReport.SetParameters(parameter);
ReportViewer1.LocalReport.Refresh();
Microsoft.Reporting.WebForms.Warning[] warnings = null;
string[] streamids = null;
String mimeType = null;
String encoding = null;
String extension = null;
Byte[] bytes = null;
fileName = "GurdianIDCard" + UserID + DateTime.Now.ToFileTime() + ".pdf";
bytes = ReportViewer1.LocalReport.Render("PDF", "", out mimeType, out encoding, out extension, out streamids, out warnings);
FileStream fs = new FileStream(PDFPath + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
byte[] data = new byte[fs.Length];
fs.Write(bytes, 0, bytes.Length);
fs.Close();
PdfLocation = PDFPath + fileName;
report.Attributes.Add("src", "../PDF/" + fileName);
private DataTable getdata(string StudentID)
{
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand("USP_PrintIDCard", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@studentClassID", SqlDbType.NVarChar).Value = StudentID;
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
adpt.Fill(dt);
return dt;
}
{
LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/Reports/ApplicantsAdmitCard.rdlc");
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "DataSet1";
List<RPT_OnlineApplicantSummary_Result> datas = db.RPT_OnlineApplicantSummary(obj.StudentCode, obj.MobileNo).ToList();
reportDataSource.Value = datas;
//reportDataSource.Value = db.OnlineApplications.Where(x => x.StudentCode == "2019-Three-001").FirstOrDefault();
localReport.DataSources.Add(reportDataSource);
string ReportType = "pdf";
string reportType = ReportType;
String mimeType = string.Empty;
String encoding = string.Empty;
String extension = ReportType == "Excel" ? "xlsx" : "pdf";
Warning[] warnings = null;
string[] streamids = null;
Byte[] bytes = null;
bytes = localReport.Render(reportType, "", out mimeType, out encoding, out extension, out streamids, out warnings);
//Response.AddHeader("content-disposotion", "attachment; filename=Urls." + extension);
//return File(bytes, extension);
string PDFPath = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("~/")) + "PDF\\";
string fileName = "sAdmitCard" + DateTime.Now.ToFileTime() + ".pdf";
bool IsExitsPDF = System.IO.File.Exists(PDFPath + fileName);
FileStream fs = new FileStream(PDFPath + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
byte[] data = new byte[fs.Length];
fs.Write(bytes, 0, bytes.Length);
fs.Close();
string PdfLocation = "/PDF/" + fileName;
ViewBag.PdfLocation = PdfLocation;
}
catch (Exception ex)
{
ex.Message.ToString();
}
<embed src="@ViewBag.PdfLocation" id="report" style="width: 100%;" height="550" name="whatever" type='application/pdf' />
=iif(RowNumber(Nothing) mod 3 = 1, false, true)
=iif(RowNumber(Nothing) mod 3 = 2, false, true)
=iif(RowNumber(Nothing) mod 3 = 0, false, true)
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="98%" ShowPrintButton="true" Visible="false"></rsweb:ReportViewer>
<embed runat="server" id="report" style="width: 98%;" height="550" name="Gurdian ID Card" type='application/pdf' />
string PDFPath = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/")) + "PDF\\";
string FilePath;
string Sign;
string sstudentID = "";
int examid = 0;
if (!string.IsNullOrEmpty(hdID.Value))
{
sstudentID = hdID.Value;
}
ReportViewer1.Reset();
DataTable dt = getdata(sstudentID);
ReportDataSource rds = new ReportDataSource("DataSet1", dt);
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.EnableExternalImages = true;
if (DivisionID == 2)
{
FilePath = @"file:\" + Server.MapPath("\\ExternalFiles\\InstituteRptLogo\\LogoHigh.png");
Sign = @"file:\" + Server.MapPath("\\ExternalFiles\\InstituteRptLogo\\PrincipalSirSign.png");
}
else
{
FilePath = @"file:\" + Server.MapPath("\\ExternalFiles\\InstituteRptLogo\\LogoPrimary.png");
Sign = @"file:\" + Server.MapPath("\\ExternalFiles\\InstituteRptLogo\\HeadSirSign.png");
}
ReportParameter[] parameter = new ReportParameter[]
{
new ReportParameter("ImagePath", FilePath),
new ReportParameter("Sign", Sign)
};
this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("../Controls/") + "GurdianIDCard.rdlc";
ReportViewer1.LocalReport.SetParameters(parameter);
ReportViewer1.LocalReport.Refresh();
Microsoft.Reporting.WebForms.Warning[] warnings = null;
string[] streamids = null;
String mimeType = null;
String encoding = null;
String extension = null;
Byte[] bytes = null;
fileName = "GurdianIDCard" + UserID + DateTime.Now.ToFileTime() + ".pdf";
bytes = ReportViewer1.LocalReport.Render("PDF", "", out mimeType, out encoding, out extension, out streamids, out warnings);
FileStream fs = new FileStream(PDFPath + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
byte[] data = new byte[fs.Length];
fs.Write(bytes, 0, bytes.Length);
fs.Close();
PdfLocation = PDFPath + fileName;
report.Attributes.Add("src", "../PDF/" + fileName);
private DataTable getdata(string StudentID)
{
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand("USP_PrintIDCard", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@studentClassID", SqlDbType.NVarChar).Value = StudentID;
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
adpt.Fill(dt);
return dt;
}
No comments:
Post a Comment