home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / zkuste / delphi / kompon / d3456 / SQLSET.ZIP / DEMO / MAIN.PAS < prev   
Pascal/Delphi Source File  |  2001-02-12  |  1KB  |  64 lines

  1. unit main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   SqlSet, DBTables, StdCtrls, Grids, DBGrids, ExtCtrls, Db;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     SQLSet1: TSQLSet;
  12.     DataSource1: TDataSource;
  13.     Panel1: TPanel;
  14.     DBGrid1: TDBGrid;
  15.     ComboBox1: TComboBox;
  16.     Label1: TLabel;
  17.     Query1: TQuery;
  18.     procedure FormCreate(Sender: TObject);
  19.     procedure ComboBox1Change(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   MainForm: TMainForm;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure TMainForm.FormCreate(Sender: TObject);
  34. begin
  35.   Query1.DataBaseName:=ExtractFilePath(ParamStr(0));
  36.   {Loading of countries in the ComboBox1}
  37.   ComboBox1.Items.Clear;
  38.   with Query1 do begin
  39.     SQL.Text:=SQLSet1.GetSQL('Countries');
  40.     Open;
  41.     First;
  42.     while not Eof do begin
  43.       ComboBox1.Items.Add(Fields[0].Value);
  44.       Next;
  45.     end;
  46.     Close;
  47.   end;
  48.   if ComboBox1.Items.Count>0 then ComboBox1.ItemIndex:=0;
  49.   DataSource1.DataSet:=Query1;
  50.   ComboBox1Change(Sender);
  51. end;
  52.  
  53. procedure TMainForm.ComboBox1Change(Sender: TObject);
  54. begin
  55. {Featuring of the list of customers from selected country}
  56.   if SQLSet1.RegisterVar('CountryVar', ComboBox1.Text) then begin
  57.     Query1.SQL.Text:=SQLSet1.GetSQL('Customers');
  58.     Query1.Open;
  59.   end;
  60. end;
  61.  
  62. end.
  63.  
  64.