unit U_BPKCList; //

interface

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

type
  TfrmBPKCList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    TBExport: TToolButton;
    Order_Main: TClientDataSet;
    Panel1: TPanel;
    Label4: TLabel;
    GDPerson: TEdit;
    Label2: TLabel;
    FactoryName: TEdit;
    Label3: TLabel;
    BPCode: TEdit;
    Label10: TLabel;
    ToFactoryName: TEdit;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column1: TcxGridDBColumn;
    v1OrderNo: TcxGridDBColumn;
    v1PSName: TcxGridDBColumn;
    v1Column20: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1GDPerson: TcxGridDBColumn;
    v1FactoryName: TcxGridDBColumn;
    v1ToFactoryName: TcxGridDBColumn;
    v1QtyUnit: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    Label5: TLabel;
    BPName: TEdit;
    v1Column18: TcxGridDBColumn;
    v1Column19: TcxGridDBColumn;
    v1Column27: TcxGridDBColumn;
    v1Column28: TcxGridDBColumn;
    Label6: TLabel;
    BPSpec: TEdit;
    Label1: TLabel;
    TaiTou: TEdit;
    v1Column4: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FPNoChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
  private
    FInt,PFInt:Integer;
    canshu1:string;
    procedure InitGrid();
    procedure InitGridWSql(fsj:string);
    procedure InitForm();
    function  DelData():Boolean;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmBPKCList: TfrmBPKCList;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}

procedure TfrmBPKCList.FormDestroy(Sender: TObject);
begin
  frmBPKCList:=nil;
end;

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

procedure TfrmBPKCList.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('跟单坯布库存列表',Tv1,'跟单管理');
end;

procedure TfrmBPKCList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add(' select A.* ');
      sql.Add(' from XH_Cloth_JH A ');
      sql.Add(' where isnull(KCQtyHZ,0)>0 and isnull(KCPSHZ,0)>0');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;

end;

procedure TfrmBPKCList.InitGridWSql(fsj:string);
begin

end;

procedure TfrmBPKCList.InitForm();
begin
  ReadCxGrid('跟单坯布库存列表',Tv1,'跟单管理');
end;

procedure TfrmBPKCList.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active=False then Exit;
  SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;

function TfrmBPKCList.DelData():Boolean;
begin

end;

procedure TfrmBPKCList.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then Exit;
  TcxGridToExcel(Self.Caption,cxGrid1);
end;

procedure TfrmBPKCList.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
  TBFind.Click;
end;

procedure TfrmBPKCList.FPNoChange(Sender: TObject);
begin
  if ADOQueryMain.Active=False then Exit;
  SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;

procedure TfrmBPKCList.FormShow(Sender: TObject);
begin
  InitForm();
end;

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

procedure TfrmBPKCList.cxTabControl1Change(Sender: TObject);
begin
  InitGrid();
  TBFind.Click;
end;

end.
