unit U_ProductOrderListNewCKMX;

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, cxCheckBox, cxCalendar, cxSplitter,
  RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, RM_e_Xls,
  cxGridBandedTableView, cxGridDBBandedTableView;

type
  TfrmProductOrderListNewCKMX = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    Label1: TLabel;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    Label3: TLabel;
    OrderNo: TEdit;
    Label5: TLabel;
    WFBCodeName: TEdit;
    v1OrderNo: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1OrderDate: TcxGridDBColumn;
    v1DeliveryDate: TcxGridDBColumn;
    v1FactoryNo1Name: TcxGridDBColumn;
    v1FactoryNo2Name: TcxGridDBColumn;
    v1FactoryNo3Name: TcxGridDBColumn;
    v1Note: TcxGridDBColumn;
    v1PRTSpec: TcxGridDBColumn;
    v1PRTMF: TcxGridDBColumn;
    v1PRTKZ: TcxGridDBColumn;
    v1PRTOrderQty: TcxGridDBColumn;
    v1OrderUnit: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1PRTQty: TcxGridDBColumn;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    v1CustomerNoName: TcxGridDBColumn;
    Label4: TLabel;
    CustomNoName: TEdit;
    v1Column3: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    RMDB_Main: TRMDBDataSet;
    RM2: TRMGridReport;
    cxGrid2DBTableView1: TcxGridDBTableView;
    cxGrid2Level1: TcxGridLevel;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBBandedTableView;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    V2Column1: TcxGridDBBandedColumn;
    V2Column2: TcxGridDBBandedColumn;
    V2Column3: TcxGridDBBandedColumn;
    V2Column4: TcxGridDBBandedColumn;
    V2Column5: TcxGridDBBandedColumn;
    V2Column6: TcxGridDBBandedColumn;
    V2Column7: TcxGridDBBandedColumn;
    V2Column8: TcxGridDBBandedColumn;
    V2Column14: TcxGridDBBandedColumn;
    V2Column18: TcxGridDBBandedColumn;
    V2Column19: TcxGridDBBandedColumn;
    Panel3: TPanel;
    Label8: TLabel;
    Button1: TButton;
    Button2: TButton;
    Panel10: TPanel;
    Image2: TImage;
    RadioGroup1: TRadioGroup;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DataSource2: TDataSource;
    CDS_ZP: TClientDataSet;
    cxStyleRepository2: TcxStyleRepository;
    cxStyle2: TcxStyle;
    cxStyleRepository3: TcxStyleRepository;
    cxStyle3: TcxStyle;
    V2Column20: TcxGridDBBandedColumn;
    V2Column22: TcxGridDBBandedColumn;
    V2Column24: TcxGridDBBandedColumn;
    V2Column25: TcxGridDBBandedColumn;
    Label2: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    SWFBColor: TEdit;
    SWFBFK10: TEdit;
    SWFBKZ10: TEdit;
    Label9: TLabel;
    SWFBHW: TEdit;
    ToolButton1: TToolButton;
    V2Column9: TcxGridDBBandedColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure TBAddClick(Sender: TObject);
    procedure OrderNoChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBBQPrintClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure Panel10MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image2Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
  private
    PPInt:Integer;
    procedure InitGrid();
    procedure InitForm();
    function  DelData(Order_Main10:TClientDataSet):Boolean;
    procedure InitGridFH();
    procedure CopyOrderData(Order_MainFF:TClientDataSet);
    { Private declarations }
  public
    FFInt:Integer;
    { Public declarations }
  end;

var
  frmProductOrderListNewCKMX: TfrmProductOrderListNewCKMX;

implementation
uses
  U_DataLink,U_OrderInPut,U_Fun,U_OrderInPutZP,U_OrderInPutNew,U_OrderInPutZPNew
  ,U_OrderInPutZPLNew,U_OrderAttachment;

{$R *.dfm}

procedure TfrmProductOrderListNewCKMX.FormDestroy(Sender: TObject);
begin
  frmProductOrderListNewCKMX:=nil;
end;

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

procedure TfrmProductOrderListNewCKMX.FormCreate(Sender: TObject);
begin
  //BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp)-7;
  //EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
end;

procedure TfrmProductOrderListNewCKMX.TBCloseClick(Sender: TObject);
begin
  Close;
  //WriteCxGrid('无纺布指示单列表',Tv1,'指示单管理');
  WriteCxBandedGrid('无纺布指示单列表MX',Tv2,'指示单管理');
end;

procedure TfrmProductOrderListNewCKMX.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add(' exec P_Select_OrderMainSub :WSql');
      Parameters.ParamByName('WSql').Value:=' and A.OrderDate>='''+formatdatetime('yyyy-MM-dd',BegDate.DateTime)+''''
                                            +' and A.OrderDate<'''+formatdatetime('yyyy-MM-dd',EndDate.DateTime+1)+'''';
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;
procedure TfrmProductOrderListNewCKMX.InitGridFH();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add('exec Order_QryList :MainId,:WSql');
      Parameters.ParamByName('WSql').Value:=' and FillTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+''''
                                           +' and FillTime<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))+'''';
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmProductOrderListNewCKMX.InitForm();
begin
  ReadCxBandedGrid('无纺布指示单列表MX',Tv2,'指示单管理');
  BegDate.DateTime:=SGetServerDate10(ADOQueryTemp)-7;
  EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
  InitGrid();

end;

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

function TfrmProductOrderListNewCKMX.DelData(Order_Main10:TClientDataSet):Boolean;
begin

end;

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

procedure TfrmProductOrderListNewCKMX.TBAddClick(Sender: TObject);
begin
  Panel3.Visible:=True;
end;

procedure TfrmProductOrderListNewCKMX.OrderNoChange(Sender: TObject);
begin
  TBFind.Click;
end;

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

procedure TfrmProductOrderListNewCKMX.TBBQPrintClick(Sender: TObject);
var
  fPrintFile:String;
begin
end;

procedure TfrmProductOrderListNewCKMX.ToolButton2Click(Sender: TObject);
 var
   fsj:string;
begin
end;

procedure TfrmProductOrderListNewCKMX.ToolButton3Click(Sender: TObject);
begin
  ModalResult:=1;
end;

procedure TfrmProductOrderListNewCKMX.CheckBox1Click(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmProductOrderListNewCKMX.CheckBox2Click(Sender: TObject);
begin
  TBRafresh.Click;
end;

procedure TfrmProductOrderListNewCKMX.CopyOrderData(Order_MainFF:TClientDataSet);
begin
end;
procedure TfrmProductOrderListNewCKMX.Panel10MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture;
  TWinControl(Panel3).perform(WM_SYSCOMMAND, $F012, 0);
end;

procedure TfrmProductOrderListNewCKMX.Image2Click(Sender: TObject);
begin
  Panel3.Visible:=False;
end;

procedure TfrmProductOrderListNewCKMX.Button2Click(Sender: TObject);
begin
  Panel3.Visible:=False;
end;

procedure TfrmProductOrderListNewCKMX.ToolButton1Click(Sender: TObject);
begin
  if Order_Main.IsEmpty then Exit;
  SelExportDataBand(Tv2,ADOQueryMain,'生产指示单');
end;

end.
