Bonjour à tous,
J'ai créé 3fiches, dont FSplash (Trouvé ds le FAQ Delphi), FLogin (pour l'identification de l'utilisateur) et la fiche principale FMain.
En fait mon seul problème, c'est quand on clique sur annuler dans FLogin mais celui ci ne veut pas quitter.
Voici le code du projet:
Et voici le code du Login:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 program gecom; uses Forms, SysUtils, UMain in 'Source\UMain.pas' {FMain}, ULogin in 'Source\ULogin.pas' {FLogin}, UDM in 'Source\UDM.pas' {DMPOS: TDataModule}, U_Societe in 'Source\U_Societe.pas' {F_Societe}, U_Article in 'Source\U_Article.pas' {F_Article}, USlpash in 'Source\USlpash.pas' {Splash}, UDMEntreprise in 'Source\UDMEntreprise.pas' {DMEntreprise: TDataModule}, Code in 'Source\Code.pas', CodeSQL in 'Source\CodeSQL.pas', UDMLocalite in 'Source\UDMLocalite.pas' {DMLocalite: TDataModule}, U_Emp in 'Source\U_Emp.pas' {F_Emp}, U_Emp_Ges in 'Source\U_Emp_Ges.pas' {F_Emp_Ges}, CodeProc in 'Source\CodeProc.pas', U_Emp_Type in 'Source\U_Emp_Type.pas' {F_Emp_Type}, U_Art_Cat in 'Source\U_Art_Cat.pas' {F_Art_Cat}, UDB_Refresh in 'Source\UDB_Refresh.pas', U_ClientSel in 'Source\U_ClientSel.pas' {F_ClientSel}, Fonction in 'Source\Fonction.pas', U_Art_Add in 'Source\U_Art_Add.pas' {F_Art_Add}, UDMRapport in 'Source\UDMRapport.pas' {DMRapport: TDataModule}; {$R *.res} begin Application.Initialize; Splash := TSplash.Create(Application); Splash.Show; Splash.Update; Application.CreateForm(TFMain, FMain); Application.CreateForm(TFLogin, FLogin); Application.CreateForm(TDMPOS, DMPOS); Application.CreateForm(TDMLocalite, DMLocalite); Application.CreateForm(TDMRapport, DMRapport); Splash.Close; Splash.Release; FLogin.Show; REPEAT Application.ProcessMessages; UNTIL(FLogin.Visible=False); Application.Run; end.
Merci de m'aider.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 .... procedure TFLogin.Quitterlapplication1Click(Sender: TObject); begin AnimateWindow(FLogin.Handle, 400, AW_BLEND or AW_HIDE); Application.Terminate; end; procedure TFLogin.FormShow(Sender: TObject); begin E_Users.Clear; E_Pass.Clear; E_Users.SetFocus; ServerStatus := True; // Message status du serveur if ServerStatus then begin SB.Panels[2].Text := MsgServerActif; end else begin SB.Panels[2].Text := MsgServerInactif; end; end; procedure TFLogin.B_ConnecterClick(Sender: TObject); var User, Pass : string; code : integer; result : boolean; begin User := E_Users.Text; Pass := E_Pass.Text; if ServerStatus then begin if (B_Connecter.Enabled) then begin // Vérification à la base de données with FLogin do begin Login.Active := False; Login.SQL.Clear; Login.SQL.Add('SELECT EMPLOYE.ID_EMP, EMPLOYE.NOM, EMPLOYE.PRENOM,' + 'EMPLOYE.ID_TYPEEMP, TYPE_EMP.DENOM'); Login.SQL.Add('FROM EMPLOYE'); Login.SQL.Add('INNER JOIN TYPE_EMP ON (EMPLOYE.ID_TYPEEMP = TYPE_EMP.ID_TYPEEMP)'); Login.SQL.Add('WHERE (EMPLOYE.LOGIN = '+ Quotedstr(User) + ') AND (EMPLOYE.PASS = '+ QuotedStr(Pass) +')'); Login.Active := True; code := Login.RecordCount; // Vérifier si le résultat est correct if (code = 1) then begin with FMain do begin SB2.Panels[2].Text := Login.Fields.FieldByName('ID_EMP').AsString; SB2.Panels[4].Text := Login.Fields.FieldByName('NOM').AsString + ' ' + Login.FieldByName('PRENOM').AsString; SB2.Panels[6].Text := Login.Fields.FieldByName('ID_TYPEEMP').AsString; SB2.Panels[8].Text := Login.Fields.FieldByName('DENOM').AsString; Show; end; FLogin.Hide; //FLogin.Destroy; end // Si le résultat est incorrect, alors afficher le message d'erreur else begin MessageDlg(MsgA003,mtError,[mbOk],0); B_Connecter.Enabled := False; E_Users.Clear; E_Pass.Clear; E_Users.SetFocus; end; end; end // Si le nom utilisateur ou le mot de passe est vide else begin E_Users.SetFocus; MessageDlg(MsgA002,mtWarning,[mbOk],0); end; end; end; procedure TFLogin.FormCreate(Sender: TObject); var hand : Thandle; begin hand := CreateRoundRectRgn(0,0,width, height, 15, 15); SetWindowRgn(handle, hand, true); IBDB.Connected := True; IBTrans.Active := True; end; procedure TFLogin.E_PassChange(Sender: TObject); begin if ((E_Pass.Text = '') OR (E_Users.Text = '')) then B_Connecter.Enabled := False else B_Connecter.Enabled := True; end; procedure TFLogin.E_UsersChange(Sender: TObject); begin if ((E_Users.Text = '') OR (E_Pass.Text = '')) then B_Connecter.Enabled := False else B_Connecter.Enabled := True; end; procedure TFLogin.FormDestroy(Sender: TObject); begin IBDB.Connected := False; IBTrans.Active := False; end; end.
Partager