⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs_idacrtti.pas

📁 Crlab公司用来连接MySQL数据库的控件
💻 PAS
📖 第 1 页 / 共 2 页
字号:

    with AddClass(TMacro, 'TCollectionItem') do begin
      AddProperty('AsDateTime', 'TDateTime', GetProp, SetProp);
      AddProperty('AsFloat', 'double', GetProp, SetProp);
      AddProperty('AsInteger', 'integer', GetProp, SetProp);
      AddProperty('AsString', 'string', GetProp, SetProp);
    end;
  end;
end;

function TFunctions.CallMethod(Instance: TObject; ClassType: TClass;
  const MethodName: String; Caller: TfsMethodHelper): Variant;
var
  DAConnection: TCustomDAConnection;
  CustomConnectDialog: TCustomConnectDialog;
  MemDataSet: TMemDataSet;
  CustomDADataSet: TCustomDADataSet;
begin
  Result := 0;

  if ClassType = TCustomDAConnection then begin
    DAConnection := TCustomDAConnection(Instance);
    if MethodName = 'OPEN' then
      DAConnection.Open
    else
    if MethodName = 'CLOSE' then
      DAConnection.Close
    else
    if MethodName = 'CONNECT' then
      DAConnection.Connect
    else
    if MethodName = 'DISCONNECT' then
      DAConnection.Disconnect
    else
    if MethodName = 'EXECSQL' then
      Result := DAConnection.ExecSQL(Caller.Params[0], [Caller.Params[1]])
    else
    if MethodName = 'GETTABLENAMES' then
      DAConnection.GetTableNames(TStrings(Integer(Caller.Params[0])))
    else
    if MethodName = 'GETDATABASENAMES' then
      DAConnection.GetDatabaseNames(TStrings(Integer(Caller.Params[0])))
    else
    if MethodName = 'GETSTOREDPROCNAMES' then
      DAConnection.GetStoredProcNames(TStrings(Integer(Caller.Params[0])))
    else
    if MethodName = 'STARTTRANSACTION' then
      DAConnection.StartTransaction
    else
    if MethodName = 'COMMIT' then
      DAConnection.Commit
    else
    if MethodName = 'ROLLBACK' then
      DAConnection.Rollback
    else
    if MethodName = 'APPLYUPDATES' then
      DAConnection.ApplyUpdates
    else
    if MethodName = 'CREATEDATASET' then
      Result := Integer(DAConnection.CreateDataSet)
    else
    if MethodName = 'REMOVEFROMPOOL' then
      DAConnection.RemoveFromPool
    else
    if MethodName = 'MONITORMESSAGE' then
      DAConnection.MonitorMessage(Caller.Params[0])
    else
    if MethodName = 'DATASETS.GET' then
      Result := Integer(DAConnection.DataSets[Caller.Params[0]])
  end
  else
  if ClassType = TCustomConnectDialog then begin
    CustomConnectDialog := TCustomConnectDialog(Instance);
    if MethodName = 'EXECUTE' then
      Result := Integer(CustomConnectDialog.Execute)
    else
    if MethodName = 'GETSERVERLIST' then
      CustomConnectDialog.GetServerList(TStrings(Integer(Caller.Params[0])))
  end
  else
  if ClassType = TMemDataSet then begin
    MemDataSet := TMemDataSet(Instance);
    if MethodName = 'PREPARE' then
      MemDataSet.Prepare
    else
    if MethodName = 'UNPREPARE' then
      MemDataSet.UnPrepare
    else
    if MethodName = 'CHECKPREPARED' then
      MemDataSet.CheckPrepared
    else
    if MethodName = 'UPDATESTATUS' then
      Result := Integer(MemDataSet.UpdateStatus)
    else
    if MethodName = 'UPDATERESULT' then
      Result := Integer(MemDataSet.UpdateResult)
    else
    if MethodName = 'APPLYUPDATES' then
      MemDataSet.ApplyUpdates
    else
    if MethodName = 'COMMITUPDATES' then
      MemDataSet.CommitUpdates
    else
    if MethodName = 'CANCELUPDATES' then
      MemDataSet.CancelUpdates
    else
    if MethodName = 'RESTOREUPDATES' then
      MemDataSet.RestoreUpdates
    else
    if MethodName = 'REVERTRECORD' then
      MemDataSet.RevertRecord
    else
    if MethodName = 'SAVETOXML' then
      MemDataSet.SaveToXML(String(Caller.Params[0]))
  end
  else
  if ClassType = TCustomDADataSet then begin
    CustomDADataSet := TCustomDADataSet(Instance);
    if MethodName = 'EXECUTE' then
      CustomDADataSet.Execute
    else
    if MethodName = 'EXECUTING' then
      Result := CustomDADataSet.Executing
    else
    if MethodName = 'FETCHING' then
      Result := CustomDADataSet.Fetching
    else
    if MethodName = 'REFRESHRECORD' then
      CustomDADataSet.RefreshRecord
    else
    if MethodName = 'FINDMACRO' then
      Result := Integer(CustomDADataSet.FindMacro(String(Caller.Params[0])))
    else
    if MethodName = 'MACROBYNAME' then
      Result := Integer(CustomDADataSet.MacroByName(String(Caller.Params[0])))
    else
    if MethodName = 'SAVESQL' then
      CustomDADataSet.SaveSQL
    else
    if MethodName = 'RESTORESQL' then
      CustomDADataSet.RestoreSQL
    else
    if MethodName = 'SQLSAVED' then
      Result := CustomDADataSet.SQLSaved
    else
    if MethodName = 'ADDWHERE' then
      CustomDADataSet.AddWhere(String(Caller.Params[0]))
    else
    if MethodName = 'DELETEWHERE' then
      CustomDADataSet.DeleteWhere
    else
    if MethodName = 'SETORDERBY' then
      CustomDADataSet.SetOrderBy(String(Caller.Params[0]))
    else
    if MethodName = 'GETORDERBY' then
      Result := CustomDADataSet.GetOrderBy;
  end;
