unit U_SCPerson; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, DB, ADODB, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, cxNavigator, cxDBData, cxClasses, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel, cxGridCustomView, cxGrid, DBClient, dxSkinsCore, dxSkinsDefaultPainters, dxSkinscxPCPainter; type TfrmSCPerson = class(TForm) ScrollBox1: TScrollBox; btn1: TSpeedButton; btn2: TSpeedButton; btn3: TSpeedButton; btn4: TSpeedButton; btn5: TSpeedButton; btn6: TSpeedButton; btn7: TSpeedButton; btn8: TSpeedButton; btn58: TSpeedButton; btn9: TSpeedButton; btn10: TSpeedButton; btn11: TSpeedButton; btn12: TSpeedButton; btn13: TSpeedButton; btn14: TSpeedButton; btn15: TSpeedButton; ADOTmp: TADOQuery; cxGrid2: TcxGrid; Tv2: TcxGridDBTableView; cxGridLevel1: TcxGridLevel; Tv2Column1: TcxGridDBColumn; cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; cxStyleRepository2: TcxStyleRepository; cxStyle2: TcxStyle; DS_ZB: TDataSource; CDS_ZB: TClientDataSet; CDS_YG: TClientDataSet; procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure btn1Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Tv2CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); private procedure InitPerson(MZB: string); { Private declarations } public FlagStr: string; FSDPerson: string; { Public declarations } end; var frmSCPerson: TfrmSCPerson; implementation uses U_DataLink, U_Fun; {$R *.dfm} procedure TfrmSCPerson.FormDestroy(Sender: TObject); begin frmSCPerson := nil; end; procedure TfrmSCPerson.InitPerson(MZB: string); type FdDy = record inc: integer; FDdys: string[32]; FdDysName: string[32]; end; var BB: array[0..100] of FdDy; i, j: Integer; begin with ADOTmp do begin Close; sql.Clear; sql.Add('select cast((ROW_NUMBER() over(order by Note,ZDYName)) as int) as keyNo,'); sql.Add(' Note,ZDYName from KH_Zdy where Type=''' + Trim(FlagStr) + ''' and note=' + quotedstr(Trim(MZB)) + ' order by Note,ZDYName '); Open; end; if ADOTmp.IsEmpty then begin Application.MessageBox('没有定义数据!', '提示', 0); Exit; end; SCreateCDS20(ADOTmp, CDS_YG); SInitCDSData20(ADOTmp, CDS_YG); for j := 0 to 15 do begin with ScrollBox1 do begin if CDS_YG.Locate('keyno', j + 1, []) then begin TSpeedButton(Controls[j]).Visible := True; TSpeedButton(Controls[j]).Caption := Trim(CDS_YG.fieldbyname('ZDYName').AsString); end else begin TSpeedButton(Controls[j]).Visible := False; TSpeedButton(Controls[j]).Caption := ''; end; end; end; end; procedure TfrmSCPerson.FormShow(Sender: TObject); begin with ADOTmp do begin Close; sql.Clear; sql.Add('select distinct A.note from KH_ZDY A where A.Type=''SCPerson'' and isnull(A.note,'''')<>'''' order by note '); Open; end; SCreateCDS20(ADOTmp, CDS_ZB); SInitCDSData20(ADOTmp, CDS_ZB); InitPerson(Trim(CDS_ZB.FieldByName('note').AsString)); end; procedure TfrmSCPerson.btn1Click(Sender: TObject); begin FSDPerson := Trim(TSpeedButton(Sender).Caption); ModalResult := 1; end; procedure TfrmSCPerson.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := cahide; end; procedure TfrmSCPerson.Tv2CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin InitPerson(Trim(CDS_ZB.FieldByName('note').AsString)); end; end.