home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 August / VPR9608A.BIN / del20try / install / data.z / CUSTORDS.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-08  |  2KB  |  58 lines

  1. unit CustOrds;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   Grids, DBGrids, StdCtrls, Mask, DBCtrls;
  8.  
  9. type
  10.   TfmCustOrd = class(TForm)
  11.     DBEdit1: TDBEdit;
  12.     DBGrid1: TDBGrid;
  13.     procedure DBGrid1Enter(Sender: TObject);
  14.     procedure DBEdit1Enter(Sender: TObject);
  15.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  16.     procedure FormActivate(Sender: TObject);
  17.   end;
  18.  
  19. var
  20.   fmCustOrd: TfmCustOrd;
  21.  
  22. implementation
  23.  
  24. uses DM, Toolbar;
  25.  
  26. {$R *.DFM}
  27.  
  28. procedure TfmCustOrd.DBGrid1Enter(Sender: TObject);
  29. begin
  30.   fmToolBar.SetNavigator(dm1.OrdersSource);
  31. end;
  32.  
  33. procedure TfmCustOrd.DBEdit1Enter(Sender: TObject);
  34. begin
  35.   fmToolBar.SetNavigator(dm1.CustomerSource);
  36. end;
  37.  
  38. procedure TfmCustOrd.FormClose(Sender: TObject; var Action: TCloseAction);
  39. begin
  40.   Action := caFree;
  41. end;
  42.  
  43. procedure TfmCustOrd.FormActivate(Sender: TObject);
  44. begin
  45.   { This procedure is necessary if to change the Datasource of the DBNavigator
  46.     in the following conditions:
  47.     1. Focus was on Orders before the user moved to the CustView form, and the
  48.        user has returned to this form by pressing Ctrl+F6, selecting it from the
  49.        Window menu or clicking on the title bar.
  50.     2. Focus was on CustView, and the user clicked on the Orders Grid (dbGrid1).
  51.        In both of the above cases, the OnEnter event of the grid doesn't execute,
  52.        leaving the navigator pointing to CustomerSource. }
  53.   if ActiveControl is TDBGrid then
  54.     DBGrid1Enter(nil)
  55. end;
  56.  
  57. end.
  58.