home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / Runimage / Delphi50 / Demos / Db / Csdemos / frmviews.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  1.6 KB  |  64 lines

  1. unit Frmviews;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Windows, Messages, Classes, Graphics, Controls,
  7.   StdCtrls, Forms, DBCtrls, DB, DBGrids, Buttons, DBTables, Grids, ExtCtrls;
  8.  
  9. type
  10.   TFrmViewDemo = class(TForm)
  11.     DBGrid1: TDBGrid;
  12.     DBNavigator: TDBNavigator;
  13.     Panel1: TPanel;
  14.     VaryingTableSource: TDataSource;
  15.     Panel2: TPanel;
  16.     VaryingTable: TTable;
  17.     BitBtn1: TBitBtn;
  18.     BtnShowEmployee: TSpeedButton;
  19.     BtnShowPhoneList: TSpeedButton;
  20.     procedure BtnShowEmployeeClick(Sender: TObject);
  21.     procedure BtnShowPhoneListClick(Sender: TObject);
  22.     procedure FormShow(Sender: TObject);
  23.   private
  24.     { private declarations }
  25.     procedure ShowTable(ATable: string);
  26.   public
  27.     { public declarations }
  28.   end;
  29.  
  30. var
  31.   FrmViewDemo: TFrmViewDemo;
  32.  
  33. implementation
  34.  
  35. {$R *.DFM}
  36.  
  37. procedure TFrmViewDemo.ShowTable( ATable: string );
  38. begin
  39.   Screen.Cursor := crHourglass;      { show user something's happening }
  40.   VaryingTable.DisableControls;      { hide data changes from user }
  41.   VaryingTable.Active := FALSE;      { close the table }
  42.   VaryingTable.TableName := ATable;  { update the name }
  43.   VaryingTable.Open;                 { open the table }
  44.   VaryingTable.EnableControls;       { paint the changes }
  45.   Screen.Cursor := crDefault;        { reset the pointer }
  46. end;
  47.  
  48. procedure TFrmViewDemo.FormShow(Sender: TObject);
  49. begin
  50.   VaryingTable.Open;
  51. end;
  52.  
  53. procedure TFrmViewDemo.BtnShowEmployeeClick(Sender: TObject);
  54. begin
  55.   ShowTable('EMPLOYEE');
  56. end;
  57.  
  58. procedure TFrmViewDemo.BtnShowPhoneListClick(Sender: TObject);
  59. begin
  60.   ShowTable('PHONE_LIST');
  61. end;
  62.  
  63. end.
  64.