Monthly rpt = new Monthly();
using
(SqlConnection con = new SqlConnection(CS))
{
con.Open();
SqlCommand cmd = new SqlCommand("spReport", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
SqlDataAdapter
da = new SqlDataAdapter(cmd);
DataSet dsTemp = new DataSet();
da.Fill(dsTemp, "tb_DentcoLab");
DataTable dt = new DataTable();
da.Fill(dt);
dt = dsTemp.Tables["tb_DentcoLab"];
if (dt.Rows.Count > 0)
{
ReportDocument repDoc = new ReportDocument();
// To show any value from Form1.cs to CrystalReport
TextObject txtDateToFrom = (TextObject)rpt.ReportDefinition.ReportObjects["txtDateToFrom"];
txtDateToFrom.Text = "" + DateTime.Now.ToString("dd
MMM yyyy") + "";
TextObject txtDocName = (TextObject)rpt.ReportDefinition.ReportObjects["txtDocName"];
txtDocName.Text = "" +
txtDoctorName.Text + "";
TextObject txtAddress = (TextObject)rpt.ReportDefinition.ReportObjects["txtAddress"];
txtAddress.Text = "" +
_DocAddress + "";
TextObject txtInvoiceNo = (TextObject)rpt.ReportDefinition.ReportObjects["txtInvoiceNo"];
txtInvoiceNo.Text = "" +
txtInvoice.Text + "";
rpt.SetDataSource(dsTemp);
RV.ReportSource = rpt;
RV.Zoom(1);
}
else
{
MessageBox.Show("No Data found");
}
}
["txtDateToFrom"],
["txtDocName"],
["txtAddress"],
["txtInvoiceNo"]
RV is the name of CrystalReportViewer
RV.Zoom(1) means zoom level set to whole page
RV.Zoom(2) means zoom level set to Page width
No comments:
Post a Comment