Rev 78 | Rev 80 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 78 | Rev 79 | ||
---|---|---|---|
1 | unit ZeiterfassungMain; |
1 | unit ZeiterfassungMain; |
2 | 2 | ||
3 | interface |
3 | interface |
4 | 4 | ||
5 | uses |
5 | uses |
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
7 | Dialogs, DB, ADODB, Grids, Wwdbigrd, Wwdbgrid, ExtCtrls, DBCtrls, StdCtrls; |
7 | Dialogs, DB, ADODB, Grids, Wwdbigrd, Wwdbgrid, ExtCtrls, DBCtrls, StdCtrls; |
8 | 8 | ||
9 | type |
9 | type |
10 | TForm1 = class(TForm) |
10 | TForm1 = class(TForm) |
11 | ADOConnection1: TADOConnection; |
11 | ADOConnection1: TADOConnection; |
12 | wwDBGrid1: TwwDBGrid; |
12 | wwDBGrid1: TwwDBGrid; |
13 | ADOTable1: TADOTable; |
13 | ADOTable1: TADOTable; |
14 | DataSource1: TDataSource; |
14 | DataSource1: TDataSource; |
15 | ADOTable1TAG: TWideStringField; |
15 | ADOTable1TAG: TWideStringField; |
16 | ADOTable1KOMMEN: TWideStringField; |
16 | ADOTable1KOMMEN: TWideStringField; |
17 | ADOTable1PAUSE_START: TWideStringField; |
17 | ADOTable1PAUSE_START: TWideStringField; |
18 | ADOTable1PAUSE_ENDE: TWideStringField; |
18 | ADOTable1PAUSE_ENDE: TWideStringField; |
19 | ADOTable1GEHEN: TWideStringField; |
19 | ADOTable1GEHEN: TWideStringField; |
20 | ADOTable1SONSTIGER_ABZUG: TWideStringField; |
20 | ADOTable1SONSTIGER_ABZUG: TWideStringField; |
21 | ADOTable1ZUHAUSE: TWideStringField; |
21 | ADOTable1ZUHAUSE: TWideStringField; |
22 | ADOTable1BERSTUNDEN_SALDO: TIntegerField; |
22 | ADOTable1BERSTUNDEN_SALDO: TIntegerField; |
23 | ADOTable1BERSTUNDEN: TIntegerField; |
23 | ADOTable1BERSTUNDEN: TIntegerField; |
24 | ADOTable1FREIER_TAG: TBooleanField; |
24 | ADOTable1FREIER_TAG: TBooleanField; |
25 | Panel1: TPanel; |
25 | Panel1: TPanel; |
26 | Button1: TButton; |
26 | Button1: TButton; |
27 | DBNavigator1: TDBNavigator; |
27 | DBNavigator1: TDBNavigator; |
28 | ADOTable1WOCHENTAG: TStringField; |
28 | ADOTable1WOCHENTAG: TStringField; |
29 | ADOTable1USERNAME: TStringField; |
29 | ADOTable1USERNAME: TStringField; |
30 | ComboBox1: TComboBox; |
30 | ComboBox1: TComboBox; |
31 | Label1: TLabel; |
31 | Label1: TLabel; |
32 | Label2: TLabel; |
32 | Label2: TLabel; |
- | 33 | ADOTable1BEMERKUNG: TStringField; |
|
33 | procedure ADOTable1NewRecord(DataSet: TDataSet); |
34 | procedure ADOTable1NewRecord(DataSet: TDataSet); |
34 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
35 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
35 | procedure ADOTable1BeforePost(DataSet: TDataSet); |
36 | procedure ADOTable1BeforePost(DataSet: TDataSet); |
36 | procedure ADOTable1BERSTUNDEN_SALDOGetText(Sender: TField; var Text: string; |
37 | procedure ADOTable1BERSTUNDEN_SALDOGetText(Sender: TField; var Text: string; |
37 | DisplayText: Boolean); |
38 | DisplayText: Boolean); |
38 | procedure ADOTable1BERSTUNDENGetText(Sender: TField; var Text: string; |
39 | procedure ADOTable1BERSTUNDENGetText(Sender: TField; var Text: string; |
39 | DisplayText: Boolean); |
40 | DisplayText: Boolean); |
40 | procedure wwDBGrid1CalcCellColors(Sender: TObject; Field: TField; |
41 | procedure wwDBGrid1CalcCellColors(Sender: TObject; Field: TField; |
41 | State: TGridDrawState; Highlight: Boolean; AFont: TFont; ABrush: TBrush); |
42 | State: TGridDrawState; Highlight: Boolean; AFont: TFont; ABrush: TBrush); |
42 | procedure ADOTable1AfterPost(DataSet: TDataSet); |
43 | procedure ADOTable1AfterPost(DataSet: TDataSet); |
43 | procedure Button1Click(Sender: TObject); |
44 | procedure Button1Click(Sender: TObject); |
44 | procedure ADOTable1TAGChange(Sender: TField); |
45 | procedure ADOTable1TAGChange(Sender: TField); |
45 | procedure ADOTable1SONSTIGER_ABZUGSetText(Sender: TField; |
46 | procedure ADOTable1SONSTIGER_ABZUGSetText(Sender: TField; |
46 | const Text: string); |
47 | const Text: string); |
47 | procedure ADOTable1ZUHAUSESetText(Sender: TField; const Text: string); |
48 | procedure ADOTable1ZUHAUSESetText(Sender: TField; const Text: string); |
48 | procedure ADOTable1GEHENSetText(Sender: TField; const Text: string); |
49 | procedure ADOTable1GEHENSetText(Sender: TField; const Text: string); |
49 | procedure ADOTable1PAUSE_ENDESetText(Sender: TField; const Text: string); |
50 | procedure ADOTable1PAUSE_ENDESetText(Sender: TField; const Text: string); |
50 | procedure ADOTable1PAUSE_STARTSetText(Sender: TField; const Text: string); |
51 | procedure ADOTable1PAUSE_STARTSetText(Sender: TField; const Text: string); |
51 | procedure ADOTable1KOMMENSetText(Sender: TField; const Text: string); |
52 | procedure ADOTable1KOMMENSetText(Sender: TField; const Text: string); |
52 | procedure FormShow(Sender: TObject); |
53 | procedure FormShow(Sender: TObject); |
53 | procedure ADOTable1WOCHENTAGGetText(Sender: TField; var Text: string; |
54 | procedure ADOTable1WOCHENTAGGetText(Sender: TField; var Text: string; |
54 | DisplayText: Boolean); |
55 | DisplayText: Boolean); |
55 | procedure ComboBox1Change(Sender: TObject); |
56 | procedure ComboBox1Change(Sender: TObject); |
56 | procedure ADOTable1TAGSetText(Sender: TField; const Text: string); |
57 | procedure ADOTable1TAGSetText(Sender: TField; const Text: string); |
57 | procedure ADOTable1AfterDelete(DataSet: TDataSet); |
58 | procedure ADOTable1AfterDelete(DataSet: TDataSet); |
58 | procedure ADOTable1TAGGetText(Sender: TField; var Text: string; |
59 | procedure ADOTable1TAGGetText(Sender: TField; var Text: string; |
59 | DisplayText: Boolean); |
60 | DisplayText: Boolean); |
60 | procedure ADOTable1KOMMENGetText(Sender: TField; var Text: string; |
61 | procedure ADOTable1KOMMENGetText(Sender: TField; var Text: string; |
61 | DisplayText: Boolean); |
62 | DisplayText: Boolean); |
62 | procedure ADOTable1PAUSE_STARTGetText(Sender: TField; var Text: string; |
63 | procedure ADOTable1PAUSE_STARTGetText(Sender: TField; var Text: string; |
63 | DisplayText: Boolean); |
64 | DisplayText: Boolean); |
64 | procedure ADOTable1PAUSE_ENDEGetText(Sender: TField; var Text: string; |
65 | procedure ADOTable1PAUSE_ENDEGetText(Sender: TField; var Text: string; |
65 | DisplayText: Boolean); |
66 | DisplayText: Boolean); |
66 | procedure ADOTable1GEHENGetText(Sender: TField; var Text: string; |
67 | procedure ADOTable1GEHENGetText(Sender: TField; var Text: string; |
67 | DisplayText: Boolean); |
68 | DisplayText: Boolean); |
68 | procedure ADOTable1SONSTIGER_ABZUGGetText(Sender: TField; var Text: string; |
69 | procedure ADOTable1SONSTIGER_ABZUGGetText(Sender: TField; var Text: string; |
69 | DisplayText: Boolean); |
70 | DisplayText: Boolean); |
70 | procedure ADOTable1ZUHAUSEGetText(Sender: TField; var Text: string; |
71 | procedure ADOTable1ZUHAUSEGetText(Sender: TField; var Text: string; |
71 | DisplayText: Boolean); |
72 | DisplayText: Boolean); |
72 | private |
73 | private |
73 | function GueltigeZeile: boolean; |
74 | function GueltigeZeile: boolean; |
74 | protected |
75 | protected |
75 | procedure ReorgDataSet; |
76 | procedure ReorgDataSet; |
76 | procedure ReorgAll; |
77 | procedure ReorgAll; |
77 | function RegelArbeitszeit: integer; |
78 | function RegelArbeitszeit: integer; |
78 | end; |
79 | end; |
79 | 80 | ||
80 | var |
81 | var |
81 | Form1: TForm1; |
82 | Form1: TForm1; |
82 | 83 | ||
83 | implementation |
84 | implementation |
84 | 85 | ||
85 | {$R *.dfm} |
86 | {$R *.dfm} |
86 | 87 | ||
87 | // TODO: Trennstriche zwischen Wochen oder zwischen Urlauben |
88 | // TODO: Trennstriche zwischen Wochen oder zwischen Urlauben |
88 | // TODO: Anmerkungen |
89 | // IDEE: Wochenend-Multiplikator |
89 | 90 | ||
90 | uses |
91 | uses |
91 | DateUtils, StrUtils, IniFiles; |
92 | DateUtils, StrUtils, IniFiles; |
92 | 93 | ||
93 | {$REGION 'Hilfsfunktionen'} |
94 | {$REGION 'Hilfsfunktionen'} |
94 | 95 | ||
95 | function SQL_Escape(const s: string): string; |
96 | function SQL_Escape(const s: string): string; |
96 | begin |
97 | begin |
97 | result := StringReplace(s, '''', '\''', [rfReplaceAll]); |
98 | result := StringReplace(s, '''', '\''', [rfReplaceAll]); |
98 | end; |
99 | end; |
99 | 100 | ||
100 | function IstLeer(f: TField): boolean; |
101 | function IstLeer(f: TField): boolean; |
101 | begin |
102 | begin |
102 | result := f.IsNull or (f.AsString = '') or (f.AsString = '00:00:00'); |
103 | result := f.IsNull or (f.AsString = '') or (f.AsString = '00:00:00'); |
103 | end; |
104 | end; |
104 | 105 | ||
105 | function Minuten(f: TField): integer; |
106 | function Minuten(f: TField): integer; |
106 | begin |
107 | begin |
107 | if IstLeer(f) then |
108 | if IstLeer(f) then |
108 | begin |
109 | begin |
109 | result := 0; |
110 | result := 0; |
110 | end |
111 | end |
111 | else |
112 | else |
112 | begin |
113 | begin |
113 | result := MinuteOfTheDay(f.AsDateTime); |
114 | result := MinuteOfTheDay(f.AsDateTime); |
114 | end; |
115 | end; |
115 | end; |
116 | end; |
116 | 117 | ||
117 | function MinutenZuHF(f: TField): string; |
118 | function MinutenZuHF_Int(min: integer): string; |
118 | var |
119 | var |
119 | d: integer; |
120 | d: integer; |
120 | begin |
121 | begin |
121 | if IstLeer(f) then |
- | |
122 | begin |
- | |
123 | result := ''; |
- | |
124 | end |
- | |
125 | else |
- | |
126 | begin |
122 | d := min; |
127 | d := f.AsInteger; |
- | |
128 | if d < 0 then |
123 | if d < 0 then |
129 | begin |
124 | begin |
130 | result := '-'; |
125 | result := '-'; |
131 | d := -d; |
126 | d := -d; |
132 | end |
127 | end |
133 | else |
128 | else |
134 | begin |
129 | begin |
135 | result := ''; |
130 | result := ''; |
136 | end; |
131 | end; |
137 | result := result + Format('%.2d:%.2d', [d div 60, d mod 60]); |
132 | result := result + Format('%.2d:%.2d', [d div 60, d mod 60]); |
138 | end; |
133 | end; |
- | 134 | ||
- | 135 | function MinutenZuHF(f: TField): string; |
|
- | 136 | begin |
|
- | 137 | if IstLeer(f) then |
|
- | 138 | begin |
|
- | 139 | result := ''; |
|
- | 140 | end |
|
- | 141 | else |
|
- | 142 | begin |
|
- | 143 | result := MinutenZuHF_Int(f.AsInteger); |
|
- | 144 | end; |
|
139 | end; |
145 | end; |
140 | 146 | ||
141 | function EchtesDatum(f: TField): TDate; |
147 | function EchtesDatum(f: TField): TDate; |
142 | begin |
148 | begin |
143 | if Copy(f.AsString, 5, 1) = '-' then |
149 | if Copy(f.AsString, 5, 1) = '-' then |
144 | begin |
150 | begin |
145 | result := EncodeDate( |
151 | result := EncodeDate( |
146 | StrtoInt(Copy(f.AsString, 1, 4)), |
152 | StrtoInt(Copy(f.AsString, 1, 4)), |
147 | StrtoInt(Copy(f.AsString, 6, 2)), |
153 | StrtoInt(Copy(f.AsString, 6, 2)), |
148 | StrtoInt(Copy(f.AsString, 9, 2)) |
154 | StrtoInt(Copy(f.AsString, 9, 2)) |
149 | ); |
155 | ); |
150 | end |
156 | end |
151 | else |
157 | else |
152 | result := StrToDate(f.AsString); |
158 | result := StrToDate(f.AsString); |
153 | end; |
159 | end; |
154 | 160 | ||
155 | function WUserName: String; |
161 | function WUserName: String; |
156 | var |
162 | var |
157 | nSize: DWord; |
163 | nSize: DWord; |
158 | begin |
164 | begin |
159 | nSize := 1024; |
165 | nSize := 1024; |
160 | SetLength(Result, nSize); |
166 | SetLength(Result, nSize); |
161 | if GetUserName(PChar(Result), nSize) then |
167 | if GetUserName(PChar(Result), nSize) then |
162 | SetLength(Result, nSize-1) |
168 | SetLength(Result, nSize-1) |
163 | else |
169 | else |
164 | RaiseLastOSError; |
170 | RaiseLastOSError; |
165 | end; |
171 | end; |
166 | 172 | ||
167 | {$ENDREGION} |
173 | {$ENDREGION} |
168 | 174 | ||
169 | function TForm1.RegelArbeitszeit: integer; |
175 | function TForm1.RegelArbeitszeit: integer; |
170 | var |
176 | var |
171 | test: TADOQuery; |
177 | test: TADOQuery; |
172 | begin |
178 | begin |
173 | test := TADOQuery.Create(nil); |
179 | test := TADOQuery.Create(nil); |
174 | try |
180 | try |
175 | test.Connection := ADOConnection1; |
181 | test.Connection := ADOConnection1; |
176 | test.Close; |
182 | test.Close; |
177 | test.SQL.Text := 'select MINUTEN from REGELARBEITSZEIT where USERNAME = ''' + SQL_Escape(ComboBox1.Text) + ''''; |
183 | test.SQL.Text := 'select MINUTEN from REGELARBEITSZEIT where USERNAME = ''' + SQL_Escape(ComboBox1.Text) + ''''; |
178 | test.Open; |
184 | test.Open; |
179 | if test.RecordCount = 0 then |
185 | if test.RecordCount = 0 then |
180 | begin |
186 | begin |
181 | result := 8 * 60; |
187 | result := 8 * 60; |
182 | end |
188 | end |
183 | else |
189 | else |
184 | begin |
190 | begin |
185 | result := test.FieldByName('MINUTEN').AsInteger; |
191 | result := test.FieldByName('MINUTEN').AsInteger; |
186 | end; |
192 | end; |
187 | finally |
193 | finally |
188 | test.Free; |
194 | test.Free; |
189 | end; |
195 | end; |
190 | end; |
196 | end; |
191 | 197 | ||
192 | procedure TForm1.ReorgAll; |
198 | procedure TForm1.ReorgAll; |
193 | var |
199 | var |
194 | saldo: integer; |
200 | saldo: integer; |
195 | baks: string; |
201 | baks: string; |
196 | bakEv: TDataSetNotifyEvent; |
202 | bakEv: TDataSetNotifyEvent; |
197 | dead: boolean; |
203 | dead: boolean; |
198 | begin |
204 | begin |
199 | if ADOTable1.ReadOnly then exit; |
- | |
200 | - | ||
201 | if ADOTable1TAG.IsNull then |
205 | if ADOTable1TAG.IsNull then |
202 | begin |
206 | begin |
203 | baks := ''; |
207 | baks := ''; |
204 | end |
208 | end |
205 | else |
209 | else |
206 | begin |
210 | begin |
207 | if Copy(ADOTable1TAG.AsString, 5, 1) = '-' then |
211 | if Copy(ADOTable1TAG.AsString, 5, 1) = '-' then |
208 | baks := ADOTable1TAG.AsString |
212 | baks := ADOTable1TAG.AsString |
209 | else |
213 | else |
210 | DateTimeToString(baks, 'YYYY-MM-DD', ADOTable1TAG.AsDateTime); |
214 | DateTimeToString(baks, 'YYYY-MM-DD', ADOTable1TAG.AsDateTime); |
211 | end; |
215 | end; |
- | 216 | ADOTable1.Requery(); |
|
- | 217 | ||
212 | bakEv := ADOTable1.AfterPost; |
218 | bakEv := ADOTable1.AfterPost; |
213 | ADOTable1.AfterPost := nil; |
219 | ADOTable1.AfterPost := nil; |
214 | ADOTable1.Requery(); |
220 | ADOTable1.DisableControls; |
215 | try |
221 | try |
216 | ADOTable1.First; |
222 | ADOTable1.First; |
217 | saldo := 0; |
223 | saldo := 0; |
218 | dead := false; |
224 | dead := false; |
219 | while not ADOTable1.Eof do |
225 | while not ADOTable1.Eof do |
220 | begin |
226 | begin |
221 | ADOTable1.Edit; |
227 | ADOTable1.Edit; |
222 | if not dead then ReorgDataSet; |
228 | if not dead then ReorgDataSet; |
223 | dead := dead or ADOTable1BERSTUNDEN.IsNull; |
229 | dead := dead or ADOTable1BERSTUNDEN.IsNull; |
224 | if dead then |
230 | if dead then |
225 | begin |
231 | begin |
226 | ADOTable1BERSTUNDEN_SALDO.Clear; |
232 | ADOTable1BERSTUNDEN_SALDO.Clear; |
227 | end |
233 | end |
228 | else |
234 | else |
229 | begin |
235 | begin |
230 | saldo := saldo + ADOTable1BERSTUNDEN.AsInteger; |
236 | saldo := saldo + ADOTable1BERSTUNDEN.AsInteger; |
231 | ADOTable1BERSTUNDEN_SALDO.AsInteger := saldo; |
237 | ADOTable1BERSTUNDEN_SALDO.AsInteger := saldo; |
232 | saldo := ADOTable1BERSTUNDEN_SALDO.AsInteger; |
238 | saldo := ADOTable1BERSTUNDEN_SALDO.AsInteger; |
233 | end; |
239 | end; |
234 | ADOTable1.Post; |
240 | ADOTable1.Post; |
235 | ADOTable1.Next; |
241 | ADOTable1.Next; |
236 | end; |
242 | end; |
237 | finally |
243 | finally |
238 | if baks <> '' then ADOTable1.Locate('USERNAME;TAG', VarArrayOf([WUserName, baks]), []); |
244 | if baks <> '' then ADOTable1.Locate('USERNAME;TAG', VarArrayOf([WUserName, baks]), []); |
239 | ADOTable1.AfterPost := bakEv; |
245 | ADOTable1.AfterPost := bakEv; |
- | 246 | ADOTable1.EnableControls; |
|
240 | end; |
247 | end; |
241 | end; |
248 | end; |
242 | 249 | ||
243 | procedure TForm1.ADOTable1AfterDelete(DataSet: TDataSet); |
250 | procedure TForm1.ADOTable1AfterDelete(DataSet: TDataSet); |
244 | begin |
251 | begin |
245 | ReorgAll; |
252 | ReorgAll; |
246 | end; |
253 | end; |
247 | 254 | ||
248 | procedure TForm1.ADOTable1AfterPost(DataSet: TDataSet); |
255 | procedure TForm1.ADOTable1AfterPost(DataSet: TDataSet); |
249 | begin |
256 | begin |
250 | ReorgAll; |
257 | ReorgAll; |
251 | end; |
258 | end; |
252 | 259 | ||
253 | function TForm1.GueltigeZeile: boolean; |
260 | function TForm1.GueltigeZeile: boolean; |
254 | begin |
261 | begin |
255 | result := false; |
262 | result := false; |
256 | 263 | ||
257 | if IstLeer(ADOTable1KOMMEN) <> IstLeer(ADOTable1GEHEN) then exit; |
264 | if IstLeer(ADOTable1KOMMEN) <> IstLeer(ADOTable1GEHEN) then exit; |
258 | if IstLeer(ADOTable1PAUSE_START) <> IstLeer(ADOTable1PAUSE_ENDE) then exit; |
265 | if IstLeer(ADOTable1PAUSE_START) <> IstLeer(ADOTable1PAUSE_ENDE) then exit; |
259 | if not IstLeer(ADOTable1PAUSE_START) and (ADOTable1PAUSE_START.AsDateTime < ADOTable1KOMMEN.AsDateTime) then exit; |
266 | if not IstLeer(ADOTable1PAUSE_START) and (ADOTable1PAUSE_START.AsDateTime < ADOTable1KOMMEN.AsDateTime) then exit; |
260 | if not IstLeer(ADOTable1PAUSE_ENDE) and (ADOTable1PAUSE_ENDE.AsDateTime < ADOTable1PAUSE_START.AsDateTime) then exit; |
267 | if not IstLeer(ADOTable1PAUSE_ENDE) and (ADOTable1PAUSE_ENDE.AsDateTime < ADOTable1PAUSE_START.AsDateTime) then exit; |
261 | if not IstLeer(ADOTable1GEHEN) and (ADOTable1GEHEN.AsDateTime < ADOTable1KOMMEN.AsDateTime) then exit; |
268 | if not IstLeer(ADOTable1GEHEN) and (ADOTable1GEHEN.AsDateTime < ADOTable1KOMMEN.AsDateTime) then exit; |
262 | if not IstLeer(ADOTable1GEHEN) and not IstLeer(ADOTable1PAUSE_START) and (ADOTable1GEHEN.AsDateTime < ADOTable1PAUSE_START.AsDateTime) then exit; |
269 | if not IstLeer(ADOTable1GEHEN) and not IstLeer(ADOTable1PAUSE_START) and (ADOTable1GEHEN.AsDateTime < ADOTable1PAUSE_START.AsDateTime) then exit; |
263 | if not IstLeer(ADOTable1GEHEN) and not IstLeer(ADOTable1PAUSE_ENDE) and (ADOTable1GEHEN.AsDateTime < ADOTable1PAUSE_ENDE.AsDateTime) then exit; |
270 | if not IstLeer(ADOTable1GEHEN) and not IstLeer(ADOTable1PAUSE_ENDE) and (ADOTable1GEHEN.AsDateTime < ADOTable1PAUSE_ENDE.AsDateTime) then exit; |
264 | 271 | ||
265 | result := true; |
272 | result := true; |
266 | end; |
273 | end; |
267 | 274 | ||
268 | procedure TForm1.ReorgDataSet; |
275 | procedure TForm1.ReorgDataSet; |
269 | var |
276 | var |
270 | m: integer; |
277 | m: integer; |
271 | begin |
278 | begin |
272 | if GueltigeZeile then |
279 | if GueltigeZeile then |
273 | begin |
280 | begin |
274 | m := (Minuten(ADOTable1GEHEN) - Minuten(ADOTable1KOMMEN)) |
281 | m := (Minuten(ADOTable1GEHEN) - Minuten(ADOTable1KOMMEN)) |
275 | - (Minuten(ADOTable1PAUSE_ENDE) - Minuten(ADOTable1PAUSE_START)) |
282 | - (Minuten(ADOTable1PAUSE_ENDE) - Minuten(ADOTable1PAUSE_START)) |
276 | - Minuten(ADOTable1SONSTIGER_ABZUG) |
283 | - Minuten(ADOTable1SONSTIGER_ABZUG) |
277 | + Minuten(ADOTable1ZUHAUSE); |
284 | + Minuten(ADOTable1ZUHAUSE); |
278 | 285 | ||
279 | if not ADOTable1FREIER_TAG.AsBoolean then |
286 | if not ADOTable1FREIER_TAG.AsBoolean then |
280 | begin |
287 | begin |
281 | m := m - RegelArbeitszeit; |
288 | m := m - RegelArbeitszeit; |
282 | end; |
289 | end; |
283 | 290 | ||
284 | ADOTable1BERSTUNDEN.AsInteger := m; |
291 | ADOTable1BERSTUNDEN.AsInteger := m; |
285 | end |
292 | end |
286 | else |
293 | else |
287 | begin |
294 | begin |
288 | ADOTable1BERSTUNDEN.Clear; |
295 | ADOTable1BERSTUNDEN.Clear; |
289 | end; |
296 | end; |
290 | end; |
297 | end; |
291 | 298 | ||
292 | procedure TForm1.ADOTable1BeforePost(DataSet: TDataSet); |
299 | procedure TForm1.ADOTable1BeforePost(DataSet: TDataSet); |
293 | begin |
300 | begin |
294 | if (ADOTable1.State = dsInsert) and ADOTable1TAG.IsNull then |
301 | if (ADOTable1.State = dsInsert) and ADOTable1TAG.IsNull then |
295 | begin |
302 | begin |
296 | AdoTable1.Cancel; |
303 | AdoTable1.Cancel; |
297 | Abort; |
304 | Abort; |
298 | end; |
305 | end; |
299 | 306 | ||
300 | ReorgDataSet; |
307 | ReorgDataSet; |
301 | end; |
308 | end; |
302 | 309 | ||
303 | procedure TForm1.ADOTable1BERSTUNDENGetText(Sender: TField; var Text: string; |
310 | procedure TForm1.ADOTable1BERSTUNDENGetText(Sender: TField; var Text: string; |
304 | DisplayText: Boolean); |
311 | DisplayText: Boolean); |
305 | begin |
312 | begin |
306 | Text := MinutenZuHF(ADOTable1BERSTUNDEN); |
313 | Text := MinutenZuHF(ADOTable1BERSTUNDEN); |
307 | end; |
314 | end; |
308 | 315 | ||
309 | procedure TForm1.ADOTable1BERSTUNDEN_SALDOGetText(Sender: TField; |
316 | procedure TForm1.ADOTable1BERSTUNDEN_SALDOGetText(Sender: TField; |
310 | var Text: string; DisplayText: Boolean); |
317 | var Text: string; DisplayText: Boolean); |
311 | begin |
318 | begin |
312 | Text := MinutenZuHF(ADOTable1BERSTUNDEN_SALDO); |
319 | Text := MinutenZuHF(ADOTable1BERSTUNDEN_SALDO); |
313 | end; |
320 | end; |
314 | 321 | ||
315 | procedure TForm1.ADOTable1GEHENGetText(Sender: TField; var Text: string; |
322 | procedure TForm1.ADOTable1GEHENGetText(Sender: TField; var Text: string; |
316 | DisplayText: Boolean); |
323 | DisplayText: Boolean); |
317 | begin |
324 | begin |
318 | Text := Copy(Sender.AsString, 1, 5); |
325 | Text := Copy(Sender.AsString, 1, 5); |
319 | end; |
326 | end; |
320 | 327 | ||
321 | procedure TForm1.ADOTable1GEHENSetText(Sender: TField; const Text: string); |
328 | procedure TForm1.ADOTable1GEHENSetText(Sender: TField; const Text: string); |
322 | begin |
329 | begin |
323 | if Text = '' then |
330 | if Text = '' then |
324 | begin |
331 | begin |
325 | ADOTable1GEHEN.Clear; |
332 | ADOTable1GEHEN.Clear; |
326 | end |
333 | end |
327 | else |
334 | else |
328 | begin |
335 | begin |
329 | ADOTable1GEHEN.AsString := Text; |
336 | ADOTable1GEHEN.AsString := Text; |
330 | end; |
337 | end; |
331 | end; |
338 | end; |
332 | 339 | ||
333 | procedure TForm1.ADOTable1KOMMENGetText(Sender: TField; var Text: string; |
340 | procedure TForm1.ADOTable1KOMMENGetText(Sender: TField; var Text: string; |
334 | DisplayText: Boolean); |
341 | DisplayText: Boolean); |
335 | begin |
342 | begin |
336 | Text := Copy(Sender.AsString, 1, 5); |
343 | Text := Copy(Sender.AsString, 1, 5); |
337 | end; |
344 | end; |
338 | 345 | ||
339 | procedure TForm1.ADOTable1KOMMENSetText(Sender: TField; const Text: string); |
346 | procedure TForm1.ADOTable1KOMMENSetText(Sender: TField; const Text: string); |
340 | begin |
347 | begin |
341 | if Text = '' then |
348 | if Text = '' then |
342 | begin |
349 | begin |
343 | ADOTable1KOMMEN.Clear; |
350 | ADOTable1KOMMEN.Clear; |
344 | end |
351 | end |
345 | else |
352 | else |
346 | begin |
353 | begin |
347 | ADOTable1KOMMEN.AsString := Text; |
354 | ADOTable1KOMMEN.AsString := Text; |
348 | end; |
355 | end; |
349 | end; |
356 | end; |
350 | 357 | ||
351 | procedure TForm1.ADOTable1NewRecord(DataSet: TDataSet); |
358 | procedure TForm1.ADOTable1NewRecord(DataSet: TDataSet); |
352 | var |
359 | var |
353 | test: TADOQuery; |
360 | test: TADOQuery; |
354 | begin |
361 | begin |
355 | ADOTable1FREIER_TAG.AsBoolean := false; |
362 | ADOTable1FREIER_TAG.AsBoolean := false; |
356 | ADOTable1USERNAME.AsString := WUserName; |
363 | ADOTable1USERNAME.AsString := WUserName; |
357 | test := TADOQuery.Create(nil); |
364 | test := TADOQuery.Create(nil); |
358 | try |
365 | try |
359 | test.Connection := ADOConnection1; |
366 | test.Connection := ADOConnection1; |
360 | test.Close; |
367 | test.Close; |
361 | test.SQL.Text := 'select * from TAGE where TAG = ''' + DateToStr(Date) + ''''; |
368 | test.SQL.Text := 'select * from TAGE where TAG = ''' + DateToStr(Date) + ''' and USERNAME = ''' + SQL_Escape(ComboBox1.Text) + ''''; |
362 | test.Open; |
369 | test.Open; |
363 | if test.RecordCount = 0 then |
370 | if test.RecordCount = 0 then |
364 | begin |
371 | begin |
365 | ADOTable1TAG.AsDateTime := Date; |
372 | ADOTable1TAG.AsDateTime := Date; |
366 | ADOTable1KOMMEN.AsString := TimeToStr(Time); |
373 | ADOTable1KOMMEN.AsString := TimeToStr(Time); |
367 | ADOTable1FREIER_TAG.AsBoolean := (DayOfWeek(Date) = 1{Sunday}) or |
374 | ADOTable1FREIER_TAG.AsBoolean := (DayOfWeek(Date) = 1{Sunday}) or |
368 | (DayOfWeek(Date) = 7{Saturday}); |
375 | (DayOfWeek(Date) = 7{Saturday}); |
369 | end; |
376 | end; |
370 | finally |
377 | finally |
371 | test.Free; |
378 | test.Free; |
372 | end; |
379 | end; |
373 | 380 | ||
374 | wwDBGrid1.SelectedField := ADOTable1TAG; |
381 | wwDBGrid1.SelectedField := ADOTable1TAG; |
375 | end; |
382 | end; |
376 | 383 | ||
377 | procedure TForm1.ADOTable1PAUSE_ENDEGetText(Sender: TField; var Text: string; |
384 | procedure TForm1.ADOTable1PAUSE_ENDEGetText(Sender: TField; var Text: string; |
378 | DisplayText: Boolean); |
385 | DisplayText: Boolean); |
379 | begin |
386 | begin |
380 | Text := Copy(Sender.AsString, 1, 5); |
387 | Text := Copy(Sender.AsString, 1, 5); |
381 | end; |
388 | end; |
382 | 389 | ||
383 | procedure TForm1.ADOTable1PAUSE_ENDESetText(Sender: TField; const Text: string); |
390 | procedure TForm1.ADOTable1PAUSE_ENDESetText(Sender: TField; const Text: string); |
384 | begin |
391 | begin |
385 | if Text = '' then |
392 | if Text = '' then |
386 | begin |
393 | begin |
387 | ADOTable1PAUSE_ENDE.Clear; |
394 | ADOTable1PAUSE_ENDE.Clear; |
388 | end |
395 | end |
389 | else |
396 | else |
390 | begin |
397 | begin |
391 | ADOTable1PAUSE_ENDE.AsString := Text; |
398 | ADOTable1PAUSE_ENDE.AsString := Text; |
392 | end; |
399 | end; |
393 | end; |
400 | end; |
394 | 401 | ||
395 | procedure TForm1.ADOTable1PAUSE_STARTGetText(Sender: TField; var Text: string; |
402 | procedure TForm1.ADOTable1PAUSE_STARTGetText(Sender: TField; var Text: string; |
396 | DisplayText: Boolean); |
403 | DisplayText: Boolean); |
397 | begin |
404 | begin |
398 | Text := Copy(Sender.AsString, 1, 5); |
405 | Text := Copy(Sender.AsString, 1, 5); |
399 | end; |
406 | end; |
400 | 407 | ||
401 | procedure TForm1.ADOTable1PAUSE_STARTSetText(Sender: TField; |
408 | procedure TForm1.ADOTable1PAUSE_STARTSetText(Sender: TField; |
402 | const Text: string); |
409 | const Text: string); |
403 | begin |
410 | begin |
404 | if Text = '' then |
411 | if Text = '' then |
405 | begin |
412 | begin |
406 | ADOTable1PAUSE_START.Clear; |
413 | ADOTable1PAUSE_START.Clear; |
407 | end |
414 | end |
408 | else |
415 | else |
409 | begin |
416 | begin |
410 | ADOTable1PAUSE_START.AsString := Text; |
417 | ADOTable1PAUSE_START.AsString := Text; |
411 | end; |
418 | end; |
412 | end; |
419 | end; |
413 | 420 | ||
414 | procedure TForm1.ADOTable1SONSTIGER_ABZUGGetText(Sender: TField; |
421 | procedure TForm1.ADOTable1SONSTIGER_ABZUGGetText(Sender: TField; |
415 | var Text: string; DisplayText: Boolean); |
422 | var Text: string; DisplayText: Boolean); |
416 | begin |
423 | begin |
417 | Text := Copy(Sender.AsString, 1, 5); |
424 | Text := Copy(Sender.AsString, 1, 5); |
418 | end; |
425 | end; |
419 | 426 | ||
420 | procedure TForm1.ADOTable1SONSTIGER_ABZUGSetText(Sender: TField; |
427 | procedure TForm1.ADOTable1SONSTIGER_ABZUGSetText(Sender: TField; |
421 | const Text: string); |
428 | const Text: string); |
422 | begin |
429 | begin |
423 | if Text = '' then |
430 | if Text = '' then |
424 | begin |
431 | begin |
425 | ADOTable1SONSTIGER_ABZUG.Clear; |
432 | ADOTable1SONSTIGER_ABZUG.Clear; |
426 | end |
433 | end |
427 | else |
434 | else |
428 | begin |
435 | begin |
429 | ADOTable1SONSTIGER_ABZUG.AsString := Text; |
436 | ADOTable1SONSTIGER_ABZUG.AsString := Text; |
430 | end; |
437 | end; |
431 | end; |
438 | end; |
432 | 439 | ||
433 | procedure TForm1.ADOTable1TAGChange(Sender: TField); |
440 | procedure TForm1.ADOTable1TAGChange(Sender: TField); |
434 | begin |
441 | begin |
435 | ADOTable1FREIER_TAG.AsBoolean := (DayOfWeek(ADOTable1TAG.AsDateTime) = 1{Sunday}) or |
442 | ADOTable1FREIER_TAG.AsBoolean := (DayOfWeek(ADOTable1TAG.AsDateTime) = 1{Sunday}) or |
436 | (DayOfWeek(ADOTable1TAG.AsDateTime) = 7{Saturday}); |
443 | (DayOfWeek(ADOTable1TAG.AsDateTime) = 7{Saturday}); |
437 | // TODO: "Wochentag" Feld aktualisieren |
444 | // TODO: "Wochentag" Feld aktualisieren |
438 | end; |
445 | end; |
439 | 446 | ||
440 | procedure TForm1.ADOTable1TAGGetText(Sender: TField; var Text: string; |
447 | procedure TForm1.ADOTable1TAGGetText(Sender: TField; var Text: string; |
441 | DisplayText: Boolean); |
448 | DisplayText: Boolean); |
442 | begin |
449 | begin |
- | 450 | if IstLeer(Sender) then |
|
- | 451 | Text := Sender.AsString |
|
- | 452 | else |
|
443 | Text := DateToStr(EchtesDatum(Sender)); |
453 | Text := DateToStr(EchtesDatum(Sender)); |
444 | end; |
454 | end; |
445 | 455 | ||
446 | procedure TForm1.ADOTable1TAGSetText(Sender: TField; const Text: string); |
456 | procedure TForm1.ADOTable1TAGSetText(Sender: TField; const Text: string); |
447 | var |
457 | var |
448 | i, punktCount: integer; |
458 | i, punktCount: integer; |
449 | begin |
459 | begin |
450 | punktCount := 0; |
460 | punktCount := 0; |
451 | for i := 1 to Length(Text) do |
461 | for i := 1 to Length(Text) do |
452 | begin |
462 | begin |
453 | if Text[i] = '.' then inc(punktCount); |
463 | if Text[i] = '.' then inc(punktCount); |
454 | end; |
464 | end; |
455 | 465 | ||
456 | if punktCount = 1 then |
466 | if punktCount = 1 then |
457 | begin |
467 | begin |
458 | ADOTable1TAG.AsString := Text + '.' + IntToStr(CurrentYear); |
468 | ADOTable1TAG.AsString := Text + '.' + IntToStr(CurrentYear); |
459 | end |
469 | end |
460 | else if (PunktCount = 2) and EndsStr('.',Text) then |
470 | else if (PunktCount = 2) and EndsStr('.',Text) then |
461 | begin |
471 | begin |
462 | ADOTable1TAG.AsString := Text + IntToStr(CurrentYear); |
472 | ADOTable1TAG.AsString := Text + IntToStr(CurrentYear); |
463 | end |
473 | end |
464 | else |
474 | else |
465 | begin |
475 | begin |
466 | ADOTable1TAG.AsString := Text; |
476 | ADOTable1TAG.AsString := Text; |
467 | end; |
477 | end; |
468 | end; |
478 | end; |
469 | 479 | ||
470 | procedure TForm1.ADOTable1WOCHENTAGGetText(Sender: TField; var Text: string; |
480 | procedure TForm1.ADOTable1WOCHENTAGGetText(Sender: TField; var Text: string; |
471 | DisplayText: Boolean); |
481 | DisplayText: Boolean); |
472 | begin |
482 | begin |
473 | try |
483 | try |
474 | if ADOTable1TAG.AsString <> '' then |
484 | if ADOTable1TAG.AsString <> '' then |
475 | Text := ShortDayNames[DayOfWeek(EchtesDatum(ADOTable1TAG))] |
485 | Text := ShortDayNames[DayOfWeek(EchtesDatum(ADOTable1TAG))] |
476 | else |
486 | else |
477 | Text := ''; |
487 | Text := ''; |
478 | except |
488 | except |
479 | Text := '??'; |
489 | Text := '??'; |
480 | end; |
490 | end; |
481 | end; |
491 | end; |
482 | 492 | ||
483 | procedure TForm1.ADOTable1ZUHAUSEGetText(Sender: TField; var Text: string; |
493 | procedure TForm1.ADOTable1ZUHAUSEGetText(Sender: TField; var Text: string; |
484 | DisplayText: Boolean); |
494 | DisplayText: Boolean); |
485 | begin |
495 | begin |
486 | Text := Copy(Sender.AsString, 1, 5); |
496 | Text := Copy(Sender.AsString, 1, 5); |
487 | end; |
497 | end; |
488 | 498 | ||
489 | procedure TForm1.ADOTable1ZUHAUSESetText(Sender: TField; const Text: string); |
499 | procedure TForm1.ADOTable1ZUHAUSESetText(Sender: TField; const Text: string); |
490 | begin |
500 | begin |
491 | if Text = '' then |
501 | if Text = '' then |
492 | begin |
502 | begin |
493 | ADOTable1ZUHAUSE.Clear; |
503 | ADOTable1ZUHAUSE.Clear; |
494 | end |
504 | end |
495 | else |
505 | else |
496 | begin |
506 | begin |
497 | ADOTable1ZUHAUSE.AsString := Text; |
507 | ADOTable1ZUHAUSE.AsString := Text; |
498 | end; |
508 | end; |
499 | end; |
509 | end; |
500 | 510 | ||
501 | procedure TForm1.Button1Click(Sender: TObject); |
511 | procedure TForm1.Button1Click(Sender: TObject); |
502 | begin |
512 | begin |
503 | ReorgAll; |
513 | ReorgAll; |
504 | end; |
514 | end; |
505 | 515 | ||
506 | procedure TForm1.ComboBox1Change(Sender: TObject); |
516 | procedure TForm1.ComboBox1Change(Sender: TObject); |
507 | begin |
517 | begin |
- | 518 | Label2.Caption := MinutenZuHF_Int(RegelArbeitszeit) + ' Std.'; |
|
- | 519 | ||
- | 520 | ADOTable1.DisableControls; |
|
- | 521 | ||
508 | ADOTable1.Active := false; |
522 | ADOTable1.Active := false; |
509 | ADOTable1.ReadOnly := ComboBox1.Text <> WUserName; |
523 | ADOTable1.ReadOnly := false; |
510 | ADOTable1.Filter := 'USERNAME = ''' + SQL_Escape(ComboBox1.Text) + ''''; |
524 | ADOTable1.Filter := 'USERNAME = ''' + SQL_Escape(ComboBox1.Text) + ''''; |
511 | ADOTable1.Filtered := true; |
525 | ADOTable1.Filtered := true; |
512 | ADOTable1.Active := true; |
526 | ADOTable1.Active := true; |
513 | ADOTable1.Last; |
- | |
514 | 527 | ||
- | 528 | ReorgAll; |
|
- | 529 | ||
- | 530 | ADOTable1.Active := false; |
|
515 | Button1.Enabled := not ADOTable1.ReadOnly; |
531 | ADOTable1.ReadOnly := ComboBox1.Text <> WUserName; |
- | 532 | ADOTable1.Active := true; |
|
516 | 533 | ||
- | 534 | ADOTable1.Last; |
|
517 | Label2.Caption := IntToStr(RegelArbeitszeit); |
535 | Button1.Enabled := not ADOTable1.ReadOnly; |
518 | 536 | ||
519 | ReorgAll; |
537 | ADOTable1.EnableControls; |
520 | end; |
538 | end; |
521 | 539 | ||
522 | procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); |
540 | procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); |
523 | begin |
541 | begin |
524 | if ADOTable1.State in [dsEdit, dsInsert] then |
542 | if ADOTable1.State in [dsEdit, dsInsert] then |
525 | begin |
543 | begin |
526 | try |
544 | try |
527 | ADOTable1.Post; |
545 | ADOTable1.Post; |
528 | except |
546 | except |
529 | on E: EAbort do |
547 | on E: EAbort do |
530 | begin |
548 | begin |
531 | exit; |
549 | exit; |
532 | end; |
550 | end; |
533 | end; |
551 | end; |
534 | end; |
552 | end; |
535 | end; |
553 | end; |
536 | 554 | ||
537 | procedure TForm1.FormShow(Sender: TObject); |
555 | procedure TForm1.FormShow(Sender: TObject); |
538 | var |
556 | var |
539 | test: TADOQuery; |
557 | test: TADOQuery; |
540 | ini: TMemIniFile; |
558 | ini: TMemIniFile; |
541 | resourcestring |
559 | resourcestring |
542 | DefaultConnectionString = 'Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Zeiterfassung;' + |
560 | DefaultConnectionString = 'Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Zeiterfassung;' + |
543 | 'Data Source=SHS\FiVe,49007;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=MARSCHALL;Use Encryption for Data=False;Tag with column collation when possible=False;'; |
561 | 'Data Source=SHS\FiVe,49007;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=MARSCHALL;Use Encryption for Data=False;Tag with column collation when possible=False;'; |
544 | begin |
562 | begin |
545 | ini := TMemIniFile.Create(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + ChangeFileExt(ExtractFileName(ParamStr(0)), '.ini')); |
563 | ini := TMemIniFile.Create(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + ChangeFileExt(ExtractFileName(ParamStr(0)), '.ini')); |
546 | try |
564 | try |
547 | ADOConnection1.ConnectionString := ini.ReadString('Connection', 'ConnectionString', DefaultConnectionString); |
565 | ADOConnection1.ConnectionString := ini.ReadString('Connection', 'ConnectionString', DefaultConnectionString); |
548 | finally |
566 | finally |
549 | ini.Free; |
567 | ini.Free; |
550 | end; |
568 | end; |
551 | ADOConnection1.Connected := true; |
569 | ADOConnection1.Connected := true; |
552 | 570 | ||
553 | {$REGION 'Username Combobox füllen'} |
571 | {$REGION 'Username Combobox füllen'} |
554 | test := TADOQuery.Create(nil); |
572 | test := TADOQuery.Create(nil); |
555 | try |
573 | try |
556 | test.Connection := ADOConnection1; |
574 | test.Connection := ADOConnection1; |
557 | test.Close; |
575 | test.Close; |
558 | test.SQL.Text := 'select distinct USERNAME from TAGE'; |
576 | test.SQL.Text := 'select distinct USERNAME from TAGE'; |
559 | test.Open; |
577 | test.Open; |
560 | ComboBox1.Items.Clear; |
578 | ComboBox1.Items.Clear; |
561 | while not test.EOF do |
579 | while not test.EOF do |
562 | begin |
580 | begin |
563 | ComboBox1.Items.Add(test.FieldByName('USERNAME').AsString); |
581 | ComboBox1.Items.Add(test.FieldByName('USERNAME').AsString); |
564 | test.Next; |
582 | test.Next; |
565 | end; |
583 | end; |
566 | finally |
584 | finally |
567 | test.Free; |
585 | test.Free; |
568 | end; |
586 | end; |
569 | 587 | ||
570 | if ComboBox1.Items.IndexOf(WUserName) = -1 then |
588 | if ComboBox1.Items.IndexOf(WUserName) = -1 then |
571 | ComboBox1.Items.Add(WUserName); |
589 | ComboBox1.Items.Add(WUserName); |
572 | 590 | ||
573 | ComboBox1.Sorted := true; |
591 | ComboBox1.Sorted := true; |
574 | 592 | ||
575 | ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(WUserName); |
593 | ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(WUserName); |
576 | 594 | ||
577 | ComboBox1Change(ComboBox1); |
595 | ComboBox1Change(ComboBox1); |
578 | {$ENDREGION} |
596 | {$ENDREGION} |
579 | 597 | ||
580 | if wwDBGrid1.CanFocus then wwDBGrid1.SetFocus; |
598 | if wwDBGrid1.CanFocus then wwDBGrid1.SetFocus; |
581 | wwDBGrid1.SelectedField := ADOTable1TAG; |
599 | wwDBGrid1.SelectedField := ADOTable1TAG; |
582 | end; |
600 | end; |
583 | 601 | ||
584 | procedure TForm1.wwDBGrid1CalcCellColors(Sender: TObject; Field: TField; |
602 | procedure TForm1.wwDBGrid1CalcCellColors(Sender: TObject; Field: TField; |
585 | State: TGridDrawState; Highlight: Boolean; AFont: TFont; ABrush: TBrush); |
603 | State: TGridDrawState; Highlight: Boolean; AFont: TFont; ABrush: TBrush); |
586 | begin |
604 | begin |
587 | if Highlight then exit; |
605 | if Highlight then exit; |
588 | 606 | ||
- | 607 | if (Field.FieldName = ADOTable1WOCHENTAG.FieldName) or |
|
589 | if (Field.FieldName = ADOTable1BERSTUNDEN.FieldName) or |
608 | (Field.FieldName = ADOTable1BERSTUNDEN.FieldName) or |
590 | (Field.FieldName = ADOTable1BERSTUNDEN_SALDO.FieldName) then |
609 | (Field.FieldName = ADOTable1BERSTUNDEN_SALDO.FieldName) then |
591 | begin |
610 | begin |
592 | ABrush.Color := clBtnFace; |
611 | ABrush.Color := clBtnFace; |
593 | end; |
612 | end; |
594 | 613 | ||
595 | if (Field.FieldName = ADOTable1BERSTUNDEN.FieldName) then |
614 | if (Field.FieldName = ADOTable1BERSTUNDEN.FieldName) then |
596 | begin |
615 | begin |
597 | if ADOTable1BERSTUNDEN.AsInteger < 0 then |
616 | if ADOTable1BERSTUNDEN.AsInteger < 0 then |
598 | begin |
617 | begin |
599 | AFont.Color := clRed; |
618 | AFont.Color := clRed; |
600 | end; |
619 | end; |
601 | end; |
620 | end; |
602 | 621 | ||
603 | if (Field.FieldName = ADOTable1BERSTUNDEN_SALDO.FieldName) then |
622 | if (Field.FieldName = ADOTable1BERSTUNDEN_SALDO.FieldName) then |
604 | begin |
623 | begin |
605 | if ADOTable1BERSTUNDEN_SALDO.AsInteger < 0 then |
624 | if ADOTable1BERSTUNDEN_SALDO.AsInteger < 0 then |
606 | begin |
625 | begin |
607 | AFont.Color := clRed; |
626 | AFont.Color := clRed; |
608 | end; |
627 | end; |
609 | end; |
628 | end; |
610 | end; |
629 | end; |
611 | 630 | ||
612 | end. |
631 | end. |
613 | 632 |