unit U_ReceivableEdit;

interface

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

type
  TfrmReceivableEdit = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Label2: TLabel;
    ZaMoney: TEdit;
    Label3: TLabel;
    SL: TEdit;
    Label4: TLabel;
    RanMoney: TEdit;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    FFFIDS: string;
    FBCIID: string;
    { Public declarations }
  end;

var
  frmReceivableEdit: TfrmReceivableEdit;

implementation

{$R *.dfm}

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

procedure TfrmReceivableEdit.FormShow(Sender: TObject);
begin
  zaMoney.SetFocus;

  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add(' select * from BS_Cloth_Info   ');
    sql.Add(' where BCIID=''' + Trim(FBCIID) + '''');
//      showmessage(sql.text);
    Open;
  end;

  ZaMoney.text := Trim(ADOQueryCmd.fieldbyname('ZaMoney').AsString);
  SL.text := Trim(ADOQueryCmd.fieldbyname('SL').AsString);
  RanMoney.text := Trim(ADOQueryCmd.fieldbyname('RanMoney').AsString);
end;

procedure TfrmReceivableEdit.Button1Click(Sender: TObject);
begin

  if StrToFloatDef(ZaMoney.Text, 0) = 0 then
    ZaMoney.Text := '0';

  if StrToFloatDef(SL.Text, 0) = 0 then
    SL.Text := '0';

  if StrToFloatDef(RanMoney.Text, 0) = 0 then
    RanMoney.Text := '0';

  try
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add(' update BS_Cloth_Info   ');
      sql.Add(' set  ZaMoney=' + ZaMoney.Text);
      sql.Add(' ,    SL=' + SL.Text);
      sql.Add(' ,    RanMoney=' + RanMoney.Text);
      sql.Add(' where BCIID=''' + Trim(FBCIID) + '''');
//      showmessage(sql.text);
      ExecSQL;
    end;
    ModalResult := 1;
  except
    application.MessageBox(PChar(Exception(ExceptObject).Message), 'ΜαΚΎΠΕΟ’', 0);

  end;
end;

end.

