unit U_GDTPList; //

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
  TfrmGDTPList = 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;
    DQFactoryName: TEdit;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1OrderNo: TcxGridDBColumn;
    v1PSName: TcxGridDBColumn;
    v1Column20: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column2: 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;
    v1Column3: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    Label7: TLabel;
    ColorName: TEdit;
    Label8: TLabel;
    GangNo: TEdit;
    Label9: TLabel;
    KZ: TEdit;
    Label11: TLabel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    v1Column5: TcxGridDBColumn;
    Label12: TLabel;
    TPType: TEdit;
    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
  frmGDTPList: TfrmGDTPList;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}

procedure TfrmGDTPList.FormDestroy(Sender: TObject);
begin
  frmGDTPList:=nil;
end;

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

procedure TfrmGDTPList.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('跟单投坯列表',Tv1,'跟单管理');
end;

procedure TfrmGDTPList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add(' exec P_View_GDTP :BegDate,:EndDate ');
      Parameters.ParamByName('BegDate').Value:=Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date));
      Parameters.ParamByName('EndDate').Value:=Trim(FormatDateTime('yyyy-MM-dd',EndDate.Date));
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;

end;

procedure TfrmGDTPList.InitGridWSql(fsj:string);
begin

end;

procedure TfrmGDTPList.InitForm();
begin
  EndDate.DateTime:=SGetServerDate10(ADOQueryTemp)+1;
  BegDate.DateTime:=SGetServerDate10(ADOQueryTemp);
  ReadCxGrid('跟单投坯列表',Tv1,'跟单管理');
end;

procedure TfrmGDTPList.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 TfrmGDTPList.DelData():Boolean;
begin

end;

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

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

procedure TfrmGDTPList.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 TfrmGDTPList.FormShow(Sender: TObject);
begin
  InitForm();
end;

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

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

end.
