Reports, as one of the typical output forms of system information, are an important function of most application systems that are extraordinary and important functions of MIS systems. Whether it has a good printing function is often related to the success or failure of the system to a certain extent. Delphi has strong reporting functions, but its reporting functions cannot meet our needs. Therefore, many Delphi experts have successively launched many excellent report controls (modules) as supplements to QuickReport, among which FastReport is a representative.
FastReport combines the advantages of QuickReport and ReportBuilder, it is small in size, fast in speed, and has all source code. When developing a drug treatment system, the author successfully produced a form-based report that was exactly the same as the drug acceptance form and drug allocation using FastReport 2.51. Let me introduce it to my friends below.
FastReport2.51 download address: http//www.skycn.com/soft/8805.Html.
Report requirements analysis
Friends working in the hospital know that when the drugs are put into the warehouse, they must fill out the drug acceptance form, and when the pharmacy staff receives the drugs, they must fill out the drug allocation form. The drug acceptance form and allocation form used by the author is not dedicated, but a general product acceptance form and allocation form. Unlike the reports used in department stores and telecommunications systems, its appearance is bar-shaped, and each sheet can be filled with five kinds of medicines, including the delivery unit, delivery order number, delivery unit, product name, specification, unit, price, Amount, etc., one style and triple combination.
To sum up, we can summarize the requirements of report design as follows:
1. Size: 21cm long and 10cm wide;
2. Each can print 5 kinds of medicines, and the subtotal of this page is found under the form.
3. When there are more than 5 drugs, start printing a new form. When there are less than 5 drugs, use blank lines to make up.
Report design
1. Open the FastReport report designer and design the "Drug Acceptance Form" according to Figure 1.
(The picture is large, please pull the scroll bar to watch)
In addition, the variables InHJ, OutHJ, CaHj, and LineCount represent "total in-store", "total out-store", "total difference" and "total data rows", and these variables will be assigned values in the program.
2. Press F11 to call up the object viewer, select Band2, and enter the following code in its OnBeforPRint event:
Begin
if LINE#-1 <>0 and LINE#-1 mod 5=0 then
Begin
showBandChild1
showBandband1
end
end
In the code, use the built-in function LINE# of FastReport to get the current line number. If the conditions are met, the header and Child3 will be displayed to start a new form.
3. Select Child3 and enter the following code in its OnBeforPrint event:
Begin
lin=lineCount //Assign value to this variable in the program
while lin mod 5<>0 do
Begin
showbandchild2 //Print empty lines
inclin
end
showBandchild3
end
The purpose of this code is to print blank lines if the last data line is not enough for a form to display.
4. Select Band3 and enter the following code in its OnBeforPrint event:
Begin
showbandchild1 // When the report is reached, the content at the bottom of the form is displayed
end
5. Save the report and return to the Delphi development environment.
Delphi Programming Part
In the Delphi programming part, we mainly complete the passing of the parameters required for the report. Because we need to access these parameters in several processes, we need to set these parameters as global variables:
Private
line1line2integer //Save line number
inputXjintemp //Subtotal entry into the warehouse, clear after every 5 lines, the same below
outXjoutemp //Output subtotal
CajiaXjcatempReal //Subtotal of price difference
Below is a list of codes for several main processes.
//Single form data merging process
procedure TInputForm.frDBDataSet1NextSender TObject
var
ReCountinteger
Begin
ReCount = Adoruku.RecordCount
Incline1 // This variable is transmitted to the report file to control the printing of empty lines
Incline2 // This variable controls the subtotal value
if not Adoruku.Eof then
Begin
inputXj=inputXj+ADORuku.fieldByName'Input Amount'.AsFloat
outXj=outXj+Adoruku.fieldByName'Out-deposit amount' .AsFloat
CajiaXj=CajiaXj+AdorukuJXCJ.AsFloat
end
// Clear the subtotal value after every 5 rows
if line2 mod 5 = 0 and ReCount>line2 div 5 5 then
Begin
intemp=inputXj
outemp=outXj
Catemp=CajiaXj
inputXj=0
outXj=0
CajiaXj=0
end
// Assign a value to the variable when it reaches the end of the dataset
if Adoruku.Eof then
Begin
intemp=inputXj
outemp=outXj
Catemp=CajiaXj
end
end
The above program was debugged and passed in Windows 2000/XP+Delphi6.0. So far, we have completed the design of the drug acceptance form, and other similar report designs can refer to the above process. Figure 2 is the preview effect of the report generated when the program is running.
(The picture is large, please pull the scroll bar to watch)