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, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;

type
  TFrmJYOrderYS = class(TForm)
    Panel1: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    Label1: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    KHName: TEdit;
    JFJGMoney: TEdit;
    ConNo: TEdit;
    MaoLMoney: TEdit;
    YGMoney: TEdit;
    Panel2: TPanel;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBBandedTableView;
    V1CRTime: TcxGridDBBandedColumn;
    V1SPName: TcxGridDBBandedColumn;
    V1TTQty: TcxGridDBBandedColumn;
    V1Price: TcxGridDBBandedColumn;
    V1PBMoney: TcxGridDBBandedColumn;
    V1KCPBPS: TcxGridDBBandedColumn;
    V1KCPBQty: TcxGridDBBandedColumn;
    V1FactoryName: TcxGridDBBandedColumn;
    cxGridLevel1: TcxGridLevel;
    Panel5: TPanel;
    cxGrid5: TcxGrid;
    TV5: TcxGridDBBandedTableView;
    V5CRTime: TcxGridDBBandedColumn;
    V5YFName: TcxGridDBBandedColumn;
    V5RMBMoney: TcxGridDBBandedColumn;
    V5BZType: TcxGridDBBandedColumn;
    V5Note: TcxGridDBBandedColumn;
    cxGridLevel5: TcxGridLevel;
    Panel3: TPanel;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBBandedTableView;
    cxGridDBBandedColumn1: TcxGridDBBandedColumn;
    cxGridDBBandedColumn2: TcxGridDBBandedColumn;
    V2Column1: TcxGridDBBandedColumn;
    cxGridDBBandedColumn3: TcxGridDBBandedColumn;
    cxGridDBBandedColumn4: TcxGridDBBandedColumn;
    cxGridDBBandedColumn5: TcxGridDBBandedColumn;
    cxGridDBBandedColumn6: TcxGridDBBandedColumn;
    V2FactoryName: TcxGridDBBandedColumn;
    cxGridLevel2: TcxGridLevel;
    cxGrid6: TcxGrid;
    TV6: TcxGridDBBandedTableView;
    V6CRTime: TcxGridDBBandedColumn;
    V6FactoryName: TcxGridDBBandedColumn;
    V6SPName: TcxGridDBBandedColumn;
    V6FLQty: TcxGridDBBandedColumn;
    V6Price: TcxGridDBBandedColumn;
    V6FLMoney: TcxGridDBBandedColumn;
    cxGridLevel6: TcxGridLevel;
    Panel4: TPanel;
    cxGrid4: TcxGrid;
    TV4: TcxGridDBBandedTableView;
    cxGridDBBandedColumn15: TcxGridDBBandedColumn;
    cxGridDBBandedColumn16: TcxGridDBBandedColumn;
    V4P_Spec: TcxGridDBBandedColumn;
    cxGridDBBandedColumn17: TcxGridDBBandedColumn;
    cxGridDBBandedColumn18: TcxGridDBBandedColumn;
    V4BZType: TcxGridDBBandedColumn;
    cxGridDBBandedColumn19: TcxGridDBBandedColumn;
    cxGridDBBandedColumn20: TcxGridDBBandedColumn;
    V4Huilv: TcxGridDBBandedColumn;
    V4RMBMoney: TcxGridDBBandedColumn;
    cxGridLevel4: TcxGridLevel;
    cxGrid3: TcxGrid;
    TV3: TcxGridDBBandedTableView;
    cxGridDBBandedColumn8: TcxGridDBBandedColumn;
    cxGridDBBandedColumn9: TcxGridDBBandedColumn;
    V3BZType: TcxGridDBBandedColumn;
    cxGridDBBandedColumn10: TcxGridDBBandedColumn;
    V3Huilv: TcxGridDBBandedColumn;
    cxGridLevel3: TcxGridLevel;
    DataSource1: TDataSource;
    ADOQueryTemp: TADOQuery;
    Order_PB: TClientDataSet;
    DataSource5: TDataSource;
    Order_FYZC: TClientDataSet;
    DataSource2: TDataSource;
    Order_RF: TClientDataSet;
    DataSource4: TDataSource;
    Order_XS: TClientDataSet;
    DataSource3: TDataSource;
    Order_SK: TClientDataSet;
    Order_FL: TClientDataSet;
    DataSource6: TDataSource;
    ToolBar2: TToolBar;
    ToolButton3: TToolButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TDJCRClick(Sender: TObject);
  private
    procedure initgrid();
    { Private declarations }
  public
    FMainid, FConnO, FYWY, FKHName, FJFJGMoney, FMaoLMoney, FYGMoney, FormID: string;       //关联合同
    { Public declarations }
  end;

