upreview.pas
上传用户:jiete_yjc
上传日期:2010-02-11
资源大小:422k
文件大小:5k
源码类别:

医药行业

开发平台:

Delphi

  1. unit upreview;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   FR_Ctrls, FR_View, ExtCtrls, FR_DSet, FR_DBSet, FR_Class, StdCtrls,udm;
  6. type
  7.   Tfpreview = class(TForm)
  8.     Panel1: TPanel;
  9.     frPreview1: TfrPreview;
  10.     frSpeedButton1: TfrSpeedButton;
  11.     frSpeedButton2: TfrSpeedButton;
  12.     frSpeedButton3: TfrSpeedButton;
  13.     frSpeedButton4: TfrSpeedButton;
  14.     frSpeedButton5: TfrSpeedButton;
  15.     frSpeedButton6: TfrSpeedButton;
  16.     frSpeedButton7: TfrSpeedButton;
  17.     frSpeedButton8: TfrSpeedButton;
  18.     frSpeedButton9: TfrSpeedButton;
  19.     frSpeedButton10: TfrSpeedButton;
  20.     frSpeedButton11: TfrSpeedButton;
  21.     frrk: TfrReport;
  22.     frdbrk: TfrDBDataSet;
  23.     frdbdj: TfrDBDataSet;
  24.     frdj: TfrReport;
  25.     procedure frSpeedButton4Click(Sender: TObject);
  26.     procedure frSpeedButton5Click(Sender: TObject);
  27.     procedure frSpeedButton6Click(Sender: TObject);
  28.     procedure frSpeedButton7Click(Sender: TObject);
  29.     procedure frSpeedButton8Click(Sender: TObject);
  30.     procedure frSpeedButton9Click(Sender: TObject);
  31.     procedure frSpeedButton10Click(Sender: TObject);
  32.     procedure frSpeedButton1Click(Sender: TObject);
  33.     procedure frSpeedButton2Click(Sender: TObject);
  34.     procedure frSpeedButton3Click(Sender: TObject);
  35.     procedure FormActivate(Sender: TObject);
  36.     procedure frSpeedButton11Click(Sender: TObject);
  37.     procedure FormKeyDown(Sender: TObject; var Key: Word;
  38.       Shift: TShiftState);
  39.     procedure frrkManualBuild(Page: TfrPage);
  40.     procedure frdjManualBuild(Page: TfrPage);
  41.     
  42.   private
  43.     { Private declarations }
  44.   public
  45.     { Public declarations }
  46.   end;
  47. var
  48.   fpreview: Tfpreview;
  49. implementation
  50. {$R *.DFM}
  51. procedure Tfpreview.frSpeedButton4Click(Sender: TObject);
  52. begin
  53.   frPreview1.First;
  54. end;
  55. procedure Tfpreview.frSpeedButton5Click(Sender: TObject);
  56. begin
  57.   frPreview1.Prev;
  58. end;
  59. procedure Tfpreview.frSpeedButton6Click(Sender: TObject);
  60. begin
  61.   frPreview1.Next;
  62. end;
  63. procedure Tfpreview.frSpeedButton7Click(Sender: TObject);
  64. begin
  65.   frPreview1.Last;
  66. end;
  67. procedure Tfpreview.frSpeedButton8Click(Sender: TObject);
  68. begin
  69.   frPreview1.LoadFromFile;
  70. end;
  71. procedure Tfpreview.frSpeedButton9Click(Sender: TObject);
  72. begin
  73.   frPreview1.SaveToFile;
  74. end;
  75. procedure Tfpreview.frSpeedButton10Click(Sender: TObject);
  76. begin
  77.  
  78.   frPreview1.Print;
  79. end;
  80. procedure Tfpreview.frSpeedButton1Click(Sender: TObject);
  81. begin
  82.   frPreview1.OnePage;
  83. end;
  84. procedure Tfpreview.frSpeedButton2Click(Sender: TObject);
  85. begin
  86.   frPreview1.Zoom := 100;
  87. end;
  88. procedure Tfpreview.frSpeedButton3Click(Sender: TObject);
  89. begin
  90.   frPreview1.PageWidth;
  91. end;
  92. procedure Tfpreview.FormActivate(Sender: TObject);
  93. begin
  94.   frSpeedButton2.Down := True;
  95.   frSpeedButton2Click(nil);
  96. end;
  97. procedure Tfpreview.frSpeedButton11Click(Sender: TObject);
  98. begin
  99.   ModalResult := mrOk;
  100.   
  101. end;
  102. procedure Tfpreview.FormKeyDown(Sender: TObject; var Key: Word;
  103.   Shift: TShiftState);
  104. begin
  105.   frPreview1.Window.FormKeyDown(Sender, Key, Shift);
  106. end;
  107. procedure Tfpreview.frrkManualBuild(Page: TfrPage);
  108. var
  109.   i, j,k: Integer; 
  110. begin
  111.   k:=trunc(frdbrk.DataSet.RecordCount/8);
  112.    with frRk.Dictionary do
  113.    begin
  114.      // creating category (space in category name required!)
  115.      Variables['allpage'] := k+1; //设置一个系统变量
  116.    end;
  117.   frdbrk.First;
  118.   //Sender.ShowBandByType(btReportTitle); //显示报表标题
  119.   for i := 0 to k do      //循环打印每页
  120.   begin
  121.     page.ShowBandByName('Band1');
  122.    //显示列头 (band2是一个主项数据,无数据源)
  123.     for j := 1 to 8 do    //循环打印每行
  124.       begin
  125.       if not frdbrk.Eof then
  126.       begin
  127.       page.ShowBandByName('Band2');
  128.         //显示主项数据 (band3是主项数据,数据源为frdbdataset1)
  129.       frdbrk.Next;   //显示下一条数据
  130.       end
  131.       else
  132.       page.ShowBandByName('band5'); //显示空白行  (band5为child band)
  133.       end ;
  134.      // page.ShowBandByName('band4');
  135.      //在实际的页面设计当中此处有一个栏目脚band 以显示合计
  136.     if i <> k then
  137.      page.NewPage
  138.      else
  139.     page.ShowBandByName('band4');     //产生新页面
  140.   end;
  141. end;
  142. procedure Tfpreview.frdjManualBuild(Page: TfrPage);
  143. var
  144.   i, j,k: Integer;
  145. begin
  146.   k:=trunc(frdbdj.DataSet.RecordCount/8);
  147.    with frdj.Dictionary do
  148.    begin
  149.      // creating category (space in category name required!)
  150.      Variables['allpage'] := k+1; //设置一个系统变量
  151.    end;
  152.   frdbdj.First;
  153.   //Sender.ShowBandByType(btReportTitle); //显示报表标题
  154.   for i := 0 to k do      //循环打印每页
  155.   begin
  156.     page.ShowBandByName('Band1');
  157.    //显示列头 (band2是一个主项数据,无数据源)
  158.     for j := 1 to 8 do    //循环打印每行
  159.       begin
  160.       if not frdbdj.Eof then
  161.       begin
  162.       page.ShowBandByName('Band2');
  163.         //显示主项数据 (band3是主项数据,数据源为frdbdataset1)
  164.       frdbdj.Next;   //显示下一条数据
  165.       end
  166.       else
  167.       page.ShowBandByName('band5'); //显示空白行  (band5为child band)
  168.       end ;
  169.      // page.ShowBandByName('band4');
  170.      //在实际的页面设计当中此处有一个栏目脚band 以显示合计
  171.     if i <> k then
  172.      page.NewPage
  173.      else
  174.     page.ShowBandByName('band4');     //产生新页面
  175.   end;
  176. end;
  177. end.