unit U_jwlAreanHelp;

interface

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

type
  TfrmJwlAreanHelp = class(TForm)
    DataSource1: TDataSource;
    ADOQuery1: TADOQuery;
    Button1: TButton;
    Button2: TButton;
    dbGrid1: TcxGrid;
    dbGrid1Level1: TcxGridLevel;
    tv1: TcxGridDBTableView;
    tv1marea1: TcxGridDBColumn;
    tv1mareaName1: TcxGridDBColumn;
    ADOConnection1: TADOConnection;
    procedure FormShow(Sender: TObject);
    procedure DBGrid1TitleClick(Column: TColumn);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure tv1DblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    str_dylx:string; //判断是哪个模块在调用
    fIsOut:Boolean;
    fCode:string;
    { Public declarations }
  end;

var
  frmJwlAreanHelp: TfrmJwlAreanHelp;

implementation
uses
  U_global;
{$R *.dfm}

procedure TfrmJwlAreanHelp.FormShow(Sender: TObject);
begin
  with adoquery1 do
  begin
    close;
    sql.Clear;
    if fIsOut then
    begin
      sql.Add('select B.marea,B.mareaName from (');
      sql.Add('select distinct Marea from Kf_nowQuan where mNumBer='''+fCode+''') A');
      sql.Add('inner join kf_marea b on B.Marea=A.Marea ');
    end
    else
      sql.Add('select marea,mareaName from Kf_marea order by marea');
    open;
  end;
end;

procedure TfrmJwlAreanHelp.DBGrid1TitleClick(Column: TColumn);
begin
 {
  with adoquery1 do
  begin
    close;
    sql.Clear;
    sql.Add('select marea,mareaName from Kf_marea   order by '+column.FieldName+'');
    open;
  end;
  }
end;

procedure TfrmJwlAreanHelp.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  action:=cafree;
end;

procedure TfrmJwlAreanHelp.Button2Click(Sender: TObject);
begin
  ModalResult:=1; 
end;

procedure TfrmJwlAreanHelp.Button1Click(Sender: TObject);
begin
  close;
end;

procedure TfrmJwlAreanHelp.tv1DblClick(Sender: TObject);
begin
  Button2Click(Button2);
end;

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

end.
