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

📄 sctvopt.pas

📁 suite component ace report
💻 PAS
📖 第 1 页 / 共 5 页
字号:
procedure TSctDSVariableOptions.UpdateCFList;
var
  FieldList, VarList, DbFieldList: TStringList;
  pg: TSctGroupPage;
  Spot: Integer;
  DSG: TSctDataSourceGuide;
  Variable: TSctVar;
  DataSource: TDataSource;
begin
  FieldList := TStringList.Create;
  VarList := TStringList.Create;
  DBFieldList := TStringList.Create;

  DSG := GetDataSourceGuide(GetFullDSName);
  if DSG <> nil then
  begin
    pg := GetGroupPage;
    DataSource := DSG.DataSource;
    if Datasource <> nil then
    begin
      if pg.VarList <> nil then
      begin
        for Spot := 0 to pg.VarList.count - 1 do
        begin
          Variable := pg.varlist.items[Spot];
          if Variable.id = vidAutoDataVar then
          begin
            if variable is TSctDbVar then
            begin
              if TSctDbvar(Variable).DataSource = DataSource then
                VarList.Add(TSctDbVar(Variable).DataField);
            end;
          end;
        end;

        if DataSource.DataSet <> nil then
        begin
          try
            DataSource.DataSet.GetFieldNames(DBFieldList);
          except
          end;
        end;

        for Spot := 0 to DbFieldList.Count - 1 do
        begin
          if VarList.IndexOf( DBFieldList[Spot] ) = -1 then
            FieldList.Add( DbFieldList[Spot] );
        end;

      end;
    end;
  end;

  CList.Clear;
  CList.Items.Assign(VarList);
  FList.Clear;
  FList.Items.Assign(FieldList);
  FieldList.Free;
  VarList.Free;
  DBFieldList.Free;
end;
{$endif}

procedure TSctDSVariableOptions.UpdateTotalList;
var
  pg: TSctGroupPage;
  Spot: Integer;
  TotalItem: TTotalItem;
  TotalVar: TSctTotalVar;
begin
  ClearList(TotalList);
  if PageManager <> nil then
  begin
    pg := TSctGroupPage(PageManager.Page);
    if pg <> nil then
    begin
      if pg.TotalVars <> nil then
      begin
        for Spot := 0 to pg.TotalVars.Count - 1 do
        begin
          TotalVar := TSctTotalVar(pg.TotalVars.Items[Spot]);

          TotalItem := TTotalItem.Create;
          TotalItem.TotalName := TotalVar.Name;
          if TotalVar.UpdateLevel <> nil then TotalItem.TotalLevelName := TotalVar.UpdateLevel.Name
          else TotalItem.TotalLevelName := 'Fill in UpdateLevel.';

          if TotalVar.Variable <> nil then TotalItem.TotalVarName := TotalVar.Variable.Name
          else TotalItem.TotalVarName := 'Fill in Variable.';

          TotalItem.Used := VarUsed(TotalVar);

          TotalItem.LevelMatch := True;
          if (TotalVar.UpdateLevel <> nil) And (TotalVar.Variable <> nil) then
          begin
            if TotalVar.Variable.UpdateLevel <> nil then
            begin
              if TotalVar.Variable.UpdateLevel <> TotalVar.UpdateLevel then
                TotalItem.LevelMatch := False;
            end;
          end;


          TotalList.Add(TotalItem);
        end;
      end;
      TotalVarList.Clear;
      for Spot := 0 to TotalList.Count - 1 do
      begin
        TotalItem := TTotalItem(TotalList.Items[Spot]);
        TotalVarList.Items.Add(TotalItem.TotalName);
      end;
    end;
  end;
end;
procedure TSctDSVariableOptions.UpdateExprList;
var
  pg: TSctGroupPage;
  Spot: Integer;
  ExprItem: TExprItem;
  ExprVar: TSctExprVar;

  function DataToString(dtype: TSctDataTypes): String;
  begin
    Result := '';
    case dtype of
      dtypeUnknown: Result := 'Unknown';
      dtypeString: Result := 'String';
      dtypeFloat: Result := 'Float';
      dtypeInteger: Result := 'Integer';
      dtypeBoolean: Result := 'Boolean';
      dtypeDateTime: Result := 'DateTime';
      dtypeBlob: Result := 'Blob';
      dtypeMemo: Result := 'Memo';
      dtypeGraphic: Result := 'Graphic';
    end;
  end;

