unit U_curencyHelp;

interface

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

type
  TfrmcurencyHelp = class(TForm)
    ToolBar1: TToolBar;
    TBOk: TToolButton;
    TBClose: TToolButton;
    ImageList24: TImageList;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    edttj: TEdit;
    cxGrid1: TcxGrid;
    tv1: TcxGridDBTableView;
    tv1curid: TcxGridDBColumn;
    tv1curName: TcxGridDBColumn;
    tv1AccRate: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    DataSource1: TDataSource;
    ADOConnection1: TADOConnection;
    ADOQueryHelp: TADOQuery;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxStyle_gridRow: TcxStyle;
    cxStyle_gridFoot: TcxStyle;
    cxStyle_gridHead: TcxStyle;
    cxStyle_gridGroupBox: TcxStyle;
    cxStyle_yellow: TcxStyle;
    cxStyle_Red: TcxStyle;
    cxStyle_fontBlack: TcxStyle;
    cxStyle_fontclFuchsia: TcxStyle;
    cxStyle_fontclPurple: TcxStyle;
    cxStyle_fontclGreen: TcxStyle;
    cxStyle_fontclBlue: TcxStyle;
    cxStyle_fontclTeal: TcxStyle;
    cxStyle_fontclOlive: TcxStyle;
    cxLookAndFeelController1: TcxLookAndFeelController;
    procedure TBOkClick(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure edttjChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure tv1DblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmcurencyHelp: TfrmcurencyHelp;

implementation
uses
  U_global;

{$R *.dfm}

procedure TfrmcurencyHelp.TBOkClick(Sender: TObject);
begin
  if ADOQueryHelp.IsEmpty then
    ModalResult:=-1
  else
    modalResult:=1;
end;

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

procedure TfrmcurencyHelp.FormCreate(Sender: TObject);
begin
  cxgrid1.Align :=alClient;
  with ADOConnection1 do
  begin
    Connected:=false;
    ConnectionString:=gConString;
    Connected:=true;
  end;
end;

procedure TfrmcurencyHelp.edttjChange(Sender: TObject);
begin
  try
    ADOQueryHelp.DisableControls;
    if trim(edttj.Text)<>'' then
    begin
      with ADOQueryHelp do
      begin
        filtered:=false;
        filter:='curid like '+quotedStr('%'+trim(edttj.Text)+'%')+
              ' or curidName like '+quotedStr(trim(edttj.Text)+'%');
        filtered:=true;
      end;
    end
    else
    begin
      with ADOQueryHelp do
      begin
        filtered:=false;
      end;
    end;
  finally
    ADOQueryHelp.EnableControls;
  end;
end;

procedure TfrmcurencyHelp.FormShow(Sender: TObject);
begin
  try
    ADOQueryHelp.DisableControls ;
    with ADOQueryHelp do
    begin
      Filtered:=False;
      close;
      sql.Clear;
      sql.Add('select A.* ');
      sql.Add('from FC_curency A order by Curid');
      open;
    end;
  finally
    ADOQueryHelp.EnableControls ;
  end;
end;

procedure TfrmcurencyHelp.tv1DblClick(Sender: TObject);
begin
  ModalResult:=1;
end;

end.
