unit U_ClothTypeSel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit,
  cxInplaceContainer, cxDBTL, cxControls, cxTLData, DB, ADODB, cxLookAndFeels,
  cxLookAndFeelPainters, cxTLdxBarBuiltInMenu, 
  dxSkinsDefaultPainters;

type
  TfrmClothTypeSel = class(TForm)
    ADOConnection1: TADOConnection;
    cxDBTreeList1: TcxDBTreeList;
    cxDBTreeList1cxDBTreeListColumn2: TcxDBTreeListColumn;
    DataSource1: TDataSource;
    ADOQueryHelp: TADOQuery;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure cxDBTreeList1DblClick(Sender: TObject);
  private
    { Private declarations }
  public
    FCTType: string;
    { Public declarations }
  end;

var
  frmClothTypeSel: TfrmClothTypeSel;

implementation

uses
  U_DataLink;
{$R *.dfm}

procedure TfrmClothTypeSel.FormCreate(Sender: TObject);
begin
  cxDBTreeList1.Align := alclient;
  try
    with ADOConnection1 do
    begin
      Connected := false;
      ConnectionString := DConString;
      Connected := true;
    end;
  except
  end;
end;

procedure TfrmClothTypeSel.FormShow(Sender: TObject);
begin
  with ADOQueryHelp do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from BS_Cloth_Type where CTType=' + quotedstr(FCTType) + ' order by CTlevel,CTOrder,CTName');
    Open;
  end;
  cxDBTreeList1.Items[0].Expand(false);
end;

procedure TfrmClothTypeSel.cxDBTreeList1DblClick(Sender: TObject);
begin
  if ADOQueryHelp.IsEmpty then
    exit;
  ModalResult := 1;
end;

end.

