unit U_CPView;

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;

type
  TfrmCPView = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    ADOQueryMain: TADOQuery;
    RM1: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    Label3: TLabel;
    SPName: TEdit;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    SPSpec: TEdit;
    Label4: TLabel;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    v2Column6: TcxGridDBColumn;
    v2Column11: TcxGridDBColumn;
    v2Column8: TcxGridDBColumn;
    v2Column1: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    ToolButton1: TToolButton;
    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 SPNameChange(Sender: TObject);
    procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure ToolButton1Click(Sender: TObject);
  private
    { Private declarations }
    procedure InitGrid();

  public
    fDEFstr5:string;
  end;

var
  frmCPView: TfrmCPView;

implementation
uses
  U_DataLink,U_RTFun,U_ZdyAttInputCP;

{$R *.dfm}



procedure TfrmCPView.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      SQL.Clear;
      sql.Add(' select * from CP_Info where DataType=''CP'' and ZFFlag=0 ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_HZ);
    SInitCDSData20(ADOQueryMain,CDS_HZ);
  finally
    ADOQueryMain.EnableControls;
  end;
  ToolButton2.Click;
end;


procedure TfrmCPView.FormDestroy(Sender: TObject);
begin
  frmCPView:=nil;
end;

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

procedure TfrmCPView.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('成品信息管理',Tv2,'客户自定义');
  Close;
end;
procedure TfrmCPView.FormShow(Sender: TObject);
begin
  ReadCxGrid('成品信息管理',Tv2,'客户自定义');
  InitGrid();
end;

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

procedure TfrmCPView.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 TfrmCPView.SPNameChange(Sender: TObject);
begin
  ToolButton2.Click;
end;


procedure TfrmCPView.Tv2CellDblClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  if CDS_HZ.IsEmpty then Exit;
  ModalResult:=1;
end;

procedure TfrmCPView.ToolButton1Click(Sender: TObject);
begin
  try
    frmZdyAttInputCP:=TfrmZdyAttInputCP.Create(Application);
    with frmZdyAttInputCP do
    begin
      FCYID:='';
      if ShowModal=1 then
      begin
        TBRafresh.Click;
      end;
    end;
  finally
    frmZdyAttInputCP.Free;
  end;
end;

end.


