Unit BaseModel;
interface
Uses SysUtils,Classes,DB,Variants;
Type
TDZModel=Class 
Private
  FValue:Variant;
  FDtype:TfieldType;
  FIsNull:Boolean;
  FFieldName:String;
  FRemark:String;
  FSize:Integer;
procedure SetValue(v:variant);
Function GetValue:Variant;
Public
  Constructor Create;
  Function ValueToString:String;
  property Value:Variant read GetValue write SetValue;
  Property DType:TfieldType read FDtype write FDtype;
  Property IsNull:boolean read FIsnull default True;
  Property FieldName:string read FFieldname write FFieldname;
  property Remark:string read Fremark write Fremark;
  property Size:integer read Fsize write Fsize;
End;
implementation

Constructor TDZModel.Create;
begin
  self.FIsnull:=True;
end;
Procedure TDZModel.SetValue(v: Variant);
begin
  self.Fvalue:=v;
  self.FIsNull:=false;
  if FDtype=ftAutoInc  then  exit;
  if variants.VarIsOrdinal(v) then
  self.FDtype:=FtInteger else 
  if variants.VarIsFloat(v) then
  self.FDtype:=FtFloat else 
  if variants.VarIsNumeric(v) then
  self.FDtype:=FtFloat else 
  if variants.VarIsStr(v) then
  self.FDtype:=FtString;
end;
Function TDZModel.GetValue ;
begin
  Result:=self.Fvalue ;
end;
Function TDZModel.ValueToString:string;
begin
  case FDtype of
  ftFloat,ftBCD,ftCurrency: result:=Floattostr(FValue);
  ftString,ftWideString,ftGuid,ftMemo:result:=''''+FValue+'''';
  FtBytes,ftAutoInc,ftSmallint,ftInteger,ftWord:result:=Inttostr(FValue);
  ftBoolean:result:=Booltostr(FValue);
  ftTime,ftDateTime,ftDate:result:=''''+DateTimeTostr(FValue)+'''';
  else Result:=''''+vartostr(self.Fvalue)+'''' ;
  end;
end;
End.
