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

  1. unit Rep;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   vivrep20, ComCtrls, Db, DBTables;
  8.  
  9. type
  10.   TRepForm = class(TForm)
  11.     VividReport: TVividReport;
  12.     VRPrintProgress: TVRPrintProgress;
  13.     VRPreview: TVRPreview;
  14.     VRPage1: TVRPage;
  15.     VRPage2: TVRPage;
  16.     VRBand1: TVRBand;
  17.     VRBand2: TVRBand;
  18.     VRBand3: TVRBand;
  19.     VRBand4: TVRBand;
  20.     VRBand5: TVRBand;
  21.     TargetLabel: TVRLabel;
  22.     FromLabel: TVRLabel;
  23.     BarcodeLabel: TVRLabel;
  24.     LogoLabel: TVRLabel;
  25.     BrandLabel: TVRLabel;
  26.     PrnTable: TTable;
  27.     PrnSource: TDataSource;
  28.     PrnTableContact: TStringField;
  29.     PrnTableCompany: TStringField;
  30.     PrnTableAddress: TStringField;
  31.     PrnTableCity: TStringField;
  32.     PrnTableState: TStringField;
  33.     PrnTableZip: TStringField;
  34.     PrnTableCountry: TStringField;
  35.     PrnTableTarget: TStringField;
  36.     
  37.     procedure PrnTableTargetGetText(Sender: TField; var Text: String; DisplayText: Boolean);
  38.     procedure VividReportBeginPrint(Sender: TObject; var APrint: TBeforeAction);
  39.     procedure VRPage2BeforePrint(Sender: TObject; var APrint: TBeforeAction);
  40.   private
  41.     { Private declarations }
  42.   public
  43.     { Public declarations }
  44.     constructor Create (AOwner: TComponent); override;
  45.   end;
  46.  
  47. var
  48.   RepForm: TRepForm;
  49.  
  50. implementation
  51.  
  52. uses Main;
  53.  
  54. {$R *.DFM}
  55.  
  56. constructor TRepForm.Create (AOwner: TComponent);
  57. begin
  58.   inherited Create (AOwner);
  59.   PrnTable.Active:= true;
  60. end;
  61.  
  62. procedure TRepForm.PrnTableTargetGetText(Sender: TField; var Text: String; DisplayText: Boolean);
  63. begin
  64.   Text := PrnTableContact.AsString + #13#10 + PrnTableCompany.AsString + #13#10 +
  65.          PrnTableAddress.AsString + #13#10 +
  66.          PrnTableCity.AsString + ', ' + PrnTableState.AsString + ' ' +
  67.          PrnTableZip.AsString + #13#10 + PrnTableCountry.AsString;
  68. end;
  69.  
  70. procedure TRepForm.VividReportBeginPrint(Sender: TObject; var APrint: TBeforeAction);
  71. begin
  72.   (FromLabel.Data as TAbsString).Value := MainForm.FromEdit.Lines.Text;
  73.   (LogoLabel.Data as TAbsPicture).Picture := MainForm.LogoImage.Picture;
  74. end;
  75.  
  76. procedure TRepForm.VRPage2BeforePrint(Sender: TObject; var APrint: TBeforeAction);
  77. var
  78.   BarText: string;
  79.   I: Integer;
  80. begin
  81.   BarText := PrnTableZip.AsString;
  82.  
  83.   I := 1;
  84.   while I <= Length (BarText) do
  85.   begin
  86.     if IsDelimiter ('0123456789',BarText,I) then Inc (I)
  87.     else Delete (BarText,I,1);
  88.   end;
  89.  
  90.   if (Length (BarText) = 5) or (Length (BarText) = 9) then
  91.   begin
  92.     (BarcodeLabel.Data as TAbsBarCode).Code.Text := BarText;
  93.     (BarcodeLabel.Data as TAbsBarCode).ModuleUHeight := 3.3;
  94.   end else (BarcodeLabel.Data as TAbsBarCode).ModuleUHeight := 0;
  95.  
  96. end;
  97.  
  98. end.
  99.