unit U_SCColor;

interface

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

type
  TfrmSCColor = class(TForm)
    ADOTmp: TADOQuery;
    ScrollBox1: TScrollBox;
    btn1: TSpeedButton;
    btn2: TSpeedButton;
    btn3: TSpeedButton;
    btn4: TSpeedButton;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    SpeedButton9: TSpeedButton;
    SpeedButton10: TSpeedButton;
    SpeedButton11: TSpeedButton;
    SpeedButton12: TSpeedButton;
    SpeedButton13: TSpeedButton;
    SpeedButton14: TSpeedButton;
    SpeedButton15: TSpeedButton;
    SpeedButton16: TSpeedButton;
    SpeedButton17: TSpeedButton;
    SpeedButton18: TSpeedButton;
    SpeedButton19: TSpeedButton;
    SpeedButton20: TSpeedButton;
    SpeedButton21: TSpeedButton;
    SpeedButton22: TSpeedButton;
    SpeedButton23: TSpeedButton;
    SpeedButton24: TSpeedButton;
    SpeedButton25: TSpeedButton;
    SpeedButton26: TSpeedButton;
    SpeedButton27: TSpeedButton;
    SpeedButton28: TSpeedButton;
    SpeedButton29: TSpeedButton;
    SpeedButton30: TSpeedButton;
    SpeedButton31: 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
  frmSCColor: TfrmSCColor;

implementation
uses
  U_DataLink;

{$R *.dfm}

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

  with ADOTmp do
  begin
    Close;
    sql.Clear;
    sql.Add('select MLColor,NewSubid from ML_OrderSubidNew where NewMLID='''+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('MLColor').AsString);
      CC[i]:=Trim(fieldbyname('NewSubid').AsString);
      i:=i+1;
      Next;
    end;
  end;
  i:=i-1;
  if i>35 then
  begin
    i:=35;
  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:=CC[j];
    end;
  end;
end;

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

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

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

end;

end.