end;


function TFunctions.GetProp(Instance: TObject; ClassType: TClass;
  const PropName: String): Variant;
var
  CustomDAConnection: TCustomDAConnection;
  CustomConnectDialog: TCustomConnectDialog;
begin
  Result := 0;

  if ClassType = TCustomDAConnection then begin
    CustomDAConnection := TCustomDAConnection(Instance);
    if PropName = 'INTRANSACTION' then
      Result := CustomDAConnection.InTransaction
    else
    if PropName = 'DATASETCOUNT' then
      Result := CustomDAConnection.DataSetCount;
  end
  else
  if ClassType = TCustomConnectDialog then begin
    CustomConnectDialog := TCustomConnectDialog(Instance);
    if PropName = 'CONNECTION' then
      Result := Integer(CustomConnectDialog.Connection)
    else
    if PropName = 'RETRIES' then
      Result := CustomConnectDialog.Retries
    else
    if PropName = 'SAVEPASSWORD' then
      Result := CustomConnectDialog.SavePassword
    else
    if PropName = 'STORELOGINFO' then
      Result := CustomConnectDialog.StoreLogInfo
    else
    if PropName = 'DIALOGCLASS' then
      Result := CustomConnectDialog.DialogClass
    else
    if PropName = 'CAPTION' then
      Result := CustomConnectDialog.Caption
    else
    if PropName = 'USERNAMELABEL' then
      Result := CustomConnectDialog.UsernameLabel
    else
    if PropName = 'PASSWORDLABEL' then
      Result := CustomConnectDialog.PasswordLabel
    else
    if PropName = 'SERVERLABEL' then
      Result := CustomConnectDialog.ServerLabel
    else
    if PropName = 'CONNECTBUTTON' then
      Result := CustomConnectDialog.ConnectButton
    else
    if PropName = 'CANCELBUTTON' then
      Result := CustomConnectDialog.CancelButton
    else
    if PropName = 'LABELSET' then
      Result := Integer(CustomConnectDialog.LabelSet)
  end
  else
  if ClassType = TMemDataSet then begin
    if PropName = 'PREPARED' then
      Result := TMemDataSet(Instance).Prepared
    else
    if PropName = 'RECORDCOUNT' then
      Result := TMemDataSet(Instance).RecordCount;
  end
  else
  if ClassType = TMacro then begin
    if PropName = 'ASDATETIME' then
      Result := TMacro(Instance).AsDateTime
    else
    if PropName = 'ASFLOAT' then
      Result := TMacro(Instance).AsFloat
    else
    if PropName = 'ASINTEGER' then
      Result := TMacro(Instance).AsInteger
    else
    if PropName = 'ASSTRING' then
      Result := TMacro(Instance).AsString;
  end;
end;

procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass;
  const PropName: String; Value: Variant);
var
  CustomConnectDialog: TCustomConnectDialog;
begin
  if ClassType = TCustomConnectDialog then begin
    CustomConnectDialog := TCustomConnectDialog(Instance);
    if PropName = 'RETRIES' then
      CustomConnectDialog.Retries := Value
    else
    if PropName = 'SAVEPASSWORD' then
      CustomConnectDialog.SavePassword := Value
    else
    if PropName = 'STORELOGINFO' then
      CustomConnectDialog.StoreLogInfo := Value
    else
    if PropName = 'DIALOGCLASS' then
      CustomConnectDialog.DialogClass := Value
    else
    if PropName = 'CAPTION' then
      CustomConnectDialog.Caption := Value
    else
    if PropName = 'USERNAMELABEL' then
      CustomConnectDialog.UsernameLabel := Value
    else
    if PropName = 'PASSWORDLABEL' then
      CustomConnectDialog.PasswordLabel := Value
    else
    if PropName = 'SERVERLABEL' then
      CustomConnectDialog.ServerLabel := Value
    else
    if PropName = 'CONNECTBUTTON' then
      CustomConnectDialog.ConnectButton := Value
    else
    if PropName = 'CANCELBUTTON' then
      CustomConnectDialog.CancelButton := Value
    else
    if PropName = 'LABELSET' then
      CustomConnectDialog.LabelSet := TLabelSet(Value);
  end
  else
  if ClassType = TMemDataSet then begin
    if PropName = 'PREPARED' then
      TMemDataSet(Instance).Prepared := Value; 
  end
  else
  if ClassType = TMacro then begin
    if PropName = 'ASDATETIME' then
      TMacro(Instance).AsDateTime := Value
    else
    if PropName = 'ASFLOAT' then
      TMacro(Instance).AsFloat := Value
    else
    if PropName = 'ASINTEGER' then
      TMacro(Instance).AsInteger := Value
    else
    if PropName = 'ASSTRING' then
      TMacro(Instance).AsString := Value;
  end;
end;

initialization
  fsRTTIModules.Add(TFunctions);

finalization
  if fsRTTIModules <> nil then
    fsRTTIModules.Remove(TFunctions);

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -