unit U_ProductOrderMainListOneSel;

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
  TfrmProductOrderMainListOneSel = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    Panel1: TPanel;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryMain: TADOQuery;
    DataSource1: TDataSource;
    Label3: TLabel;
    OrderNo: TEdit;
    v1OrderNo: TcxGridDBColumn;
    v1MPRTSpec: TcxGridDBColumn;
    Order_Main: TClientDataSet;
    v1MPRTCodeName: TcxGridDBColumn;
    v1MPRTMF: TcxGridDBColumn;
    v1MPRTKZ: TcxGridDBColumn;
    v1OrdDefStr1: TcxGridDBColumn;
    ToolButton3: TToolButton;
    v1Column4: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column8: 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 OrderNoKeyPress(Sender: TObject; var Key: Char);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
  private
    DQdate:TDateTime;
    procedure InitGrid();
    procedure InitForm();
    { Private declarations }
  public
    FFInt,FCloth:Integer;

    { Public declarations }
  end;

var
  frmProductOrderMainListOneSel: TfrmProductOrderMainListOneSel;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}

procedure TfrmProductOrderMainListOneSel.FormDestroy(Sender: TObject);
begin
  frmProductOrderMainListOneSel:=nil;
end;

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

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

procedure TfrmProductOrderMainListOneSel.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('指示单列表选择主信息one',Tv1,'生产指示单管理');
end;

procedure TfrmProductOrderMainListOneSel.InitGrid();
begin
  if Length(Trim(OrderNo.Text))<3 then Exit;
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add('select B.* ');
      sql.add('from JYOrder_Main B');
      SQL.Add('where B.OrderNo like '''+'%'+Trim(OrderNo.Text)+'%'+'''');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;


procedure TfrmProductOrderMainListOneSel.InitForm();
begin
  ReadCxGrid('指示单列表选择主信息one',Tv1,'生产指示单管理');
  InitGrid();
end;

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

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

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

procedure TfrmProductOrderMainListOneSel.Tv1CellDblClick(
  Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  ModalResult:=1;
end;

end.
