unit U_JYOrderYS;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, ExtCtrls, StdCtrls, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
  cxCalendar, cxButtonEdit, cxTextEdit, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
  cxGridCustomView, cxGrid, cxGridBandedTableView, cxGridDBBandedTableView,
  DBClient, ADODB, cxCurrencyEdit, cxGridCustomPopupMenu, cxGridPopupMenu;

type
  TFrmJYOrderYS = class(TForm)
    Panel1: TPanel;
    Label2: TLabel;
    KHName: TEdit;
    Label3: TLabel;
    OrderNo: TEdit;
    Panel2: TPanel;
    cxGrid1: TcxGrid;
    cxGridLevel1: TcxGridLevel;
    TV1: TcxGridDBBandedTableView;
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    V1CRTime: TcxGridDBBandedColumn;
    V1SPName: TcxGridDBBandedColumn;
    V1TTQty: TcxGridDBBandedColumn;
    V1Price: TcxGridDBBandedColumn;
    V1PBMoney: TcxGridDBBandedColumn;
    Panel3: TPanel;
    Panel4: TPanel;
    V1KCPBQty: TcxGridDBBandedColumn;
    V1KCPBPS: TcxGridDBBandedColumn;
    DataSource1: TDataSource;
    DataSource2: TDataSource;
    DataSource4: TDataSource;
    DataSource5: TDataSource;
    Order_PB: TClientDataSet;
    Order_RF: TClientDataSet;
    Order_XS: TClientDataSet;
    Order_FYZC: TClientDataSet;
    ADOQuery1: TADOQuery;
    ADOQuery2: TADOQuery;
    ADOQuery4: TADOQuery;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBBandedTableView;
    cxGridDBBandedColumn1: TcxGridDBBandedColumn;
    cxGridDBBandedColumn2: TcxGridDBBandedColumn;
    V2Column1: TcxGridDBBandedColumn;
    cxGridDBBandedColumn4: TcxGridDBBandedColumn;
    cxGridDBBandedPrice: TcxGridDBBandedColumn;
    cxGridDBBandedColumn6: TcxGridDBBandedColumn;
    V2FactoryName: TcxGridDBBandedColumn;
    cxGridLevel2: TcxGridLevel;
    Panel5: TPanel;
    cxGrid5: TcxGrid;
    TV5: TcxGridDBBandedTableView;
    V5CRTime: TcxGridDBBandedColumn;
    V5YFName: TcxGridDBBandedColumn;
    V5RMBMoney: TcxGridDBBandedColumn;
    cxGridLevel5: TcxGridLevel;
    Label1: TLabel;
    ConNo: TEdit;
    cxGrid4: TcxGrid;
    TV4: TcxGridDBBandedTableView;
    cxGridDBBandedColumn15: TcxGridDBBandedColumn;
    cxGridDBBandedColumn16: TcxGridDBBandedColumn;
    cxGridDBBandedColumn18: TcxGridDBBandedColumn;
    cxGridDBBandedColumn19: TcxGridDBBandedColumn;
    cxGridDBBandedColumn20: TcxGridDBBandedColumn;
    V4Column9: TcxGridDBBandedColumn;
    V4Column11: TcxGridDBBandedColumn;
    cxGridLevel4: TcxGridLevel;
    cxGrid3: TcxGrid;
    TV3: TcxGridDBBandedTableView;
    cxGridDBBandedColumn8: TcxGridDBBandedColumn;
    cxGridDBBandedColumn9: TcxGridDBBandedColumn;
    cxGridDBBandedColumn10: TcxGridDBBandedColumn;
    cxGridLevel3: TcxGridLevel;
    DataSource3: TDataSource;
    ADOQuery3: TADOQuery;
    Order_SK: TClientDataSet;
    V5BZType: TcxGridDBBandedColumn;
    V3BZType: TcxGridDBBandedColumn;
    V3Huilv: TcxGridDBBandedColumn;
    Label4: TLabel;
    MaoLMoney: TEdit;
    Label5: TLabel;
    YGMoney: TEdit;
    V1FactoryName: TcxGridDBBandedColumn;
    V5Note: TcxGridDBBandedColumn;
    V4Huilv: TcxGridDBBandedColumn;
    DataSource6: TDataSource;
    Order_FL: TClientDataSet;
    cxGridPopupMenu2: TcxGridPopupMenu;
    Label6: TLabel;
    SJMoney: TEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
  private
    procedure initgrid();
    { Private declarations }
  public
    FMainid,FConnO,FOrderNo,FYWY,FKHName,FMaoLMoney,FYGMoney,FSJMoney: string;       //关联合同
    { Public declarations }
  end;

