unit U_ProductOrderListSel1;

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,
  Menus;

type
  TfrmProductOrderListSel1 = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    Panel1: TPanel;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    Label3: TLabel;
    OrderNoM: TEdit;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    PopupMenu1: TPopupMenu;
    N2: TMenuItem;
    ADOQueryPrint: TADOQuery;
    CDS_Print: TClientDataSet;
    ToolButton3: TToolButton;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1OrderNo: TcxGridDBColumn;
    v1ConNo: TcxGridDBColumn;
    v1KHConNO: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1OrdDefStr1: TcxGridDBColumn;
    v1DeliveryDate: TcxGridDBColumn;
    v1MPRTCodeName: TcxGridDBColumn;
    v1MPRTSpec: TcxGridDBColumn;
    v1MPRTMF: TcxGridDBColumn;
    v1MPRTKZ: TcxGridDBColumn;
    v1PRTColor: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1PRTOrderQty: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    v1Column4: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure OrderNoMKeyPress(Sender: TObject; var Key: Char);
    procedure Tv1DblClick(Sender: TObject);
  private
    DQdate:TDateTime;
    procedure InitGrid();
    procedure InitForm();
    { Private declarations }
  public
    FFInt,FCloth:Integer;

    { Public declarations }
  end;

var
  frmProductOrderListSel1: TfrmProductOrderListSel1;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}

procedure TfrmProductOrderListSel1.FormDestroy(Sender: TObject);
begin
  frmProductOrderListSel1:=nil;
end;

procedure TfrmProductOrderListSel1.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caHide;
end;

procedure TfrmProductOrderListSel1.FormCreate(Sender: TObject);
begin
  cxgrid1.Align:=alClient;
end;

procedure TfrmProductOrderListSel1.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('指示单列表选择坯布仓库',Tv1,'生产指示单管理');
end;

procedure TfrmProductOrderListSel1.InitGrid();
begin
  if Length(Trim(OrderNoM.Text))<3 then Exit;
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add('select B.*,A.*');
      sql.add('from JYOrder_sub A');
      sql.Add('inner join  JYOrder_Main B on B.mainID=A.mainID ');
      SQL.Add('where B.OrderNo like '''+'%'+Trim(OrderNoM.Text)+'%'+'''');
//      sQL.Add('and isnull(B.status,''0'')<>''0'' ');
//      sql.add('and isnull(B.status,''0'')<>''4''');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;


procedure TfrmProductOrderListSel1.InitForm();
begin

end;

procedure TfrmProductOrderListSel1.FormShow(Sender: TObject);
begin
  ReadCxGrid('指示单列表选择坯布仓库',Tv1,'生产指示单管理');
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add('select B.*,A.*');
      sql.add('from JYOrder_sub A');
      sql.Add('inner join  JYOrder_Main B on B.mainID=A.mainID ');
//      sql.Add('left  join JYOrderCon_Main C on C.conNO=B.conNO ');
//      SQL.Add('where B.OrdDate>=GETDATE()-15 ');
//      sQL.Add('where isnull(B.status,''0'')<>''0'' ');
//      sql.add('and isnull(B.status,''0'')<>''4''');
//      ShowMessage(SQL.Text);
      Open;
    end;
     SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main); 
end;

procedure TfrmProductOrderListSel1.ToolButton3Click(Sender: TObject);
begin
  IF Order_Main.IsEmpty then exit;
  ModalResult:=1;
end;

procedure TfrmProductOrderListSel1.OrderNoMKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key=#13 then
  begin
    InitGrid();
  end;
end;

procedure TfrmProductOrderListSel1.Tv1DblClick(Sender: TObject);
begin
//  ToolButton3.Click;
end;

end.
