unit U_SKCR_YF;

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, cxPC, RM_e_Xls, cxCurrencyEdit;

type
  TfrmSKCR_YF = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    Label1: TLabel;
    ConPerson1: TEdit;
    ADOQueryMain: TADOQuery;
    ToolButton1: TToolButton;
    RMDB_PB: TRMDBDataSet;
    Label3: TLabel;
    CustomerNoName: TEdit;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    V1OrdDate: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    Label6: TLabel;
    begdate: TDateTimePicker;
    Enddate: TDateTimePicker;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_HZ: TDataSource;
    CDS_HZ: TClientDataSet;
    v2CustomerNoName: TcxGridDBColumn;
    v2ConNo: TcxGridDBColumn;
    TCK: TToolButton;
    Label4: TLabel;
    ConNo: TEdit;
    v2YWY: TcxGridDBColumn;
    v2PBMoney: TcxGridDBColumn;
    v2JGMoney: TcxGridDBColumn;
    v2ZFMoney: TcxGridDBColumn;
    TPrint: TToolButton;
    v2SKMoney: TcxGridDBColumn;
    Order_PB: TClientDataSet;
    Order_FYZC: TClientDataSet;
    Order_RF: TClientDataSet;
    Order_XS: TClientDataSet;
    Order_SK: TClientDataSet;
    RMDB_FYZC: TRMDBDataSet;
    RMD_RF: TRMDBDataSet;
    RMDB_XS: TRMDBDataSet;
    RMDB_SK: TRMDBDataSet;
    ADOQuery1: TADOQuery;
    RMXLSExport1: TRMXLSExport;
    ADOQuery2: TADOQuery;
    ADOQuery3: TADOQuery;
    ADOQuery4: TADOQuery;
    ADOQuery5: TADOQuery;
    RM1: TRMGridReport;
    v2YGMoney: TcxGridDBColumn;
    Label5: TLabel;
    MPRTType: TComboBox;
    THTCX: TToolButton;
    v2MPRTCodeName: TcxGridDBColumn;
    v2Qty: TcxGridDBColumn;
    v2QTYUnit: TcxGridDBColumn;
    ComboBox1: TComboBox;
    v2PRTOrderQty: TcxGridDBColumn;
    v2TSMoney: TcxGridDBColumn;
    v2HYMoney: TcxGridDBColumn;
    v2YSZMoney: TcxGridDBColumn;
    RMDB_FL: TRMDBDataSet;
    Order_FL: TClientDataSet;
    ADOQuery6: TADOQuery;
    v2YGLiRun: TcxGridDBColumn;
    v2FLMoney: TcxGridDBColumn;
    v2ZJCKDate: 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 CustomerNoNameChange(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure cxGridDBColumn8PropertiesEditValueChanged(Sender: TObject);
    procedure cxGridDBColumn5PropertiesEditValueChanged(Sender: TObject);
    procedure cxGridDBColumn1PropertiesEditValueChanged(Sender: TObject);
    procedure cxGridDBColumn3PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure cxGridDBColumn6PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v2Column3PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure ToolButton1Click(Sender: TObject);
    procedure v2Column4PropertiesEditValueChanged(Sender: TObject);
    procedure v2Column1PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure VBBPropertiesEditValueChanged(Sender: TObject);
    procedure ConNoChange(Sender: TObject);
    procedure v2Column1PropertiesEditValueChanged(Sender: TObject);
    procedure v2DerateMoneyPropertiesEditValueChanged(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure v2ComTaitouPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure TCKClick(Sender: TObject);
    procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure ConNoKeyPress(Sender: TObject; var Key: Char);
    procedure TPrintClick(Sender: TObject);
    procedure THTCXClick(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private declarations }

    procedure InitGridHZ();
    procedure InitGrid();
    function  SaveData():Boolean;
    Procedure SetStatus();

  public
    fflag:integer;
    { Public declarations }
    RKFlag,FCYID,fmanage:String;

  end;

var
  frmSKCR_YF: TfrmSKCR_YF;

implementation
uses
  U_DataLink,U_Fun,U_ZDYHelp, U_ProductOrderList, U_ProductOrderNewList,
  U_ZdyAttachment,U_ProductOrderListSel, U_JYOrderYS, U_JYOrderCon_CX,U_ConInPutXF_LRDB;

{$R *.dfm}

Procedure TfrmSKCR_YF.SetStatus();
var
  i:integer;
begin

end;

procedure TfrmSKCR_YF.InitGrid();
var ZDY:string;
begin
  if ComboBox1.Text='制单日期' then
  begin
    ZDY:=' and OrdDate>='''+Trim(FormatDateTime('yyyy-MM-dd',begdate.DateTime))+''''
       +' and OrdDate<'''+Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1))+''' ';
  end
  else
  begin
    ZDY:=' and ZJCKDate>='''+Trim(FormatDateTime('yyyy-MM-dd',begdate.DateTime))+''''
       +' and ZJCKDate<'''+Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1))+''' ';
  end;
  with ADOQueryMain do
  begin
    Close;
    SQL.Clear;
    sql.Add('exec P_YFFK_HZCX :ZDY');
    Parameters.ParamByName('ZDY').Value:=ZDY;
    Open;
  end;
  SCreateCDS20(ADOQueryMain,CDS_HZ);
  SInitCDSData20(ADOQueryMain,CDS_HZ);
end;

procedure TfrmSKCR_YF.InitGridHZ();
begin
end;

procedure TfrmSKCR_YF.FormDestroy(Sender: TObject);
begin
  frmSKCR_YF:=nil;
end;

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

procedure TfrmSKCR_YF.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('订单毛利',Tv2,'财务管理');
  {with ADOQueryCmd do
  begin
    Close;
    SQL.Clear;
    sql.Add('delete CK_YP_CR where isnull(CRTime,'''')='''' and CYID='''+Trim(FCYID)+''' and CRType='''+Trim(RKFlag)+'''');
    ExecSQL;
  end;}
  Close;
end;

procedure TfrmSKCR_YF.FormShow(Sender: TObject);
begin
  ReadCxGrid('订单毛利',Tv2,'财务管理');
  Enddate.DateTime:=SGetServerDate(ADOQueryTemp);
  begdate.DateTime:=SGetServerDate(ADOQueryTemp)-15;
  //SetStatus();
  //InitGrid();
end;

procedure TfrmSKCR_YF.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmSKCR_YF.ToolButton2Click(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
    SCreateCDS20(ADOQueryMain,CDS_HZ);
    SInitCDSData20(ADOQueryMain,CDS_HZ);
  end;
end;

procedure TfrmSKCR_YF.CustomerNoNameChange(Sender: TObject);
begin
  ToolButton2.Click;
end;

procedure TfrmSKCR_YF.Button2Click(Sender: TObject);
begin
  if CDS_HZ.IsEmpty then Exit;
  if Application.MessageBox('确定要删除数据吗？','提示',32+4)<>IDYES then Exit;
  if Trim(CDS_HZ.fieldbyname('SubID').AsString)<>'' then
  begin
    with ADOQueryCmd do
    begin
      Close;
      SQL.Clear;
      sql.Add('delete YCL_SG_HZ where SubID='''+Trim(CDS_HZ.fieldbyname('SubID').AsString)+'''');
      ExecSQL;
    end;
  end;
  CDS_HZ.Delete;
end;

function TfrmSKCR_YF.SaveData():Boolean;
var
  maxId,CRID:String;
begin
  try
    ADOQueryCmd.Connection.BeginTrans;
    if GetLSNo(ADOQueryCmd,maxId,'FK','YF_Money_CR',4,1)=False then
    begin
      Result:=False;
      ADOQueryCmd.Connection.RollbackTrans;
      Application.MessageBox('取最大号失败！','提示',0);
      Exit;
    end;
    with ADOQueryCmd do
    begin
      Close;
      SQL.Clear;
      sql.Add('select * from YF_Money_KC where FactoryName='''+Trim(CDS_HZ.fieldbyname('FactoryName').AsString)+''' ');
      Open;
    end;
    if ADOQueryCmd.IsEmpty=False then
    begin
      CRID:=ADOQueryCmd.fieldbyname('CRID').AsString;
    end else
    begin
      with ADOQueryCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('Update YF_Money_CRID set CRID=CRID+1');
        sql.Add('select * from YF_Money_CRID ');
        Open;
      end;
      CRID:=ADOQueryCmd.fieldbyname('CRID').AsString;
      with ADOQueryCmd do
      begin
        Close;
        SQL.Clear;
        sql.Add('select * from YF_Money_KC where 1<>1');
        Open;
      end;
      with ADOQueryCmd do
      begin
        Append;
        FieldByName('CRID').Value:=StrToInt(CRID);
        FieldByName('FactoryNo').Value:=Trim(CDS_HZ.fieldbyname('FactoryNo').AsString);
        FieldByName('FactoryName').Value:=Trim(CDS_HZ.fieldbyname('FactoryName').AsString);
        FieldByName('ZdyStr1').Value:='应收收';
     //   FieldByName('YFDefFlag1').Value:=fFlag;
        Post;
      end;
    end;
    with ADOQueryCmd do
    begin
      Close;
      SQL.Clear;
      sql.Add('select * from YF_Money_CR where 1<>1');
      Open;
    end;
    with ADOQueryCmd do
    begin
      Append;
      FieldByName('YFID').Value:=Trim(maxId);
      FieldByName('CRID').Value:=StrToInt(CRID);
      //SSetSaveDataCDSNew(ADOQueryCmd,Tv2,CDS_HZ,'YF_Money_CR',3);
      FieldByName('Filler').Value:=Trim(DName);
      FieldByName('CRType').Value:='收款登记';
      FieldByName('CRFlag').Value:='应收收';
      FieldByName('QtyFlag').Value:=-1;
      FieldByName('FactoryNo').Value:=Trim(CDS_HZ.fieldbyname('FactoryNo').AsString);
      FieldByName('FactoryName').Value:=Trim(CDS_HZ.fieldbyname('FactoryName').AsString);
      FieldByName('CRTime').Value:=SGetServerDate(ADOQueryTemp);
      FieldByName('YFDefFlag1').Value:=fFlag;
      FieldByName('status').Value:=0;
      Post;
    end;
    with CDS_HZ do
    begin
      Edit;
      FieldByName('YFId').Value:=Trim(maxId);
      FieldByName('CRID').Value:=StrToInt(CRID);
    end;
    ADOQueryCmd.Connection.CommitTrans;
    Result:=True;
  except
    Result:=True;
    ADOQueryCmd.Connection.RollbackTrans;
    Application.MessageBox('增行失败!','提示',0);
  end;
end;

procedure TfrmSKCR_YF.cxGridDBColumn8PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalue,FFieldName:String;
begin
  mvalue:=TcxTextEdit(Sender).EditingText;
  FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
  with CDS_HZ do
  begin
    Edit;
    FieldByName(FFieldName).Value:=Trim(mvalue);
    Post;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('UPdate YCL_SG_HZ ');
    if Trim(mvalue)<>'' then
    begin
      sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
    end else
    begin
      sql.Add(' Set '+FFieldName+'=NULL');
    end;
    SQL.Add(',Editer='''+Trim(DName)+'''');
    SQL.Add(',Edittime=getdate() ');
    SQL.Add(' where SubId='''+Trim(CDS_HZ.fieldbyname('SubId').AsString)+'''');
    ExecSQL;
  end;
end;

procedure TfrmSKCR_YF.cxGridDBColumn5PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalue,FQty,FPrice,FMoney,FHuiLv,FBBMoney,FKCBB,FFieldName:String;
begin
  mvalue:=TcxTextEdit(Sender).EditingText;
  if Trim(mvalue)='' then
  begin
    mvalue:='0';
  end;
  FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
  with CDS_HZ do
  begin
    Edit;
    FieldByName(FFieldName).Value:=Trim(mvalue);
    Post;
  end;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select isnull(BBMoney,0) BBMoney from YF_Money_CR where YFID='''+cds_hz.fieldbyname('YFID').AsString+'''');
    Open;
  end;
  FKCBB:=ADOQueryTemp.fieldbyname('BBMoney').AsString;

  FQty:=Trim(CDS_HZ.fieldbyname('Qty').AsString);
  if Trim(FQty)='' then FQty:='0';

  FPrice:=Trim(CDS_HZ.fieldbyname('Price').AsString);
  if Trim(FPrice)='' then FPrice:='0';
  FQty:=Trim(CDS_HZ.fieldbyname('Qty').AsString);
  if Trim(FQty)='' then FQty:='0';

  FMoney:=Trim(CDS_HZ.fieldbyname('Money').AsString);
  if Trim(FMoney)='' then FMoney:='0';

  FHuiLv:=Trim(CDS_HZ.fieldbyname('HuiLv').AsString);
  if Trim(FHuiLv)='' then FHuiLv:='0';

  {FBBMoney:=Trim(CDS_HZ.fieldbyname('BBMoney').AsString);
  if Trim(FBBMoney)='' then FBBMoney:='0'; }

  if Trim(FFieldName)<>'Money' then
  begin
    if Trim(FFieldName)<>'HuiLv' then
    begin
      FBBMoney:=FloatToStr(StrToFloat(FQty)*StrToFloat(FPrice)*StrToFloat(FHuiLv));
      FMoney:=FloatToStr(StrToFloat(FQty)*StrToFloat(FPrice));
    end else
    begin
      FBBMoney:=FloatToStr(StrToFloat(FMoney)*StrToFloat(FHuiLv));
    end;

  end else
  begin
    FBBMoney:=FloatToStr(StrToFloat(FMoney)*StrToFloat(FHuiLv));
  end;
  with CDS_HZ do
  begin
    Edit;
    FieldByName('Money').Value:=StrToFloat(FMoney);
    FieldByName('BBMoney').Value:=StrToFloat(FBBMoney);
    Post;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('UPdate YF_Money_CR ');
    sql.Add(' Set '+FFieldName+'='+Trim(mvalue));
    if Trim(FFieldName)<>'Money' then
    begin
      sql.Add(',Money='+FMoney);
    end;

    sql.Add(',BBMoney='+FBBMoney);
    SQL.Add(',Editer='''+Trim(DName)+'''');
    SQL.Add(',Edittime=getdate() ');
    SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
    
    SQL.Add('Update YF_Money_KC Set KCBBMoney=KCBBMoney-'+FKCBB+'+'+FBBMoney);
    sql.Add(' where CRID='''+Trim(CDS_HZ.fieldbyname('CRID').AsString)+'''');
    ExecSQL;
  end;
  tv2.Controller.EditingController.ShowEdit();
end;

procedure TfrmSKCR_YF.cxGridDBColumn1PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalue,FFieldName:String;
begin
  mvalue:=TcxTextEdit(Sender).EditingText;
  FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
  with CDS_HZ do
  begin
    Edit;
    FieldByName(FFieldName).Value:=Trim(mvalue);
    Post;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('UPdate YF_Money_CR ');
    if Trim(mvalue)<>'' then
    begin
      sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
    end else
    begin
      sql.Add(' Set '+FFieldName+'=NULL');
    end;
    SQL.Add(',Editer='''+Trim(DName)+'''');
    SQL.Add(',Edittime=getdate() ');
    SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
    ExecSQL;
  end;
   tv2.Controller.EditingController.ShowEdit();
end;

procedure TfrmSKCR_YF.cxGridDBColumn3PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='YFName';
      flagname:='项目及摘要';
      if Trim(DParameters3)='项目分开' then
        MainType:='收款';
      if ShowModal=1 then
      begin
        with Self.CDS_HZ do
        begin
          Edit;
          FieldByName('YFCode').Value:=Trim(ClientDataSet1.fieldbyname('ZdyNo').AsString);
          FieldByName('YFName').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('UPdate YF_Money_CR ');
          sql.Add(' Set YFCode='''+Trim(ClientDataSet1.fieldbyname('ZdyNo').AsString)+'''');
          sql.Add(' ,YFName='''+Trim(ClientDataSet1.fieldbyname('ZdyName').AsString)+'''');
          SQL.Add(',Editer='''+Trim(DName)+'''');
          SQL.Add(',Edittime=getdate() ');
          SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
          ExecSQL;
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmSKCR_YF.cxGridDBColumn6PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='OrderUnit';
      flagname:='数量单位';
      if ShowModal=1 then
      begin
        Self.CDS_HZ.Edit;
        Self.CDS_HZ.FieldByName('QtyUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('UPdate YF_Money_CR ');
          sql.Add(' Set QtyUnit='''+Trim(ClientDataSet1.fieldbyname('ZdyName').AsString)+'''');
          SQL.Add(',Editer='''+Trim(DName)+'''');
          SQL.Add(',Edittime=getdate() ');
          SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
          ExecSQL;
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmSKCR_YF.v2Column3PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='BZType';
      flagname:='币种';
      if ShowModal=1 then
      begin
        Self.CDS_HZ.Edit;
        Self.CDS_HZ.FieldByName('BZType').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('UPdate YF_Money_CR ');
          sql.Add(' Set BZType='''+Trim(ClientDataSet1.fieldbyname('ZdyName').AsString)+'''');
          SQL.Add(',Editer='''+Trim(DName)+'''');
          SQL.Add(',Edittime=getdate() ');
          SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
          ExecSQL;
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmSKCR_YF.ToolButton1Click(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then Exit;
  SelExportData(Tv2,ADOQueryMain,'订单利润表');
end;

procedure TfrmSKCR_YF.v2Column4PropertiesEditValueChanged(Sender: TObject);
var
  mvalue,FMoney,FHuiLv,FBBMoney,FKCBB,FFieldName:String;
begin
  mvalue:=TcxTextEdit(Sender).EditingText;
  if Trim(mvalue)='' then
  begin
    mvalue:='0';
  end;
  FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
  with CDS_HZ do
  begin
    Edit;
    FieldByName(FFieldName).Value:=Trim(mvalue);
    Post;
  end;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select isnull(BBMoney,0) BBMoney from YF_Money_CR where YFID='''+cds_hz.fieldbyname('YFID').AsString+'''');
    Open;
  end;
  FKCBB:=ADOQueryTemp.fieldbyname('BBMoney').AsString;

  FMoney:=Trim(CDS_HZ.fieldbyname('Money').AsString);
  if Trim(FMoney)='' then FMoney:='0';

  FHuiLv:=Trim(CDS_HZ.fieldbyname('HuiLv').AsString);
  if Trim(FHuiLv)='' then FHuiLv:='0';

  {FBBMoney:=Trim(CDS_HZ.fieldbyname('BBMoney').AsString);
  if Trim(FBBMoney)='' then FBBMoney:='0'; }

  FBBMoney:=FloatToStr(StrToFloat(FMoney)*StrToFloat(FHuiLv));
  with CDS_HZ do
  begin
    Edit;
    FieldByName('Money').Value:=StrToFloat(FMoney);
    FieldByName('BBMoney').Value:=StrToFloat(FBBMoney);
    Post;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('UPdate YF_Money_CR ');
    sql.Add(' Set '+FFieldName+'='+Trim(mvalue));
    sql.Add(',BBMoney='+FBBMoney);
    SQL.Add(',Editer='''+Trim(DName)+'''');
    SQL.Add(',Edittime=getdate() ');
    SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
    
    SQL.Add('Update YF_Money_KC Set KCBBMoney=KCBBMoney+'+FKCBB+'-'+FBBMoney);
    sql.Add(' where CRID='''+Trim(CDS_HZ.fieldbyname('CRID').AsString)+'''');
    ExecSQL;
  end;
   tv2.Controller.EditingController.ShowEdit();
end;

procedure TfrmSKCR_YF.v2Column1PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmProductOrderListSel:=TfrmProductOrderListSel.Create(Application);
    with frmProductOrderListSel do
    begin
      FFInt:=1;
      //frmProductOrderList.v1Column4.Visible:=True;
      if ShowModal=1 then
      begin
        with Self.CDS_HZ do
        begin
          Edit;
          FieldByName('MainId').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('MainId').AsString);
          FieldByName('OrderNo').Value:=Trim(frmProductOrderListSel.Order_Main.fieldbyname('OrderNo').AsString);
          with ADOQueryCmd do
          begin
            Close;
            sql.Clear;
            sql.Add('UPdate YF_Money_CR ');
            sql.Add(' Set MainId='''+Trim(frmProductOrderListSel.Order_Main.fieldbyname('MainId').AsString)+'''');
            sql.Add(' ,OrderNo='''+Trim(frmProductOrderListSel.Order_Main.fieldbyname('OrderNo').AsString)+'''');
            SQL.Add(',Editer='''+Trim(DName)+'''');
            SQL.Add(',Edittime=getdate() ');
            SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
            ExecSQL;
          end;
        end;
      end;
    end;
  finally
    frmProductOrderListSel.Free;
  end;
end;

procedure TfrmSKCR_YF.VBBPropertiesEditValueChanged(Sender: TObject);
var
  mvalue,FKCBB:string;
begin
  mvalue:=TcxTextEdit(Sender).EditingText;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select isnull(BBMoney,0) BBMoney from YF_Money_CR where YFID='''+cds_hz.fieldbyname('YFID').AsString+'''');
    Open;
  end;
  FKCBB:=ADOQueryTemp.fieldbyname('BBMoney').AsString;
  if Trim(mvalue)='' then mvalue:='0';
  with CDS_HZ do
  begin
    Edit;
    FieldByName('BBMoney').Value:=StrToFloat(mvalue);
    Post;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('UPdate YF_Money_CR ');
    sql.Add(' set BBMoney='+mvalue);
    SQL.Add(',Editer='''+Trim(DName)+'''');
    SQL.Add(',Edittime=getdate() ');
    SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
    
    SQL.Add('Update YF_Money_KC Set KCBBMoney=KCBBMoney+'+FKCBB+'-'+mvalue);
    sql.Add(' where CRID='''+Trim(CDS_HZ.fieldbyname('CRID').AsString)+'''');
    ExecSQL;
  end;
   tv2.Controller.EditingController.ShowEdit();
end;

procedure TfrmSKCR_YF.ConNoChange(Sender: TObject);
begin
  ToolButton2.Click;
end;

procedure TfrmSKCR_YF.v2Column1PropertiesEditValueChanged(Sender: TObject);
var
  mvalue,FFieldName:String;
begin
  mvalue:=TcxTextEdit(Sender).EditingText;
  FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
  with CDS_HZ do
  begin
    Edit;
    FieldByName(FFieldName).Value:=Trim(mvalue);
    Post;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('UPdate YF_Money_CR ');
    sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
    SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
    ExecSQL;
  end;
   tv2.Controller.EditingController.ShowEdit();
end;
procedure TfrmSKCR_YF.v2DerateMoneyPropertiesEditValueChanged(
  Sender: TObject);
var
  mvalue:string;
begin
  mvalue:=TcxTextEdit(Sender).EditingText;

  if Trim(mvalue)='' then mvalue:='0';
  with CDS_HZ do
  begin
    Edit;
    FieldByName('DerateMoney').Value:=StrToFloatdef(mvalue,0);
    Post;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('UPdate YF_Money_CR ');
    sql.Add(' set DerateMoney='+mvalue);
    SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
    ExecSQL;
  end;
   tv2.Controller.EditingController.ShowEdit();
end;

procedure TfrmSKCR_YF.cxTabControl1Change(Sender: TObject);
begin
  SetStatus();
  InitGrid();
end;

procedure TfrmSKCR_YF.v2ComTaitouPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='ComTaiTou';
      flagname:='公司抬头';
      if ShowModal=1 then
      begin
        with Self.CDS_HZ do
        begin
          Edit;
          FieldByName('ComTaiTou').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('UPdate YF_Money_CR ');
          sql.Add(' Set ComTaiTou='''+Trim(ClientDataSet1.fieldbyname('ZdyName').AsString)+'''');
          SQL.Add(',Editer='''+Trim(DName)+'''');
          SQL.Add(',Edittime=getdate() ');
          SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
          ExecSQL;
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmSKCR_YF.TCKClick(Sender: TObject);
begin
  if CDS_HZ.IsEmpty then exit;
  FrmJYOrderYS:=TFrmJYOrderYS.create(self);
  with FrmJYOrderYS do
  begin
    FConnO:=trim(CDS_HZ.fieldbyname('ConNO').AsString);
    FYWY:=trim(CDS_HZ.fieldbyname('YWY').AsString);
    FKHName:=trim(CDS_HZ.fieldbyname('CustomerNoName').AsString);
    FMaoLMoney:=trim(CDS_HZ.fieldbyname('MLMoney').AsString);
    FYGMoney:=trim(CDS_HZ.fieldbyname('YGMoney').AsString);
    FMainid:=trim(CDS_HZ.fieldbyname('ConCKID').AsString);
    if showmodal=1 then
    begin
      initgrid();
    end;
    free;
  end;
end;

procedure TfrmSKCR_YF.Tv2CellDblClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
var
  FName:string;
begin
  FName:=tv2.Controller.FocusedColumn.DataBinding.FilterFieldName;
  if trim(FName)='ConNo' then
  begin
    THTCX.Click;
  end
  else
  begin
    TCK.Click;
  end;
end;

procedure TfrmSKCR_YF.FormCreate(Sender: TObject);
begin
  cxGrid2.Align:=alClient;
end;

procedure TfrmSKCR_YF.ConNoKeyPress(Sender: TObject; var Key: Char);
var ZDY:string;
begin
  if key=#13 then
  begin
    if ComboBox1.Text='制单日期' then
    begin
      ZDY:=' and ConNo like '''+'%'+trim(ConNo.Text)+'%'+'''';
    end
    else
    begin
      ZDY:=' and ConNo like '''+'%'+trim(ConNo.Text)+'%'+''' and exists (select Mainid from YF_Money_CR BB inner join JYOrder_Main CC on BB.OrderNO=CC.OrderNo '
           +' where BB.CRTime>='''+Trim(FormatDateTime('yyyy-MM-dd',begdate.DateTime))+''' '
           +' and BB.CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1))+''' )';
    end;
    with ADOQueryMain do
    begin
      Close;
      SQL.Clear;
      sql.Add('exec P_YFFK_HZCX :ZDY');
      Parameters.ParamByName('ZDY').Value:=ZDY;
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_HZ);
    SInitCDSData20(ADOQueryMain,CDS_HZ);
  end;
