type
TContact =
class(TObject)
private
FContactID: integer;
FSalutation: integer;
FTitle: integer;
FFName1:
String;
FFName2:
String;
FLName:
String;
FBirthdate: TDateTime;
FPAddStreet:
String;
...
OQuery: TZQuery;
...
procedure SetFCcontactID(
const Value: Integer);
procedure SetFFName1(
const Value:
String);
procedure SetFSalutation(
const Value: Integer);
procedure SetFTitle(
const Value: Integer);
procedure SetFBirthdate(
const Value: TDateTime);
procedure SetFFName2(
const Value:
String);
procedure SetFLName(
const Value:
String);
procedure SetFPAddStreet(
const Value:
String);
...
public
property ContactID: Integer
read FContactID
write SetFCcontactID;
property Salutation: Integer
read FSalutation
write SetFSalutation;
property Title: Integer
read FTitle
write SetFTitle;
property ForeName1:
String read FFName1
write SetFFName1;
property ForeName2:
String read FFName2
write SetFFName2;
property LastName:
String read FLName
write SetFLName;
property Birthdate: TDateTime
read FBirthdate
write SetFBirthdate;
property Street:
String read FPAddStreet
write SetFPAddStreet;
...
procedure LoadContact(aID: Integer);
procedure AddCustomer(aCustomer: TCustomer);
procedure RemoveCustomer(aID: Integer);
constructor create;
...
procedure TContact.LoadContact(aID: Integer);
var
myCustomer: TCustomer;
begin
OQuery.SQL.Text:='
SELECT * FROM kom_ko2000 WHERE id=:id';
OQuery.ParamByName('
id').AsInteger:=aID;
OQuery.Open;
If OQuery.RecordCount > 0
then
begin
Salutation:=OQuery.fieldbyname('
salutation').AsInteger;
Title:=OQuery.fieldbyname('
title').AsInteger;
ForeName1:=OQuery.fieldbyname('
fname1').AsString;
ForeName2:=OQuery.fieldbyname('
fname2').AsString;
ForeName1:=OQuery.fieldbyname('
fname1').AsString;
LastName:=OQuery.fieldbyname('
lname').AsString;
Birthdate:=OQuery.fieldbyname('
birthdate').AsDateTime;
Street:=OQuery.fieldbyname('
street').AsString;
Postal:=OQuery.fieldbyname('
postal').AsString;
City:=OQuery.fieldbyname('
city').AsString;
Region:=OQuery.fieldbyname('
region').AsString;
Country:=OQuery.fieldbyname('
country').AsInteger;
AddNote:=OQuery.fieldbyname('
addnote').AsString;
Phone1:=OQuery.fieldbyname('
phone1').AsString;
Phone2:=OQuery.fieldbyname('
phone2').AsString;
Mobile:=OQuery.fieldbyname('
mobile').AsString;
Fax:=OQuery.fieldbyname('
fax').AsString;
EMail1:=OQuery.fieldbyname('
email1').AsString;
EMail2:=OQuery.fieldbyname('
email2').AsString;
ContactBy:=OQuery.fieldbyname('
contactby').AsInteger;
ContactDate:=OQuery.fieldbyname('
contactdate').AsDateTime;
ContactCreatedBy:=OQuery.fieldbyname('
contactcreatedby').AsInteger;
MaritalStatus:=OQuery.fieldbyname('
maritalstatus').AsInteger;
MALetter:=OQuery.fieldbyname('
maletter').AsInteger;
MAEmail:=OQuery.fieldbyname('
maemail').AsInteger;
MAFax:=OQuery.fieldbyname('
mafax').AsInteger;
MAPhone:=OQuery.fieldbyname('
maphone').AsInteger;
Note:=OQuery.fieldbyname('
note').AsString;
// Customer zu Contact laden
CustomerList.Clear;
OQuery.SQL.Text:='
SELECT c.id FROM kom_ko3000 cc JOIN kom_ko1000 c ON c.id = cc.custid WHERE cc.contactid=:contactid ORDER BY c.name1 ASC';
OQuery.ParamByName('
contactid').AsInteger:=ContactID;
OQuery.Open;
While not OQuery.Eof
do
begin
myCustomer:=TCustomer.Create;
myCustomer.LoadCustomer(OQuery.fieldbyname('
id').AsInteger);
AddCustomer(myCustomer);
OQuery.Next;
end;
// ====================================================================
end;
OQuery.Close;
end;