unit U_ConDJFenPei;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
  cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin,
  StdCtrls, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
  cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
  cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
  RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdFTP,ShellAPI,IniFiles, cxCheckBox, cxCalendar,
  cxButtonEdit, cxTextEdit, cxDropDownEdit;

type
  TfrmConDJFenPei = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    Label1: TLabel;
    YFName: TEdit;
    ADOQueryMain: TADOQuery;
    Label3: TLabel;
    FactoryName: TEdit;
    Label2: TLabel;
    Label6: TLabel;
    begdate: TDateTimePicker;
    Enddate: TDateTimePicker;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    Label4: TLabel;
    OrderNo: TEdit;
    Label8: TLabel;
    HZFactoryName: TEdit;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1ConNo: TcxGridDBColumn;
    v1CustomerNoName: TcxGridDBColumn;
    v1Column13: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1MPRTCodeName: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    v1Column11: TcxGridDBColumn;
    v1Column12: TcxGridDBColumn;
    v1MPRTSpec: TcxGridDBColumn;
    v1PRTOrderQty: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1PRTPrice: TcxGridDBColumn;
    v1PRTColor: TcxGridDBColumn;
    v1MPRTCF: TcxGridDBColumn;
    v1Column14: TcxGridDBColumn;
    v1MPRTMF: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    v1Column3: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
  private
    { Private declarations }

    procedure InitGrid();

  public
    { Public declarations }
    ConNo,FCIID:String;

  end;

var
  frmConDJFenPei: TfrmConDJFenPei;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}



procedure TfrmConDJFenPei.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      SQL.Clear;
      sql.Add('select A.*,B.* ');
      sql.Add(' from JYOrderCon_Main A  ');
      sql.Add(' inner join JYOrderCon_Sub B on A.MainId=B.MainId');
      sql.Add(' where A.MainId in(');
      sql.Add(' select PIMainId from JYOrder_CI where CIID='''+Trim(FCIID)+''')');
      SQL.Add(' and isnull(B.WFPDJMoney,0)<>0 ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_HZ);
    SInitCDSData20(ADOQueryMain,CDS_HZ);
  finally
    ADOQueryMain.EnableControls;
  end;
end;


procedure TfrmConDJFenPei.FormDestroy(Sender: TObject);
begin
  frmConDJFenPei:=nil;
end;

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

procedure TfrmConDJFenPei.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('合同定金分配',Tv1,'财务管理');
  Close;
end;
procedure TfrmConDJFenPei.FormShow(Sender: TObject);
begin
  ReadCxGrid('合同定金分配',Tv1,'财务管理');
  InitGrid();
end;

procedure TfrmConDJFenPei.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;
procedure TfrmConDJFenPei.ToolButton2Click(Sender: TObject);
begin
  ModalResult:=1;
end;

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

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

end.