end;

procedure TfrmSKCR_YF.TPrintClick(Sender: TObject);
var fPrintFile:string;
    FPBPS,FPBQty,FPBMoney:double;
    FRFPS,FRFQty,FRFMoney:double;
    FFLPS,FFLQty,FFLMoney:double;
    FPS,FQty,FRMBMoney,FUSDMoney:double;
    FSKRMBMoney,FSKUSDMoney:double;
begin
  if CDS_HZ.IsEmpty then exit;
  with Adoquery1 do
  begin
    close;
    sql.clear;
    sql.add('select D.CRTime,D.FactoryName,C.SPName,AA.ConCKID,Sum(C.Qty) TTQty,Max(D.Price) Price,Sum(C.Qty*D.Price) PBMoney ');
    sql.Add('from (select B.OrdMainidCK,B.ConCKID,BiLV=SUM(B.Qty)/(select SUM(A.Qty) from CK_SXPB_CR A where A.CRFlag=''入库'' and A.CKName=''待检布'' and A.OrdMainidRK=B.OrdMainidCK)');
    sql.Add(' from CK_SXPB_CR B ');
		sql.Add(' where B.CRFlag=''出库'' and B.CKName=''待检布'' and B.CRType<>''检验退回'' group by B.OrdMainidCK,B.ConCKID) AA');
    sql.Add(' inner join CK_SXPB_CR C on C.CRFlag=''出库'' and C.ORDMainIdCK=AA.OrdMainidCK ');
    sql.Add(' inner join YF_Money_CR D on C.FZSPID=D.MainId');
    sql.Add(' where AA.ConCKID='''+trim(CDS_HZ.fieldbyname('ConCKID').AsString)+'''');
    sql.Add(' and exists(select W.SPID from CK_SXPB_CR W where W.SPID=C.FZSPID and W.CRFlag=''入库'' and isnull(W.CRType,'''')=''采购入库'' and isnull(W.CKName,'''')<>''辅料'')');
    sql.Add(' group by D.CRTime,D.FactoryName,C.SPName,AA.ConCKID');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_PB);
  SInitCDSData20(Adoquery1,Order_PB);
  FPBPS:=0;FPBQty:=0;FPBMoney:=0;
  with Order_PB do
  begin
    first;
    while not eof do
    begin
      FPBQty:=FPBQty+fieldbyname('TTQty').AsFloat;
      FPBMoney:=FPBMoney+fieldbyname('PBMoney').AsFloat;
      next;
    end;
  end;
  with Adoquery1 do
  begin
    close;
    sql.clear;
    sql.add('select D.CRTime,D.FactoryName,C.SPName,AA.ConCKID,Sum(C.Qty) FLQty,Max(D.Price) Price,Sum(C.Qty*D.Price) FLMoney ');
    sql.Add('from (select B.OrdMainidCK,B.ConCKID,BiLV=SUM(B.Qty)/(select SUM(A.Qty) from CK_SXPB_CR A where A.CRFlag=''入库'' and A.CKName=''待检布'' and A.OrdMainidRK=B.OrdMainidCK)');
    sql.Add(' from CK_SXPB_CR B ');
		sql.Add(' where B.CRFlag=''出库''  and B.CKName=''待检布'' and B.CRType<>''检验退回'' group by B.OrdMainidCK,B.ConCKID) AA');
    sql.Add(' inner join CK_SXPB_CR C on C.CKName=''辅料'' and C.CRFlag=''出库'' and C.ORDMainIdCK=AA.ORDMainIdCK ');
    sql.Add(' inner join YF_Money_CR D on C.FZSPID=D.MainId');
    sql.Add(' where AA.ConCKID='''+trim(CDS_HZ.fieldbyname('ConCKID').AsString)+'''');
    sql.Add(' group by D.CRTime,D.FactoryName,C.SPName,AA.ConCKID');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_FL);
  SInitCDSData20(Adoquery1,Order_FL);
  FFLPS:=0;FFLQty:=0;FFLMoney:=0;
  with Order_FL do
  begin
    first;
    while not eof do
    begin
      FFLQty:=FFLQty+fieldbyname('TTQty').AsFloat;
      FFLMoney:=FFLMoney+fieldbyname('PBMoney').AsFloat;
      next;
    end;
  end;

  with Adoquery1 do
  begin
    close;
    sql.clear;
    sql.add('select D.CRTime,D.FactoryName,C.SPName,AA.ConCKID,C.SPCF PRTColor,Sum(C.Qty) JGQty,Max(D.Price) Price,Sum(C.Qty*D.Price) JGMoney ');
    sql.Add('from (select B.OrdMainidRK,B.ConCKID,BiLV=SUM(B.Qty)/(select SUM(A.Qty) from CK_SXPB_CR A where A.CRFlag=''出库'' and A.CKName=''待检布'' and A.OrdMainidCK=B.OrdMainidRK)');
    sql.Add(' from CK_SXPB_CR B ');
		sql.Add(' where B.CRFlag=''入库'' and B.CKName=''成品'' and B.CRType<>''检验退回'' group by B.OrdMainidRK,B.ConCKID) AA');
    sql.Add(' inner join CK_SXPB_CR C on C.CKName in (''外加工'',''待检布'',''成品'') and C.CRFlag=''出库'' and C.OrdMainidCK=AA.OrdMainidRK ');
    sql.Add(' inner join YF_Money_CR D on C.FZSPID=D.MainId');
    sql.Add(' where AA.ConCKID='''+trim(CDS_HZ.fieldbyname('ConCKID').AsString)+'''');
    sql.Add(' group by D.CRTime,D.FactoryName,C.SPName,AA.ConCKID,C.SPCF');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_RF);
  SInitCDSData20(Adoquery1,Order_RF);
  FRFPS:=0;FRFQty:=0;FRFMoney:=0;
  with Order_RF do
  begin
    first;
    while not eof do
    begin
      FRFQty:=FRFQty+fieldbyname('JGQty').AsFloat;
      FRFMoney:=FRFMoney+fieldbyname('JGMoney').AsFloat;
      next;
    end;
  end;
  with AdoQuery1 do
  begin
    close;
    sql.clear;
    sql.add('select A.ConNo,A.CRTime,A.P_CodeName,isnull(E.PRTColor,E.SOrdDefStr4) PRTColor,A.BZType,A.Price');
    sql.add(',Sum(A.PS) PS,Sum(A.Qty) Qty');
    sql.add(',Huilv=isnull((select top 1 T.HuiLV from JYOrder_HuiLV T where A.CRTime>=T.BegDate and A.CRTime<isnull(T.EndDate,A.CRTime+1) and A.BZType<>''￥'' and A.BZType<>''RMB'' and T.GSType=A.GSType),1)');
    sql.add(',RMBMoney=cast(Sum(A.Money)*isnull((select TOP 1 C.HuiLV From JYOrder_HuiLV C where A.CRTime>=C.BegDate and A.CRTime<isnull(C.EndDate,A.CRTime+1) and A.BZType<>''￥'' and A.BZType<>''RMB'' and C.GSType=A.GSType),1) as decimal(18,2))');
    sql.Add(',Sum(case when (A.BZType<>''￥'') and (A.BZType<>''RMB'') then A.Money else 0 end) USDMoney');
    sql.add(' from YF_Money_CR A ');
    sql.Add(' left join CK_SXPB_CR C on A.YFTypeId=C.SPID and C.CRFlag=''出库'' ');
    sql.Add(' left join JYOrder_Main B on B.Mainid=C.OrdMainidCK');
    sql.Add(' left join JYOrder_Sub E on E.Subid=isnull(C.OrdSubidCK,A.Subid)');
    sql.add(' where isnull(A.ConID,C.ConCKID)='''+trim(CDS_HZ.fieldbyname('ConCKID').AsString)+''' and A.CRType=''应收款登记'' ');
    sql.add(' and A.CRFlag=''应收收'' and isnull(A.Status,'''')=''2''');
    sql.add(' group by A.ConNo,A.CRTime,A.P_CodeName,E.PRTColor,E.SOrdDefStr4,A.BZType,A.Price,A.GSType'); //待观察
    open;
  end;
  SCreateCDS20(Adoquery1,Order_XS);
  SInitCDSData20(Adoquery1,Order_XS);
  FPS:=0;FQty:=0;FRMBMoney:=0;FUSDMoney:=0;
  with Order_XS do
  begin
    first;
    while not eof do
    begin
      FQty:=FQty+fieldbyname('Qty').asfloat;
      FRMBMoney:=FRMBMoney+fieldbyname('RMBMoney').asfloat;
      FUSDMoney:=FUSDMoney+fieldbyname('USDMoney').asfloat;
      next;
    end;
  end;
  with AdoQuery1 do
  begin
    close;
    sql.clear;
    sql.add('select B.ConNo,A.CRTime,A.BZType');
    sql.add(',Huilv=isnull((select top 1 C.HuiLV from JYOrder_HuiLV C where A.CRTime>=C.BegDate and A.CRTime<isnull(C.EndDate,A.CRTime+1) and A.BZType<>''￥'' and A.BZType<>''RMB'' and C.GSType=A.GSType),1)');
    sql.add(',RMBMoney=cast((sum(E.Num)*isnull((select TOP 1 C.HuiLV From JYOrder_HuiLV C where A.CRTime>=C.BegDate and A.CRTime<isnull(C.EndDate,A.CRTime+1) and A.BZType<>''￥'' and A.BZType<>''RMB'' and C.GSType=A.GSType),1)) as decimal(18,2))');
    sql.add(',USDMoney=(case when (A.BZType<>''￥'') and (A.BZType<>''RMB'') then sum(E.Num) else 0 end)');
    sql.add('from YF_Money_CR A ');
    sql.add('inner join YF_log E on E.ListNo=A.YFID ');
    sql.Add('inner join YF_Money_CR B on B.YFID=E.ToNo and B.CRType=''应收款登记'' ');
    sql.add('where B.ConID='''+trim(CDS_HZ.fieldbyname('ConCKID').AsString)+''' and A.CRType=''收款登记'' ');
    sql.Add(' and isnull(A.Status,'''')=''2''');
    sql.add('group by B.ConNo,A.CRTime,A.BZType,A.GSType');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_SK);
  SInitCDSData20(Adoquery1,Order_SK);
  FSKRMBMoney:=0;FSKUSDMoney:=0;
  with Order_SK do
  begin
    first;
    while not eof do
    begin
      FSKRMBMoney:=FSKRMBMoney+fieldbyname('RMBMoney').asfloat;
      FSKUSDMoney:=FSKUSDMoney+fieldbyname('USDMoney').asfloat;
      next;
    end;
  end;
  with AdoQuery1 do
  begin
    close;
    sql.clear;
    sql.add('select A.CRTime,A.YFName,A.BZType,A.Note ');
    sql.add(',RMBMoney=(Sum(A.Money)*isnull((select top 1 C.HuiLV from JYOrder_HuiLV C where A.CRTime>=C.BegDate and A.CRTime<isnull(C.EndDate,A.CRTime+1)');
    sql.Add(' and A.BZType<>''￥'' and A.BZType<>''RMB'' and C.GSType=A.GSType),1))');
    sql.add(' from YF_Money_CR A ');
    sql.add(' where A.ConID='''+trim(CDS_HZ.fieldbyname('ConCKID').AsString)+''' and A.CRType in (''应付款登记'',''付款杂费'')');
    sql.Add(' and isnull(A.Status,''0'')<>''0''');
    sql.Add(' and not exists(select B.SPID from CK_SXPB_CR B where B.SPID=A.YFTypeId and B.CRFlag=''出库'' and B.CRType<>''正常入库'')');
    sql.add(' group by A.CRTime,A.YFName,A.BZType,A.GSType,A.Note');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_FYZC);
  SInitCDSData20(Adoquery1,Order_FYZC);
  fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\订单利润表.rmf';
  if FileExists(fPrintFile) then
  begin
    RMVariables['FConNo']:=trim(CDS_HZ.fieldbyname('ConNO').asstring);
    RMVariables['FConPerson1']:=trim(CDS_HZ.fieldbyname('ConPerson1').asstring);
    RMVariables['FCustomerNoName']:=trim(CDS_HZ.fieldbyname('CustomerNoName').asstring);
    RMVariables['MLMoney']:=CDS_HZ.fieldbyname('MLMoney').AsFloat;
    RMVariables['YGMoney']:=CDS_HZ.fieldbyname('YGMoney').AsFloat;
    RMVariables['FPBPS']:=FPBPS;
    RMVariables['FPBQty']:=FPBQty;
    RMVariables['FPBMoney']:=FPBMoney;
    RMVariables['FRFPS']:=FRFPS;
    RMVariables['FRFQty']:=FRFQty;
    RMVariables['FRFMoney']:=FRFMoney;

    RMVariables['FFLPS']:=FFLPS;
    RMVariables['FFLQty']:=FFLQty;
    RMVariables['FFLMoney']:=FFLMoney;

    RMVariables['FPS']:=FPS;
    RMVariables['FQty']:=FQty;
    RMVariables['FRMBMoney']:=FRMBMoney;
    RMVariables['FUSDMoney']:=FUSDMoney;
    RMVariables['FSKRMBMoney']:=FSKRMBMoney;
    RMVariables['FSKUSDMoney']:=FSKUSDMoney;
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end else
  begin
    Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\订单利润表.rmf'),'提示',0);
  end;
