unit U_XcCodeHelp10;

interface

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

type
  TfrmXcCodeHelp10 = class(TForm)
    tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    tv1sel: TcxGridDBColumn;
    tv1Name: TcxGridDBColumn;
    tv1Note: TcxGridDBColumn;
    ToolBar2: TToolBar;
    TOk: TToolButton;
    ToolButton2: TToolButton;
    ImageList24: TImageList;
    DS_Help: TDataSource;
    ADOQueryHelp: TADOQuery;
    CDS_Help: TClientDataSet;
    ADOConnection1: TADOConnection;
    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_clFuchsia: TcxStyle;
    cxStyle_fontclPurple: TcxStyle;
    cxStyle_fontclGreen: TcxStyle;
    cxStyle_fontclBlue: TcxStyle;
    procedure ToolButton2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure TOkClick(Sender: TObject);
    procedure tv1DblClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    procedure InitGrid();
  public
    pflag:string;  //类型标志
    fDivChar:string;
    fIsDoubleSel:Boolean;
    fSelResult:string;
  end;

var
  frmXcCodeHelp10: TfrmXcCodeHelp10;

implementation
uses
  U_formPas,U_global;
{$R *.dfm}

procedure TfrmXcCodeHelp10.ToolButton2Click(Sender: TObject);
begin
  close;
end;

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

end;
/////////////////////////////////////////////
procedure TfrmXcCodeHelp10.InitGrid();
begin
  try
    with ADOQueryHelp do
    begin
      close;
      sql.clear;
      sql.Add('exec P_Get_XC_code');
      sql.Add(quotedStr(pflag));
      Open;
    end;
    CreateCDS20(ADOQueryHelp,CDS_help);
    InitCDSData20(ADOQueryHelp,CDS_help);
  finally
  end;
end;
procedure TfrmXcCodeHelp10.TOkClick(Sender: TObject);
begin
  fSelResult:='';
  if fDivChar='' then
     fDivChar:=';';
  try
    CDS_help.DisableControls;
    with CDS_help do
    begin
      CDS_help.First ;
      while not CDS_help.eof do
      begin
        if fieldByName('sel').asBoolean then
        begin
          if trim(fSelResult)='' then
            fSelResult:=trim(fieldByName('名称').AsString) +fDivChar
          else
            fSelResult:=fSelResult+trim(fieldByName('名称').AsString)+fDivChar ;
        end;
        CDS_help.Next ;
      end;
    end;
  finally
    CDS_help.EnableControls ;
  end;
  ModalResult:=1;
end;

procedure TfrmXcCodeHelp10.tv1DblClick(Sender: TObject);
begin
  Tok.Click ;
end;

procedure TfrmXcCodeHelp10.FormShow(Sender: TObject);
begin
  self.Caption :='输入帮助(类别：'+pFlag+')';
  InitGrid();
  tv1sel.Visible:=fIsDoubleSel;
end;

end.
