zoukankan      html  css  js  c++  java
  • 数据字典的使用一例

    字典数据表设计,table字段设置排序

    读取字典元数据方法
    procedure SetDataSet(dataset: TDataSet; const table: string);
    var
      d: TADOQuery;
      i: Integer;
    begin
      if dataset = nil then Exit;
      if not dataset.Active then Exit;
      if table = '' then Exit;
      d := TADOQuery.Create(nil);
      try
        with d do
        begin
          Connection := uFunction.GetConnection;
          Close;
          SQL.Clear;
          SQL.Text := 'select table, ename, cname, width, visible from dictionary '+
            'where table = :a';
          Parameters.ParamByName('a').Value := table;
          Open;
        end;
        if d.IsEmpty then Exit;
        d.First;
        while not d.Eof do
        begin
          for I := 0 to dataset.FieldCount - 1 do
          begin
            if dataset.Fields[i].FieldName = d.FindField('ename').AsString then
            begin
              dataset.Fields[i].DisplayLabel := d.FindField('cname').AsString;
              dataset.Fields[i].DisplayWidth := d.FindField('width').AsInteger;
              dataset.Fields[i].Visible := d.FindField('visible').AsBoolean;
              Break;
            end; 
          end;
          d.Next;
        end;
      finally
        d.Free;
      end;
    end;
    调用示例
    procedure TformEmployee.HYVisualPluginCreate(Sender: TObject);
    begin
      with ADOQuery1 do
      begin
        Connection := uFunction.GetConnection;
        Close;
        SQL.Clear;
        SQL.Text := 'select * from employee';
        Open;
      end;
      uFunction.SetDataSet(ADOQuery1, 'employee');
    end;
    效果图片
  • 相关阅读:
    原型和原型链的理解
    vue2.0 购物车小球的实现
    canvas 实现规则多边形
    ES6全套教程
    利用canvas实现雪花的飘动
    前端 原型对象中this的认识
    JavaScript——创建对象
    javaScript——原型继承四步曲
    AltiumDesigner使用小窍门 (转)
    C指针理解(转)
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940687.html
Copyright © 2011-2022 走看看