usettlepay.~pas
来自「DELPHI编程入门篇.从基础入手,浅显易懂,一定物有所值.」· ~PAS 代码 · 共 173 行
~PAS
173 行
unit Usettlepay;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, ADODB;
type
Tfrmsettlepay = class(TForm)
Label2: TLabel;
Edit1: TEdit;
ComboBox1: TComboBox;
Label1: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Edit4: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
ADOQuery1: TADOQuery;
Label5: TLabel;
Edit5: TEdit;
procedure FormCreate(Sender: TObject);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure BitBtn1Click(Sender: TObject);
procedure ComboBox1Select(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmsettlepay: Tfrmsettlepay;
implementation
uses Udatamodule;
{$R *.dfm}
procedure Tfrmsettlepay.FormCreate(Sender: TObject);
var
ayear,amonth,adate:word;
ctext,smonth,sdate:string;
begin
decodedate(date,ayear,amonth,adate);
smonth:=inttostr(amonth);
sdate:=inttostr(adate);
if length(smonth) = 1 then smonth:='0'+smonth;
if length(sdate) = 1 then sdate:='0'+sdate;
ctext:=inttostr(ayear)+smonth+sdate;
adoquery1.SQL.Text:='select max(settleid) as maxid from prsettle where settleid like '''+ctext+'%''';
adoquery1.Open;
if adoquery1.FieldByName('maxid').AsString <> '' then
edit5.Text:=inttostr(strtoint64(adoquery1.Fields[0].AsString)+1)
else
edit5.Text:=ctext+'0001';
adoquery1.Close;
adoquery1.SQL.Text:='select provname from provinfo';
adoquery1.Open;
while not adoquery1.Eof do
begin
combobox1.Items.Add(adoquery1.fields[0].AsString);
adoquery1.Next;
end;
adoquery1.Close;
combobox1.ItemIndex:=-1;
end;
procedure Tfrmsettlepay.Edit3KeyPress(Sender: TObject; var Key: Char);
var
s:string;
i,cpoint:integer;
begin
if ((not (key in ['0'..'9'])) and (key <> '.') and (key <> #8)) then
begin
key:=chr(0);
showmessage('请输入数字或小数点');
exit;
end
else begin
cpoint:=0;
s:=edit3.Text;
for i:=1 to length(s) do
if s[i] = '.' then inc(cpoint);
if (((cpoint > 0) or (s = '')) and (key = '.')) then
begin
key:=chr(0);
exit;
end;
end;
end;
procedure Tfrmsettlepay.BitBtn1Click(Sender: TObject);
begin
if edit1.Text = '' then
begin
showmessage('请选择供应商!');
exit;
end;
if edit3.Text = '' then
begin
showmessage('请输入付款金额!');
exit;
end;
if edit4.Text = '' then
begin
showmessage('请输入经手人!');
exit;
end;
adoquery1.SQL.Text:='insert into prsettle values("'+edit5.Text+'",'+
'#'+datetostr(date)+'#,"'+edit1.Text+'","'+edit3.Text+'","'+edit4.Text+'")';
adoquery1.ExecSQL;
adoquery1.Close;
showmessage('保存成功!');
end;
procedure Tfrmsettlepay.ComboBox1Select(Sender: TObject);
var
allpay:currency;
begin
allpay:=0;
adoquery1.SQL.Text:='select provid from provinfo where provname = '''+combobox1.Text+'''';
adoquery1.Open;
edit1.Text:=adoquery1.Fields[0].AsString;
adoquery1.Close;
adoquery1.SQL.Text:='select accounts from stockin where provid = '''+edit1.Text+'''';
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
while not adoquery1.Eof do
begin
allpay:=allpay + adoquery1.fieldbyname('accounts').AsCurrency;
adoquery1.Next;
end;
end;
adoquery1.Close;
adoquery1.SQL.Text:='select accounts from refund where provid = '''+edit1.Text+'''';
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
while not adoquery1.Eof do
begin
allpay:=allpay - adoquery1.fieldbyname('accounts').AsCurrency;
adoquery1.Next;
end;
end;
adoquery1.Close;
adoquery1.SQL.Text:='select payed from prsettle where provid = '''+edit1.Text+'''';
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
while not adoquery1.Eof do
begin
allpay:=allpay - adoquery1.fieldbyname('payed').AsCurrency;
adoquery1.Next;
end;
end;
adoquery1.Close;
edit2.Text:=currtostr(allpay);
end;
procedure Tfrmsettlepay.BitBtn2Click(Sender: TObject);
begin
self.Close;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?