Bonjour à tous,
POSTE A
J'aimerai avoir votre point de vue sur l'utilisation de différent évenement de mes composants TShape.
(Cela pourra également interresser certainement d'autre Delphiste)
1) je créer mes composants dynamiquement selon les enregistrements d'un base de données ACCESS acces par ADO.
2) Move And Resize des Shapes
- Evenement TFormPrincipal.OnMouseDown
- Evenement TFormPrincipal.OnMouseMove
- Evenement TFormPrincipal.OnMouseUp
3) La suppression du Shape
- Evenement TFormPinicpal.PopupMenu1 (Supprimer1Click)
4) La modification du Shape
- Evenement TFormPrincipal.OnDlbClk
- Evenement TFormPrincipal.WMUser
// -1- Création dynamique //
Evenement MiseEnPlaceDesTShapeDejaExistant
// -2- Move and Resize //
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 Procedure TFormPrincipal.MiseEnPlaceDesTShapeDejaExistant; Var Shape: TRuShape; DateDebut, DateFin : TDateTime; begin DateDebut := Calendrier.date; // on recherche le lundi while DayOfWeek(dateDebut) <> 2 do // 5 c'est le jeudi Begin DateDebut := IncDay(DateDebut,-1) end; DateFin := IncDay(DateDebut, 5); With ModuleDeDonneeSecondaire.ADOQueryCalendrier do Begin Sql.Clear; Sql.Add('Select * From Calendrier '); Sql.Add('Where DateDebut Between :xDebut AND :xFin ' ); Parameters.ParamByName('xDebut').Value := FormatDateTime('dd/mm/yyyy',DateDebut); Parameters.ParamByName('xFin').Value := FormatDateTime('dd/mm/yyyy',DateFin); Try Try Open; NbRecord := Recordset.RecordCount; StatusBar1.Panels[3].Text := 'Chargement des tâches'; Application.ProcessMessages; with ProgressBarPrincipal do Begin Visible := True; Min:= 0; Max:= NbRecord; Position :=0; Parent := StatusBar1; SetBounds((StatusBar1.Panels[0].Width+StatusBar1.Panels[1].Width) ,4,StatusBar1.Panels[2].Width-2,StatusBar1.Height-10); end; while not Eof do Begin Shape := TRuShape.Create(StringGridSemaine); With Shape do Begin ParentFont := False; Font.Size := 7; Font.Name := 'Tahoma'; Name := 'PANEL' + Fields.Fields[31].AsString; Caption := Fields.Fields[45].AsString; Top := Fields.Fields[28].AsInteger; left := Fields.Fields[25].AsInteger; Height := Fields.Fields[22].AsInteger; Width := Fields.Fields[30].AsInteger; Parent := StringGridSemaine; PopupMenu := Self.PopupMenu1; OnDblClick := Self.ShapeDblClick; OnMouseDown := Self.ShapeMouseDown; OnMouseMove := Self.ShapeMouseMove; OnMouseUp := Self.ShapeMouseUp; Hint := Fields.Fields[23].AsString; ShowHint := True; Pen.Color := Fields.Fields[20].AsInteger; StartColor := clCream; EndColor := Fields.Fields[20].AsInteger; Tag := Fields.Fields[3].AsInteger; // MakeLong(ADOCalendrier.Fields.Fields[3].AsInteger, 0); end; StringGridSemaine.CheckInBounds; ProgressBarPrincipal.Position := ProgressBarPrincipal.Position + 1; Next; end; Except on E : Exception do ShowMessage(E.ClassName+' erreur soulevée, avec le message : '+E.Message + #13 +#10 + 'La lecture des tâches dans l''onglet Semaine n''est pas possible.'+ #13 +#10 + 'Si le problème persiste, merci de prendre contact avec votre revendeur.'); end; Finally ProgressBarPrincipal.Visible := False; StatusBar1.Panels[3].Text := ''; Close; end; end; end;
Evenement ShapeMouseDown
Evenement ShapeMouseMove
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184 procedure TFormPrincipal.ShapeMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Var ChaineDroite, ChaineGauche, ChaineDroiteX : String; begin TimerInsert.Enabled := False; // On stop la detection des taches du poste TimerDelete.Enabled := False; ModifDirecte := False; NumLigneModifDirecte := 0; NumSemaineModifDirecte := 0; NumAnneeModifDirecte := 0; NumEditModifDirecte := 0; NumLeftModifDirecte := 0; NumDateFinNumItem := 0; NumDateDebutNumItem :=0; Hint1ModifDirecte := ''; Hint2ModifDirecte := ''; Hint3ModifDirecte := ''; Hint4ModifDirecte := ''; Hint5ModifDirecte := ''; Hint6ModifDirecte := ''; Hint7ModifDirecte := ''; Hint10ModifDirecte := ''; TelCltModifDirecte := ''; PortableModifDirecte := ''; CpClientModifDirecte := ''; VilleClientModifDirecte := ''; ObjetModifDirecte := ''; // Permet de stopper cette evenement si il y a un double-clique sur le shape // Mais il passe quand même au moins un fois ICI if (Button = mbRight) Then begin Application.ShowHint := False; Exit; End; If (ssLeft in Shift) AND Not(ssDouble in shift) then begin StatusBar1.Panels[0].Text := 'Modification Directe'; ChaineDroite:=Droite('PANEL',TShape(Sender).Name); ChaineGauche:=Gauche('PANEL',TShape(Sender).Name); ChaineDroiteX := Droite('X',TShape(Sender).Name); If (X >= TShape(Sender).Width-3) then // And (ssCtrl in Shift) Begin Application.ShowHint := False; With ModuleDeDonneeSecondaire.ADOQuery do Begin SQL.Clear; SQL.Add('SELECT ACol, Arow, NumeroSemaine, NumeroAnnee, NumEdit, Name, left ' ); SQL.Add(', HeureFinNumItem, DateFinNumItem, DateDebutNumItem, NumDevis '); SQL.Add(', Hint1, Hint2, Hint3, Hint4, Hint5, Hint6, Hint7, Hint8, Hint9, Hint10 '); SQL.Add(', Telclient, PortableClient, CpClient, VilleClient, Objet '); SQL.Add('FROM Calendrier '); if (ChaineGauche = '') and (ChaineDroite <> '') then Begin SQL.Add('Where Calendrier.NumEdit=:Search'); Parameters.ParamByName('Search').Value := ChaineDroite; end Else Begin SQL.Add('Where Calendrier.Name=:Search'); Parameters.ParamByName('Search').Value := ChaineDroiteX; end; Try Try Open; NumLigneModifDirecte := Fields.Fields[1].AsInteger; NumSemaineModifDirecte := Fields.Fields[2].AsInteger; NumAnneeModifDirecte := Fields.Fields[3].AsInteger; NumEditModifDirecte := Fields.Fields[4].AsInteger; NumLeftModifDirecte := Fields.Fields[6].AsInteger; NumDateFinNumItem := Fields.Fields[8].AsInteger; NumDateDebutNumItem := Fields.Fields[9].AsInteger; Hint1ModifDirecte := Fields.Fields[11].AsString; Hint2ModifDirecte := Fields.Fields[12].AsString; Hint3ModifDirecte := Fields.Fields[13].AsString; Hint4ModifDirecte := Fields.Fields[14].AsString; Hint5ModifDirecte := Fields.Fields[15].AsString; Hint6ModifDirecte := Fields.Fields[16].AsString; Hint7ModifDirecte := Fields.Fields[17].AsString; Hint10ModifDirecte := Fields.Fields[20].AsString; TelCltModifDirecte := Fields.Fields[21].AsString; PortableModifDirecte := Fields.Fields[22].AsString; CpClientModifDirecte := Fields.Fields[23].AsString; VilleClientModifDirecte := Fields.Fields[24].AsString; ObjetModifDirecte := Fields.Fields[25].AsString; Except on E : Exception do ShowMessage(E.ClassName+' error raised, avec le message : '+E.Message + #13 +#10 + 'La lecture des informations de cette tâche n''est pas possible.'+ #13 +#10 + 'Si le problème persiste, merci de prendre contact avec votre revendeur.'); End; Finally Close; end; SQL.Clear; // Ici on doit rechercher quel longueur maxi je peut étirer // quel tâche se trouve à ma droite ? que left maxi ? SQL.Add('SELECT ACol, Arow, NumeroSemaine, NumeroAnnee, left '); SQL.Add('FROM Calendrier '); SQL.Add('Where Calendrier.NumeroSemaine=:xSemaine '); SQL.Add('And Calendrier.NumeroAnnee=:XAnnee '); SQL.Add('And Calendrier.ARow=:xRow '); SQL.Add('And Calendrier.Left>:xLeft '); SQL.Add('Order By Calendrier.Left'); Parameters.ParamByName('xSemaine').Value := NumSemaineModifDirecte; Parameters.ParamByName('XAnnee').Value := NumAnneeModifDirecte; Parameters.ParamByName('xRow').Value := NumLigneModifDirecte; Parameters.ParamByName('xLeft').Value := NumLeftModifDirecte; Open; if Recordset.RecordCount > 0 then MaxXModifDirecte := Fields.Fields[4].AsInteger Else MaxXModifDirecte := StringGridSemaine.CellRect(StringGridSemaine.ColCount-1,Fields.Fields[1].AsInteger).Right;// StringGridSemaine.Width-6; Close; ModifDirecte := True; end; Cote:=2; // permet de voir dans la cellue(0,1) les jours et heures bouger; end else Begin Application.ShowHint := False; TitreModifDirecte := 'Déplacement en Cours...'; StringGridSemaine.Cells[0,1] := TitreModifDirecte; TShape(Sender).BringToFront; With ModuleDeDonneeSecondaire.ADOQuery do Begin SQL.Clear; SQL.Add('SELECT * FROM Calendrier '); if (ChaineGauche = '') and (ChaineDroite <> '') then Begin SQL.Add('Where Calendrier.NumEdit=:Search'); Parameters.ParamByName('Search').Value := ChaineDroite; end Else Begin SQL.Add('Where Calendrier.Name=:Search'); Parameters.ParamByName('Search').Value := ChaineDroiteX; end; Try Try Open; NumLigneModifDirecte := Fields.Fields[3].AsInteger; NumSemaineModifDirecte := Fields.Fields[4].AsInteger; NumAnneeModifDirecte := Fields.Fields[7].AsInteger; NumDateDebutNumItem := Fields.Fields[11].AsInteger; NumDateFinNumItem := Fields.Fields[12].AsInteger; DifDateModifDirecte := NumDateFinNumItem - NumDateDebutNumItem; // permet d'ajouter ce calcul lorsque je déplace la tâche NumLeftModifDirecte := Fields.Fields[25].AsInteger; NumEditModifDirecte := Fields.Fields[31].AsInteger; Hint1ModifDirecte := Fields.Fields[42].AsString; Hint2ModifDirecte := Fields.Fields[43].AsString; Hint3ModifDirecte := Fields.Fields[44].AsString; Hint4ModifDirecte := Fields.Fields[45].AsString; Hint5ModifDirecte := Fields.Fields[46].AsString; Hint6ModifDirecte := Fields.Fields[47].AsString; Hint7ModifDirecte := Fields.Fields[48].AsString; Hint10ModifDirecte := Fields.Fields[51].AsString; TelCltModifDirecte := Fields.Fields[36].AsString; PortableModifDirecte := Fields.Fields[37].AsString; CpClientModifDirecte := Fields.Fields[39].AsString; VilleClientModifDirecte := Fields.Fields[40].AsString; ObjetModifDirecte := Fields.Fields[41].AsString; Except on E : Exception do ShowMessage(E.ClassName+' error raised, avec le message : '+E.Message + #13 +#10 + 'La lecture des informations de cette tâche n''est pas possible.'+ #13 +#10 + 'Si le problème persiste, merci de prendre contact avec votre revendeur.'); End; Finally Close; end end; Cote:=3; Pos := Point(X,Y); ModifDirecte := True; end; end; end;
Evenement ShapeMouseUp
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 procedure TFormPrincipal.ShapeMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var xHeure, xColonne: Integer; xCol, xRow: Integer; MinX, MaxX: integer; Pt : TPoint; begin if Y > StringGridSemaine.ClientHeight then Exit; if (Sender is TShape) then Begin TShape(Sender).Cursor := crSizeAll; //Cursor pour le déplacement if (X >= TShape(Sender).Width-3) then TShape(Sender).Cursor:=CrHsplit; // Cursor pour l'étirement if (Cote = 3) then // Si on déplace le Shape (valeur donnée par MouseDown) Begin // AndNotOr Pt := TShape(Sender).ClientToParent(Point(x,y)); Pt.Y := Pt.Y - StringGridSemaine.DefaultRowHeight; // Correction nécessaire pour décalage d'une ligne, Se calcul retire une hauteur de ligne par defaut StringGridSemaine.MouseToCell(Pt.X, Pt.Y, xCol, xRow); //Renvoi les ligne/colonne if InRange(xRow, StringGridSemaine.FixedRows, StringGridSemaine.RowCount-1) then begin TShape(Sender).Top := StringGridSemaine.CellRect(xCol, xRow).Top; //Déplacement du Shape sur la nouvelle ligne TShape(Sender).Tag := xRow; //MakeLong(xRow,0); end; MinX := StringGridSemaine.CellRect(StringGridSemaine.FixedCols, xRow).Left; //Position mini. en X (Left 1ère colonne éditable) MaxX := StringGridSemaine.CellRect(StringGridSemaine.ColCount -1, xRow).Right - TShape(Sender).Width; //Position maxi. en X (Right dernière colonne -Panel.Width) if ((TShape(Sender).Left + X - Pos.X) mod 6 = 0) then Begin X := (TShape(Sender).Left + X - Pos.X)-1; TShape(Sender).Left := EnsureRange(X, MinX, MaxX); //Déplacement en X end; end; if (Cote = 2) then // Si on étire le Shape (valeur donnée par MouseDown) Begin MinX := 6; // Taille la plus petit, correspondant à 1/2 heure MaxX := X + TShape(Sender).Left; // grandeur du Shape if (X > MinX) and (X mod 6 = 0) and (MaxX <= MaxXModifDirecte) then Begin xColonne:= ((TShape(Sender).Width + TShape(Sender).left - (StringGridSemaine.ColWidths[0]+5)) div StringGridSemaine.DefaultColWidth); xHeure:= (((TShape(Sender).left - StringGridSemaine.ColWidths[0]) - (StringGridSemaine.DefaultColWidth * xColonne))+ TShape(Sender).Width) div 6; TitreModifDirecte := 'au '+ JModifDirecte.Strings[xColonne] + ' à '+ HModifDirecte.Strings[xHeure]; StringGridSemaine.Cells[0,1] := TitreModifDirecte; TShape(Sender).Width := X; end; end; end; end;
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209 procedure TFormPrincipal.ShapeMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Var xColonne, xColonneDebut, xHeure, xHeureDebut, xLigne: Integer; JourDeDebutEnNbr, JourDeFinEnNbr: Integer; HintModifDirecte, xCodeSal, xDateFin: String; begin StatusBar1.Panels[0].Text := 'Planning Light '+Commun.Version; Try Try If ModifDirecte Then Begin ShapeEncoursDeDeplacement := TShape(Sender).Name; UneTacheAEteCreer := True; xColonne:= ((TShape(Sender).Width + TShape(Sender).left - (StringGridSemaine.ColWidths[0] + 5)) div StringGridSemaine.DefaultColWidth); xHeure:= (((TShape(Sender).left - StringGridSemaine.ColWidths[0]) - (StringGridSemaine.DefaultColWidth * xColonne))+ TShape(Sender).Width) div 6; xColonneDebut:= ((TShape(Sender).left - (StringGridSemaine.ColWidths[0])) div StringGridSemaine.DefaultColWidth); xHeureDebut:= ((TShape(Sender).left - StringGridSemaine.ColWidths[0]) - (StringGridSemaine.DefaultColWidth * xColonneDebut)) div 6; if Cote = 2 then // SI on étire la Tâche Begin With ModuleDeDonneeSecondaire.ADOQueryCalendrier do Begin SQL.Clear; SQL.Add('SELECT * From Calendrier'); Active:=true; Locate('NumEdit', NumEditModifDirecte, []); Edit; FieldByName('HeureFinNumItem').Value := xHeure; FieldByName('DateFinNumItem').Value := xColonne; FieldByName('Width').Value := TShape(Sender).Width; FieldByName('TaillePanel').Value := TShape(Sender).Width + TShape(Sender).left; xDateFin := ''; if NumDateDebutNumItem = xColonne then Begin FieldByName('Hint8').Value := xDateFin; FieldByName('NumeroAnneeFin').Value := Annee; end else Begin xDateFin := JModifDirecte.Strings[xColonne]; FieldByName('Hint8').Value := xDateFin; // Date Fin FieldByName('NumeroMoisFin').Value := Droite('/',xDateFin); FieldByName('DateFin').AsDateTime := StrToDate(Droite(' ',xDatefin)); end; FieldByName('Hint9').Value := HModifDirecte.Strings[xHeure]; // Heure Fin // On refait le Hint du Shape HintModifDirecte := 'Client : Néant'; if Hint1ModifDirecte <> '' then HintModifDirecte := Hint1ModifDirecte; if Hint2ModifDirecte <> '' then HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + 'Devis : ' + Hint2ModifDirecte; if Hint3ModifDirecte <> '' then HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + 'Tranche : ' + Hint3ModifDirecte; if Hint4ModifDirecte <> '' then HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + 'Catégorie : ' + Hint4ModifDirecte; HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + '-----------------------------------'; HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + 'Salarié : '+Hint5ModifDirecte; HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + '-----------------------------------' + Chr(13)+Chr(10); if TelCltModifDirecte <> '' then HintModifDirecte := HintModifDirecte + 'Tél : ' + TelCltModifDirecte + Chr(13) + Chr(10); if PortableModifDirecte <> '' then HintModifDirecte := HintModifDirecte + 'Gsm : ' + PortableModifDirecte + Chr(13) + Chr(10); if CpClientModifDirecte+VilleClientModifDirecte <> '' then HintModifDirecte := HintModifDirecte + 'Cp/Ville : ' + CpClientModifDirecte+' '+VilleClientModifDirecte + Chr(13) + Chr(10); if TelCltModifDirecte+PortableModifDirecte+CpClientModifDirecte+VilleClientModifDirecte <> '' then HintModifDirecte := HintModifDirecte + '-----------------------------------' + Chr(13)+Chr(10); if NumDateDebutNumItem <> xColonne then Begin HintModifDirecte := HintModifDirecte + 'Du ' + Hint6ModifDirecte + ' ' + Hint7ModifDirecte + ' au ' + JModifDirecte.Strings[xColonne] + ' ' + HModifDirecte.Strings[xHeure] + Chr(13)+Chr(10) end else Begin HintModifDirecte := HintModifDirecte + 'Le ' + Hint6ModifDirecte + ' de ' + Hint7ModifDirecte + ' à ' + HModifDirecte.Strings[xHeure] + Chr(13)+Chr(10) end; if ObjetModifDirecte <> '' then Begin HintModifDirecte := HintModifDirecte + 'Objet : ' + ObjetModifDirecte + Chr(13)+Chr(10); HintModifDirecte := HintModifDirecte + '-----------------------------------' + Chr(13)+Chr(10); end; if Hint10ModifDirecte <> '' then HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + Hint10ModifDirecte; FieldByName('Hint').Value := HintModifDirecte; // Recherche du jour debut et de fin en nombre JourDeFinEnNbr := StrToInt(JoursEnNbr[xColonne]); FieldByName('NumJourFin').Value := JourDeFinEnNbr; Post; Close; TShape(Sender).Hint := HintModifDirecte; end; end else Begin if (Cote = 3) Then // Si on Déplace la tâche Begin xLigne := TShape(Sender).Tag; xCodeSal := TrouveCodeSalarie(StringGridSemaine.Cells[0,Xligne]); if xCodeSal <> '' then Begin if ShapeEnConflit(TShape(Sender).left,TShape(Sender).Width, xCodeSal, IntToStr(StrToInt(NumeroDeSemaine)),IntToStr(NumAnneeModifDirecte), TShape(Sender).Name) then Begin // On replace le Shape automatiquement si conflit TShape(Sender).left:= NumLeftModifDirecte; // TShape(Sender).Top:= NumligneModifDirecte*StringGridSemaine.DefaultRowHeight; TShape(Sender).Tag := NumligneModifDirecte; //MakeLong(NumligneModifDirecte,0); StringGridSemaine.CheckInBounds; end else Begin With ModuleDeDonneeSecondaire.ADOQueryCalendrier do Begin SQL.Clear; SQL.Add('SELECT * From Calendrier'); Active:=true; Locate('NumEdit', NumEditModifDirecte, []); Edit; FieldByName('CodeSalarie').Value := xCodeSal; FieldByName('NomSalarie').Value := StringGridSemaine.Cells[0,Xligne]; FieldByName('ACol').Value := xColonneDebut + 1; FieldByName('ARow').Value := xLigne; FieldByName('NumeroSemaine').Value := NumeroDeSemaine; //NumSemaineModifDirecte; FieldByName('NumeroMoisFin').Value := Droite('/',JModifDirecte.Strings[xColonne]); FieldByName('NumeroMoisDeb').Value := Droite('/',JModifDirecte.Strings[xColonneDebut]); FieldByName('NumeroAnnee').Value := NumAnneeModifDirecte; FieldByName('HeureDebutNumItem').Value := xHeureDebut; FieldByName('HeureFinNumItem').Value := xHeure; FieldByName('DateDebutNumItem').Value := xColonneDebut; FieldByName('DateFinNumItem').Value := xColonne; FieldByName('DateDebut').AsDateTime := StrToDate(Droite(' ',JModifDirecte.Strings[xColonneDebut])); FieldByName('DateFin').AsDateTime := StrToDate(Droite(' ',JModifDirecte.Strings[xColonne])); FieldByName('Left').Value := TShape(Sender).left; FieldByName('Top').Value := TShape(Sender).Top; FieldByName('TaillePanel').Value := TShape(Sender).left + TShape(Sender).Width; FieldByName('Hint5').Value := StringGridSemaine.Cells[0,Xligne]; FieldByName('Hint6').Value := JModifDirecte.Strings[xColonneDebut]; FieldByName('Hint7').Value := HModifDirecte.Strings[xHeureDebut]; if xColonne <> xColonneDebut then FieldByName('Hint8').Value := JModifDirecte.Strings[xColonne] else FieldByName('Hint8').Value := ''; FieldByName('Hint9').Value := HModifDirecte.Strings[xHeure]; // On refait le Hint du Panel HintModifDirecte := 'Client : Néant'; if Hint1ModifDirecte <> '' then HintModifDirecte := 'Client : ' + Hint1ModifDirecte; if Hint2ModifDirecte <> '' then HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + 'Devis : ' + Hint2ModifDirecte; if Hint3ModifDirecte <> '' then HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + 'Tranche : ' + Hint3ModifDirecte; if Hint4ModifDirecte <> '' then HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + 'Catégorie : ' + Hint4ModifDirecte; HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + '-----------------------------------'; HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + 'Salarié : '+StringGridSemaine.Cells[0,Xligne]; HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + '-----------------------------------' + Chr(13)+Chr(10); if TelCltModifDirecte <> '' then HintModifDirecte := HintModifDirecte + 'Tél : ' + TelCltModifDirecte + Chr(13) + Chr(10); if PortableModifDirecte <> '' then HintModifDirecte := HintModifDirecte + 'Gsm : ' + PortableModifDirecte + Chr(13) + Chr(10); if CpClientModifDirecte+VilleClientModifDirecte <> '' then HintModifDirecte := HintModifDirecte + 'Cp/Ville : ' + CpClientModifDirecte+' '+VilleClientModifDirecte + Chr(13) + Chr(10); if TelCltModifDirecte+PortableModifDirecte+CpClientModifDirecte+VilleClientModifDirecte <> '' then HintModifDirecte := HintModifDirecte + '-----------------------------------' + Chr(13)+Chr(10); if xColonneDebut <> xColonne then Begin HintModifDirecte := HintModifDirecte + 'Du ' + JModifDirecte.Strings[xColonneDebut] + ' ' + HModifDirecte.Strings[xHeureDebut] + ' au ' + JModifDirecte.Strings[xColonne] + ' ' + HModifDirecte.Strings[xHeure] + Chr(13)+Chr(10) end else Begin HintModifDirecte := HintModifDirecte + 'Le ' + JModifDirecte.Strings[xColonneDebut] + ' de ' + HModifDirecte.Strings[xHeureDebut] + ' à ' + HModifDirecte.Strings[xHeure] + Chr(13)+Chr(10) end; if ObjetModifDirecte <> '' then Begin HintModifDirecte := HintModifDirecte + 'Objet : ' + ObjetModifDirecte + Chr(13)+Chr(10); HintModifDirecte := HintModifDirecte + '-----------------------------------' + Chr(13)+Chr(10); end; if Hint10ModifDirecte <> '' then HintModifDirecte := HintModifDirecte + Chr(13)+Chr(10) + Hint10ModifDirecte; FieldByName('Hint').Value := HintModifDirecte; // recherche et affectation du jour debut et de fin en nombre JourDeDebutEnNbr := StrToInt(JoursEnNbr[xColonneDebut]); JourDeFinEnNbr := StrToInt(JoursEnNbr[xColonne]); FieldByName('NumJourDebut').Value := JourDeDebutEnNbr; FieldByName('NumJourFin').Value := JourDeFinEnNbr; Post; Close; TShape(Sender).Hint := HintModifDirecte; TShape(Sender).Tag := xLigne;//MakeLong(xLigne,0); end; end; end; end; end; end; Except on E : Exception do Begin ShowMessage(E.ClassName+' error raised, avec le message : '+E.Message + #13 +#10 + 'L''enregistrement de cette tâche n''est pas possible.'+ #13 +#10 + 'La tâche va être replacée automatiquement.' + #13 +#10 + 'Si le problème persiste, merci de prendre contact avec votre revendeur.'); // On replace le Shape en cas d'erreur TShape(Sender).left:= NumLeftModifDirecte; TShape(Sender).Tag := NumligneModifDirecte; StringGridSemaine.CheckInBounds; ModuleDeDonneeSecondaire.ADOQueryCalendrier.Close; ShapeEncoursDeDeplacement := ''; end; end; Finally Application.ShowHint := True; Cote:=0; StringGridSemaine.Cells[0,1] := ''; TimerInsert.Enabled := True; // On remet la detection des taches du poste TimerDelete.Enabled := True; end; end;
Partager