Ver Mensaje Individual
  #1  
Antiguo 18-09-2006
DANY DANY is offline
Miembro
 
Registrado: nov 2003
Posts: 145
Reputación: 21
DANY Va por buen camino
Saber clase hija

Tengo un metodo que automatiza la generacion de inserts en la clase base , leyendo las propertys de las clases hijas. El asunto es que tambien em toma las propertys de la clase base, como pregunto por si el campo pertenece a un clase determinada?, ya que uso self como parametro dado que no se cual
aca les dejo mi codigo:
Código Delphi [-]
procedure TClaseTablas.Insertar;
var
  I, CantidadProp, Count : Integer;
  PropList: PPropList ;
  ValoresCampos:  array of variant ;
  Campos, Parametros: TStrings ;
  SQL: String ;
begin
  CantidadProp := GetPropList(Self, PropList);
  Count := 0;
  Campos := TStringList.Create ;
  Parametros := TStringList.Create ;
  Campos.Add(' Insert into ( ');
  Parametros.Add(' Values ( ');
  for I := 0 to CantidadProp  -1 do
  begin
    if (PropList[i].PropType^.Kind = tkClass) then
      Continue;

//ACA DEBERIA IR ALGO COMO IF PROPLIS[i] NO ES DE LA CLASE BASE.

    if I = CantidadProp  -1  then
    Begin
      Campos.Add (PropList[i].Name+ ')');
      Parametros.Add ( ':'+ PropList[i].Name+')');
    End
    Else
    Begin
      Campos.Add ( PropList[i].Name+ ' , ') ;
      Parametros.Add (':'+PropList[i].Name+' , ');
    End;


    inc (Count) ;
    SetLength(ValoresCampos, Count);
    ValoresCampos[Count-1] := GetValorPropiedad(Self, PropList[i].Name);

  End;


  SQL := Campos + Parametros ;
  fDatos.EjecutarQuery(SQL, ValoresCampos , False );


end;
Saludos...
Responder Con Cita