CustomerRegistrationProgramby UsingDelphi
CustomerRegistrationProgramby UsingDelphi
Faculty of Engineering
Graduation Project
COM 400
Nicosia - 2008
ACKNOWLEDGEMENT
First of all, I would like give my special thanks to my supervisor Umit SOYER. He
· lped and supported me to complete my project by any means of necessary. In addition
ıo this he never doubted about me, he always believed in me that I will fulfill and
succeed on my project. I am glad to that I did not disappoint him.
Tf!RGAY BALTEPE
-:,.
ABSTRACT
The aim of this program is registering the customers of a hostel and when the residing
ends , making a registry out for the customer ,calculating the total price and displaying
them as active or inactive.As a programming language Delphi was used and as a
taoase Access was used.
chosed Delphi as programming language because Delphi speeds Win32 development
· y combining Delphi's proven visual Rapid Application Development approach for
accelerated Win32 development with support for Windows Vista, AJAX, and
streamlined database connectivity. In the real world, developers need to be able to
develop applications that run on multiple platforms, not just the latest and greatest. Most
new machines come with Windows Vista, while existing machines will continue
running Windows 2000 or XP. Developers must support this mixed-use environment,
because they can't count on their organization or customers upgrading en masse. They
have to meet the demand for critical new technologies and trends in marketplace by
including support for these technologies in their applications, but they want to retain the
flexibility of developing on the platform that is most productive for them. Access
database is one of the the world's most popular database because of its consistent fast
performance, high reliability and ease of use. In Microsoft Access 2003, you can view
information on dependencies between database objects. Viewing a list of objects that
use a specific object helps maintain a database over time and avoid errors related to
missing record sources. For example, the Quarterly Orders query in the Sales database
is no longer needed, but before deleting it, you might want to find out which other
objects in the database use the query. Then, you could either change the record source
of the dependent objects, or delete them, before deleting the Quarterly Orders query.
Viewing a complete list of dependent objects helps you save time and minimize
errors.In addition to viewing the list of objects that are bound to a selected object, you
can also view the objects that are being used by the selected object.Macros, modules,
and data access pages are not searched for dependencies. Access projects do not support
this feature.
11
Table of Contents
ACKNOWLEDGEMENT I
ABSTRACT II
TABLE OF CONTENTS III
INTRODUCTION 1
1. 1 Introduction to Delphi 2
1 .2 What is Delphi? 2
1 .2. 1 Delphi Compliers 2
1.2.2 What kind of programming can you do with Delphi? 3
1 .2.3 History of Delphi 4
1.2.4 Advantages & Disadvantages Delphi 6
1.3 Delphi 6 Editions 7
1.3.1 Delphi 6 Architect. ?
1 .3 .2 Installation Delphi 6 8
1 .4 A Tour of the Environment.. , 1O
'
1 .4. 1 Running Delphi for the First Time 1O
1 .4.2 The Delphi IDE 11
1.4.3 The Menus & Toolbar 12
1 .4.4 The Component Palette , 12
1 .4.5 The Code Editor 13
1 .4.6 The Object Inspector 14
1.4.7 The Object TreeView 15
1 .4.8 Class Completion 16
1 .4.9 Debugging applications 17
1 .4. 1 O Exploring Databases 18
1.4.11 Templates and the Object Repository 19
1.5 Programming with Delphi 20
1.5.1 Starting a New Application ; 20
1.5.2 Setting Property Values - 21
1.5.3 Adding objects to the form 22
1 .5.4 Add a Table and a StatusBar to the Form 22
1.5.5 Connecting to a Database , l'ı ••.••.••.••••.••.••.••••• 24
lll
2.9.1 Simple Code Base Report .40
2.9.2 Tabular Code Based Report .41
2.9.3 Graphical Code Based Report .43
2. 1 O Visually Designed Reports 45
2.10.1 The Visual Designer .45
2.10.2 Interacting with the Project.. .48
2.11 Data Aware Reports 55
2.11 .1 The Database Connection 55
2.11.2 The Driver Data View 55
2.11.3 Regions and Bands 58
2.11.4 Adding Fields : 59
2.11.5 Adding the Report to Your Project.. 60
CONCLUSION 69
REFERENCES 70
APPENDIX 71
ıv
INTRODUCTION
••
1
CHAPTER 1
Delphi is based around the Pascal language but is more developed object orientated
derivative. Unlike Visual Basic, Delphi uses punctuation in its basic syntax to make the
program easily readable and to help the compiler sort the code. Although Delphi code is
not case sensitive there is a generally accepted way of writing Delphi code. The main
reason for this is so that any programmer can read your code and easily understand what
you are doing, because they write their code like you write yours.
For the purposes of this series I will be using Delphi 6. Delphi 6 provides all the tools
you need to develop test and deploy Windows applications, including a large number of
so-called reusable components.
Borland Delphi provides a .cross platform solution when used with Borland Kylix -
Borland's RAD tool for the Linux platform.
2
• Turbo Delphi: Free industrial strength Delphi RAD (Rapid Application
Development) environment and compiler for Windows. It comes with 200+
components and its own Visual Component Framework.
• Turbo Delphi for .NET: Free industrial strength Delphi application development
environment and compiler for the Microsoft .NET platform.
You probably won't be using it to write embedded systems for washing machines,
toasters cir fuel injection systems, but for more or less anything else, it can be used (and
the chances are that probably someone somewhere hasl)
• Graphics Applications
• Multimedia Applications
~
• Image processing/Image recognition
• Data analysis
. ••
• System tools
This is not intended to be an exhaustive list, more an indication of the depth and breadth
of Delphi's applicability. Because it is possible to access any and all of the Windows
API, and because if all else fails, Delphi will allow you to drop a few lines of assembler
code directly into your ordinary Pascal instructions, it is possible to do more or less
3
anything. Delphi can also be used to write Dynamically Linked Libraries (DLLs) and
can call out to DLLs written in other programming languages without difficulty.
Because Delphi is based on the concept of self contained Components (elements of code
that can be dropped directly on to a form in your application, and exist in object form,
performing their function until they are no longer required), it is possible to build
applications very rapidly. Because Delphi has been available for quite some time, the
number of pre-written components has been increasing to the point that now there is a
component to do more or less anything you can imagine. The job of the programmer has
become one of gluing together appropriate components with code that operates them as
required.
The chief architect behind Delphi, and its predecessor Turbo Pascal , was Anders
Hejlsberg until he was headhunted in 1996 by Microsoft , where he worked on Visual
J++ and subsequently became the chief designer of C Sharp programming language C#
and a key participant in the creation of the Microsoft .NET Framework.
••
In 2001 a Linux version known as Kylix programming tool Kylix became available.
However, due to low quality and subsequent lack of interest, Kylix was abandoned after
•
version 3.
Support for Linux and Windows cross platform development (through Kylix and the
CLX component library) was added in 2002 with the release of Delphi 6.
Delphi 8, released December 2003, was a .NET -only release that allowed developers to
compile Delphi Object Pascal code into .NET Microsoft Intermediate Language MSIL.
It was also significant in that it changed its IDE for the first time, from the multiple-
4
floating-window-on-desktop style IDE to a look and feel similar to Microsoft's Visual
Studio.NET.
Although Borland fulfilled one of the biggest requests from developers (.NET support),
it was criticized both for making it available too late, when a lot of former Delphi
developers had already moved to C#, and for focusing so much on backward
compatibility that it was not very easy to write new code in Delphi. Delphi 8 also lacked
significant high-level features of the c sharp, C# language, as well as many of the more
appealing features of Microsoft's Visual Studio IDE. (There were also concerns about
the future of Delphi Win32 development. Because Delphi 8 did not support Win32,
Delphi 7. 1 was included in the Delphi 8 package.)
The next version, Delphi 2005 (Delphi 9), included the Win32 and .NET development
in a single IDE, reiterating Borland's commitment to Win32 developers. Delphi 2005
includes design-time manipulation of live data from a database. It also includes an
improved IDE and added a "for ... in" statement (like C#'s for each) to the language.
However, it was criticized by some for its bugs; both Delphi 8 and Delphi 2005 had
stability problems when shipped, which were only partially resolved in service packs.
In late 2005, Delphi 2006 was released and federated development of C# and
Delphi.NET, Delphi Win32 and C++ into a single IDE. It was much more stable than
Delphi 8 or Delphi 2005 when shipped, and improved even more after the service packs
and several hot fixes.
On February 8, 2006, Borland announced that it was looking for a buyer for its IDE and
•
database line of products, which include Delphi, to concentrate on its Application
Lifecycle Management ALM line. The news met with voluble optimism from the
remaining Delphi users.
On September 6, 2006, The Developer Tools Group (the working name of the not yet
spun off company) of Borland Software Corporation released single language versions
of Borland Developer Studio, bringing back the popular "Turbo" moniker. The Turbo
product set includes Turbo Delphi for Win32, Turbo Delphi for .NET, Turbo C++, and
5
Turbo C#. Each version is available in two editions: "Explorer" a free downloadable
version and "Professional" a relatively cheap (US$399) version which opens access to
thousands of third-party components. Unlike earlier "Personal" editions of Delphi, new
"Explorer" editions can be used for commercial development.
On November 14, 2006, Borland announced the cancellation of the sale of its
Development tools; instead of that it would spin them off into an independent company
named "CodeGear"
6
Disadvantages:
• Access to platform and third party libraries require header files to be translated
to Pascal. This creates delays and introduces the possibilities of errors in
translation.
• There are fewer published books on Delphi than on other popular programming
languages such as C++ and C#
• A reluctance to break any code has lead to some convoluted language design
choices, and orthogonally and predictability have suffered
Delphi 6 Architect is designed for professional enterprise developers who need to adapt
quickly to changing business rules and manage sophisticated applications that
synchronize with multiple database schemas. Delphi 2006 Architect includes an
advanced ECO III framework that allows developers to rapidly deploy scalable external
7
facing Web applications with executable state diagrams, object-relational mapping, and
transparent persistence.
Delphi 6 Architect includes all of the capabilities of the Enterprise edition, and includes
the complete ECO III framework, including new support for ECO State Machines
powered by State Chart visual diagrams, and simultaneous persistence to multiple and
mixed database servers.
We are prompted to select a product to install; you only have one choice "Delphi 6":
While the setup runs, you'll need to enter your serial number and the authorization key
(the two you got from inside a CdRom driver).
8
~la:IJiı,•tWJ~'M,;,jjl·İı'.«'·
~r..v,,:i,,
After that, you have to pick the Setup Type, choose Typical. This way Delphi 6
Enterprise will be installed with the most common options. The next screen prompts
you to choose the Destination folder.
At the end of the installation process, the set-up program will create a sub menu in the
Programs section of the Start menu, leading to the main Delphi 6 Enterprise program
plus some additional tools.
9
I;; Borland Delphi 13 ~
I
Figure 1.5 Start Menu
• Choose Programs I Borland Delphi 6 I Delphi 6 from the Windows Start menu
• Choose Run from the Windows Start menu and type Delphi32
• Double-click Delphi32.exe in the $(DELPHI)\Bin folder. Where $(DELPHI) is a
folder where Delphi was installed. The default is C:\Program
Files\Borland\Delphi6.
• Double-click the Delphi icon on the Desktop (if you've created a shortcut)
Borland Delphi.ô •
10
1.4.2 The Delphi IDE
As explained before, one of the ways to start Delphi is to choose Programs I Borland
Delphi 6 I Delphi 6 from the Windows Start menu.
When Delphi starts (it could even take one full minute to start - depending on your
hardware performance) you are presented with the IDE: the user interface where you
can design, compile and debug your Delphi projects.
Like most other development tools (and unlike other Windows applications), Delphi
••
IDE comprises a number of separate windows.
•
Some of the facilities that are included in the "Integrated Development Environment"
(IDE) are listed below:
• A syntax sensitive program file editor
• A rapid optimizing compiler
• Built in debugging /tracing facilities
• A visual interface developer
• Syntax sensitive help files
• Database creation and editing tools
11
• Image/Icon/Cursor creation I editing tools
• Version Control CASE tools
speed bar
."
component palette
The title bar of the main window contains the name of the current project (you'll see in
some of the future chapters what exactly is a Delphi project). The menu bar includes a
dozen drop-down menus - we'll explain many of the options in these menus later
through this course. The toolbar provides a number of shortcuts to most frequently used
operations and commands - such as running a project, or adding a new form to a project.
To find out what particular button does, point your mouse "over" the button and wait for
the tool tip. As you can see from the tool tip (for example, point to [Toggle Form/Unit]),
many tool buttons have keyboard shortcuts ([F12]).
The menus and toolbars are freely customizable. I suggest you to leave the default
arrangement while working through the chapters of this course.
12
click to see \ı'ı/in32 controls
Depending on the version of Delphi (assumed Delphi 6 Personal through this course),
you start with more than 85 components at your disposal - you can even add more
components later (those that you create or from a third party component vendor).
The components on the Component Palette are grouped according to the function they
perform. Each page tab in the Component palette displays a group of icons representing
the components you can use to design your application interface. For example, the
Standard and Additional pages include controls such as an edit box, a button or a scroll
box.
To see all components on a particular page (for example on the Win32 page) you simply
click the tab name on the top of the palette. If a component palette lists more
components that can be displayed on a page an arrow will appear on a far right side of
the page allowing you to click it to scroll right. If a component palette has more tabs
(pages) that can be displayed, more tabs can be displayed by clicking on the arrow
buttons on the right-hand side. "
••
1.4.5 The Code Editor
Each time you start Delphi, a new project is created that consists of one *empty*
window. A typical Delphi application, in most cases, will contain more than one
window - those windows are referred to as forms.
In our case this form has a name, it is called Form 1. This form can be renamed, resized
and moved, it has a caption and the three standard buttons which are minimize,
maximize and close. As you can see a Delphi form is a regular Windows window
13
;s~;'.jf
Di~l:0!3a,;
!IBIS"
r-orm:ı ; TYcıCilll;
If the Forml is the active window and you press [F12], the Code Editor window will be
placed on top. As you design user interface of your application, Delphi automatically
generates the underlying Object Pascal code. More lines will be added to this window as
you ,add your own code that drives your application. This window displays code for the
current form (Forml); the text is stored in a (so-called) unit - Unitl. You can open
multiple files in the Code Editor. Each file opens on a new page of the Code editor, and
each page is represented by a tab at the top of the window.
14
lSffli,i•MAffi
!I Forrn1 _ .
;~ Pr~p~ı~es
ı, ..
t[çe~ı[l
-
For example, each form has a Caption (the text that appears on it's title bar). To change
the captions of Forml first activate the form by clicking on it. In the Object Inspector
find the property Caption (in the left column), note that it has the 'Forml' value (in the
right column). To change the captions of the form simply type the new text value, like
'My Form' (without the single quotes). When you press [Enter] the caption of the form
will change to My Form.
Note that some properties can be changed more simply, the position of the form on the
screen can be set by entering the value for the Left and Top properties - or the form can
be simply dragged to the desired location.
15
HJ·~ Default {Session}
;.~ Edit1
:·~ Edit2
-iğ Edit3
, . . rg lmage1
L ·!3J I mage3
: ·W I rnage4
i· r;ı I rnage5
L ..~ lrnagelist1
l-4 lrnagelist2
! . eJ Label1
ı ;.
i. ..!]j.,.;:,.
• /-·{;il
Label2
Label3
!. ,.....~ I :.hol..1
The Object TreeView, Object Inspector and the Form Designer (the Forml window)
work cooperatively. If you have an object on a form (we have not placed any yet) and
click it, its properties and events are displayed in the Object Inspector and the
component becomes focused in the Object TreeView.
To configure Class Completion, choose Tools I Environment Options and click the
Explorer tab.
16
Type Library I Environment Variables I Delphi Direct I Internet
Preferences I Designer I Object Inspector I Palette l Librar}' Explorer
17
Run
t-
. t, Run F9 W(
rI V
I
Parameters...
· fı< Regb.-te. r Active>: Ser. veı
Uııre,;;ıi:;ter ,6,ctive>'. ~erv0,
Install ::oM+ obıects
\
· Cl!" Step Over
c:ı Tr ace Into
·~~ Trace to Next Source Line
'ITH Run to Cursor
FS
F7
Shift+F7
F4
I
Run Until Retum Shift+FC:
_ Show Execution Point
mı Pro,;ıram Pause
m Program Reset Ctrl+F2
~I It,. Inspect ..
('Qj
Evaluate/Modify ...
+ Add Wateh ...
Ctrl+F7
Ctrl+F5
L Add Breakpoint
Figurel.14 Run
To use the debugger, you must compile your program with debug information. Choose
Project I Options, select the Compiler page, and check Debug Information. Then you
can begin a debugging session by running the program from the IDE. To set debugger
options, choose Tools I Debugger Options.
Many debugging windows are available, including Breakpoints, Call Stack, Watches,
Local Variables, Threads, Modules, CPU, and Event Log. Display them by choosing
View I Debug Windows. To learn how to combine debugging windows for more
convenient use, see "Docking tool windows". •
18
Definition Dal.a
rs;;ın
:678
!cinsi
Ekran Karlı
456 Harddisk
013 Hoıddisk
'012 Anakarl
011 Cdrom dg
-
New j ActiveX I Multitier l Project1 l Forms I Dialogs I Projects I Data Modules
• ii
Batch File
~
CLX
Application
- @
Component
[~1
Console
Application
~
Control Panel
Application
~
Control Panel
Module
[] ~
r
~ Eel ;;:;;;;;;;
~
Data Module DLL Wizard Form Frame Package Project Group Report
Service
~
Service
m
Te:-:t
~
Thread Object
~
Unit
~.
Web Server
I
Reso. urce DLL Application
Wizard Application
~
XML Data
Binding
I
r
_J. I OK I_.~ t[elp
19
You can add your own objects to the Repository to facilitate reusing them and sharing
them with other developers. Reusing objects lets you build families of applications with
common user interfaces and functionality; building on an existing foundation also
reduces development time and improves quality. The Object Repository provides a
central location for tools that members of a development team can access over a
network.
Before beginning a new application, create a folder to hold the source files.
1. Create a folder in the Projects directory off the main Delphi directory.
2. Open a new project.
Each application is represented by a project. When you start Delphi, it opens a blank
project by default. If another project is already open, choose File I New Application
to create a new project. When you open a new project, Delphi automatically creates
the following files.
• Projectl .DPR : a source-code file associated with the project. This is
called a project fıJe.
• Unitl.PAS : a source-code file associated with the main project form.
This is called a unit file.
• Unitl .DFM : a resource file that stores information about the main
project form. This is called a form file.
3. Choose File I Save All to save your files to disk. When the Save dialog appears,
navigate to your folder and save each file using its default name.
Later on, you can save your work at any time by choosing File I Save All.
20
When you save your project, Delphi creates additional files in your project directory.
You don't need to worry about them but don't delete them.
When you open a new project, Delphi displays the project's main form, named Forml
by default. You'll create the user interface and other parts of your application by placing
The default form has maximize, minimize buttons and a close button, and a control
menu
Next to the form, you'll see the Object Inspector, which you can use to set property
values for the form and components you place on it.
•
The drop-down list at the top of the Object Inspector shows the current selected object.
When an object is selected the Object Inspector shows its properties.
21
Find the form's Color property in the Object Inspector and click the drop-down list
displayed to the right of the property. Choose clAqua from the list.
Components
Component palette tabs
"'
When you find the Table component, click it once to select it, and then click on the
form to place the component. The Table component is non visual, so it doesn't matter
22
where you put it. Delphi names the object Table 1 by default. (When you point to the
component on the form, Delphi displays its name--Table 1--and the type of object it is-
Table.)
....
. •G•
Ol1, • •
.~~.--•:
. • Tabieı: TTable I
Select Tablel op the form, and then choose the DatabaseName property in the Object
Inspector. Select DBDEMOS from the drop-down list.
23
'.:.ti Form1
i3 l?'ı
Default {Session}
E ~ij DBDEMOS {Alias}
l±l·? 4, <?> {Table1}
Table1 TT able
Properties Events I I
,~ AutoRefresh Fabe . J
i .CachedUpdat. False , .
Constraints fT CheckConstraints,ı
DatabaseNamelDB DEMOS
. Exc~~ve ı
'["" Fi;ldİ5;f; DefaultDD ·
:!-"'"""'·" ·""""''·"'''""'""
j Filter Excel Files
("""i:iİt~·;;d IBLocal
ıt~r~1:?t!rs:. ~e~i·~:cess D etebese I~
; : sinem
lndexFıeldNaımı:-=.c~---__J
r~f.~t~~:,ıli~~~;~,i;j
i
Double-click the StatusBar component on the Win32 page of the Component palette.
This adds a status bar to the bottom of the application.
Set the AutoHint property of the status bar to True. The easiest way to do this is to
double-click on False next to AutoHint in the Object Inspector. (Setting AutoHint to
• •
True allows Help hints to appear in the status bar at runtime.)
24
1. From the Data Access page of the Component palette, drop a DataSource
component onto the form. The DataSource component is non visual, so it doesn't
matter where you put it on the form. Set its DataSet property to Table 1.
2. From the Data Controls page, choose the DBGrid component and drop it onto
your form. Position it in the lower left comer of the form above the status bar,
and then expand it by dragging its upper right comer.
If necessary, you can enlarge the form by dragging its lower right comer. Your form
should now resemble the following figure:
The Data Control page on Component palette holds components that let you view
database tables .
. .•~.. •·
~ı- D-+I·
,ı.,.-
.
.• ".'9:-.ıı: J .
••
......
.. . . . .
. . " .. ·•· ..
25
3. Set DBGrid properties to align the grid with the form. Double-click Anchors in
the Object Inspector to display akLeft, ak'Top, akRight, and akBottom; set them
all to true.
4. Set the DataSource property of DBGrid to DataSourcel (the default name of the
DataSource component you just added to the form).
Now you can finish setting up the Tablel object you placed on the form earlier.
5. Select the Tablel object on the form, and then set its TableName property to
BIOLIFE.DB. (Name is still Tablel.) Next, set the Active property to True.
When you set Active to True, the grid fills with data from the BIOLIFE.DB database
table. If the grid doesn't display data, make sure you've correctly set the properties of all
the-objects on the form, as explained in the instructions above. (Also verify that you
copied the sample database files into your ... \Borland Shared\Data directory when you
installed Delphi.)
26
The DBGrid control displays data at design time, while you are working in the IDE.
This allows you to verify that you've connected to the database correctly. You cannot,
however, edit the data at design time; to edit the data in the table, you'll have to run the
application.
6. Press F9 to compile and run the project. (You can also run the project by
clicking the Run button on the Debug toolbar, or by choosing Run from the Run
menu.)
7. In connecting our application to a database, we've used three components and
several levels of indirection. A data-aware control (in this case, a DBGrid)
points to a DataSource object, which in tum points to a dataset object (in this
case, a Table). Finally, the dataset (Tablel) points to an actual database table
(BIOLIFE), which is accessed through the BDE alias DBDEMOS. (BDE aliases
are configured through the BDE Administrator.)
This architecture may seem complicated at first, but in the long run it simplifies
development and maintenance. For more information, see "Developing database
applications" in the Developer's Guide or online Help.
••
27
CHAPTER2
=
~RavePrciiect
,-~, ..;~- .
l
·
ı;;:1""%,i' Report Lıbrary
Ei l]füı R eport1
[ill] Page1
-~ Globel Page Catalog
Sl···@, Data View Dictionary
,:, ../'tını D etebesel
28
2.2 Design Tools
Rave is all about easy management. Besides making reporting easy and organized, Rave
likes to keep itself organized and all according to what you want.
Since Rave is designed to be of ease to you there are three easy three ways for you to
manage the many toolbars within Rave, which are:
• Tab-docking
• Normal docking
• Free-floating
Rave's many toolbars make it easy to design even the most complicated report. The
toolbars include: Project, Designer, Zoom, Alignment, Color, Line, Font, Standard,
Drawing, Report and Barcode component toolbars. Since it is possible to create and
install new components, you ••may have other component toolbar buttons in your
designer.
The Project toolbar provides quick access to project level functions such as New
Project, Project Open, Project Save, New Report, New Global Page, New Data View,
New Report Page or Execute Report.
29
Figure 2.4 Designer Toolbar
The Designer toolbar allows you to change the characteristics of the Page in the Visual
Designer. Characteristics such as whether the grid is being shown, snap to grid, draw
grid on top, show band headers, show rulers, and show the waste area of the page. The
last button brings up Rave's extensive Preferences dialog, which is described later.
When you are working on a report with a complex design, you will find it much easier
if you become familiar with the Zoom toolbar, which gives you quick access to Rave's
extensive zooming capabilities. Select the zoom percent from a drop down list, type it in
or use the Zoom Tool, Zoom In, Zoom Out, Zoom Selected, Zoom Page Width or Zoom
Whole Page buttons.
• ••
To help keep your report looking professional, Rave's Alignment toolbar provides
access to a whole host of options to micro-manage the components on your page. The
Left/Top, Center, Right/Bottom, Center In Parent, Space Equally, Equate
Widths/Heights options offer the traditional alignment options. The Move Forward,
Move Behind, Bring to Front and Send to Back order movement buttons allow you to
change the print order of components and are visually backed up by the listing of the
components in the Project Tree. Lastly, the buttons Tap Left, Tap Right, Tap Up and
30
Tap Down allow you to micro-adjust the position of components to the exact position
you need.
The Color toolbar allows you to quickly select the primary and secondary colors of your
components. There are 8 color spots that you can use to store any custom colors that
you will be reusing throughout the project. If the colors available aren't enough, you can
double click on the custom color palettes and create a different color using Rave's Color
Editor (shown at right). With the Color Editor, you can select from a wider variety or
colors or create your own combination of Red, Green and Blue and even select a
percent saturation for the current color.
I Color Editor D
II Current Color - Yellow (25%)
,;J.fJlY_<·_;,~,,--)t>iöl'·':i•'''k 0f.~A•>??. '>···,-,~·, ···"'°"'·-=·• QK
The Line toolbar is a useful tool for changing the line/border thickness and style for
components such as Line and Circle. Sizes are listed in points instead .•of pixels so that
your lines will always be the same thickness on your reports no matter the resolution of
31
The Font toolbar provides quick access to a text component's font and alignment
properties. It can also be useful for quickly viewing the font options for the currently
This is where Rave's Mirroring technology comes in. When a component is set to mirror
another, it assumes the appearance and properties of the component it is mirroring. The
two components can be on the same page, across pages within the same report or on a
global page. This is the primary purpose of a global page. You can almost think of it
like an Object Repository, a central location for you to store reporting items that you
want accessible to more than one report. If the component is a container control like
TRaveSection (similar to Delphi's TPanel), all child components are mirrored as well.
When the original component changes, all mirroring components will also change.
While the mirrored component ••cannot change it properties, you can add additional
Your customer wants a standard page header and footer on every page of their 50
reports. Now imagine you have all the reports done and your customer wants to change
The Old Way - You would need to open up all 50 report definitions and change them
one at a time.
32
The Rave Way - You would mirror the standard header and footer on each report you
create and then any changes would only have to be done in one location. Also, if the
standard header included a large bitmap, your reporting project would only contain a
single copy rather than the many copies that a traditional report designer would require.
You have to replicate a pre-printed form. The problem is there are 6 different variations
of this form with only minor differences between each.
The Old Way - Assuming a traditional report designer could even handle this type of
report, you would create the first form, cut and paste it into the second, make the minor
modifications, then repeat for the other 4 forms, ending up with 6 reports that would be
hard to maintain and take up a lot more memory.
The Rave Way - You would first create the common items of the form on a separate
page, then mirror those on each form and add the unique parts for each as needed. If
anything ever needed to be changed in the common section of the form, you would only
need to change it in one place and since you're sharing most of the form's content, the
report definitions take up much less room.
eject
E ~ Report Libr&ry
I I::::·~
ıntroductionReport
MasterDetailReport
Grouping Report
:-··- Mirror Report
~i-- DırtaMirrorReport
,t
±1 1""' USSection
=1 rt"" Intersection 1com~•rıy J
D Rectangle? fAddf1 I
lC1ti/P•-+-St:it'i +' "·+Zip- - - • - - - - -l
--,It' Sections ın;;;ıı.=.,---;;;;m.ı .. 1····-··········--
mtl Datalext2
TText1
TText2
F.!:1 rt_-Addr10rılySection
$ 1•• Addr1 Addr2Section
(t] ~-- AddressSection
I
MulUPogoR,pori
MeilMerç::ı~Report
TwoDetails
VV2TeıxForm
Invoice
~~ Global Page catalog
!±l ~ GlobalP&ge1
. f±l· ~ Globıı1Page2
1 1 E!-4> Data View Dictionary
!±l ~ CustomerDV
~ OrdersDV
~ BiolifeDV
l±! ~ ClientsDV
~ ltemsDV
33
Every text component has a F ontMirror property which you can assign to a F ontMaster
component. This will allow you to change the fonts of many text controls from a single
location. Imagine having Header, Body and Footer FontMaster components on a global
page and changing the appearance of all of your reports with just a few mouse clicks.
Text - This component is used to display fixed text on your report for items such as
column headers or report titles.
Memo - This component is used to display fixed text in a word wrapped fashion on your
"'
report. Using the MailMergeltems property and the Mail Merge Editor shown below,
you can create a mail merge
. .
type of report where Rave will replace tokens in the memo
text with a replacement string. Note that this replacement string can be edited with the
Edit button, which will display the Data Text Editor for quite a bit of extra functionality.
34
Bitmap - This component is used to display a bitmap (* .bmp). Through the FileLink
Metafile - This component is used to display a metafile (* .wmf). Through the FileLink
property you can reference a file on the hard disk.
FontMaster - This component is used to control the font characteristics of any text
control through their FontMirror properties. See Reuse and Maintenance for more
information.
Line - Draws a diagonal line. (This may not seem like a unique feature but did you
know that most Delphi reporting tools cannot create a diagonal line visually.)
Region - This component acts as a container for Band and DataBand components. To
create a composite or sub-report, simply drop more than one region on a page and add
35
·-
Report Ci
Band - This component is primarily used to create header and footer bands in a banded
style report. A Band component can only be created within a region and it's purpose is
controlled through the Band Style Editor shown below. The Band Style Editor displays
a virtual layout of all of your bands for the given print locations of each band or data
band. Note that you can create as many Bands as you like and a Band may print in
multiple locations if the report design requires it. So for example, if you want a solid
horizontal line to appear above and below a detail body, you could create a single band
and set it to print on both the Body Header and Body Footer. You can also control the
Print Occurrence for a Band, having it continue on a new page or column or any
combination of occurrence settings. You can set a Band to group on specific fields and
can create as many different types of group headers or footers as your report requires.
Basically, with Rave's Band and DataBand components, you'll be able to create just
about any banded style layout that you can imagine.
36
DataBand - The DataBand component is fairly similar to a band component except that
it is tied to a particular Data View and iterates across the rows in the Data View. You can
link DataBands together for Master-Detail to unlimited levels or multiple details on the
same level. Some advanced features that are supported by a DataBand include
KeepBodyTogether, KeepRowTogther, StartNewPage, MaxRows and Orphan/Widow
control.
DataText - The DataText component is the primary means to output fields from your
database. You can quickly select a specific Data View and DataField with Property
Panel or use the Data Text Editor shown below to create any combination of string
constants, data fields, report variables or project parameters. The & concatenation
operator is the same as the + operator, except that it also inserts a space. Report
Variables are items such as total pages or current date and time in a variety of formats.
Project Parameters are custom variables that you create and initialize from your Delphi
application. Project Parameters can be used for items such as user defined report titles,
printing the current user name or other custom information.
Data Fields
Data View Dateı Field
Defautt
@ Selected [custornerDV -·
Data Text
'Page' & Report.CurrentPage& 'of' & Report.TotalPages
QK . J! I Çancel
37
DataMemo - This component is very similar to the Memo component except that it
retrieves data from a DataField. DataMemo component's print text data out in a word
wrapped fashion and the DataField can be any text type, not just memo fields. It also
CalcText - This component is used to perform simple operations such as Sum, Average,
Count, Min and Max on a data field. You can set the value as a running total and place
custom bitmaps.
Mirrored Section
Page2.USSection
38
2.7 Barcode Components
2.8 Anchors
Anchors are a powerful way to create a report that dynamically adjusts to changing
sizes. This allows you to create reports that can print well whether the user selects
landscape or portrait, 8.5" by 11" or A4. There are 6 different anchor values for both the
horizontal and vertical dimensions to allow you to control each component in exactly
the manner that it needs. The Anchor Editor (shown at right) even shows you a helpful
bitmap of how each anchor setting works.
"'
Vertical Anctıor Horizontal Anchor
0Iop O~ett
Q~ottom Q[lıght • ••
Oçenter @Cı;_nter
O~retch Ostretctı
0Res[ze QResi~e
osıı.read QSpreag_
·-;
I,.. ı
liiı Ill .
lk2
QK j [ Çancel j
39
2.9 Code Based Reports
Lately Delphi has decided to include Rave Reports as the default reporting solution,
replacing Quick Reports. Since they work in very different paradigms, many people
were confused by the new environment. This is intended as an introduction for people
who haven't worked with Rave yet, and would like to start.
Nowadays Delphi ships with Rave Reports 5.0.8. If you haven't already, download the
update from the registered users page, since it fixes some important problems.
You can develop reports with Rave using two different ways: Code Based or with the
Visual Designer.
With Code Based, you write reports using plain Delphi code. That provides a very
flexible way displaying any kind of data, allowing any kind of complex layouts.
To write a code based report, just drop a TRvSystem component on the form and write
the report on the OnPrint event handler. Sender is the report you are creating, and can
be typecasted to TBaseReport. It contains all the methods you need to output
information to that particular report.
40
To execute this report, call RvSystem.Execute method.
So, what does that simple code do? First, it calls SetFont to select the font and size of
the text that will be printed from that point on. Then it positions the cursor on the
coordinates (1, 1 ). These coordinates are expressed using the units set in the
SystemPrinter.Units property of the RvSystem object, and it defaults to Inches. You can
set it to unUser and set a number relative to Inches in the SystemPrinter.UnitsFactor
property. For example, if UnitsFactor was set to 0.5 then 1 unit would correspond to
half an inch. Finally, the code calls the Print method to output the text. Here's the
output:
o'.f 1
NewLine;
New Line;
ClearTabs;
SetTab(0.2, pjLeft, 1.7, O, O, O);
SetTab(l.7, pjRight, 3.1, O, O, O);
SetTab(3.l, pjRight, 3.5, O, O, O);
SetTab(3.5, pjRight, 4.5, O, O, O);
SetFont('Arial', 10);
Bold := True;
PrintTab('Folder Name');
PrintTab('Number of Files');
PrintTab('Number of Folders');
PrintTab('Size of Files');
Bold := False;
NewLine;
~
FolderList := TStringList.Create;
try
Root := IncludeTrailingPathDelimiter(ExtractFileDrive(ParamStr(O)) );
EnumFolders(FolderList, Root);
for i :=Oto FolderList.Count - 1 do
begin
PrintTab(FolderList[i]);
GetFolderlnfo(IncludeTrailingPathDelimiter(Root+FolderList[i]),
42
PrintT ab(F ormat('o/ou', [NumF olders]));
PrintTab(Format('o/ou bytes',[SizeFiles]));
NewLine;
end;
finally
FolderList.Free;
end;
end;
end;
Notice that a different approach has been taken: instead of specifying the coordinates of
each text output, the printing was done using Lines and Columns as references. The line
heigh depends on the size of the current font: each unit represents 1/72nds of an inch, so
each line printed with a size 10 font will have, aproximatelly, a height of 0.138 inches.
Lines are advanced after calls to PrintLn or NewLine. Colums are defined using calls to
the SetTabs method, and the PrintTab method will print the text in the current column
and advance to the next one. Here's the output:
var
Bitmap : TBitmap;
43
begin
with Report do
begin
Canvas.Brush.Color:= clGray;
Rectangle(0.3, 0.3, 4.7, 3.3);
SetFont('Arial', 15);
FontColor := clRed;
PrintXY(0.5,0.5, 'Just look at all the graphics!');
Bitmap := TBitmap.Create;
try
Bitmap.LoadFromFile('delphi.bmp');
PrintBitmap(3.5,0.3,l,l, Bitmap);
PrintBitmap(l,2,3,3, Bitmap);
Canvas.Pen.Color := clBlue;
Canvas.Brush.Bitmap := Bitmap;
Ellipse(S,0.3,6,3 .3);
Ellipse(2, 1 ,4, 1.9);
finally
Bitmap.Free;
end;
Canvas.Pen.Color:= clBlack;
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clYellow;
Pie(0.7,0.7,l.7,l.7,l,l,l,2); "'
Canvas.Brush.Color:= clGreen;
•
Pie(0.7 ,0.7 ,1.7 ,1.7 ,1,2, 1,1);
end;
end;
In this example the methods Rectangle, Ellipse and Pie have been used draw shapes
with different fills. Bitmaps were outputted using PrintBitmap and as the brush of the
44
Figure 2.22 Report Preview
To get started with the Rave Visual Designer, drop a TRvProject in a form. This will be
the link from your application to the reports you are developing. If you want, you can
add a TRvSystem and link your RvProject to it, through it's Engine property. The
RvSystem is the object responsible for the general configuration of the reports: the
printer that is going to be used, the margins, the number of pages, and so on. To start a
new project, double click the RvProject you added to the form, or select "Rave Visual
45
This is the interface that you will be working on:
,.~}P~a:P~:~:~: \'
·~ Global Page Cataio;
· 4> Data View Dictions'
The interface is simple, and you might be familiar with some parts of it from Delphi's
IDE. On the top there's the menu, the toolbar, and the component pallete that contain the
components that will be used in the reports. In the left there's the Object Inpector, which
will be used to adjust the properties of the components of the report. In the middle
there's the Page Designer or the Event Editor, and in the left there's the very usefull
Project Treeview. For a quick overview of the components in the pallete, you can go to
Nevrona's Visual Designer page.
A Rave Project File can have one or more reports. That way you can keep common
items between them in a single location, called Global Pages. If you expand the Report
Library node of the Project Treeview, you can see that right now you are working on
Reportl. Clicking on it, its properties will show on the Inspector. Let's change it's name
and call it SimpleReport. Next, go to the Standard tab on the Component Pallete, and
pick a Text component and add it to the page. Change its text property, and adjust its
size and position. Here's how it looks like:
46
Figure 2.24 Component Palette: Standard Tab
As you can see, the properties that were changed from the default values are shown in
bold. In this case, I changed the Font, Text and Truncate properties. By default it does
not highlight Name, Pos and Size changes. If you'd like to see them, right click the
Inspector and uncheck "Exclude Name, Size and Pos changes" in the context menu.
You might have also noticed that Rave does not have an auto size property. You can use
the Truncate property to have that effect: if truncate is false, the design time size will
have no effect.
You can see the result of this simple report right on the designer: Press F9 or use
File/Execute Report to run it. Now let's do it in our application. Save your project and
••
return to Delphi. Change to ProjectFile property of RvProject to point to the file you
just saved. To run the report, add a call to the Execute method of the RvProject object in
RvProject.Execute will only work for now because we only have one report in this
project. If we had multiple reports, we'd have to call SelectReport to choose one before
calling Execute, or calling ExecuteReport directly.
47
Here's the output:
<
~ı
t£l.
Tip: If you Close and Open your project before executing, you won't need to to
recompile your application or restart it to see the changes you just made in the designer.
You can only select the Project and a Report through the Project Treeview. A page,
however, can be selected using the Project Treeview or clicking on it's title above the
page designer.
Among other uses, you can print parameters. So, for instance, if the title of your report
can be user-defined , you could pass it from your application into the report as a
parameter.
48
Let's add a new report to this project to see how parameters work. To do that, click the
fourth button on the toolbar or choose File/New Report. Call it ParametrizedReport,
changing its name through the object inspector. This report is going to be very similar to
Now we need to define the parameter that is going to be printed. To do that, still having
the report as the selected object, open the property editor the the parameters property.
There should be listed all parameters of this report, each on a separate line. Add a
tsı:rin'ns~f:ditor
Name
I
;·. \\1
.. I
~ı .: ti
I
·ı_ .· ,ıi 0~' j' · -~'Çcimcel l,··ı
Figure 2.26 Strings Editor
Parameters can be printed using a DataText component, available in the Report tab of
the component pallete. Add a DataText to the page, and open the property editor of the
Datal ield property. There you can choose which field is going to be printed, when
working with DataAware reports. You can also choose Project Variables, Parameters
and Post-Initialize Variables from there.
So choose the parameter added previously from the Parameters drop-down combo and
press the Insert Parameter button. The data text expression is now Param.Name. Press
49
OK and try to execute the report, as before. Nothing is printed, since the parameter has
We need to set this parameter before printing. Don't forget to save your changes, and
return to Delphi, adding a call to SelectReport before Execute, so we can see the right
report. Before executing, though, we need to set the parameter we added. That is made
using RvProject's SetParam method. This is how my code looks like right now:
Now, when we execute the report, we are going to see the string we set as a parameter
printed.
Tip: You can use RvProject.GetReportList to get a list of avaible projects, and add them
to a ComboBox, or a RadioGroup, for example. That makes selecting the report easier.
But this is too simple. Let's change the expression that is going to be printed. Return to
Rave Designer and open the property editor for the DataText we added. You can add
••
any text you want, combining text, fields, parameters and variables. I changed it to this:
50
Here's the result:
Post-Initialize Variables
Post-Initialize Variables, or simply PI Vars, are variables whose value is only known
after the report has already been printed. It may sound strange, at first, but think about
the number of pages of a report, for example. We can only know it's value after the
report is ready. Actually TotalPages is a report variable that acts like a PI var, and can
easily be printed using DataTexts as we did with Parameters.
Global Pages
When you have parts of reports that are common to two or more reports, you can put
these in a global page. Let's supose we have a header with our company name, the date
and time that report is being printed, the current page and the number of pages of that
report. We want that header to be.in every report. How can we do it?
First, add a global page to the project, using File/New Global Page, or the Toolbar
shortcut. In that page, add a section component, available in the standard tab of the
component palette.
Sections are logical groupings of components. They can be used to group component so
they can be easily moved around the report or as containers for Mirrors, as we are doing
right now.
51
Inside that section we add what we want to be printed. In this case, a few DataTexts.
Hint: Instead of changing the font property of several components to the same font, link
them to a FontMaster component, available in the standard tab, and set the font on it.
That way is easier to change the font in the future, in case it's needed.
Now add another section to the Page1 of SimpleReport. Set its Mirror property to
GlobalPagel.Sectionl. You will see a copy of the header you created in the global page.
Do the same thing to ParametrizedReport. Now both reports share the same header.
=====--~~~~----~~~~~____:._~~~~~~~-~.
Introduction to Rave Reports
Page 1 ort
31 /08t2003 16:42
••
Conditional Printing
Sometimes ~e need to print certain parts of a reporting depending of some conditions.
Rave has a very powerful way of dealing with this. We can conditionally mirror
sections depending on field values or parameters. Let's create a new Report, calling it a
ConditionalReport.
52
Let's pretend that this new report is a trick one. The user can choose the header that is
going to be printed, from two different kinds of headers. He can also choose for the
report to be printed without a header. We are going to use a parameter to tell the report
what kind of header is going to be printed, and a DataMirrorSection to select the proper
header at runtime.
First, add a parameter to this new report called HeaderKind. Let's assume that it will
have the values HO (for no header), Hl (for the first header), H2 (for the second kind of
header). Now add a new section to the global page (you can reach it through the Project
Treeview), with the second kind of header layout. I created a header similar to the first
one, changing the font title and adding a border around the values. It looks like this:
53
Notice that I gave more meaningful names to each of the sections earlier.
Hint: You can use the OnMirrorValue event of the DataMirrorSection to work on
ranges of values.
Now return to Delphi and add the code to set the parameter according to the user's
choice. I added a ComboBox with the options and my code looks like this:
begin
RvProject. Open;
RvProject. SelectReport( cmbReports. Text,F alse);
case cmbReports.Itemindex of
1: RvProject.SetParam('Name',edName.Text);
2: RvProject. SetParam('HeaderKind' ,F ormat('H%d', [cmbHeaderKind.Itemindex]) );
end;
RvProject.Execute;
RvProject.Close;
end;
Now the proper header will be printed according to the user's choice.
.
When you deploy your application, you must include you project file. You can have it
as a separated file, so you can update it in a easier way, only shipping a new one,
without recompiling your application, or include it in your executable. It's easy to do
that: open the property editor for the StoreRAV property of RvProject. There you can
press Load to include the file in the DFM, Save to extract a previously saved file, and
Clear to remove an embedded file. When there's a file loaded in this property, you don't
54
2.11 Data Aware Reports
If you intend to deploy your application using Nevrona's Rave Report Server, you
should use Driver Data Views.
nnettıi:ır:ıs'
55
Choose Database Connection, and you will be asked which Data Link you are going to
be using. There is a folder called DataLinks where Rave has been installed, containing
some files with the .rvd extensions, responsible from the connection mechanism. By
default, you can choose between BDE, DbExpress and ADO. I'll be using BDE for this
example. Choose BDE, press Finish, and the Database Connection Parameters window
will show up. Every Data Link has a different set of connection parameters available,
similar to those available in the Delphi IDE. For now, just set Alias to DbDemos and
press OK. Notice that a Database object has been added to the Project Treeview, under
r,?fuvePrciiect
51·~ Report Library
,GJ llmJ Report1
·• ····· llifil Page1
: -~ Global Page Catalog
8··0- Data View Dictionary
. . ,ftj Database1
Notice that the settings you configured in the Database Connection Parameters, after the
wizard, including usemame and password, if applicable, were saved in the AuthDesign
property of the Database component. In the AuthRun property you can use different
settings to be used at runtime, when your report has been deployed.
We are going to create now the Driver Data View. Click on New Data Object, and then
choose Driver Data View. You"should now choose the Database Connection that is
going to be used by this Data View: choose the Database created in the previous step. A
Query Advanced Designer will show up. Drag andDrop the table customer.db from the
table list to the Layout window. It should look like this:
56
animais.dbf
customer_db {Tl l biolife db
RH·' l clients.dbf
O CustNo country.db
rı Company custoly.db
U Addr1 customer.db
0 Addr2 employee.db
O City events.db
O State holdings dbf
O Zip tf}\dbf
0
O Countr!,
Phone 1 u··."I.
··.ıı master.dbf
nextcust.db
0 F.6X ·'
nextitem.db
OT axRate r,;:.:-ıI nextord.db
O Contact
n I ~-•I~, .~:~~r...:,k .
[!iıı orders-db
parts.db
reservat.db
vendors.db
venues.db
EditGH; l
Figure 2.35 Query Advanced Designer Window
If you have more than one table, you should drag and drop fields that should be joined
between tables. If you press the Editor button you can check the generated SQL, or
type-in a more complex query. Let's keep the simple Customer Listing for now. Press
OK and a DriverDataView will be added to the Project Treeview, below the Database
components, having the selected fields as subitems:
57
Notice that I renamed the Database Connection and the Data Viewto more appropriate
names. It's in the Treeview where properties of the fields should be set, like the Display
Bands should be put inside Regions. Regions delimitate the width of the bands, and the
maximum height that bands can use before starting a new page. One page can have
Add a Region to the Page covering its whole area. Inside the region add a Band, to be
used as the report header, a DataBand, to print the customer information, and another
If you wish to change the ordering of existing bands in a report, use the Move Forward
Rename the bands to more meaningful names ,(I used Header, CustomerData and
Footer). Set the DataView property of CustomerData to DvCustomer, and set
CustomerData as the ControllerBand of the Header and Footer bands. You should also
run the Band Style Editor, from the Object Inspector, and set the Print Location of those
two bands to Body Header and Body Footer, respectively. You can have an idea on how
the report is going to be printed observing the Band Display as you change the settings.
It shows iterating bands repeated three times, and other bands only once:
58
, Header (8)
+ CustornerData (Master)
+ CustomerData (Master)
• Customerüata (Master)
1 FooterfM
We also want the Header to be printed in other pages in case the listing spans more than
one page: check the New Page option in the Print Occurrence groupbox, in that same
dialog.
The Footer band will only print when DvCustomers has reached its end. If you want it
printed in every page, regardless of that, just put the components directly on the page,
below the region, and not in a Band.
In the editor, you can quickly identify the relationship between bands, their styles and
their print occurrences:
. -··.. - --- . -- ...
..
[ ]J_E'.~gioiı1 i t:~ader,'
\ ,;j;;Re;~io~j:f-~~dr
Don't forget that you can use the tools on the Alignment Toolbar to align the
components, even if they are in different bands.
59
I added a title to the Header band and a simple text to the Footer band, indicating that
the listing has ended. Later on the series we are going to see how to use the Calcüp and
CalcTotal components to be able to add totals, averages and other calculated values to
the Footer.
ADO.
60
CHAPTER3
3 USERMANUAL
3.1 Enter Form
When user executes this program, first password enter screen appears. In this screen
user enters a password as seen in the figure 3. 1 below.If the user wants to leave the
program without entering , this can be done by clicking the EXIT button.
"'···~. 'flh ~· -- ..-· - ------- --~
iJJ E~Trn·
Figure 3.1
61
3.2 Main Form
After password are entered, main screen appears as seen in the figure 3 .2
below.RENT A ROOM and EXIT buttons exists in this form.When the user clicks
the RENT A ROOM button, HONEYHILL HOSTEL form shows up as you may
Figure 3.2
62
3.3 Honeyhill Hostel Form
There are five pages in this form .First page is the Customer Registration page
as you may see in the figure 3.4 below.And the other pages follow this pages
consecutively as Customer Registration Out,Search,Registries General Status,Rooms
General Status.
SURNAME
TEL
' ·:~
rsren DATE
110\\'MANYU'R
Figure 3.3
63
3.3.1 Customer Registration Page
In this page, there are six empty fields which are used for entering customer
information.One of these fields has fixed numbers as 1,2,3,4 related with the
number of the people who will be stayed in a room .When user clicks on one of
these numbers , a panel shows up on the right of the page with the rooms inside of it
and the rooms are displayed as blue if the chosen number suits to room ,because
some of rooms maybe full, if it happens like that the rooms are displayed as white. The
panel includes 2 empty fields and 20 rooms as rectangles with written room numbers
on them .One of these fields displays the unit price of the room and the other
displays the room no when the user move around mouse point over the rooms
.When the user clicks on a room these two fields catches the unit price and the room
number.After all informations are ensured , the user can save this customer registry .
After the registration process are completed for the customer , seems as active in
the system until the registration out process is completed by the user .
Figure 3.4
64
3.3.2 Customer Registration Out Page
This page was designed to make customer registries out or inactive.If the user enters
into the field of name one of the first letters that customer names have , all customer
infos as name , surname , roomno and customers.registerno shows up on the black
screen.If a complete customer name is entered into the name field ,only one line
shows up on the screen which is related with this customer.After the line appears,the
user clicks on the line and the empty fields which are on the left of the screen ,
catches the informations about the customer as surname ,leaving date ,unit price of the
room,enter date , howmany people have stayed in the room, howmany days have been
stayed on the hostel and the total price which is calculated by the program.When the
user press the Save Registration Out button , the process of making customer
inactive is being performed.If Registration Out Cancel button is pressed ,the process
of making customer inactive is canceled and the all fields are cleared.
tlJııtd[
L£AVIHGCDAT£
Figure 3.5
65
3.3.3 Search Page
There are options in this page to search customers as search by roomno,search by
name and search by the dates.It is possible to see the customers as active or inactive
on the screen.
;'#HON&YHILL,HO.STEL
---~ ...., . ., .... ·:· .... , ..... ' """' " .. ---=···"'-···~------..,,_.._.__.......,,. =--o,·:--~-----···-"''-:'-""'""-..--. -~---~ --~--,---
t CI.ISTOMJB_REGISTRATION J CUSTOMER REGISTRATION Ol!! fSEA~REGISTRlES'GENEAM. STATU$ J"ROOMS.GEt-!~~J.ı.L Ş.TA!!JS}: -
\1fil/J "·' ·=J, . .. - ·' "' .
Figure 3.6
66
3.3.4 Registries General Status
There are three options to see the registries.First the user can choose the all the
registries box and the all registries appear on the screen .If the user wants to see
the acrive registries ,active registries box is choosed and the all active registries
show up on the screen .The user can use the nonactive registries box which is the
last option and after that user sees the all nonactive registries on the screen.
Figure 3.7
67
3.3.5 Rooms General Status
In page you can see the rooms fullness status with the ratios.There are 20 panels
on the page with shape of rectangles.If the user presses the 'Show the fullness ratio
button' ,the ratios appears in the rectangles.If the roomno 102 is full ,the ratio
appears as 2/2 or if the user presses the other button which is 'Show the being empty
ratio' and if the room 102 is full ,it appears as 0/2 .If the room which is for 4
people has 3 people inside of it the fullness ratio appears for this room as 3/4 and the
being empty ratio appears as 1/4.
Figure 3.8
68
CONCLUSION
It was a really good decision for me to use Delphi as programming language and
Access as a database.Because I succeeded everything that I have planned before
started to my project.In the most situations I used the internet and searched some
books.I had some difficulties with the SQL commands and programming in this
project.But with the help of the some books and internet, I accomplished.
This program is enough for a hostel to register its customers and control this
registration .With making some extra additions , this program can be made more
functional.
••
69
REFERENCES
http://www.w3schools.com/sql
http://www.delphibasics.co.uk
Delphi 7 Ezel Balkan Book
Delphi 7 Zirvedeki Beyinler Nihat Demirli Yuksel lnan (ebook)
Borland Delphi 6 for Windows (e Book)
Mastering Delphi 6 - Mastering Delphi 7
70
APPENDIX
Program Codes
unit turgay;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB, DB, Grids, DBGrids, Mask, ExtCtrls, ComCtrls,
TabNotBk, DBCtrls;
type
TForm1 = class(TForm)
ads1: TADODataSet;
adq1: TADOQuery;
dsl: TDataSource;
TabbedNotebookl: TTabbedNotebook;
Label4: TLabel;
Label8: TLabel;
Label9: TLabel;
Labellü: TLabel;
Label13: TLabel;
Labe114:TLabel; ••
Edit5: TEdit;
Edit7: TEdit;
MaskEdit3: TMaskEdit;
MaskEdit4: TMaskEdit;
Button4: TButton;
ComboBoxl: TComboBox;
Labell: TLabel;
Edit2: TEdit;
71
Label2: TLabel;
DBGridl: TDBGrid;
Label5: TLabel;
Edit8: TEdi t;
Edit9: TEdit;
Label6: TLabel;
Edit4: TEdit;
Editl O: TEdit;
Buttonl: TButton;
Label3: TLabel;
Label 1 1: TLabel;
Editll: TEdit;
Label12: TLabel;
Edit12: TEdit;
Label 15: TLabel;
Label16: TLabel;
Edit13: TEdit;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton7: TRadioButton;
DBGrid2: TDBGrid;
GroupBox 1: TGroupBox;
Button2: TButton;
Label18: TLabel;
MaskEdit 1: TMaskEdit; .•.
MaskEdit2: TMaskEdit;
GroupBox2: TGroupBox;
Label19: TLabel;
Edit15: TEdit;
GroupBox3: TGroupBox;
Edit16: TEdit;
Button6: TButton;
DBGrid3: TDBGrid;
72
GroupBox5: TGroupBox;
GroupBox6: TGroupBox;
GroupBox7: TGroupBox;
GroupBox8: TGroupBox;
GroupBox9: TGroupBox;
GroupBoxlO: TGroupBox;
GroupBox 11 : TGroupBox;
GroupBox12: TGroupBox;
GroupBox 13: TGroupBox;
GroupBox14: TGroupBox;
GroupBox 16: TGroupBox;
GroupBox 1 7: TGroupBox;
GroupBox20: TGroupBox;
GroupBox21: TGroupBox;
GroupBox22: TGroupBox;
GroupBox23: TGroupBox;
GroupBox 18: TGroupBox;
GroupBox4: TGroupBox;
GroupBox 15: TGroupBox;
GroupBox 19: TGroupBox;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel; ••
Label25: TLabel;
Label26: TLabel;
Label27: TLabel;
Label28: TLabel;
Label29: TLabel;
Label30: TLabel;
Label31: TLabel;
Label32: TLabel;
73
Label33: TLabel;
Label34: TLabel;
Label35: TLabel;
Label36: TLabel;
Label3 7: TLabel;
Label38: TLabel;
Label39: TLabel;
Button8: TButton;
Button7: TButton;
Label40: TLabel;
Label4 l: TLabel;
Label42: TLabel;
Label43: TLabel;
Label44: TLabel;
Label7: TLabel;
GroupBox24: TGroupBox;
ol Ol: TPanel;
0201: TPanel;
0301: TPanel;
0401: TPanel;
0501: TPanel;
0502: TPanel;
0402: TPanel;
0302: TPanel;
0202: TPanel;
•
0102: TPanel;
0103: TPanel;
0203: TPanel;
0303: TPanel;
0403: TPanel;
0503: TPanel;
o104: TPanel;
0204: TPanel;
74
0304: TPanel;
0404: TPanel;
0504: TPanel;
Label54: TLabel;
Label53: TLabel;
Label52: TLabel;
Label5 l: TLabel;
Label50: TLabel;
Label48: TLabel;
Label47: TLabel;
Label46: TLabel;
Label45: TLabel;
Label49: TLabel;
Label 1 7: TLabel;
Edit14: TEdit;
Editl 7: TEdit;
Edit6: TEdit;
Editl: TEdit;
Edit3: TEdit;
Button3: TButton;
adc 1: TADOConnection;
Buttons: TButton;
75
procedure Edit2Change(Sender: TObject);
procedure Edit9Enter(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure RadioButtonl Click(Sender: TObject);
procedure RadioButtonlEnter(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Edit15Change(Sender: TObject);
procedure TabbedNotebooklChange(Sender: TObject; NewTab: Integer;
Y: Integer);
procedure o303MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Edit8Exit(Sender: TObject);
••
procedure MaskEdit3Exit(Sender: TObject);
procedure o201MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure o504MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure o301MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure o401MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure o501MouseMove(Sender: TObject; Shift: TShiftState; X,
76
Y: Integer);
procedure o102MouseMove(Sender: Tübject; Shift: TShiftState; X,
Y: Integer);
procedure o202MouseMove(Sender: Tübject; Shift: TShiftState; X,
Y: Integer);
procedure o302MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure o402MouseMove(Sender: Tübject; Shift: TShiftState; X,
Y: Integer);
procedure o502MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure o 103MouseMove(Sender: Tübject; Shift: TShiftState; X,
Y: Integer);
procedure o203MouseMove(Sender: Tübject; Shift: TShiftState; X,
Y: Integer);
procedure o403MouseMove(Sender: Tübject; Shift: TShiftState; X,
Y: Integer);
procedure o503MouseMove(Sender: Tübject; Shift: TShiftState; X,
Y: Integer);
procedure o 104MouseMove(Sender: Tübject; Shift: TShiftState; X,
Y: Integer);
procedure o204MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
...
procedure o304MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure o404MouseMove(Sender: Tübject; Shift: TShiftState; X,
Y: Integer);
procedure MaskEdit3KeyPress(Sender: Tübject; var Key: Char);
procedure Edit2KeyPress(Sender: Tübject; var Key: Char);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: Tübject);
77
private
{ Private declarations }
public
{ Public declarations }
end;
var
Forml: TForml;
gonder:integer;
cambaz:integer;
implementation
{$R *.dfm}
function fiyat_goster( oda: string) :integer;
begin
form l .adq l .close;
forml .adql .SQL.clear;
forml.adql.sql.add('select * from rooms where roomno=:oda');
end;
procedure TForml .Button4Click(Sender: Tübject);
•
begin
adsl.CommandText:='select * from customers';
ads l .Active:=true;
ads 1 .Insert;
ads l .FieldByName('identityno').AsString:=maskedit3 .Text;
ads l .FieldByName('name').AsString:=editS. Text;
ads 1 .FieldByName('sumame').AsString:=edit6.Text;
ads l .FieldByN ame('tel').AsString:=maskedit4. Text;
78
ads l .FieldByName('active').AsBoolean:=true;
adsl .Post;
gonder:=ads l .F ieldB yN ame('registerno').Aslnteger;
ads l .Active:=false;
ads l .Active:=true;
ads 1.Insert;
ads l .FieldByName('registerno').Aslnteger:=gonder;
ads l .FieldByName('howmany').value:=combobox l .Text;
adsl .FieldByName('roomno').AsString:=editl .Text;
ads l .FieldByName('enterdate').AsDateTime:=strtodate( edit7 .Text);
adsl.Post;
ads l .Active:=false;
adql.Close;
adq 1. SQL. Clear;
adql.SQL.Add('select * from rooms where roomno='"+editl.Text+'" ');
adql.Open;
adql.Edit;
adql .FieldByName('empty').Aslnteger:=adq l .fıeldbyname('empty').Aslnteger-
II
maskedit3. Text:='###########';
edit5.Text:=";
edit6.Text:=";
maskedit4.Text:=' ( ) - ';
edit7.Text:=";
combo box 1. Text:=' .. choose';
editl.Text:=";
end;
79
procedure TForml.Edit7Enter(Sender: Tübject);
begin
edit? .Text:=datetostr( date);
end;
begin
groupbox24.Visible:=true;
adql.Close;
adq l .SQL.Clear;
adql.SQL.Add('select * from rooms');
adql.Open;
adql.First;
repeat
Tpanel(F indcomponent(' o'+adq 1. fıeldbyname('roomno ').asstring)) .color: =clMenu;
adql.Next;
until adq l .Eof;
adql.Close;
adql.SQL.Clear;
adql.SQL.Add('select * from rooms where empty>=:bull');
adq l .Parameters(O] .Value:=strtoint( comboboxl .Text);
adql.Open;
if adq l .RecordCount<>O then begin
•
adq l .First;
repeat
Tpanel(F indcom ponent(' o'+adq l .fıeldbyname('roomno ') .asstring)) .color: =cl blue;
adql.Next;
until adq l .Eof;
end
else showmessage('NOPE');
end;
80
procedure Tforml.goster(Sender: Tobject);
var
gelen:Tpanel;
begin
gelen:=Tpanel(sender);
adq 1. Close;
adql.SQL.Clear;
adq 1 .SQL.Add('select * from rooms where roomno=bul2');
adq 1 .Parameters[O] .Value:=copy(gelen.Caption,2,3);
adql.Open;
if adq 1 .FieldByName('empty').value=O then begin showmessage('this room is full');
editl.Text:=";
editl 7.text:=";
end
else
editl .text:=copy(gelen.Caption,2,4);
editl4.Visible:=false;
editl 7.Visible:=true;
editl 7 .text:=inttostr( adq 1 .FieldByName('unitprice').value );
if (strtoint(adq 1 .FieldByName('capacity').AsString)<strtoint( comboboxl .Text))
then begin showmessage('THIS ROOM ISNT FOR YOU');
editl.Text:=";
editl 7 .text:=";
end;
•
if
(strtoint( adq 1 .FieldByName('capacity').AsString)>=(strtoint( comboboxl .Text))) and
(adql .FieldByName('empty').value<strtoint( comboboxl .Text)) then
showmessage('THIS ROOM IS FOR YOU BUT FULL');
end;
procedure TForml .Form.Create(Sender: TObject);
begin
adc 1 .Connected:=true;
81
I
groupbox24.Visible:=false;
editl 7.Visible:=false;
tabbednotebook l .Pagelndex:=O;
end;
procedure TF orm l .Edit8Enter(Sender: TObject);
begin
edit8.Text:=datetostr(date);
end;
begin
edit2.Text:=adq l .fieldbyname('name').AsString;
edit3 .Text:=adq l .fieldbyname('sumame').AsString;
edit4.Text:=adq l .fieldbyname('enterdate').Value;
editl O .Text:=adq l .fieldbyname('unitprice').Value;
editl l .Text:=adq l .fieldbyname('identityno').Value;
editl2.Text:=adq l .fieldbyname('howmany').Value;
end;
begin
•
adc l .Connected:=false;
end;
begin
adql.Close;
adq l .SQL.Clear;
82
from customers,custreg,rooms where
adq l .SQL.Add('select *
and customers.registemo=custreg.registemo and
rooms.roomno=custreg.roomno
active=true and name like:a');
adql.parameters[O].value:=edit2.text+'%';
adql.Open;
end;
begin
end;
var k:integer;
begin
adql.Close;
adq l .SQL.Clear;
customers,custreg where
* from
adq l .SQL.Add('select
(custreg.enterdate>=t 1) and
(customers.registemo=custreg.registemo) and
(custreg.leavingdate<=t2)');
adql .Parameters[O].Value:=maskeditl .text;
adq l .Parameters[l] .Value:=maskedit2.text;
•
adql.Open;
k:=O;
adq l .First;
while not adq l .Eof do begin
k:=k+l;
adq 1.Next; end;
if k=O then showmessage('THERE IS NO ANY REGISTRY BETWEEN THESE
DATES');
83
end;
begin
group box l .Visible:=true;
end;
begin
group box l .Visible:=true;
end;
begin
groupbox2.Visible:=true;
end;
begin
adq l .Close;
adql.SQL.Clear;
adql.SQL.Add('select ' from customers,custreg where
(custom ers.registerno-custreg.registemo) and (custreg.odano-'"+editl 6 .text+"')');
IN THIS ROOM');
end;
begin
adq l .Close;
adq l .SQL.Clear;
84
customers,custreg where
* from
adq l .SQL.Add('select
customers.registemo=custreg.registemo and name like:a');
adq l .Parameters[O] .Value:=editl 5.Text+'%';
adql.Open;
end;
var i:integer;
begin
adq l .close;
adql.SQL.Clear;
for i:=20 to 39 do
tlabel( find com ponent('label' +inttostr(i))). Caption:=";
end;
active=true');
adql.Open;
end;
85
procedure TForın l .RadioButton5Click(Sender: TObject);
begin
adql.Close;
adq l .SQL.Clear;
adq l .SQL.add('select identityno,name,surname,enterdate,leavingdate from customers
inner join custreg on customers.registemo=custreg.registemo where active=false');
adql.Open;
end;
begin
adq 1. Close;
adql.SQL.Clear;
adq 1.SQL.add('select
identityno,name,sunıame,active,roomno,howmany,enterdate,leavingdate from
adql.Open;
end;
var i:integer;
begin
adql.Close;
adql .SQL.Clear;
adql.SQL.Add('select * from rooms');
adql.Open;
i:=-1;
adqI .First;
while not adql .Eof do begin
i:=i+1;
86
TLabel(findcomponent('label'+inttostr(i+ 20))) .caption:=inttostr( strtoint( adq l .fieldbyna
me('capacity').asstring)-
adq l .fieldbyname('empty').asinteger)+'/'+adq l .fieldbyname('capacity').asstring;
adql.Next;
end;
end;
var i:integer;
begin
adq l .Close;
adq l .SQL.Clear;
adql .SQL.Add('select * from rooms');
adql.Open;
i:=-1;
adq l .First;
while not adq l .Eof do begin
i:=i+ l;
TLabel( findcomponent('label'+inttostr(i +20))) .caption:=inttostr( adq l .fieldbyname('empt
y').asinteger)+'/'+adq l .fieldbyname('capacity').asstring;
adql.Next;
end;
end;
procedure TForml .Buttonl Click(Sender: Tübject);
begin
adq l .Close;
adql.SQL.Clear; where
from rooms,customers,custreg
adq l .SQL.Add('select * and
and customers.registemo=custreg.registemo
rooms.roomno=custreg.roomno
customers .registemo=o l');
adq l .Parameters[O).Value:=cambaz;
87
adql.Open;
adql.Edit;
adql.FieldByName('leavingdate').AsDateTime:=strtodate(edit8.Text);
adq l .FieldByName('empty').Aslnteger:=adq l .FieldByName('empty').Aslnteger+strtoint
(edit12.text);
adq l .FieldByName('active').AsBoolean:=False;
adq l .FieldByName('total').Value:=strtoint( edit9.Text);
adql.Post;
editl l.Text:=";
edit2.Text:==";
edit3.Text:==";
edit4.Text:==";
edit8.Text:==";
edit9.Text:==";
editl O. Text:=";
edit12.Text:==";
edit13.Text:=";
end;
begin
if key=# 13 then begin
adq l.Close;
adq l .SQL.Clear;
adq l .SQL.Add('select * from customers,custreg where
(customers.registemo=custreg.registemo) and (custreg.roomno=='"+editl 6.text+"')');
adql.Open;
if adq l .RecordCount=O then showmessage('UNTIL NOW NOBODY HA VE STA YED
end;
88
end;
var k:integer;
begin
if key=# 13 then
begin
adq 1 .Close;
adql.SQL.Clear;
customers,custreg where
adq 1 .SQL.Add('select * from
(custreg.enterdate>=t 1) and
(customers.registemo=custreg.registemo) and
(custreg.leavingdate<=t2)');
adq 1 .Parameters[O] .Value:=maskeditl .text;
adq 1 .P ammeters [ 1]. Value: =maskedit2. text;
adql.Open;
k:=O;
adq 1.First;
while not adq 1 .Eof do begin
k:=k+l;
adq 1.Next; end;
ifk=O then showmessage('THERE IS NO REGISTRY BETWEEN THESE DATES');
end;
end;
Y: Integer);
begin
editl 4.Text:=inttostr(fıyat_goster(' 1 O 1 '));
89
•
end;
Y: Integer);
begin
edit 14.Text:=inttostr( fiyat_goster('303 '));
end;
begin
edit 13.Text:=floattostr( strtodate( edit8 .text )-adq l .fieldbyname('enterdate').AsDateTime );
end;
var
i,s:integer;
begin
s:=O;
for i:=1 to length(maskedit3.Text) do begin
if copy(maskedit3.Text,i,1)<>'#' then s:=s+ 1;
end;
••
if s<l l then showmessage('ENTER MORE CHARACTER');
end;
Y: Integer);
begin
editl 4.Text:=inttostr(fiyat_goster('20 l '));
end;
90
Y: Integer);
begin
edit 14.Text:=inttostr( fıyat_goster(' 504') );
end;
91
editl 4.Text:=inttostr(fiyat_goster('202') );
end;
Y: Integer);
begin
edit 14. Text:=inttostr( fiyat_goster('302') );
end;
Y: Integer);
begin
edit 14. Text:=inttostr( fiyat_goster('402') );
end;
Y: Integer);
begin
editl 4.Text:=inttostr(fiyat_goster(' 502 '));
end;
Y: Integer);
begin
editl 4.Text:=inttostr(fiyat_goster(' 103'));
••
end;
Y: Integer);
begin
editl 4. Text:=inttostr(fiyat_goster('203 '));
end;
92
procedure TForml.o403MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
editl 4.Text:=inttostr( fiyat_goster('403 '));
end;
Y: Integer);
begin
edit 14.Text:=inttostr(fiyat_goster(' 503 '));
end;
Y: Integer);
begin
editl 4.Text:=inttostr(fiyat_goster(' 104'));
end;
Y: Integer);
begin
edit 14. Text:=inttostr(fiyat_goster('204') );
end;
Y: Integer);
begin
edit 14.Text:=inttostr(fiyat_goster('304') );
end;
Y: Integer);
begin
93
edit 14. Text:=inttostr( fiyat_goster(' 404') );
end;
begin
if key=char(VK ~RETURN)then begin
key:=#0;
postmessage(Handle, WM_ NEXTDLGCTL,0,0);
end;
end;
begin
if key=char(VK _RETURN)then begin
key:=#0;
postmessage(Handle, WM_ NEXTDLGCTL,0,0);
end;
end;
begin
editl 1 .Text:=";
edit2.Text:=";
edit3.Text:=";
edit4.Text:=";
•
edit8.Text:=";
edit9.Text:=";
editlO.Text:=";
edit12.Text:=";
edit13.Text:=";
end;
94
var
a:integer;
begin
a:=messagedlg('ARE YOU SURE?',mtconfirmation,[ mbyes, mbno ],O);
if a=mryes then
application. Terminate;
end;
end.
95