Rev 78 | Rev 80 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 78 | Rev 79 | ||
---|---|---|---|
Line 28... | Line 28... | ||
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); |
Line 83... | Line 84... | ||
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'} |
Line 112... | Line 113... | ||
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 |
Line 134... | Line 129... | ||
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 |
Line 194... | Line 200... | ||
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 |
Line 207... | Line 211... | ||
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 |
Line 235... | Line 241... | ||
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 |
Line 356... | Line 363... | ||
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); |
Line 438... | Line 445... | ||
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 |
Line 503... | Line 513... | ||
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 |
Line 584... | Line 602... | ||
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 |