unit U_SxXnKcList;

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
  TfrmSxXnKcList = 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;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    cxGridLevel1: TcxGridLevel;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    v2Column6: TcxGridDBColumn;
    v2Column2: TcxGridDBColumn;
    Name: TEdit;
    v2Column10: TcxGridDBColumn;
    v2Column15: TcxGridDBColumn;
    v2Column19: TcxGridDBColumn;
    EndDate: TDateTimePicker;
    Label4: TLabel;
    BegDate: TDateTimePicker;
    Label1: TLabel;
    v2Column1: TcxGridDBColumn;
    v2Column3: TcxGridDBColumn;
    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;
  end;

var
  frmSxXnKcList: TfrmSxXnKcList;

implementation
uses
  U_DataLink,U_Fun,U_ZDYHelp;

{$R *.dfm}



procedure TfrmSxXnKcList.InitGrid();
begin
  try

    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;                
      SQL.Clear;
      sql.Add(' exec P_View_LLKC'+quotedstr(trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))));
      sql.Add(' ,'+quotedstr(trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))));
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_HZ);
    SInitCDSData20(ADOQueryMain,CDS_HZ);
    CDS_HZ.Last;
  finally
    ADOQueryMain.EnableControls;
  end;
end;


procedure TfrmSxXnKcList.FormDestroy(Sender: TObject);
begin
  frmSxXnKcList:=nil;
end;

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

procedure TfrmSxXnKcList.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid(self.Caption,Tv2,'纱线仓库');
  Close;
end;
procedure TfrmSxXnKcList.FormShow(Sender: TObject);
begin
  ReadCxGrid(self.Caption,Tv2,'纱线仓库');
  InitGrid();
end;

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

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


procedure TfrmSxXnKcList.ToolButton1Click(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then Exit;
  TcxGridToExcel(self.Caption,cxgrid2);
end;

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

  EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
  BegDate.DateTime:=EndDate.DateTime;
end;

end.


