UNIT5 User Control Crystal Report Setup Project
UNIT5 User Control Crystal Report Setup Project
This Provide additional re-use flexibility with large scale web project. It’s also help to
find bug and resolve bug in short time.
If you want some changes in your code then you have to write code at one place (user
control) that effect in every web form or every Form of window application.
Using this technique you can save your extra effort and also save your time.
The above steps are making a one user control now we can add a property of that
control using get and set method.
Syntax
Example
class Number
{
private int number;
public int Anumber // Property
{
get
{
return number;
}
set
{
number = value;
1
}
}
}
After writing method we can use that method like other methods in our windows form.
Just like a method we can also add an event to user control using EventHandler class.
Example
1. Create a new Windows Forms Control Library project from the list of templates
available and name it "TimerTickControl".
3
3. Add a label control to your form and name it "lblTimerTick" and clear its Text
Property.
4. Now to add an Icon to the control we will add an image to the project by right-clicking
the project then select "Add" -> "Existing Item" then select the image then select "Set it
Build Action" -> "Embedded Resource" from the Properties.
5. Rename "UserControl1.cs" to "TimerTick.cs".
6. To add an Icon to the control use the ToolboxBitmap attribute to provide your
Control a visual appearance.
namespace TimerTickControl
{
[ToolboxBitmap(@"D:\CSharp Project
AvadhTutor\TimerTickControl\TimerTickControl\LiveTimer.bmp")]
public partial class TimerTick : UserControl
{
public TimerTick()
{
InitializeComponent();
}
}
}
7. Add a Timer Component to your project and set its Enabled Property to "True" and
the Interval to "1000".
using System;
namespace TimerTickControl
{
[ToolboxBitmap(@"D:\CSharp Project
AvadhTutor\TimerTickControl\TimerTickControl\LiveTimer.bmp")]
public partial class TimerTick : UserControl
{
public TimerTick()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
lblTimerTick.Text = DateTime.Now.ToString();
}
}}
11. Now add a reference ("Project" - > "Add Reference") to the DLL by locating it from the Path where it is.
Now the DLL has been added to your project.
13. Right-Click on the "My Controls" Tab and select "Choose Items". The following dialog appears:
7
14. Now click "Browse" and select the DLL, the control with the icon is displayed as shown here:
15. Click "OK" to add the control to the Toolbox. That is, our control is ready to be added to the project.
16. Now try adding the control to the project by double-clicking on it.
17. Once the control has been added, it will show a running timer text in the control.
Code re-usability.
Time saving.
Less effort.
Easy to find Bug and fix it.
Save memory also.
The Crystal Reports makes it easy to create simple reports, and also has comprehensive
tools that you need to produce complex or specialized reports in csharp and other
programming languages.
Copy and paste the following source code and run your C# project.
Step 1
Step 2
Go to the Solution Explorer and right-click on your project name and select
Step 3 Now create a new crystal report document as using the report wizard and
choose an expert Standard. You can see in below figure.
Step 4
From project data ADO.Net DataSet select datatable1 Click the next Button.
10
Step 5
Step 6
Step 7
12 Step 8
Step 9
Step 10
Types of Reports
1. Parameterized reports:-
Parameters reports are the reports which accept parameters to complete the report.
2. Linked reports:-
The linked report is Report Server-side item which provides a link to an existing report on
the server.
3. Snapshot reports:-
Snapshot report is a pre-executed report that contains layout information and query results
that were retrieved at a specific point in time.
4. Cached reports:-
Cached reports are saved for a copy of the processed reports.
13
5. Drilldown reports:-
Drill Down Reports in SSR allowing Users to Show or Hide the Column Data by providing
plus and minus symbols on a text box.
7. Subreports:-
SubReport data can be used to display another report in the Main report.
8. CrossTab report:-
A crosstab report provides a different view of data by showing values at the intersection
points of rows and columns. In the Create a Crosstab Report sample, the returned items
appear by Product line, and by Order method.
1. Report Header
This section is typically used for the report title and other information you want
to appear at the beginning of the report. It can also be used for charts and cross-
tabs that include data for the entire report.
2. Page Header
This section is typically used for information that you want to appear at the top
of each page. This can include such things as chapter names, the name of the
document, and other similar information. This section can also be used to display
14 field titles above the fields on a report.
3. Details
4. Report Footer
This section is used for information you want to appear only once at the end of
the report (such as grand totals) and for charts and cross-tabs that include data
for the entire report.
5. Page Footer
This section typically contains the page number and any other information you
want to appear on the bottom of each page.
If a group, summary, or subtotal is added to the report, the program creates two
additional sections:
1. Group Header
This section typically holds the group name field, and can be used to display
charts or cross-tabs that include data specific to the group. It is printed once at
the beginning of a group.
2. Group Footer
This section typically holds the summary value, if any, and can be used to display
charts or cross-tabs. It is printed once at the end of a group.
When a group, summary, or subtotal is added, the Group Header area appears
directly above the Details area and the Group Footer area appears directly below
the Details area.
Formulas are used to insert data in the report that does not exist with any of the objects. If there
is a need to perform some calculations or to add specialized data in the report, you can use
formulas.
Common formulas are − Calculations, string functions like UPPERCASE, date functions,
etc.
Syntax
Components
Crystal Reports has the following types of formulas − Report formulas and conditional
formatting formulas.
If you have a Crystal Reports with Qty and Price fields and you need an additional field
in your Crystal Reports for Total, that is TOTAL = QTY X PRICE . In these types of
situations you can use the Formula Field in Crystal Reports.
After you create the above Crystal Reports, your CR designer screen is look like the
following picture :
Next step is to create a Formula Field for showing the result of Qty X Price .
Right Click the Formula Field in the Field Explorer and click New. Then you will get an
Input Message Box , type Total in textbox and click Use Editor.
16
Now you can see Total Under the Formula Field . Drag the field in to the Crystal Reports
where you want to display Total.
Now the designing part is over and the next step is to call the Crystal Reports in C# and
view it in Crystal Reports Viewer control .
17
A summary field can be used to sum, count, and find the maximum/minimum of a
field.
In the Crystal Reports designer view window, right click on the Report Footer , just
below the Total field and select Insert -> Summary .
Then you will get a screen , select the Total from the combo box and select Sum from
next Combo Box , and summary location Grand Total (Report Footer) . Click Ok button
18
Now you can see @Total is just below the Total field in the report Footer.
When you run this program your screen will look like the following picture.
The Special Field object is used for printing all report-related information. For example,
it can print the current page number or the total number of pages. This field was created
as a catch-all for all the miscellaneous types of report information that you need. Table
2-3 lists the available fields and what they mean
Step 2
a. Right-click on the solution and choose "Add" -> "New Project" to add a new setup
project.
Create a "Select project" named "Setup1" from the "Other Project Types -> Visual Studio
installer".
20
Step 3: Select here Setup and Deployment in the left side bar in project types.
1. Application Folder
2. User's Desktop
3. User's Program Menu
Step 4: These three options are the three places where we want to copy our setup fules during the
installation process. From here we have to select one option. Suppose I select User's Desktop. Then Right
click on User's Desktop option and select Add-> Project Output. The window will look like as.
Step 5: After clicking on Project Output, a new window will open. Here we select first four options. Now
click on OK.
21
Step 7: After this, let's test our setup by going right clicing on the setup project in
Solution Explorer and click on Install menu item.
Step 8: After copmpleting the installation go on desktop there you will find all files you
have included in the setup on the desktop.
Blog
pandyaripal.blogspot.com
instagram
instagram.com/avadhtutor
24