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;
    效果图片
  • 相关阅读:
    Quartz Cron表达式详解
    面向对象设计的SOLID原则
    JDK动态代理Demo代码,简单易懂
    <x:forEach/>遍历RSS新闻
    <x:parse/>获取RSS新闻
    fn:length()方法
    使用一个map映射出两个对象,再把两者关系对应起来
    用户注册_发邮件,激活
    ajax 的json联动
    封装ajax小工具:
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940687.html
Copyright © 2011-2022 走看看