unit U_InspectionInfo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
  cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
  cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
  cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
  cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
  RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
  cxTextEdit, cxDBLookupComboBox;

type
  TfrmInspectionInfo = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    ADOQueryMain: TADOQuery;
    ToolButton1: TToolButton;
    RM1: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    Label3: TLabel;
    C_CodeName: TEdit;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    Label1: TLabel;
    C_Code: TEdit;
    Label2: TLabel;
    DEFstr5: TEdit;
    EndDate: TDateTimePicker;
    Label4: TLabel;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column22: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1Column33: TcxGridDBColumn;
    v1Column13: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column40: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1Column20: TcxGridDBColumn;
    v1Column36: TcxGridDBColumn;
    v1Column21: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column23: TcxGridDBColumn;
    v1Column12: TcxGridDBColumn;
    v1Column35: TcxGridDBColumn;
    v1Column31: TcxGridDBColumn;
    v1Column32: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column16: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v1Column11: TcxGridDBColumn;
    v1Column25: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column34: TcxGridDBColumn;
    v1Column17: TcxGridDBColumn;
    v1Column14: TcxGridDBColumn;
    v1Column29: TcxGridDBColumn;
    v1Column30: TcxGridDBColumn;
    v1Column15: TcxGridDBColumn;
    v1Column19: TcxGridDBColumn;
    v1Column24: TcxGridDBColumn;
    v1Column27: TcxGridDBColumn;
    v1Column18: TcxGridDBColumn;
    v1Column26: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column37: TcxGridDBColumn;
    v1Column38: TcxGridDBColumn;
    v1Column28: TcxGridDBColumn;
    v1Column39: TcxGridDBColumn;
    v1Column41: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure C_CodeNameChange(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private

    { Private declarations }
    canshu1: string;
    procedure InitGrid();
  public
    fkhType: string;
    Fmanage: string;
    FEnddate, FMainId, FSubId, FDName, FCarNo: string;
  end;

var
  frmInspectionInfo: TfrmInspectionInfo;

implementation

uses
  U_DataLink, U_Fun, U_ZDYHelp, U_WageListInput;

{$R *.dfm}

procedure TfrmInspectionInfo.InitGrid();
begin
  try

    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      SQL.Clear;
      sql.Add(' exec P_Viwe_InspectionInfo' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', enddate.DateTime))));
      sql.Add(',' + quotedstr(trim(FDName)));
      sql.Add(',' + quotedstr(trim(FMainId)));
      sql.Add(',' + quotedstr(trim(FSubId)));
      sql.Add(',' + quotedstr(trim(FCarNo)));
//      showmessage(sql.Text)  ;
      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_HZ);
    SInitCDSData20(ADOQueryMain, CDS_HZ);
    CDS_HZ.Last;
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmInspectionInfo.FormDestroy(Sender: TObject);
begin
  frmInspectionInfo := nil;
end;

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

procedure TfrmInspectionInfo.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid(self.Caption, Tv1, '验布报告');
  Close;
end;

procedure TfrmInspectionInfo.FormShow(Sender: TObject);
begin
  ReadCxGrid(self.Caption, Tv1, '验布报告');
  InitGrid();
end;

procedure TfrmInspectionInfo.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmInspectionInfo.ToolButton2Click(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS20(ADOQueryMain, CDS_HZ);
    SInitCDSData20(ADOQueryMain, CDS_HZ);
  end;
end;

procedure TfrmInspectionInfo.C_CodeNameChange(Sender: TObject);
begin
  ToolButton2.Click;
end;

procedure TfrmInspectionInfo.ToolButton1Click(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then
    Exit;
  TcxGridToExcel(self.Caption, cxgrid1);

end;

procedure TfrmInspectionInfo.FormCreate(Sender: TObject);
begin
  canshu1 := Trim(DParameters1);
end;

end.

