unit U_SettlementHelp;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, cxDropDownEdit, ComCtrls, ToolWin,
  ImgList, ADODB, cxGridLevel, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid;

type
  TfrmSettlementHelp = class(TForm)
    dbGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    Tv1code: TcxGridDBColumn;
    Tv1Name: TcxGridDBColumn;
    dbGrid1Level1: TcxGridLevel;
    ADOConnection1: TADOConnection;
    DataSource1: TDataSource;
    ADOQueryHelp: TADOQuery;
    ImageList24: TImageList;
    ToolBar1: TToolBar;
    TBOk: TToolButton;
    TBClose: TToolButton;
    procedure FormCreate(Sender: TObject);
    procedure TBOkClick(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure Tv1DblClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    procedure  InitGrid();
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmSettlementHelp: TfrmSettlementHelp;

implementation
uses
  U_global;

{$R *.dfm}

procedure TfrmSettlementHelp.FormCreate(Sender: TObject);
begin
  with ADOConnection1 do
  begin
    Connected:=False;
    ConnectionString:=gConString;
    Connected:=True;
  end;
  dbGrid1.Align:=alClient;
end;

procedure TfrmSettlementHelp.InitGrid();
begin
  try
    ADOQueryHelp.DisableControls;
    with ADOQueryHelp do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select SSCode Code,SSName Name from GY_Settlement');
      Open;
    end;
  finally
    ADOQueryHelp.EnableControls;
  end;
end;

procedure TfrmSettlementHelp.TBOkClick(Sender: TObject);
begin
  if ADOQueryHelp.IsEmpty then Exit;
  ModalResult:=1;
end;

procedure TfrmSettlementHelp.TBCloseClick(Sender: TObject);
begin
  ModalResult:=-1;
end;

procedure TfrmSettlementHelp.Tv1DblClick(Sender: TObject);
begin
  TBOk.Click;
end;

procedure TfrmSettlementHelp.FormShow(Sender: TObject);
begin
  InitGrid();
end;

end.
