home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DELPHI / SSBC21.ZIP / DEMOS / REPORTFM.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1996-05-14  |  2.4 KB  |  95 lines

  1. unit Reportfm;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, SSBC, StdCtrls, Quickrep, ExtCtrls, DB, DBTables, Qrssbc;
  8.  
  9. type
  10.   TfmReport = class(TForm)
  11.     QuickReport: TQuickReport;
  12.     tbCustomer: TTable;
  13.     dsCustomer: TDataSource;
  14.     bndDetail: TQRBand;
  15.     QRDBText1: TQRDBText;
  16.     QRDBText2: TQRDBText;
  17.     QRDBText3: TQRDBText;
  18.     QRDBText4: TQRDBText;
  19.     QRDBText5: TQRDBText;
  20.     QRDBText6: TQRDBText;
  21.     QRDBText7: TQRDBText;
  22.     tbCustomerCustNo: TFloatField;
  23.     tbCustomerCompany: TStringField;
  24.     tbCustomerAddr1: TStringField;
  25.     tbCustomerAddr2: TStringField;
  26.     tbCustomerCity: TStringField;
  27.     tbCustomerState: TStringField;
  28.     tbCustomerZip: TStringField;
  29.     tbCustomerCountry: TStringField;
  30.     tbCustomerPhone: TStringField;
  31.     tbCustomerFAX: TStringField;
  32.     tbCustomerTaxRate: TFloatField;
  33.     tbCustomerContact: TStringField;
  34.     tbCustomerLastInvoiceDate: TDateTimeField;
  35.     btReport: TButton;
  36.     SSBarcode1: TSSBarcode;
  37.     QRssBarcode1: TQRssBarcode;
  38.     procedure tbCustomerZipGetText(Sender: TField; var Text: OpenString;
  39.       DisplayText: Boolean);
  40.     procedure btReportClick(Sender: TObject);
  41.   private
  42.     { Private declarations }
  43.   public
  44.     { Public declarations }
  45.   end;
  46.  
  47. var
  48.   fmReport: TfmReport;
  49.  
  50. implementation
  51.  
  52. {$R *.DFM}
  53.  
  54. procedure TfmReport.tbCustomerZipGetText(Sender: TField;
  55.   var Text: OpenString; DisplayText: Boolean);
  56.  
  57. var
  58.   St : string;
  59.  
  60.  
  61.   function IsNumeric(St : string) : boolean;
  62.  
  63.   var
  64.     X   : integer;
  65.     AcceptSet : set of char;
  66.   begin
  67.     Result := true;
  68.     AcceptSet := ['0'..'9','-'];
  69.     for X := 1 to Length(St) do
  70.       if not (St[X] in AcceptSet) then
  71.         Result:= false;
  72.   end;
  73.  
  74. begin
  75.   { it is the programmer's responsibility to make sure, when an ssBarcode is linked to a
  76.     DataSource/DataField, that the values being passed to the barcode are legal for that
  77.     symbology.  In this case, we are using PostNet, which requires a numeric zip code.
  78.     Since the DBDEMOS:CUSTOMERS.DB file has some non-U.S. zip codes, we must write a
  79.     GetText handler to throw out any codes that aren't numeric. }
  80.  
  81.   St := Sender.AsString;
  82.   if (not IsNumeric(St)) or (not (Length(St) in [5,9,10,11])) then
  83.     Text := ''
  84.   else
  85.     Text := St;
  86.  
  87. end;
  88.  
  89. procedure TfmReport.btReportClick(Sender: TObject);
  90. begin
  91.   QuickReport.Preview;
  92. end;
  93.  
  94. end.
  95.