begin
  ClearList(ExprList);
  if PageManager <> nil then
  begin
    pg := TSctGroupPage(PageManager.Page);
    if pg <> nil then
    begin
      if pg.VarList <> nil then
      begin
        for Spot := 0 to pg.VarList.Count - 1 do
        begin
          if TSctVar(pg.Varlist.Items[Spot]).id = vidExprVar then
          begin
            ExprVar := TSctExprVar(pg.Varlist.Items[Spot]);
            ExprItem := TExprItem.Create;
            ExprItem.ExprName := ExprVar.Name;

            if ExprVar.UpdateLevel <> nil then ExprItem.ExprLevelName := ExprVar.UpdateLevel.Name
            else ExprItem.ExprLevelName := 'Fill in UpdateLevel.';

            ExprItem.ExprEventName := AceGetMethodValue(ExprVar, 'OnGetData', PageManager.PageDesigner);
            if ExprItem.ExprEventName = '' then
                ExprItem.ExprEventName := 'Fill in OnGetData event.';

            ExprItem.ExprTypeName := DataToString(ExprVar.DataType);
            ExprItem.Used := VarUsed(ExprVar);

            ExprList.Add(ExprItem);
          end;
        end;
      end;
      ExprVarList.Clear;
      for Spot := 0 to ExprList.Count - 1 do
      begin
        ExprItem := TExprItem(ExprList.Items[Spot]);
        ExprVarList.Items.Add(ExprItem.ExprName);
      end;
    end;
  end;
end;




function TSctDSVariableOptions.GetGroupPage: TSctGroupPage;
begin
  Result := nil;
  if PageManager <> nil then
  begin
    Result := TSctGroupPage(PageManager.Page);
  end;
end;
function TSctDSVariableOptions.DsgOk: Boolean;
begin
  Result := (DsgList.Count > 0) And (DataSourceList.Row < DsgList.Count) And (DataSourceList.Row >= 0);
end;

{$ifdef AceBDE}
function TSctDSVariableOptions.GetFullDSName: String;
begin
  Result := '';
  if DsgOk then
  begin
    Result := TDsgItem(DsgList.Items[DataSourceList.Row]).DataSourceName;
  end;
end;
{$endif}
{$ifdef AceBDE}
function TSctDSVariableOptions.GetDataSourceGuide(FullDSName: String): TSctDataSourceGuide;
var
  Spot: Integer;
  pg: TSctGroupPage;
  DataSource: TDataSource;
  MySpot: Integer;
begin
  Result := nil;
  if Not (FullDSName = '') then
  begin
    pg := GetGroupPage;
    if pg <> nil then
    begin
      Spot := 0;
      FullDSName := UpperCase(FullDSName);
      while (Result = nil) And (Spot < pg.FullDSNames.Count) do
      begin
        if (UpperCase(pg.FullDSNames[Spot]) = FullDSName) then
        begin
          DataSource := TDataSource(pg.FullDsList.Items[Spot]);
          if DataSource <> nil then
          begin
            MySpot := 0;
            while (Result = nil) And (MySpot < pg.DataSourceList.Count) do
            begin
              if TSctDataSourceGuide(pg.DataSourceList[MySpot]).DataSource = DataSource then
              begin
                Result := TSctDataSourceGuide(pg.DataSourceList.Items[MySpot]);
              end;
              Inc(MySpot);
            end;
          end;
        end;
        Inc(Spot);
      end;
    end;
  end;
end;
{$endif}
{$ifdef AceBDE}
function TSctDSVariableOptions.GetDbVar(DSG: TSctDataSourceGuide; FieldName: String): TSctDbVar;
var
  pg: TSctGroupPage;
  Spot: Integer;
  Variable: TSctVar;
begin
  Result := nil;
  if DSG <> nil then
  begin
    pg := GetGroupPage;

    Spot := 0;
    While (Result = nil) And (Spot < pg.VarList.Count) do
    begin
      Variable := pg.varlist.items[Spot];
      if Variable.id = vidAutoDataVar then
      begin
        if (TSctDbvar(Variable).DataSource = DSG.DataSource) And
           (TSctDbVar(Variable).DataField = FieldName) then Result := TSctDBVar(Variable);
      end;
      Inc(Spot);
    end;
  end;
end;
{$endif}
{$ifdef AceBDE}
procedure TSctDSVariableOptions.AddDbVar(DSG: TSctDataSourceGuide; FieldName: String);
var
  rvar: TSctDbVar;
begin
  if DSG <> nil then
  begin
    if GetDBVar(DSG, FieldName) = nil then
    begin
      rvar := TSctdbvar.Create(PageManager.Page.Owner);
      SctAutoSetComponentName(rvar, lowercase(DSG.DataSource.DataSet.Name) + FieldName+'Var', False);
{      SctAutoSetComponentName(rvar, lowercase(DSG.DataSource.DataSet.Name) + FieldName, False);}
{      SctAutoSetComponentName(rvar, 'AutoDBVar_' + FieldName, False);}
      rvar.Parent := TSctGroupPage(PageManager.Page);
      rvar.Autovar := DSG.CreateVariables;
      rvar.id := vidAutoDataVar;
      rvar.DataSource := DSG.DataSource;
      rvar.DataField := FieldName;
      rvar.UpdateLevel := DSG.UpdateLevel;
    end;
  end;
end;
{$endif}
procedure TSctDSVariableOptions.DeleteVar(MyVar: TSctVar);
begin
try
  if MyVar <> nil then
  begin
    MyVar.Parent := nil;
    MyVar.Free;
  end;