end;

procedure TfrmSKCR_YF.THTCXClick(Sender: TObject);
begin
  if CDS_HZ.IsEmpty then exit;
  try
    frmConInPutXF_LRDB:=TfrmConInPutXF_LRDB.Create(Application);
    with frmConInPutXF_LRDB do
    begin
      PState:=1;
      FSubid:=Trim(Self.CDS_HZ.fieldbyname('ConCKID').AsString);
      FMainid:=Trim(Self.CDS_HZ.fieldbyname('Mainid').AsString);
      FYGMoney:=Self.CDS_HZ.fieldbyname('YGMoney').AsFloat;
      FZJSJCBMoney:=CDS_HZ.fieldbyname('ZFMoney').AsFloat
                    +CDS_HZ.fieldbyname('FLMoney').AsFloat+CDS_HZ.fieldbyname('PBMoney').AsFloat+CDS_HZ.fieldbyname('JGMoney').AsFloat;
      FSJFlv:=CDS_HZ.fieldbyname('SOrdQty8').AsFloat;
      FSJGLMoney:=CDS_HZ.fieldbyname('GLMoney').AsFloat;
      FSJKPMoney:=CDS_HZ.fieldbyname('KPMoney').AsFloat;
      FZT:='1';
      if ShowModal=1 then
      begin

      end;
    end;
  finally;
    frmConInPutXF_LRDB.Free;
  end;
end;

procedure TfrmSKCR_YF.ComboBox1Change(Sender: TObject);
begin
  InitGrid();
end;

end.
