TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to Make CrystalReport and Search Data in C# .NET
Pintoo Yadav
Jan 28
2015
Code
5.3
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
CrystalDecisions.CrystalReports.Engine;
using
System.Data.OleDb;
using
SakshiHospital;
namespace
ClientManagementApp
{
public
partial
class
Cry_Report : Form
{
public
Cry_Report()
{
InitializeComponent();
// Cry_Report
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(721, 439);
this
.Name =
"Cry_Report"
;
this
.Text =
"Cry_Report"
;
this
.Load +=
new
System.EventHandler(
this
.Cry_Report_Load);
this
.ResumeLayout(
false
);
//
//// CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
this
.SuspendLayout();
}
private
void
Cry_Report_Load(
object
sender, EventArgs e)
{
}
private
void
Cry_Report_Load_1(
object
sender, EventArgs e)
{
//reportViewer1.ProcessingMode = ProcessingMode.Local;
//reportViewer1.LocalReport.ReportPath = @".\Report1.rdlc";
////Customers dsCustomers = GetData();
////ReportDataSource datasource = new ReportDataSource("Customers", dsCustomers.Tables[0]);
//reportViewer1.LocalReport.DataSources.Clear();
////reportViewer1.LocalReport.DataSources.Add(datasource);
//this.reportViewer1.RefreshReport();
}
private
void
btnshow_Click(
object
sender, EventArgs e)
{
try
{
// string bill_no = "B_00" + txtbillno.Text;
DataSet ds =
new
DataSet();
// con = new OleDbConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString);
OleDbConnection con =
new
OleDbConnection(
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=ClientMgmtDb1.accdb;"
);
con.Open();
OleDbDataAdapter da =
new
OleDbDataAdapter();
if
(txtbillno.Text ==
""
)
{
da =
new
OleDbDataAdapter(
"select ID,NAME,AMT,AMC_INC,AMC,AMOUNT_INWORDS,BILL_Number,NARAT,VAT,S_T,VAT_PAY,SERVICE_TAX,VAT_AMT,SERVICETAX_AMT,TOTAL_AMOUNT FROM tbl_ClientDetails where NAME='"
+ txtbillno.Text.Trim() +
"'"
, con);
}
else
da =
new
OleDbDataAdapter(
"select ID,NAME,AMT,AMC_INC,AMC,AMOUNT_INWORDS,BILL_Number,NARAT,VAT,S_T,VAT_PAY,SERVICE_TAX,VAT_AMT,SERVICETAX_AMT,TOTAL_AMOUNT FROM tbl_ClientDetails where BILL_Number='"
+ txtbillno.Text.Trim() +
"'"
, con);
// da = new OleDbDataAdapter("select Bill.Bill_no,Bill.opd_id ,Bill.paitient_name,Bill.SEX,Bill.age,Bill.gurdian_name,Bill.Contact_no,Bill.Date_admission,Bill.Date_Discharge,Bill.Dignosis_dr,Bill.Operation_dr,Bill.Adv_amount,Bill.total_amount,Bill_Details.particular,Bill.address,Bill_Details.value from Bill join Bill_Details on Bill.Bill_no=Bill_Details.Bill_no and Bill.Bill_no='" + bill_no + "'", con);
da.Fill(ds,
"Dataset1"
);
CrystalReport1 cr =
new
CrystalReport1();
// cr.SetParameterValue("BILL_Number", txtbillno.Text);
cr.SetDataSource(ds.Tables[0]);
this
.crystalReportViewer1.ReportSource = cr;
this
.crystalReportViewer1.Show();
con.Close();
}
catch
(OleDbException s)
{
MessageBox.Show(
"Server Problem..."
);
}
}
private
void
txtbillno_TextChanged(
object
sender, EventArgs e)
{
txtbillno.BackColor = System.Drawing.Color.Aqua;
}
private
void
txtbillno_KeyUp(
object
sender, KeyEventArgs e)
{
}
}
}
CrystalReport
C#
.NET