Einzelnen Beitrag anzeigen

Ykcim

Registriert seit: 29. Dez 2006
Ort: NRW
804 Beiträge
 
Delphi 10.4 Sydney
 
#1

Felder einer Klasse werden nicht erkannt

  Alt 27. Okt 2012, 12:15
Hallo Zusammen,

ich mache gerade meine ersten Schritte in der OOP. Das heißt, dass ich erst seit ein paar Tagen mit Klassen arbeite. Eigentlich hat es nach guter Anleitung auch geklappt, aber jetzt stehe ich gerade auf dem Schlauch:

Ich habe eine Klasse definiert und möchte im constructor create Klassenvariablen einen Wert zuweisen. Aber aus irgendeinem Grund knallt es.

Ich habe hier meinen Code:
Delphi-Quellcode:
TFA_Info = class
      strict protected
         FWAAUNR: string;
         FWAAUPO: string;
         FWATENR: string;
         FTEBEZ1: string;
         FLagerBest: string;
         FSicherBest: string;
      public
         constructor create(Grid: TAdvStringGrid; SpalteWAAUNR, SpalteWAAUPO,
                            SpalteWATENR, SpalteTEBEZ1: integer);
         function GetLagerBest: string;
         function GetSicherBest: string;
         function GetWAAUNR: string;
         function GetWAAUPO: string;
         function GetWATENR: string;
         function GetTEBEZ1: string;
         property LagerBestand: string read GetLagerBest;
         property SicherheitsBestand: string read GetSicherBest;
         property WAAUNR: string read GetWAAUNR;
         property WAAUPO: string read GetWAAUPO;
         property WATENR: string read GetWATENR;
         property TEBEZ1: string read GetTEBEZ1;
   end;

Und hier der Implementationsteil

Delphi-Quellcode:
constructor TFA_Info.create(Grid: TAdvStringGrid; SpalteWAAUNR, SpalteWAAUPO,
                            SpalteWATENR, SpalteTEBEZ1: integer);
begin
   FWAAUNR:=Grid.Cells[SpalteWAAUNR,Grid.Row];
   FWAAUPO:=Grid.Cells[SpalteWAAUPO,Grid.Row];
   FWATENR:=Grid.Cells[SpalteWATENR,Grid.Row];
   FTEBEZ1:=Grid.Cells[SpalteTEBEZ1,Grid.Row];

   Main.MySelectQuery.SQL.Clear;
   Main.MySelectQuery.SQL.Add('select sum(LSLGBE) from oms14 ');
   Main.MySelectQuery.SQL.Add('where WATENR= :WATENR ');
   Main.MySelectQuery.SQL.Add('group by WATENR');
   Main.MySelectQuery.ParamByName('WATENR').AsString:=FWAAUNR;
   Main.MySelectQuery.Open;
   FLagerBest:=Main.MySelectQuery.Fields.Fields[0].Text;
end;

function TFA_Info.GetLagerBest;
begin
   Result:=FLagerBest;
end;

function TFA_Info.GetSicherBest;
begin
   Result:=FSicherBest;
end;

function TFA_Info.GetWAAUNR;
begin
   Result:=FWAAUNR;
end;

function TFA_Info.GetWAAUPO;
begin
   Result:=FWAAUPO;
end;

function TFA_Info.GetWATENR;
begin
   Result:=FWATENR;
end;

function TFA_Info.GetTEBEZ1;
begin
   Result:=FTEBEZ1;
end;

Hat jemand eine Idee, was ich da falsch mache?

Vielen Dank
Ykcim
Patrick

Geändert von Ykcim (27. Okt 2012 um 12:26 Uhr)
  Mit Zitat antworten Zitat