programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Tuesday, October 1, 2013

Example of Crystal report(Crystal_report_in programming )

Example of Crystal report(Crystal_report_in programming )

clearly  read out old post of related this post .we refer to all of u that read old post for the theoretical knowledge.

Now here we tell how to create and take one example also .

step 1:create a data set .

step2:make report :

Crystal_report_in programming

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 ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
        AutoDataBind="true" EnableDatabaseLogonPrompt="False"
        EnableParameterPrompt="False" ReuseParameterValuesOnRefresh="True"
        ToolPanelView="None" />

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)

            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)

                        String VoucherID = ds.Tables[0].Rows[0]["VoucherId"].ToString();
                        CMD = "SELECT VoucherID,ParticularName,Amount FROM Fee_VucherParticulars Where VoucherID = " + VoucherID;
                        ds = ObjCF.GetData(CMD);
                        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());


                        ds = objCommom.RunSQLQuery("select SUM(Amount) as Total from Fee_VucherParticulars where VoucherID="+VoucherID);
                        _doc = new ReportDocument();
                        CrystalReportViewer1.ReportSource = _doc;
                        ViewState["REPORT"] = alldata;


                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script type='text/javascript'>alert('There is some problem in Printing Receipt. Please contact Administrator.');</script>", false);
                    if (ViewState["REPORT"] != null)
                        _doc = new ReportDocument();
                        CrystalReportViewer1.ReportSource = _doc;
        catch (Exception ex) { }

    private void AddImageColumn(DataTable objDataTable, String strFieldName)

        DataColumn objDataColumn = new DataColumn(strFieldName, Type.GetType("System.Byte[]"));

    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));
        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:

we can also refer to you for seen  a video for this process if you need the refer YouTube
Watch videos.......

Other Related Post:

Here we give the list of Examples related to gridview: