Example of Crystal report(Crystal_report_in asp.net programming )
Example of Crystal report(Crystal_report_in asp.net programming )
clearly read out old post of related this post .we refer to all of u that read old post for the theoretical knowledge.
step 1:create a data set .
step2:make report :
step 3: create a .asp page
<%@ Page Title="" Language="C#" MasterPageFile="~/FEE/MasterPage2.master" AutoEventWireup="true" CodeFile="PrintVoucher.aspx.cs" Inherits="FEE_PrintVoucher" %><%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
AutoDataBind="true" EnableDatabaseLogonPrompt="False"
EnableParameterPrompt="False" ReuseParameterValuesOnRefresh="True"
ToolPanelView="None" />
</asp:Content>
For videos Tutorials click Here
code behind asp page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using CommonFunctions;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
public partial class FEE_PrintVoucher : System.Web.UI.Page
{
clsCommon objCommom = new clsCommon();
String CMD;
clsCommonFunctions ObjCF = new clsCommonFunctions();
DataSet ds;
ReportDocument _doc;
clsFee _objFee = new clsFee();
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Request.QueryString["VoucherID"] != "")
{
if (!Page.IsPostBack)
{
ds = new DataSet();
DataSet alldata = new DataSet();
String str = "SELECT Fee_voucherDetail.VoucherId, REPLACE(CONVERT(varchar(11), Fee_voucherDetail.PaymentDate, 113), ' ', '-') as PaymentDate, fee_ExpenseHead.ExpHeadName As OnAccountOf FROM Fee_voucherDetail INNER JOIN fee_ExpenseHead ON Fee_voucherDetail.OnAccountOf = fee_ExpenseHead.ExpenseHeadID where Fee_voucherDetail.VoucherId='" + Request.QueryString["VoucherID"] + "'";
//ds = _objFee.Select_Student_FeeReceiptDetail(Convert.ToInt32(Session["FeeStudentID"].ToString()),
// Convert.ToInt32(Request.QueryString["InstallmentID"].ToString()));
//ds = _objFee.Select_Student_FeeReceiptDetail(9,1);
ds = objCommom.RunSQLQuery(str);
if (ds.Tables[0].Rows.Count > 0)
{
alldata.Tables.Add(ds.Tables[0].DefaultView.ToTable("VoucherDetail"));
String VoucherID = ds.Tables[0].Rows[0]["VoucherId"].ToString();
CMD = "SELECT VoucherID,ParticularName,Amount FROM Fee_VucherParticulars Where VoucherID = " + VoucherID;
ds = ObjCF.GetData(CMD);
alldata.Tables.Add(ds.Tables[0].DefaultView.ToTable("VoucherParticular"));
CMD = "SELECT SchoolName, SchoolAddress as [Address], Phone as ContactNo, Logo, Email FROM SchoolDetails";
ds = ObjCF.GetData(CMD);
AddImageColumn(ds.Tables[0], "SchoolLogo");
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (File.Exists(this.Server.MapPath(dr["Logo"].ToString())))
LoadImage(dr, "SchoolLogo", dr["Logo"].ToString());
}
alldata.Tables.Add(ds.Tables[0].DefaultView.ToTable("SchoolDetail"));
ds = objCommom.RunSQLQuery("select SUM(Amount) as Total from Fee_VucherParticulars where VoucherID="+VoucherID);
alldata.Tables.Add(ds.Tables[0].DefaultView.ToTable("TotalAmount"));
_doc = new ReportDocument();
_doc.Load(Server.MapPath("../FEE/Voucher.rpt"));
_doc.SetDataSource(alldata);
CrystalReportViewer1.ReportSource = _doc;
ViewState["REPORT"] = alldata;
}
else
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script type='text/javascript'>alert('There is some problem in Printing Receipt. Please contact Administrator.');</script>", false);
ds.Dispose();
alldata.Dispose();
}
else
{
if (ViewState["REPORT"] != null)
{
_doc = new ReportDocument();
_doc.Load(Server.MapPath("../FEE/Voucher.rpt"));
_doc.SetDataSource((DataSet)ViewState["REPORT"]);
CrystalReportViewer1.ReportSource = _doc;
}
}
}
}
catch (Exception ex) { }
}
private void AddImageColumn(DataTable objDataTable, String strFieldName)
{
DataColumn objDataColumn = new DataColumn(strFieldName, Type.GetType("System.Byte[]"));
objDataTable.Columns.Add(objDataColumn);
}
private void LoadImage(DataRow objDataRow, string strImageField, String FilePath)
{
FileStream fs = new FileStream(Server.MapPath(FilePath), System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] Image = new byte[fs.Length];
fs.Read(Image, 0, Convert.ToInt32(fs.Length));
fs.Close();
objDataRow[strImageField] = Image;
}
}
After completion of these steps you have a report with connected to data base .now you need a .Aspx form in which you add report .and in this .aspx from you want to data base connection and sql query by which you give the data to report .
After this you are ready to build web sit .when you build and any problem is comes out then solve it .otherwise run the web site .
i hope the developers understand this post .
Other CrystalReport related Post:
- Make Crystal Report.
- Crystal report Advantages
- Example of Crystal Report:
- Retrieving current page number and total pages from Crystal Report
- Show message box in asp.net for display total no of pages in crystal report
we can also refer to you for seen a video for this process if you need the refer YouTube
Watch videos.......
Other Asp.net Related Post:
- Example jQuery Validate on CheckBoxList using C#
- Limitation of Characters in Asp.net Textbox ,TextArea in asp.net
- How do you do html text encodes using JavaScript
- Check Uncheck all html CheckBox controls using jQuery:
- Check Uncheck all asp.net CheckBox in asp.net using jQuery
- Example of jQuery Validate on Radiobuttonlist in Asp.Net using C#
- Validate ASP.Net RadioButtonList using JavaScript Example
- Example of jQuery Validate on Radiobuttonlist in Asp.Net using C#
- Cropping image using jQuery in asp.net
- Displaying the textbox value in javascript Messagebox
- Get selected radio button values using JQuery
- Fill data into Dropdown list by using Jquery
- jQuery Crop Image in Asp.net using Jcrop jQuery
- Example jQuery Validate on CheckBoxList using C#
- Check Uncheck all asp.net CheckBox in asp.net using jQuery
- Check Uncheck all html CheckBox controls using jQuery:
- Asp.net CheckBoxList using jQuery.
- Get selected radio button values using JQuery.
Here we give the list of Examples related to gridview:
- Show gridview Row Details.
- Templatefield in gridview
- Introduction of Asp.net grid view Control.
- Example of Templatefield in gridview .
- Example of DropDownList inside GridView
- Check box in ASP.NET GridView
- Ckeck box list example using javascript in grid.
- Check box in ASP.NET GridView
- Show grid view row details in to tooltip.
- How to Bind Grid view Form database.
- Show gridview Row Details And Give Example.
- Example of Template field.
- How to Bind Grid view Form database.
- Template field in asp.net grid view.
- Example of DropDownList inside GridView control
- Introduction of Asp.net grid view Control.
- Example of C# for Bind Data to asp.net Textbox inside gridview control
- Bind Data to asp.net textbox control in inside of gridview Using C# Example