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;
    效果图片
  • 相关阅读:
    进制
    变量
    cmd命令和快捷键
    面向对象和面向过程
    iterations 快捷键
    SQL语句分类和语法
    MySQL语法规范
    Web-Scale-IT 到底是啥?
    安全的应用程序开发和应用程序安全防御
    如何像后端一样写前端代码?
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940687.html
Copyright © 2011-2022 走看看