Thursday, February 4, 2016

C# Crystal Report Tutorial In Urdu - How to use Stored Procedure in Crystal Report


Code here

Form - Form1.cs code
using System;
using System.Windows.Forms;

namespace CrystalReportDemo2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void ExitButton_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void ShowReport1Button_Click(object sender, EventArgs e)
        {
            ReportForm reportForm = new ReportForm();
            reportForm.LoadReport = @"Reports\Report1.rpt";
            reportForm.ShowDialog();
        }

        private void ShowReport2Button_Click(object sender, EventArgs e)
        {
            ReportForm reportForm = new ReportForm();
            reportForm.LoadReport = @"Reports\Report2.rpt";
            reportForm.ShowDialog();
        }
    }
}
Form - ReportForm.cs code
using System;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;

namespace CrystalReportDemo2
{
    public partial class ReportForm : Form
    {
        public ReportForm()
        {
            InitializeComponent();
        }

        public string LoadReport { get; set; }

        private void ReportForm_Load(object sender, EventArgs e)
        {
            ShowReport(this.LoadReport);
        }

        private void ShowReport(string report)
        {
            ReportDocument rdoc = new ReportDocument();

            rdoc.Load(report);

            ReportCrystalReportViewer.ReportSource = rdoc;
        }
    }
}

2 comments: