unit U_PayableEdit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DB, ADODB;

type
  TfrmPayableEdit = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Label1: TLabel;
    Button2: TButton;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Price: TEdit;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    FFFIDS: string;
    { Public declarations }
  end;

var
  frmPayableEdit: TfrmPayableEdit;

implementation

{$R *.dfm}

procedure TfrmPayableEdit.Button2Click(Sender: TObject);
begin
  Close;
end;

procedure TfrmPayableEdit.Button1Click(Sender: TObject);
begin
  if StrToFloatDef(Price.Text, 0) = 0 then
    Price.Text := '0';
  try
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add(' update Finance_Flow   ');
      sql.Add(' set  Price=' + Price.Text);
      sql.Add(' ,Amount=Round((Qty * ' + Price.Text + ' + isnull(OtherFee,0) - isnull(Deduction,0)), 2)');
      sql.Add(' where ISNULL(status, ''0'')=''0''  ');
      sql.Add(' and EXISTS(select X.RTValue from [dbo].[F_Tool_SplitString](' + quotedstr(FFFIDS) + ','','')  X where X.RTValue=Finance_Flow.FFID) ');
//      showmessage(sql.text);
      ExecSQL;
    end;
    ModalResult := 1;
  except
    application.MessageBox(PChar(Exception(ExceptObject).Message), 'ΜαΚΎΠΕΟ’', 0);

  end;
end;

end.

