unit U_ProductOrderListSel_cx;

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
  TfrmProductOrderListSel_cx = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    Panel1: TPanel;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    Label3: TLabel;
    ConNO: TEdit;
    v1ConNo: TcxGridDBColumn;
    v1DeliveryDate: TcxGridDBColumn;
    v1PRTColor: TcxGridDBColumn;
    v1PRTCF: TcxGridDBColumn;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    v1PRTCodeName: TcxGridDBColumn;
    v1PRTMF: TcxGridDBColumn;
    v1PRTOrderQty: TcxGridDBColumn;
    v1PRTKZ: TcxGridDBColumn;
    v1PRTCode: TcxGridDBColumn;
    ADOQueryPrint: TADOQuery;
    CDS_Print: TClientDataSet;
    ToolButton3: TToolButton;
    v1Column4: TcxGridDBColumn;
    v1PRTColorNo: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1OrderUnit: TcxGridDBColumn;
    v1styleNo: TcxGridDBColumn;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    v1SOrdDefStr4: 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 ConNOKeyPress(Sender: TObject; var Key: Char);
    procedure Tv1DblClick(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
  private
    DQdate:TDateTime;
    procedure InitGrid();
    procedure InitForm();
    { Private declarations }
  public
    FFInt,FCloth:Integer;

    { Public declarations }
  end;

var
  frmProductOrderListSel_cx: TfrmProductOrderListSel_cx;

implementation
uses
  U_DataLink,U_OrderInPut,U_Fun;

{$R *.dfm}

procedure TfrmProductOrderListSel_cx.FormDestroy(Sender: TObject);
begin
  frmProductOrderListSel_cx:=nil;
end;

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

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

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

procedure TfrmProductOrderListSel_cx.InitGrid();
begin
  if Length(Trim(ConNO.Text))<3 then Exit;
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add('select B.*,A.* ');
      sql.add('from JYOrderCon_sub A ');
      sql.Add('inner join JYOrderCon_Main B on B.mainID=A.mainID ');
      SQL.Add('where B.ConNO like '''+'%'+Trim(ConNO.Text)+'%'+'''');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;


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

procedure TfrmProductOrderListSel_cx.FormShow(Sender: TObject);
begin
  InitForm();
  if FFInt=1 then
  begin
    v1Column4.Visible:=False;
    v1Column4.Hidden:=True;
  end;
end;

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

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

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

procedure TfrmProductOrderListSel_cx.N1Click(Sender: TObject);
begin
    SelOKNo(Order_Main,True);
end;

procedure TfrmProductOrderListSel_cx.N2Click(Sender: TObject);
begin
  SelOKNo(Order_Main,false);
end;

end.
