crystal reports are not much hard as you think.when we got into it,it is really no big deal.here i am going to explain how we can generate class ID using crystal reports.I learnt about crystal reports deeply because of my 3rd year SEP project in my campus(SLIIT).Now i have considerable knowledge of crystal reports as i did it many times with customizing.So if you want to know crystal reports,what you should do is create every possible ways by customizing reports.
1.First we should create a table or view according to data fields we need to generate the report.Following shows a view which i used to create a A/L class ID for my client.
2.Then we should add a data set to access actual database values through the crystal report.here in visual c# items we can find a field as data and there we have data set item.it is xsd file.just give a name.but it is good to give a name which explains the data set.
5.After adding crystal report viewer this is what you can see.left side column we can use to add another tools if we need.right side column is where you are going to generate the report.
Then this is what we get after generate report.this is individual report generating.
1.First we should create a table or view according to data fields we need to generate the report.Following shows a view which i used to create a A/L class ID for my client.
2.Then we should add a data set to access actual database values through the crystal report.here in visual c# items we can find a field as data and there we have data set item.it is xsd file.just give a name.but it is good to give a name which explains the data set.
3.then we get a window like below.here i added my view to the window by drag and drop.first you need to expand "Server Explorer" from "View" menu in visual studio.then it will show all available connections with database server.i selected "SIMS_" as my database which i have my data for the report.there i selected view named "idstudentview" and drag it to window and dropped.
4.Then i created a new windows form and i should add crystal report viewer to it.you can find crystal report viewer from tool box under "Reporting" section.drag and drop it to the windows form.
5.After adding crystal report viewer this is what you can see.left side column we can use to add another tools if we need.right side column is where you are going to generate the report.
6.Here i added few combo boxes,radio buttons,labels and buttons according to my purpose.I want to create IDs for A/L students by selecting A/L year and the stream.and also i want to create single ID by giving student ID.so that i created those group boxes.
7.Then we should add crystal report by clicking arrow which is shown in step 5 image right side.if not we can add manually using tool box.
8.After clicking "create a new crystal report" following window will appear.we should give a name here.
9.Then it will show a window like below.there we can select fields from field explorer.by right clicking in design view we can customize report in many ways.
here this image shows how can we change "stdimage" blob value field.Like this other fields also can change
10.also in field explorer by right clicking on "database fields" we can have following database expert window and also we can data sets at this point also.
11 This is what i designed in my crystal report design view.
12. We can change displaying methods also.here when we select format with multiple columns we can have columns with same kind of data fields .but different values
13.In generate report button click event we should write the code to connect database and the report together through data set.
This method will return MySQL data adapter object and we can use it to create report
public static MySqlDataAdapter Getadapter(string qry)
{
try
{
comm.CommandText = qry;
MySqlDataAdapter dr = new MySqlDataAdapter(comm);
return dr;
}
catch (Exception)
{
return null;
}
finally
{
// comm.Cancel();
}
}
//Then we can add following code to button click event.i wrote the method for "Bulk IDs" generate part.
string query = "select * from idstudentvw where stdalyear='"+cmbAlYear.Text+"' and stdstream='"+CmbStramreport.Text+"' "; //query which returns data fields for report
MySqlDataAdapter adapter = access.GetAdapter(query);
backgrounddata ds = new backgrounddata(); //this is data set
dra.Fill(re.Tables[0]);
backgroundreport cry = new backgroundreport(); //this is crystal report
cry.SetDataSource(re);
crystalReportViewer1.ReportSource = cry; //this is crystal report viewer
crystalReportViewer1.Refresh();
This is bulk id generating report.
So ,that's all we should do to create crystal report.we can have different kind of reports.i just upload another few reports which i created for my projects.
a) 1st page
2)2nd page
3)3rd page
can you post the complete source code ?
ReplyDelete