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

  1. unit SrvrDM;
  2.  
  3. {
  4.   This is the server side of the demo.  A Login procedure has been added to the
  5.   RemoteDataModule which the client will use to login.  You can use the Type
  6.   Library Editor or the Edit | Add To Interface menu to add a procedure to the
  7.   type library.
  8. }
  9. interface
  10.  
  11. uses
  12.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13.   ComServ, ComObj, VCLCom, StdVcl, DataBkr, DBClient, Server_TLB,
  14.   Db, DBTables, Provider;
  15.  
  16. type
  17.   TLoginDemo = class(TRemoteDataModule, ILoginDemo)
  18.     Country: TTable;
  19.     CountryProvider: TDataSetProvider;
  20.     procedure LoginDemoCreate(Sender: TObject);
  21.     procedure LoginDemoDestroy(Sender: TObject);
  22.   private
  23.     FLoggedIn: Boolean;
  24.     FUserName: string;
  25.     procedure CheckLogin;
  26.   protected
  27.     procedure Login(const UserName, Password: WideString); safecall;
  28.   end;
  29.  
  30. var
  31.   LoginDemo: TLoginDemo;
  32.  
  33. implementation
  34.  
  35. uses SrvrFrm;
  36.  
  37. {$R *.DFM}
  38.  
  39. { This procedure is a helper to check that someone has actually logged into the
  40.   server. }
  41. procedure TLoginDemo.CheckLogin;
  42. begin
  43.   if not FLoggedIn then
  44.     raise Exception.Create('Not logged in');
  45. end;
  46.  
  47. procedure TLoginDemo.Login(const UserName, Password: WideString);
  48. begin
  49.   { Just add the UserName to the ListBox on Form1 and set the login flag to
  50.     true.}
  51.   Form1.ListBox1.Items.Add(UserName);
  52.   FLoggedIn := True;
  53.   FUserName := UserName;
  54. end;
  55.  
  56. procedure TLoginDemo.LoginDemoCreate(Sender: TObject);
  57. begin
  58.   FLoggedIn := False;
  59. end;
  60.  
  61. procedure TLoginDemo.LoginDemoDestroy(Sender: TObject);
  62. begin
  63.   { Remove the Name from the list}
  64.   with Form1.ListBox1.Items do Delete(IndexOf(FUserName));
  65. end;
  66.  
  67. initialization
  68.   TComponentFactory.Create(ComServer, TLoginDemo,
  69.     Class_LoginDemo, ciMultiInstance, tmSingle);
  70. end.
  71.