home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / delphi / cbsuite.lzh / SU1SRC.ZIP / REPDEM03.PAS < prev    next >
Pascal/Delphi Source File  |  1996-12-01  |  2KB  |  82 lines

  1. unit Repdem03;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   StdCtrls, Forms, DBCtrls, DB, DBGrids, Buttons, DBTables, Grids,
  8.   ExtCtrls, Printers, PrnGridR,  CB_Types, CB_MFunc;
  9.  
  10. type
  11.   Tdem03form = class(TForm)
  12.     DBGrid1: TDBGrid;
  13.     Panel1: TPanel;
  14.     DataSource1: TDataSource;
  15.     Panel2: TPanel;
  16.     Query1: TQuery;
  17.     Label1: TLabel;
  18.     Label2: TLabel;
  19.     Preview: TBitBtn;
  20.     Exit: TBitBtn;
  21.     Query1PartNo: TFloatField;
  22.     Query1VendorNo: TFloatField;
  23.     Query1Description: TStringField;
  24.     Query1OnHand: TFloatField;
  25.     Query1OnOrder: TFloatField;
  26.     Query1Cost: TCurrencyField;
  27.     Query1ListPrice: TCurrencyField;
  28.     Query1OnOrderValue: TCurrencyField;
  29.     Query1OnHandValue: TCurrencyField;
  30.     Label3: TLabel;
  31.     PrintGridReport1: TPrintGridReport;
  32.     procedure FormCreate(Sender: TObject);
  33.     procedure PreviewClick(Sender: TObject);
  34.     procedure Query1CalcFields(DataSet: TDataset);
  35.   private
  36.     { private declarations }
  37.   public
  38.   end;
  39.  
  40. var
  41.   dem03form: Tdem03form;
  42.  
  43. implementation
  44.  
  45. {$R *.DFM}
  46.  
  47. procedure Tdem03form.FormCreate(Sender: TObject);
  48. begin
  49.   Query1.Open;
  50.  
  51.   { SubTotals will be on field VenderNo}
  52.   PrintGridReport1.SetSubTotalField(1, 'VendorNo','Vendor Number');
  53.  
  54.   { Do not total next 4 fields, but do all the rest  }
  55.   PrintGridReport1.SetPrintTotal('PartNo', False);
  56.   PrintGridReport1.SetPrintTotal('Cost', False);
  57.   PrintGridReport1.SetPrintTotal('ListPrice', False);
  58.   PrintGridReport1.SetPrintTotal('VenderNo', False);
  59. end;                                                           
  60.  
  61. procedure Tdem03form.PreviewClick(Sender: TObject);
  62. begin
  63.     Query1.DisableControls;
  64.  
  65.     { Force Orientation to Landscape }
  66.     PrintGridReport1.Orientation := Landscape;
  67.  
  68.    { and send query for preview }
  69.     PrintGridReport1.Execute;
  70.     Printer.Orientation := poPortrait;
  71.    Query1.EnableControls;
  72. end;
  73.  
  74.  
  75. procedure Tdem03form.Query1CalcFields(DataSet: TDataset);
  76. begin
  77.     Query1OnOrderValue.Value := Query1OnOrder.Value*Query1Cost.Value;
  78.   Query1OnHandValue.Value := Query1Cost.Value*Query1OnHand.Value;
  79.  end;
  80.  
  81.  
  82. end.