unit Main; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Bde.DBTables, Vcl.Grids, Vcl.DBGrids, Vcl.OleCtrls, CACHEQUERYLib_TLB, TLLib_TLB, Vcl.OleServer, CacheActiveX_TLB, Vcl.StdCtrls, Datasnap.DBClient, UiContext, Vcl.ComCtrls, DnaCodeService, Vcl.ExtCtrls, GebruikerService, frameDnaCodes, frameGebruikers; type TfmMain = class(TForm) CacheQuery1: TCacheQuery; frmDnaCodes: TfrmDnaCodes; pnlLinks: TPanel; Panel2: TPanel; pnlKnoppen: TPanel; pnlFrames: TPanel; frmGebruikers: TfrmGebruikers; pcFrames: TPageControl; tsDnaCodes: TTabSheet; tsGebruikers: TTabSheet; procedure tsGebruikersShow(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private fUiContext: TUiContext; public property UiContext: TUiContext Read fUiContext Write fUiContext; end; var fmMain: TfmMain; implementation uses Agent, System.StrUtils, LoginScherm; {$R *.dfm} procedure TfmMain.FormCreate(Sender: TObject); begin UiContext := TUiContext.Create(); if ParamStr(1) <> '' then UiContext.ServerName := Copy(ParamStr(1),Pos('=',ParamStr(1))+1,length(ParamStr(1))) else UiContext.ServerName := 'tve-w10'; end; procedure TfmMain.FormShow(Sender: TObject); var fLoginScherm: TfmLogin; fGebruikerAanmeldenResponse: GebruikerAanmeldenResponse; begin fLoginScherm := TfmLogin.Create(self); fLoginScherm.ShowModal; if fLoginScherm.ModalResult = mrOk then begin fGebruikerAanmeldenResponse := TAgent.Create(UiContext).GebruikerAanmelden(fLoginScherm.edtInitialen.Text, fLoginScherm.edtLoginCode.Text); try if fGebruikerAanmeldenResponse.Header.Status <> '200' then begin ShowMessage(fGebruikerAanmeldenResponse.Header.Omschrijving); Application.Terminate; end else begin UiContext.Initialen := fLoginScherm.edtInitialen.Text; UiContext.LoginCode := fLoginScherm.edtLoginCode.Text; Self.Caption := 'PlanScan '+UiContext.Initialen; pcFrames.ActivePageIndex := 0; end; except on E: Exception do begin ShowMessage(E.Message); Application.Terminate; end; end; fGebruikerAanmeldenResponse.Free; end else begin Application.Terminate; end; fLoginScherm.Free; end; procedure TfmMain.FormClose(Sender: TObject; var Action: TCloseAction); begin TAgent.Create(UiContext).GebruikerAfmelden(UiContext.Initialen, UiContext.LoginCode); end; procedure TfmMain.tsGebruikersShow(Sender: TObject); begin UiContext.LoginCode := '1513'; UiContext.Initialen := 'TSN'; //ZoekAlleGebruikers(); end; end.