home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / Runimage / Delphi50 / Demos / Midas / Mstrdtl / clntmain.pas < prev    next >
Pascal/Delphi Source File  |  1999-08-11  |  3KB  |  96 lines

  1. unit ClntMain;
  2.  
  3. { This demo uses the IBLOCAL alias which is setup by the install program
  4.   when you install Delphi 5.0 if you have installed Local Interbase.
  5.  
  6.   This example demonstrates how ClientDataSets can be used in a master-detail
  7.   application. This is the client application.  You must compile and
  8.   run the Server application before running this program.
  9. }
  10.  
  11. interface
  12.  
  13. uses
  14.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  15.   ComCtrls, ExtCtrls, DBCtrls, ToolWin, Grids, DBGrids, StdCtrls, Mask, Db,
  16.   Buttons;
  17.  
  18. type
  19.   TClientForm = class(TForm)
  20.     Label2: TLabel;
  21.     MemberGrid: TDBGrid;
  22.     Label5: TLabel;
  23.     Label6: TLabel;
  24.     DescMemo: TDBMemo;
  25.     ProjectGrid: TDBGrid;
  26.     AddBtn: TButton;
  27.     DeleteBtn: TButton;
  28.     LeaderBtn: TButton;
  29.     ProductCombo: TDBComboBox;
  30.     Toolbar: TPanel;
  31.     DBNavigator1: TDBNavigator;
  32.     ApplyUpdatesBtn: TSpeedButton;
  33.     procedure MemberGridDrawColumnCell(Sender: TObject; const Rect: TRect;
  34.       DataCol: Integer; Column: TColumn; State: TGridDrawState);
  35.     procedure DeleteBtnClick(Sender: TObject);
  36.     procedure AddBtnClick(Sender: TObject);
  37.     procedure FormCreate(Sender: TObject);
  38.     procedure LeaderBtnClick(Sender: TObject);
  39.     procedure ApplyUpdatesBtnClick(Sender: TObject);
  40.   end;
  41.  
  42. var
  43.   ClientForm: TClientForm;
  44.  
  45. implementation
  46.  
  47. uses ClntDM;
  48.  
  49. {$R *.DFM}
  50.  
  51. { Bold the leader in the member list. }
  52. procedure TClientForm.MemberGridDrawColumnCell(Sender: TObject; const Rect: TRect;
  53.   DataCol: Integer; Column: TColumn; State: TGridDrawState);
  54. begin
  55.   if DM.ProjectTEAM_LEADER.Value = DM.Emp_ProjEMP_NO.Value then
  56.     MemberGrid.Canvas.Font.Style := [fsBold];
  57.   MemberGrid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
  58. end;
  59.  
  60. procedure TClientForm.DeleteBtnClick(Sender: TObject);
  61. begin
  62.   DM.Emp_Proj.Delete;
  63. end;
  64.  
  65. procedure TClientForm.AddBtnClick(Sender: TObject);
  66. begin
  67.   MemberGrid.SetFocus;
  68.   DM.Emp_Proj.Append;
  69.   MemberGrid.EditorMode := True;
  70. end;
  71.  
  72. { Set the column width to the width of the grid. }
  73. procedure TClientForm.FormCreate(Sender: TObject);
  74. begin
  75.   MemberGrid.Columns[0].Width := MemberGrid.ClientWidth - GetSystemMetrics(SM_CXVSCROLL);
  76. end;
  77.  
  78. { Set the team leader. }
  79. procedure TClientForm.LeaderBtnClick(Sender: TObject);
  80. var
  81.   NewLeader: Integer;
  82. begin
  83.   NewLeader := DM.Emp_ProjEMP_NO.Value;
  84.   if not (DM.Project.State in dsEditModes) then
  85.     DM.Project.Edit;
  86.   DM.ProjectTEAM_LEADER.Value := NewLeader;
  87.   MemberGrid.Refresh;
  88. end;
  89.  
  90. procedure TClientForm.ApplyUpdatesBtnClick(Sender: TObject);
  91. begin
  92.   DM.ApplyUpdates;
  93. end;
  94.  
  95. end.
  96.