unit U_SCPerson;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, DB, ADODB;

type
  TfrmSCPerson = class(TForm)
    ScrollBox1: TScrollBox;
    btn1: TSpeedButton;
    btn2: TSpeedButton;
    btn3: TSpeedButton;
    btn4: TSpeedButton;
    btn5: TSpeedButton;
    btn6: TSpeedButton;
    btn7: TSpeedButton;
    btn8: TSpeedButton;
    btn58: TSpeedButton;
    btn9: TSpeedButton;
    btn10: TSpeedButton;
    btn11: TSpeedButton;
    btn12: TSpeedButton;
    btn13: TSpeedButton;
    btn14: TSpeedButton;
    btn15: TSpeedButton;
    ADOTmp: TADOQuery;
    procedure FormDestroy(Sender: TObject);

    procedure FormShow(Sender: TObject);
    procedure btn1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
     procedure InitPerson();
    { Private declarations }
  public
    FlagStr:String;
    FSDPerson:String;
    { Public declarations }
  end;

var
  frmSCPerson: TfrmSCPerson;

implementation
uses
  U_DataLink;

{$R *.dfm}

procedure TfrmSCPerson.FormDestroy(Sender: TObject);
begin
  frmSCPerson:=nil;
end;
procedure TfrmSCPerson.InitPerson();
var
  BB:array[0..100] of string;
  i,j:Integer;
begin

  with ADOTmp do
  begin
    Close;
    sql.Clear;
    sql.Add('select ZDYName from KH_Zdy where Type='''+Trim(FlagStr)+'''  '); //order by ZDYName
    Open;
  end;
  if ADOTmp.IsEmpty then
  begin
    Application.MessageBox('没有定义数据！','提示',0);
    Exit;
  end;
  with ADOTmp do
  begin
    First;
    i:=0;
    while not Eof do
    begin
      BB[i]:=Trim(fieldbyname('ZDYName').AsString);
      i:=i+1;
      Next;
    end;
  end;
  i:=i-1;
  if i>63 then
  begin
    i:=63;
  end;
  for j:=0 to i do
  begin
    with ScrollBox1 do
    begin
      TSpeedButton(Controls[j]).Visible:=True;
      TSpeedButton(Controls[j]).Caption:=BB[j];
      {TSpeedButton(Controls[j]).Hint:=BB[j];
      if Length(BB[j])>4 then
      begin
        TSpeedButton(Controls[j]).Caption:=Copy(Trim(BB[j]),1,4)+#13+Copy(Trim(BB[j]),5,Length(BB[j])-4);
      end else
        TSpeedButton(Controls[j]).Caption:=BB[j]; }
    end;
  end;
end;

procedure TfrmSCPerson.FormShow(Sender: TObject);
begin
  InitPerson();
end;

procedure TfrmSCPerson.btn1Click(Sender: TObject);
begin
  FSDPerson:=Trim(TSpeedButton(Sender).Caption);
  ModalResult:=1;
end;

procedure TfrmSCPerson.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 // Action:=caHide;

end;

end.
