home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / WinesCalc / Main.pas < prev    next >
Pascal/Delphi Source File  |  1998-03-17  |  1KB  |  46 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, Buttons, Grids, DBGrids, ExtCtrls, DBCtrls, Db, DBTables;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     DataSource1: TDataSource;
  12.     Table1: TTable;
  13.     DBNavigator1: TDBNavigator;
  14.     DBGrid1: TDBGrid;
  15.     BitBtn1: TBitBtn;
  16.     Table1Name: TStringField;
  17.     Table1Source: TStringField;
  18.     Table1Vintage: TStringField;
  19.     Table1Purchased: TDateField;
  20.     Table1DaysOld: TIntegerField;
  21.     procedure Table1DaysOldGetText(Sender: TField; var Text: String;
  22.       DisplayText: Boolean);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.   end;
  28.  
  29. var
  30.   MainForm: TMainForm;
  31.  
  32. implementation
  33.  
  34. {$R *.DFM}
  35.  
  36. { Calculate the Days Old virtual field using today's
  37.   date (returned by the SysUtils Date function) and
  38.   the value of the database table's Purchased value. }
  39. procedure TMainForm.Table1DaysOldGetText(Sender: TField;
  40.   var Text: String; DisplayText: Boolean);
  41. begin
  42.   Text := FloatToStr(Date - Table1Purchased.Value);
  43. end;
  44.  
  45. end.
  46.