unit1.~pas

来自「Delphi函数参考大全的CD」· ~PAS 代码 · 共 60 行

~PAS
60
字号
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Provider: TEdit;
    PayMoney: TEdit;
    Factmoney: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    ADOConnection1: TADOConnection;
    ADOQuery1: TADOQuery;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  money: Integer;
begin
  With ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select count from tb_count where provider = :name');
    Parameters.ParamByName('name').Value := Trim(Provider.Text);
    Open;
  end;
  Money := Round(ADOQuery1.Fields[0].Value); //应付金额
  PayMoney.Text := IntToStr(Money); //在编辑框中显示应付金额
  With ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('Update tb_count set count = count-:count where provider = :name');
    Parameters.ParamByName('name').Value := Trim(Provider.Text);
    Parameters.ParamByName('count').Value := StrToFloat(Factmoney.Text);//实付金额
    ExecSQL;
  end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?