unit U_JYG;

interface

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

type
  TfrmJYG = class(TForm)
    ScrollBox1: TScrollBox;
    btn1: TSpeedButton;
    btn2: TSpeedButton;
    btn3: TSpeedButton;
    btn4: TSpeedButton;
    ADOTmp: TADOQuery;
    btn5: TSpeedButton;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton6: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    SpeedButton9: TSpeedButton;
    SpeedButton10: TSpeedButton;
    SpeedButton11: TSpeedButton;
    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
  frmJYG: TfrmJYG;

implementation

uses
  U_DataLink;

{$R *.dfm}

procedure TfrmJYG.FormDestroy(Sender: TObject);
begin
  frmJYG := nil;
end;

procedure TfrmJYG.InitPerson();
type
  FdDy = record
    inc: integer;
    FDdys: string[32];
    FdDysName: string[32];
  end;
var
  BB: array[0..100] of FdDy;
  i, j: Integer;
begin

  with ADOTmp do
  begin
    Close;
    sql.Clear;
//    sql.Add('select UserID Note, UserName ZDYName from SY_User where Udept=''挡车工'' order by UserID ');
    sql.Add('select Note,ZDYName from KH_Zdy where Type=''' + Trim(FlagStr) + ''' order by Note,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].inc := i;
      BB[i].FDdys := Trim(fieldbyname('Note').AsString);
      BB[i].FdDysName := Trim(fieldbyname('ZDYName').AsString);
      i := i + 1;
      Next;
    end;
  end;
  i := i - 1;
  if i > 15 then
  begin
    i := 15;
  end;
  for j := 0 to i do
  begin
    with ScrollBox1 do
    begin
      TSpeedButton(Controls[j]).Visible := True;
      TSpeedButton(Controls[j]).Caption := BB[j].FdDysName;
    end;
  end;
end;

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

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

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

end;

end.

