http://www.c-sharpcorner.com/UploadFile/0146e3/crystal-report-in-visual-studio-2010/
public void BindCrystalReport()
{
ReportDocument rDoc = new ReportDocument();
ds_CollectionRegister dset = new ds_CollectionRegister();
SqlCommand cmd = new SqlCommand("sp_CollectionRegisterReport", con);
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@FranchiseCode", SqlDbType.VarChar).Value = Session["CollectionFCode"].ToString();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dset.Tables["dt_CollectionRegister"]);
con.Close();
rDoc.Load(Server.MapPath("../Report/CollectionRegisterReport2.rpt"));
rDoc.SetDataSource(dset.Tables["dt_CollectionRegister"]);
BindCompDetails(rDoc);
CrystalReportViewer1.HasPrintButton = true;
CrystalReportViewer1.HasExportButton = true;
CrystalReportViewer1.ReportSource = rDoc;
}
public void BindCompDetails(ReportDocument Obj)
{
DataTable dtCompany = objCommon.GetCompAddress();
if (dtCompany.Rows.Count > 0)
{
TextObject CompName = ((TextObject)Obj.ReportDefinition.Sections["Section1"].ReportObjects["txtCompName"]);
CompName.Text = dtCompany.Rows[0]["companyname"].ToString();
TextObject CompAddress = ((TextObject)Obj.ReportDefinition.Sections["Section1"].ReportObjects["txtCompAddress"]);
CompAddress.Text = dtCompany.Rows[0]["Add1"].ToString();
TextObject CompPhone = ((TextObject)Obj.ReportDefinition.Sections["Section1"].ReportObjects["txtCompPhone"]);
CompPhone.Text = dtCompany.Rows[0]["Phone"].ToString();
//TextObject Franchise = ((TextObject)Obj.ReportDefinition.Sections["Section2"].ReportObjects["txt_Franchise"]);
//Franchise.Text = Session["AdmissionFranchise"].ToString();
}
//DataTable dtYear = objCommon.GetYear();
//if (dtYear.Rows.Count > 0)
//{
// TextObject Year = ((TextObject)Obj.ReportDefinition.Sections["Section2"].ReportObjects["txt_Session"]);
// Year.Text = "Session " + dtYear.Rows[0]["SessionStr"].ToString();
//}
}
Generate Sequence number in crystal Report
http://thebunwangs.blogspot.in/2009/12/how-do-automatic-sequence-number-in.html
public void BindCrystalReport()
{
ReportDocument rDoc = new ReportDocument();
ds_CollectionRegister dset = new ds_CollectionRegister();
SqlCommand cmd = new SqlCommand("sp_CollectionRegisterReport", con);
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@FranchiseCode", SqlDbType.VarChar).Value = Session["CollectionFCode"].ToString();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dset.Tables["dt_CollectionRegister"]);
con.Close();
rDoc.Load(Server.MapPath("../Report/CollectionRegisterReport2.rpt"));
rDoc.SetDataSource(dset.Tables["dt_CollectionRegister"]);
BindCompDetails(rDoc);
CrystalReportViewer1.HasPrintButton = true;
CrystalReportViewer1.HasExportButton = true;
CrystalReportViewer1.ReportSource = rDoc;
}
public void BindCompDetails(ReportDocument Obj)
{
DataTable dtCompany = objCommon.GetCompAddress();
if (dtCompany.Rows.Count > 0)
{
TextObject CompName = ((TextObject)Obj.ReportDefinition.Sections["Section1"].ReportObjects["txtCompName"]);
CompName.Text = dtCompany.Rows[0]["companyname"].ToString();
TextObject CompAddress = ((TextObject)Obj.ReportDefinition.Sections["Section1"].ReportObjects["txtCompAddress"]);
CompAddress.Text = dtCompany.Rows[0]["Add1"].ToString();
TextObject CompPhone = ((TextObject)Obj.ReportDefinition.Sections["Section1"].ReportObjects["txtCompPhone"]);
CompPhone.Text = dtCompany.Rows[0]["Phone"].ToString();
//TextObject Franchise = ((TextObject)Obj.ReportDefinition.Sections["Section2"].ReportObjects["txt_Franchise"]);
//Franchise.Text = Session["AdmissionFranchise"].ToString();
}
//DataTable dtYear = objCommon.GetYear();
//if (dtYear.Rows.Count > 0)
//{
// TextObject Year = ((TextObject)Obj.ReportDefinition.Sections["Section2"].ReportObjects["txt_Session"]);
// Year.Text = "Session " + dtYear.Rows[0]["SessionStr"].ToString();
//}
}
Generate Sequence number in crystal Report
http://thebunwangs.blogspot.in/2009/12/how-do-automatic-sequence-number-in.html
No comments:
Post a Comment