Thema: Delphi Geburtstagsabfrage

Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.199 Beiträge
 
Delphi 12 Athens
 
#11

AW: Geburtstagsabfrage

  Alt 24. Apr 2023, 19:28
Und auch das Doppelte rauswerfen.

Delphi-Quellcode:
if CalcBirthday(Patient1Qry.FieldByName('GEBURTSDATUM').AsDateTime) and (Geburtstagheute = False) then
    begin
      //lblAlter.Font.Color := clRed;
      MessageDlg('Patient / Klient / Kunde hat heute Geburtstag.?', mtConfirmation, [mbOK],0);
      Geburtstagheute := True;
    end
;
// else
// begin
      if CalcBirthday(Patient1Qry.FieldByName('GEBURTSDATUM').AsDateTime) then
        lblAlter.Font.Color := clRed
      else
        lblAlter.Font.Color := clBlack;
// end;
Im ersten IF ist etwas, was auch im 2. IF nochmal drin ist -> die Farbe.

Delphi-Quellcode:
HatGeburtstag := CalcBirthday(Patient1Qry.FieldByName('GEBURTSDATUM').AsDateTime);
if HatGeburtstag and not GeburtstagHeute then
  MessageDlg('Patient / Klient / Kunde hat heute Geburtstag?', mtConfirmation, [mbOK], 0);
GeburtstagHeute := True;

//if HatGeburtstag then
// lblAlter.Font.Color := clRed
//else
// lblAlter.Font.Color := clBlack;
lblAlter.Font.Color := IfThen(HatGeburtstag, clRed, clBlack);
2 Drittel weniger Code, nichts Mehrfach und vermutlich auch übersichtlicher/verständlicher.


wobei

Delphi-Quellcode:
HatGeburtstag := CalcBirthday(Patient1Qry.FieldByName('GEBURTSDATUM').AsDateTime);
//if HatGeburtstag and not GeburtstagHeute then GeburtstagHeute := MessageDlg('Patient / Klient / Kunde hat heute Geburtstag?', mtConfirmation, [mbClose,mbIgnore], 0) = mrIgnore;
//if HatGeburtstag then GeburtstagHeute := GeburtstagHeute or (MessageDlg('Patient / Klient / Kunde hat heute Geburtstag?', mtConfirmation, [mbClose,mbIgnore], 0) = mrIgnore);
GeburtstagHeute := GeburtstagHeute or (HatGeburtstag and (MessageDlg('Patient / Klient / Kunde hat heute Geburtstag?', mtConfirmation, [mbClose,mbIgnore], 0) = mrIgnore));
lblAlter.Font.Color := IfThen(HatGeburtstag, clRed, clBlack);
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests

Geändert von himitsu (24. Apr 2023 um 19:34 Uhr)
  Mit Zitat antworten Zitat