home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 February / Chip_2004-02_cd1.bin / program / delphi / navody / d56 / ec1vr2.exe / #setuppath# / Delphi / Mastdet / Main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2003-12-09  |  3.0 KB  |  131 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   vivrep20, Menus, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     MainMenu: TMainMenu;
  12.     PrintItem: TMenuItem;
  13.     PrintSetupItem: TMenuItem;
  14.     ExitItem: TMenuItem;
  15.     AboutItem: TMenuItem;
  16.     SpeedBar: TPanel;
  17.     SpeedButton1: TSpeedButton;  // &Print...
  18.     SpeedButton2: TSpeedButton;  // P&rint Setup...
  19.     SpeedButton3: TSpeedButton;  // E&xit
  20.     SpeedButton4: TSpeedButton;  // &About...
  21.     PrintPreviewItem: TMenuItem;
  22.     SpeedButton5: TSpeedButton;
  23.     CurPrintItem: TMenuItem;
  24.     AllPrintItem: TMenuItem;
  25.     PrevCurrentItem: TMenuItem;
  26.     PrevAllItem: TMenuItem;
  27.     CustPanel: TPanel;
  28.     CustLabel: TLabel;
  29.     CustGrid: TDBGrid;
  30.     Splitter1: TSplitter;
  31.     OrderPanel: TPanel;
  32.     OrderLabel: TLabel;
  33.     OrderGrid: TDBGrid;
  34.     ListPrintItem: TMenuItem;
  35.     PrevListItem: TMenuItem;
  36.     VRPreview: TVRPreview;
  37.     VRPrintProgress: TVRPrintProgress;
  38.  
  39.     procedure PrintSetup(Sender: TObject);
  40.     procedure Exit(Sender: TObject);
  41.     procedure About(Sender: TObject);
  42.     procedure AllPrint(Sender: TObject);
  43.     procedure CurPrint(Sender: TObject);
  44.     procedure PrevCurrent(Sender: TObject);
  45.     procedure PrevAll(Sender: TObject);
  46.     procedure ListPrint(Sender: TObject);
  47.     procedure PrevList(Sender: TObject);
  48.   private
  49.     { Private declarations }
  50.   public
  51.     { Public declarations }
  52.   end;
  53.  
  54. var
  55.   MainForm: TMainForm;
  56.  
  57. implementation
  58.  
  59. uses Rep, About, Dm;
  60.  
  61. {$R *.DFM}
  62.  
  63. procedure TMainForm.PrintSetup(Sender: TObject);
  64. begin
  65.   RepForm.VividReport.PrinterSetup;
  66. end;
  67.  
  68. procedure TMainForm.Exit(Sender: TObject);
  69. begin
  70.   Close;
  71. end;
  72.  
  73. procedure TMainForm.About(Sender: TObject);
  74. begin
  75.   AboutBox.ShowModal;
  76. end;
  77.  
  78. procedure TMainForm.AllPrint(Sender: TObject);  
  79. begin
  80.   if RepForm.VividReport.PrintSetup then RepForm.VividReport.Print;
  81. end;
  82.  
  83. procedure TMainForm.CurPrint(Sender: TObject);
  84. begin
  85.   RepForm.ChildReport.DataSource := Nil;
  86.   try
  87.     DModule.RepCustTable.GotoCurrent (DModule.ViewCustTable);
  88.     if RepForm.ChildReport.PrintSetup then RepForm.ChildReport.Print;
  89.   finally
  90.     RepForm.ChildReport.DataSource := DModule.RepCustDSource;
  91.   end;
  92. end;
  93.  
  94. procedure TMainForm.PrevCurrent(Sender: TObject);
  95. begin
  96.   RepForm.ChildReport.DataSource := Nil;
  97.   try
  98.     DModule.RepCustTable.GotoCurrent (DModule.ViewCustTable);
  99.     RepForm.ChildReport.PrintPreview (VRPreview);
  100.   finally
  101.     RepForm.ChildReport.DataSource := DModule.RepCustDSource;
  102.   end;
  103. end;
  104.  
  105. procedure TMainForm.PrevAll(Sender: TObject);
  106. begin
  107.   RepForm.VividReport.PrintPreview (VRPreview);
  108. end;
  109.  
  110. procedure TMainForm.ListPrint(Sender: TObject);
  111. begin
  112.   RepForm.Page3.Printed := false;
  113.   try
  114.     if RepForm.VividReport.PrintSetup then RepForm.VividReport.Print;
  115.   finally
  116.     RepForm.Page3.Printed := true;
  117.   end;
  118. end;
  119.  
  120. procedure TMainForm.PrevList(Sender: TObject);
  121. begin
  122.   RepForm.Page3.Printed := false;
  123.   try
  124.     RepForm.VividReport.PrintPreview (VRPreview);
  125.   finally
  126.     RepForm.Page3.Printed := true;
  127.   end;
  128. end;
  129.  
  130. end.
  131.