unit U_JNPRTList;

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, cxPC, cxCheckComboBox, cxDropDownEdit, Menus, RM_e_Xls, TeEngine,
  Series, TeeProcs, Chart, DbChart, cxLookAndFeels, cxLookAndFeelPainters,
  cxNavigator;

type
  TfrmJNPRTList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    cxGridLevel1: TcxGridLevel;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    Panel1: TPanel;
    v2Column1: TcxGridDBColumn;
    ADOQueryPrt: TADOQuery;
    Tv2Column6: TcxGridDBColumn;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    cxGridDBColumn2: TcxGridDBColumn;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    Tv2Column2: TcxGridDBColumn;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    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 cxTabControl1Change(Sender: TObject);
    procedure Tv2CellClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
  private
    { Private declarations }
    procedure InitGrid();
  public
    fFlag: integer;
    { Public declarations }
    RKFlag, FCYID, fmanage: string;
  end;

var
  frmJNPRTList: TfrmJNPRTList;

implementation

uses
  U_DataLink, U_Fun, U_ZDYHelp;

{$R *.dfm}



procedure TfrmJNPRTList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      SQL.Clear;
      sql.Add('exec P_JN_KC  ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_HZ);
    SInitCDSData20(ADOQueryMain, CDS_HZ);
  finally
    ADOQueryMain.EnableControls;

  end;
end;

procedure TfrmJNPRTList.FormDestroy(Sender: TObject);
begin
  frmJNPRTList := nil;
end;

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

procedure TfrmJNPRTList.TBCloseClick(Sender: TObject);
begin

  Close;
end;

procedure TfrmJNPRTList.FormShow(Sender: TObject);
begin


  InitGrid();
end;

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

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

procedure TfrmJNPRTList.cxTabControl1Change(Sender: TObject);
begin
  InitGrid;
end;

procedure TfrmJNPRTList.Tv2CellClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  if CDS_HZ.IsEmpty then Exit;
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      SQL.Clear;
      sql.Add('exec P_JN_KC_MX :JNCarNo  ');
      Parameters.ParamByName('JNCarNo').Value:=Trim(CDS_HZ.fieldbyname('JNCarNo').AsString);
      Open;
    end;
    SCreateCDS20(ADOQueryMain, ClientDataSet1);
    SInitCDSData20(ADOQueryMain, ClientDataSet1);
  finally
    ADOQueryMain.EnableControls;

  end;
end;

end.

