unit U_BPShengChanListSel;

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
  TfrmBPShengChanListSel = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    Panel1: TPanel;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    Label3: TLabel;
    ConNoM: TEdit;
    Order_Main: TClientDataSet;
    ToolButton3: TToolButton;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column5: TcxGridDBColumn;
    v1Column19: TcxGridDBColumn;
    v1OrderNo: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column18: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v1Column17: TcxGridDBColumn;
    v1PRTMF: TcxGridDBColumn;
    v1PRTKZ: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1PRTOrderQty: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Qty1: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    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 ConNoMKeyPress(Sender: TObject; var Key: Char);
    procedure Tv1DblClick(Sender: TObject);
  private
    procedure InitForm();
    { Private declarations }
  public
    FFInt,FCloth:Integer;

    { Public declarations }
  end;

var
  frmBPShengChanListSel: TfrmBPShengChanListSel;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}

procedure TfrmBPShengChanListSel.FormDestroy(Sender: TObject);
begin
  frmBPShengChanListSel:=nil;
end;

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

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

procedure TfrmBPShengChanListSel.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('白坯生产单选择坯',Tv1,'白坯生产单管理');
end;




procedure TfrmBPShengChanListSel.InitForm();
begin
  ReadCxGrid('白坯生产单选择坯',Tv1,'白坯生产单管理');
end;

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

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

procedure TfrmBPShengChanListSel.ConNoMKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key=#13 then
  begin
    //if Length(Trim(ConNoM.Text))<4 then Exit;
    try
      ADOQueryMain.DisableControls;
      with ADOQueryMain do
      begin
        Filtered:=False;
        Close;
        sql.Clear;
        sql.Add('exec Cloth_QryList '''',:WSql');
        Parameters.ParamByName('WSql').Value:=' and OM.conNo like '''+'%'+Trim(ConNoM.Text)+'%'+''''
                                              +' and OM.ConType=''生产'' ';
        Open;
      end;
      SCreateCDS20(ADOQueryMain,Order_Main);
      SInitCDSData20(ADOQueryMain,Order_Main);
    finally
      ADOQueryMain.EnableControls;
    end;
  end;
end;

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

end.
