unit U_JcFlawHelp;

interface

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

type
  TfrmJcFlawHelp = class(TForm)
    ADOQueryHelp: TADOQuery;
    btOk: TBitBtn;
    btNo: TBitBtn;
    dbGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    Tv1FlawCode: TcxGridDBColumn;
    Tv1FlawChn: TcxGridDBColumn;
    dbGrid1Level1: TcxGridLevel;
    DataSource1: TDataSource;
    ADOConnection1: TADOConnection;
    cxLookAndFeelController1: TcxLookAndFeelController;
    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;
    CDSHELP: TClientDataSet;
    v1sel: TcxGridDBColumn;
    CheckBox1: TCheckBox;
    procedure btNoClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btOkClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Tv1DblClick(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
  private
    procedure InitData();
  public
    Fflag:string;  //类型标志
    fDivChar:string;
    pColumns:integer;
    fSelResult:string;
  end;

var
  frmJcFlawHelp: TfrmJcFlawHelp;

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

procedure TfrmJcFlawHelp.btNoClick(Sender: TObject);
begin
  ModalResult:=-1;
end;

procedure TfrmJcFlawHelp.FormCreate(Sender: TObject);
begin
  with ADOConnection1 do
  begin
    Connected:=false;
    ConnectionString:=gConString;
    Connected:=true;
  end;
end;
////////////////////////////////////////////////
  //函数：
////////////////////////////////////////////////
procedure TfrmJcFlawHelp.InitData();
begin
  with ADOQueryHelp do
  begin
    close;
    sql.clear;
    sql.Add('select * from JC_Flaw');
  //  sql.Add('where flag='''+Fflag+'''');
  //  sql.Add('and Valid=''Y''');
    sql.Add('order by FlawCode');
    Open;
  end;

  CreateCDS20(ADOQueryHelp,cdsHelp);
  InitCDSData20(ADOQueryHelp,cdsHelp);

end;
procedure TfrmJcFlawHelp.FormShow(Sender: TObject);
begin
 // self.Caption :='输入帮助(类别：'+FFlag+')';
  InitData();
end;

procedure TfrmJcFlawHelp.btOkClick(Sender: TObject);
begin
  if cdshelp.IsEmpty then exit;
 { fSelResult:='';
  if trim(fDivChar)='' then fDivChar:=';';
  with  cdshelp do
  begin
    DisableControls;
    First;
    while not Eof do
    begin
      if fieldbyname('sel').AsBoolean then
      fSelResult:=fSelResult+Trim(Fieldbyname('FlawChn').AsString)+Trim(fDivChar);
      next;
    end;
    First;
    EnableControls;
  end;    }
  ModalResult:=1;
end;

procedure TfrmJcFlawHelp.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TfrmJcFlawHelp.Tv1DblClick(Sender: TObject);
begin
  btOk.Click ;
end;

procedure TfrmJcFlawHelp.CheckBox1Click(Sender: TObject);
begin
  if cdshelp.IsEmpty then exit;
  with  cdshelp do
  begin
    DisableControls;
    First;
    while not Eof do
    begin
      edit;
      fieldbyname('sel').AsBoolean:=checkbox1.Checked;
      post;
      next;
    end;
    First;
    EnableControls;
  end;
end;

end.