finally
end;
end;

{$ifdef AceBDE}
procedure TSctDSVariableOptions.CListDelete;
var
  DSG: TSctDataSourceGuide;
  List: TStringList;
  Spot: Integer;
begin
  DSG := GetDataSourceGuide(GetFullDSName);
  if DSG <> nil then
  begin
    if AceIsAncestor(DSG) then ShowMessage('Selection contains a component '
              + 'introduced in an ancestor form which cannot be deleted')
    else
    begin
      List := TStringList.Create;
      for Spot := 0 to clist.Items.Count - 1 do
      begin
        if clist.Selected[Spot] then List.Add(clist.Items[Spot])
      end;
      SelectComponent(nil);
      for Spot := 0 to List.Count - 1 do DeleteVar(GetDbVar(DSG, List[Spot]));
      List.Free;
      RefreshLists;
      PageManager.PageDesigner.Modified;
    end;
  end;
end;
{$endif}
{$ifdef AceBDE}
procedure TSctDSVariableOptions.FListDefine;
var
  DSG: TSctDataSourceGuide;
  List: TStringList;
  Spot: Integer;
begin
  DSG := GetDataSourceGuide(GetFullDSName);
  if DSG <> nil then
  begin
    if AceIsAncestor(DSG) then ShowMessage('Selection contains a component '
            + 'introduced in an ancestor form.  Define fields there.')
    else
    begin
      List := TStringList.Create;
      for Spot := 0 to flist.Items.Count - 1 do
      begin
        if flist.Selected[Spot] then List.Add(flist.Items[Spot])
      end;
      for Spot := 0 to List.Count - 1 do AddDbVar(DSG, List[Spot]);
      List.Free;
      RefreshLists;
      PageManager.PageDesigner.Modified;
    end;
  end;
end;
{$endif}

function TSctDSVariableOptions.GetVar(VarName: String): TSctVar;
var
  pg: TSctGroupPage;
  Spot: Integer;
begin
  Result := nil;
  pg := GetGroupPage;
  if pg <> nil then
  begin
    if pg.VarList <> nil then
    begin
      Spot := 0;
      while (Result = nil) And (Spot < pg.VarList.Count) do
      begin
        if TSctVar(pg.VarList.Items[Spot]).Name = VarName then Result := pg.VarList.Items[Spot];
        Inc(Spot);
      end;
    end;
  end;
end;

procedure TSctDSVariableOptions.AddTotal(List: TListBox);
var
  Spot: Integer;
  MyVar: TSctVar;
  rvar: TSctTotalVar;

  SList: TStringList;
  VarName: String;
  DSG: TSctDataSourceGuide;
  Current: Integer;
begin
  if List.SelCount > 0 then
  begin
    Current := TotalVarList.Items.Count;
    SList := TStringList.Create;
    for Spot := 0 to List.Items.Count - 1 do
    begin
      if List.Selected[Spot] then SList.Add(List.Items[Spot]);
    end;

{$ifdef AceBDE}
    DSG := GetDataSourceGuide(GetFullDSName);
{$endif}
    for Spot := 0 to SList.Count - 1 do
    begin
      VarName := SList[Spot];

      if List = ExprVarList then MyVar := GetVar(VarName)
{$ifdef AceBDE}
      else if List = DBVarList then MyVar := GetVar(VarName)
      else MyVar := GetDbVar(DSG, VarName);
{$else}
  ;
{$endif}

      if MyVar <> nil then
      begin
        rvar := TSctTotalVar.Create(PageManager.Page.Owner);
{$ifdef AceBDE}
        if MyVar is TSctDbVar then VarName := TSctDbVar(MyVar).DataField
        else
{$endif}
          VarName := MyVar.Name;

        SctAutoSetComponentName(rvar, 'TotalOf' + VarName, False);
        rvar.Parent := TSctGroupPage(PageManager.Page);
        rvar.updatelevel := MyVar.UpdateLevel;
        rvar.Variable := MyVar;
      end;
    end;

    SList.Free;
    if PageManager <> nil then PageManager.PageDesigner.Modified;
    RefreshLists;
    Inc(Current);
    for Spot := Current to TotalVarList.Items.Count do
    begin
      TotalVarList.Selected[Spot-1] := True;
    end;
    TotalVarList.ItemIndex := TotalVarList.Items.Count - 1;
    TotalVarListClick(TotalVarList);
  end;
end;

{$ifndef AceBDE}
procedure TSctDSVariableOptions.AddManualDBVar(List: TListBox);
begin
end;
{$else}
procedure TSctDSVariableOptions.AddManualDBVar(List: TListBox);
var
  Spot: Integer;
  SList: TStringList;
  VarName: String;
  DSG: TSctDataSourceGuide;
  rvar: TSctDBVar;
  Current: Integer;
begin
  if List.SelCount > 0 then
  begin
    Current := DBVarList.Items.Count;
    SList := TStringList.Create;
    for Spot := 0 to List.Items.Count - 1 do
    begin

⌨️ 快捷键说明

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