How to create students id cards using crystal report in C#(w

Aug 31 2013 11:03 PM

Hi frinds, first of all i want to say sorry for the my bad english...  

nw i m doing live  school project using c#(windows application), there is need crystal report using student id card, i have created student id card using crystal report,

but client asking we need single page getting two id cards for two various students in report... 

so i have posted my project's screen shot with coding,plis help me quickly, bcoz i want summit project comming monday(2-09-2013)....

so plis help me friends... i hope u all.... 

plis post step by step post as coding and crystal..

and sorry for the hiding school address bcoz its my life frinds....

by murugan

this id screen shot 

//////////first student  id--coding 

        private void idCombo1_SelectedIndexChanged(object sender, EventArgs e)
        {

            string query;
            try
            {

                sqlcon.Open();
                sqlcmd = new OleDbCommand("select * from Student_Table where Roll_No='" + idCombo1.Text + "'", sqlcon);
                da = new OleDbDataAdapter(sqlcmd);
                dt.Clear();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    //Assign data to the primary report
                    ReportDocument RptDoc = new ReportDocument();
                    //RptDoc.Load(Application.StartupPath + @"\Report\NewTcReport.rpt");
                    RptDoc.Load(Application.StartupPath + "\\report\\ID_Crystal.rpt");
                    RptDoc.SetDataSource(dt);


                    //Get sub report and assign datatable1 to that report
                    foreach (ReportObject repOp in RptDoc.ReportDefinition.ReportObjects)
                    {
                        if (repOp.Kind == ReportObjectKind.SubreportObject)
                        {
                            string SubRepName = ((SubreportObject)repOp).SubreportName;
                            ReportDocument subRepDoc = RptDoc.Subreports[SubRepName];
                            subRepDoc.SetDataSource(dt1);
                        }
                    }
                    //Assign report to the crystal report viewer
                    crystalReportViewer1.ReportSource = RptDoc;
                    crystalReportViewer1.Refresh();
                }
                sqlcon.Close();

            }
            catch (Exception ex)
            {

            }
           
        }

//////////Second student  id--coding


        private void idCombo2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string query;
            try
            {

                sqlcon.Open();
                sqlcmd = new OleDbCommand("select * from Student_Table where Roll_No='" + idCombo2.Text + "'", sqlcon);
                da = new OleDbDataAdapter(sqlcmd);
                dt.Clear();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    //Assign data to the primary report
                    ReportDocument RptDoc = new ReportDocument();
                    //RptDoc.Load(Application.StartupPath + @"\Report\NewTcReport.rpt");
                    RptDoc.Load(Application.StartupPath + "\\report\\ID_Crystal.rpt");
                    RptDoc.SetDataSource(dt);


                    //Get sub report and assign datatable1 to that report
                    foreach (ReportObject repOp in RptDoc.ReportDefinition.ReportObjects)
                    {
                        if (repOp.Kind == ReportObjectKind.SubreportObject)
                        {
                            string SubRepName = ((SubreportObject)repOp).SubreportName;
                            ReportDocument subRepDoc = RptDoc.Subreports[SubRepName];
                            subRepDoc.SetDataSource(dt1);
                        }
                    }
                    //Assign report to the crystal report viewer
                    crystalReportViewer1.ReportSource = RptDoc;
                    //crystalReportViewer1.Refresh();
                }
                sqlcon.Close();

            }
            catch (Exception ex)
            {

            }
        }

 

 

 


Answers (4)