| 1 |
unit UserSessionUnit; |
unit UserSessionUnit; |
| 2 |
|
|
| 3 |
{ |
{ |
| 4 |
This is a DataModule where you can add components or declare fields that are specific to |
This is a DataModule where you can add components or declare fields that are specific to |
| 5 |
ONE user. Instead of creating global variables, it is better to use this datamodule. You can then |
ONE user. Instead of creating global variables, it is better to use this datamodule. You can then |
| 6 |
access the it using UserSession. |
access the it using UserSession. |
| 7 |
} |
} |
| 8 |
interface |
interface |
| 9 |
|
|
| 10 |
uses |
uses |
| 11 |
IWUserSessionBase, SysUtils, Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option, |
IWUserSessionBase, SysUtils, Classes, Unit3; |
|
FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, |
|
|
FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt, FireDAC.UI.Intf, |
|
|
FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Phys, FireDAC.Phys.IB, |
|
|
FireDAC.Phys.IBDef, Data.DB, FireDAC.Comp.Client, FireDAC.Comp.DataSet, Unit4; |
|
| 12 |
|
|
| 13 |
type |
type |
| 14 |
TPage = (Main,Info); |
TPage = (Main,Info); |
| 15 |
|
|
| 16 |
TIWUserSession = class(TIWUserSessionBase) |
TIWUserSession = class(TIWUserSessionBase) |
| 17 |
procedure IWUserSessionBaseDestroy(Sender: TObject); |
procedure IWUserSessionBaseDestroy(Sender: TObject); |
| 18 |
|
procedure IWUserSessionBaseCreate(Sender: TObject); |
| 19 |
private |
private |
| 20 |
FDM: TDataModule1; |
FDM: TDataModule3; |
| 21 |
function GetDM: TDataModule1; |
function GetDM: TDataModule3; |
| 22 |
{ Private declarations } |
{ Private declarations } |
| 23 |
public |
public |
| 24 |
{ Public declarations } |
{ Public declarations } |
|
user_number: integer; |
|
| 25 |
FPage: TPage; |
FPage: TPage; |
| 26 |
property DM: TDataModule1 read GetDM; |
user_number: integer; |
| 27 |
|
property DM: TDataModule3 read GetDM; |
| 28 |
end; |
end; |
| 29 |
|
|
| 30 |
implementation |
implementation |
| 33 |
|
|
| 34 |
{ TIWUserSession } |
{ TIWUserSession } |
| 35 |
|
|
| 36 |
function TIWUserSession.GetDM: TDataModule1; |
function TIWUserSession.GetDM: TDataModule3; |
| 37 |
begin |
begin |
| 38 |
if Assigned(FDM) = false then |
if Assigned(FDM) = false then |
| 39 |
FDM:=TDataModule1.Create(nil); |
FDM:=TDataModule3.Create(nil); |
| 40 |
result:=FDM; |
result:=FDM; |
| 41 |
end; |
end; |
| 42 |
|
|
| 43 |
|
procedure TIWUserSession.IWUserSessionBaseCreate(Sender: TObject); |
| 44 |
|
begin |
| 45 |
|
FPage:=Main; |
| 46 |
|
user_number:=1; |
| 47 |
|
end; |
| 48 |
|
|
| 49 |
procedure TIWUserSession.IWUserSessionBaseDestroy(Sender: TObject); |
procedure TIWUserSession.IWUserSessionBaseDestroy(Sender: TObject); |
| 50 |
begin |
begin |
| 51 |
FreeAndNil(FDM); |
FreeAndNil(FDM); |
| 53 |
|
|
| 54 |
end. |
end. |
| 55 |
|
|
| 56 |
|
|