unit U_DJBKCList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView,
  cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView,
  cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView,
  cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu,
  cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, cxCheckBox, RM_Common,
  RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, Menus,
  cxCalendar, cxButtonEdit, cxTextEdit, BtnEdit, cxPC, cxLookAndFeels,
  cxLookAndFeelPainters, cxNavigator;

type
  TfrmDJBKCList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBExport: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    cxGridPopupMenu1: TcxGridPopupMenu;
    CDS_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    RMDBHZ: TRMDBDataSet;
    CDS_HZ: TClientDataSet;
    CDS_PRT: TClientDataSet;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    Label3: TLabel;
    SPName: TEdit;
    Label7: TLabel;
    OrderNo: TEdit;
    cxGrid2: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column13: TcxGridDBColumn;
    v2Column1: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v2Column6: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    cxGrid2Level1: TcxGridLevel;
    ADOQueryPrint: TADOQuery;
    v1Column22: TcxGridDBColumn;
    v1Column15: TcxGridDBColumn;
    Label9: TLabel;
    conno: TEdit;
    Label10: TLabel;
    SPColor: TEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBRafreshClick(Sender: TObject);
    procedure ConNoMChange(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure SPIDChange(Sender: TObject);
    procedure SPSpecChange(Sender: TObject);
    procedure FactoryNameChange(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
  private
    procedure SetStatus();
    procedure InitGrid();
    { Private declarations }
  public
    canshu1:string;
    { Public declarations }
  end;

//var
//  frmDJBRKList: TfrmDJBRKList;

implementation
uses
  U_DataLink,U_RTFun,U_DJBCKInPut, U_ZDYHelp, U_ZdyAttachGYS;

{$R *.dfm}

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

procedure TfrmDJBKCList.InitGrid();

begin

  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.add('exec P_View_DJBKC ') ;
      Open;

    end;
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

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

procedure TfrmDJBKCList.ConNoMChange(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  end;
end;

procedure TfrmDJBKCList.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid(trim(self.Caption),Tv1,'开卡管理');
  Close;
end;

procedure TfrmDJBKCList.FormShow(Sender: TObject);
begin
  SetStatus();
 
  ReadCxGrid(trim(self.Caption),Tv1,'开卡管理');
  InitGrid();
end;

procedure TfrmDJBKCList.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then exit;
  TcxGridToExcel('待检布入库列表',cxGrid2);
end;

procedure TfrmDJBKCList.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
  end;
end;

procedure TfrmDJBKCList.N1Click(Sender: TObject);
begin
  SelOKNo(CDS_Main,True);
end;

procedure TfrmDJBKCList.N2Click(Sender: TObject);
begin
  SelOKNo(CDS_Main,False);
end;

procedure TfrmDJBKCList.SPIDChange(Sender: TObject);
begin
 
  TBFind.Click;
end;

procedure TfrmDJBKCList.SPSpecChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmDJBKCList.FactoryNameChange(Sender: TObject);
begin
  TBFind.Click;
end;

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

end.