var
  FrmJYOrderYS: TFrmJYOrderYS;

implementation
Uses
    U_DataLink,U_ZDYHelp,U_Fun;
{$R *.dfm}

procedure TFrmJYOrderYS.initgrid();
var FSKMoney,FPBMoney,FJGMoney,FZCMoney:double;    
begin
  with Adoquery1 do
  begin                                
    close;
    sql.clear;
    sql.add('exec P_Get_OrderZd '+quotedstr(Trim(FOrderNo))+',''布匹费用'' ');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_PB);
  SInitCDSData20(Adoquery1,Order_PB);
//  with Adoquery1 do
//  begin
//    close;
//    sql.clear;
//
//    open;
//  end;
//  SCreateCDS20(Adoquery1,Order_FL);
//  SInitCDSData20(Adoquery1,Order_FL);
  with Adoquery1 do
  begin
    close;
    sql.clear;
    sql.add('exec P_Get_OrderZd '+quotedstr(Trim(FOrderNo))+',''加工费'' ');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_RF);
  SInitCDSData20(Adoquery1,Order_RF);
  with AdoQuery1 do
  begin
    close;
    sql.clear;
    sql.add('exec P_Get_OrderZd '+quotedstr(Trim(FOrderNo))+',''销售金额'' ');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_XS);
  SInitCDSData20(Adoquery1,Order_XS);
  with AdoQuery1 do
  begin
    close;
    sql.clear;
    sql.add('exec P_Get_OrderZd '+quotedstr(Trim(FOrderNo))+',''收款金额'' ');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_SK);
  SInitCDSData20(Adoquery1,Order_SK);
  with AdoQuery1 do
  begin
    close;
    sql.clear;
    sql.add('exec P_Get_OrderZd '+quotedstr(Trim(FOrderNo))+',''费用支出'' ');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_FYZC);
  SInitCDSData20(Adoquery1,Order_FYZC);
end;

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

procedure TFrmJYOrderYS.FormDestroy(Sender: TObject);
begin
  FrmJYOrderYS:=nil;
end;

procedure TFrmJYOrderYS.FormShow(Sender: TObject);
begin
  ReadCxBandedGrid('坯布2',Tv1,'订单收付款明细');
  ReadCxBandedGrid('染费1',Tv2,'订单收付款明细');
  ReadCxBandedGrid('收款1',Tv3,'订单收付款明细');
  ReadCxBandedGrid('费用支出1',Tv5,'订单收付款明细');
  ReadCxBandedGrid('销售出库1',Tv4,'订单收付款明细');
  ConNo.Text:=trim(FConnO);
  OrderNo.Text:=trim(FOrderNo);
  KHName.Text:=trim(FKHName);
//  MaoLMoney.Text:=trim(FMaoLMoney);
  YGMoney.Text:=trim(FYGMoney);
  SJMoney.Text:=trim(FSJMoney);
  initgrid();
end;

procedure TFrmJYOrderYS.TBCloseClick(Sender: TObject);
begin
  WriteCxBandedGrid('坯布2',Tv1,'订单收付款明细');
  WriteCxBandedGrid('染费1',Tv2,'订单收付款明细');
  WriteCxBandedGrid('收款1',Tv3,'订单收付款明细');
  WriteCxBandedGrid('费用支出1',Tv5,'订单收付款明细');
  WriteCxBandedGrid('销售出库1',Tv4,'订单收付款明细');
  Close;
end;

end.