var
  FrmJYOrderYS: TFrmJYOrderYS;

implementation

uses
  U_DataLink, U_ZDYHelp, U_Fun, U_DJBCKOutList_CX;
{$R *.dfm}

procedure TFrmJYOrderYS.initgrid();
var
  FSKMoney, FPBMoney, FJGMoney, FZCMoney: double;
begin
  with ADOQueryTemp do
  begin
    close;
    sql.clear;
    sql.add('exec P_LR_PB @Mainid=' + quotedstr(FMainid));
    open;
  end;
  SCreateCDS20(ADOQueryTemp, Order_PB);
  SInitCDSData20(ADOQueryTemp, Order_PB);
  with ADOQueryTemp do
  begin
    close;
    sql.clear;
    sql.add('exec P_LR_JG @Mainid=' + quotedstr(FMainid));
    open;
  end;
  SCreateCDS20(ADOQueryTemp, Order_RF);
  SInitCDSData20(ADOQueryTemp, Order_RF);

  with ADOQueryTemp do
  begin
    close;
    sql.clear;
    sql.add('exec P_LR_FL @Mainid=' + quotedstr(FMainid));
    open;
  end;
  SCreateCDS20(ADOQueryTemp, Order_FL);
  SInitCDSData20(ADOQueryTemp, Order_FL);
  with ADOQueryTemp do
  begin
    close;
    sql.clear;
    sql.add('exec P_LR_YSK @Mainid=' + quotedstr(FMainid));
    open;
  end;
  SCreateCDS20(ADOQueryTemp, Order_XS);
  SInitCDSData20(ADOQueryTemp, Order_XS);

  with ADOQueryTemp do
  begin
    close;
    sql.clear;
    sql.add('exec P_LR_SK @Mainid=' + quotedstr(FMainid));
    open;
  end;
  SCreateCDS20(ADOQueryTemp, Order_SK);
  SInitCDSData20(ADOQueryTemp, Order_SK);

  with ADOQueryTemp do
  begin
    close;
    sql.clear;
    sql.add('exec P_LR_FYZC @Mainid=' + quotedstr(FMainid));
    open;
  end;
  SCreateCDS20(ADOQueryTemp, Order_FYZC);
  SInitCDSData20(ADOQueryTemp, 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('坯布', Tv1, '订单收付款明细');
  ReadCxBandedGrid('染费', Tv2, '订单收付款明细');
  ReadCxBandedGrid('收款', Tv3, '订单收付款明细');
  ReadCxBandedGrid('费用支出1', Tv5, '订单收付款明细');
  ReadCxBandedGrid('销售出库', Tv4, '订单收付款明细');
  ReadCxBandedGrid('辅料成本', Tv6, '订单收付款明细');
  ConNo.Text := trim(FConnO);
  KHName.Text := trim(FKHName);
  MaoLMoney.Text := trim(FMaoLMoney);
  YGMoney.Text := trim(FYGMoney);
  JFJGMoney.Text := trim(FJFJGMoney);
  initgrid();
end;

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

procedure TFrmJYOrderYS.TDJCRClick(Sender: TObject);
begin
  frmDJBCKOutList_CX := TfrmDJBCKOutList_CX.Create(self);
  with frmDJBCKOutList_CX do
  begin
    FDJConNO := trim(self.ConNo.Text);
    if showmodal = 1 then
    begin

    end;
    free;
  end;
end;

end.

