usettlecharge.~pas
来自「DELPHI编程入门篇.从基础入手,浅显易懂,一定物有所值.」· ~PAS 代码 · 共 146 行
~PAS
146 行
unit Usettlecharge;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Buttons;
type
Tfrmsettlecharge = class(TForm)
Label5: TLabel;
Edit5: TEdit;
Label2: TLabel;
Edit1: TEdit;
ComboBox1: TComboBox;
Label1: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Edit4: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
ADOQuery1: TADOQuery;
procedure FormCreate(Sender: TObject);
procedure ComboBox1Select(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmsettlecharge: Tfrmsettlecharge;
implementation
{$R *.dfm}
procedure Tfrmsettlecharge.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 clisettle 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 Tfrmsettlecharge.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 wholesale where clientid = '''+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 whrefund where clientid = '''+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 clisettle where clientid = '''+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 Tfrmsettlecharge.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 clisettle values("'+edit5.Text+'",'+
'#'+datetostr(date)+'#,"'+edit1.Text+'","'+edit3.Text+'","'+edit4.Text+'")';
adoquery1.ExecSQL;
adoquery1.Close;
showmessage('保存成功!');
end;
procedure Tfrmsettlecharge.BitBtn2Click(Sender: TObject);
begin
self.Close;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?