unit U_BGMXSelList;

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, cxPC, cxButtonEdit, cxTextEdit, cxDropDownEdit;

type
  TfrmBGMXSelList = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryMain: TADOQuery;
    DataSource1: TDataSource;
    Order_Main: TClientDataSet;
    PopupMenu1: TPopupMenu;
    N2: TMenuItem;
    Panel1: TPanel;
    Label9: TLabel;
    OrderNo: TEdit;
    ToolButton2: TToolButton;
    N1: TMenuItem;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v2Column2: TcxGridDBColumn;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridDBColumn3: TcxGridDBColumn;
    v2Column3: TcxGridDBColumn;
    v2Column4: TcxGridDBColumn;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBColumn4: TcxGridDBColumn;
    v2Column1: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    v2Column6: TcxGridDBColumn;
    v2Column7: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    DataSource2: TDataSource;
    CDS_HZ: TClientDataSet;
    cxGridPopupMenu2: TcxGridPopupMenu;
    v2Column5: 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 OrderNoKeyPress(Sender: TObject; var Key: Char);
    procedure ToolButton2Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
  private
    procedure InitForm();
    { Private declarations }
  public
    FFInt,FCloth:Integer;

    { Public declarations }
  end;

var
  frmBGMXSelList: TfrmBGMXSelList;

implementation
uses
  U_DataLink,U_ConInPut,U_RTFun;

{$R *.dfm}

procedure TfrmBGMXSelList.FormDestroy(Sender: TObject);
begin
  frmBGMXSelList:=nil;
end;

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

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

procedure TfrmBGMXSelList.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('报关明细列表选择1',Tv1,'发票管理');
end;
procedure TfrmBGMXSelList.InitForm();
begin
  ReadCxGrid('报关明细列表选择1',Tv1,'发票管理');
end;
procedure TfrmBGMXSelList.FormShow(Sender: TObject);
begin
  InitForm();
end;

procedure TfrmBGMXSelList.OrderNoKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    if Length(OrderNo.Text)<3 then Exit;
    try
      ADOQueryMain.DisableControls;
      with ADOQueryMain do
      begin
        Filtered:=False;
        Close;
        SQL.Clear;
        sql.Add(' select A.*,B.OrderNo,B.ComTaiTou,C.Chker,C.ChkTime,C.ChkStatus,  ');
        sql.Add(' FPMoney=(select Sum(Money) from FP_GYSNB AA where AA.BFID=A.BFID)');
        sql.Add(' from JYOrder_BG_KPFee A  ');
        sql.Add(' inner join JYOrder_BG_CK C on A.BCId=C.BCId');
        sql.Add(' inner join JYOrder_BG B on A.BGId=B.BGId');
        SQL.Add(' where  B.OrderNo like '''+'%'+Trim(OrderNo.Text)+'%'+'''');
        Open;
      end;
      SCreateCDS20(ADOQueryMain,Order_Main);
      SInitCDSData20(ADOQueryMain,Order_Main);
    finally
      ADOQueryMain.EnableControls;
    end;
  end;
end;

procedure TfrmBGMXSelList.ToolButton2Click(Sender: TObject);
begin
  if Order_Main.IsEmpty then Exit;
  if Order_Main.Locate('SSel',True,[])=False then
  begin
    Application.MessageBox('没有选择数据!','提示',0);
    Exit;
  end;
  ModalResult:=1;
end;

procedure TfrmBGMXSelList.N2Click(Sender: TObject);
begin
  SelOKNo(Order_Main,True);
end;

procedure TfrmBGMXSelList.N1Click(Sender: TObject);
begin
  SelOKNo(Order_Main,False);
end;

end.
