📄 sd.~pas
字号:
unit sd;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, DBCtrlsEh, ExtCtrls, Buttons;
type
TForm4 = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
DBComboBoxEh1: TDBComboBoxEh;
Label2: TLabel;
DBComboBoxEh2: TDBComboBoxEh;
BitBtn1: TBitBtn;
Label5: TLabel;
Label6: TLabel;
DBNumberEditEh1: TDBNumberEditEh;
DBNumberEditEh2: TDBNumberEditEh;
Bevel2: TBevel;
BitBtn3: TBitBtn;
Label7: TLabel;
DBComboBoxEh5: TDBComboBoxEh;
Bevel3: TBevel;
Label8: TLabel;
DBDateTimeEditEh1: TDBDateTimeEditEh;
BitBtn2: TBitBtn;
Label3: TLabel;
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses maindata;
{$R *.dfm}
procedure TForm4.FormShow(Sender: TObject);
var
years,months,days:word;
begin
decodedate(date,years,months,days);
dbcomboboxeh1.Text:=inttostr(years);
dbcomboboxeh2.Text:=inttostr(months-1);
with datamodule1.floorQ do
begin
sql.clear;
sql.add('select * from floor');
open;
first;
end;
//for nn:=1 to dbcomboboxeh1.Items.Count do
// dbcomboboxeh1.Items.Delete(nn-1);
while not datamodule1.floorQ.Eof do
begin
dbcomboboxeh5.Items.Add(datamodule1.floorQ.fieldbyname('floorname').asstring);
datamodule1.floorQ.Next;
end;
dbdatetimeEditeh1.Value:=date-30;
label3.Caption:='只需任收租月的最后一天'+chr(13)+'如收8月份的,就选8月31号';
end;
procedure TForm4.BitBtn1Click(Sender: TObject);
begin
if dbcomboboxeh5.Value='' then
begin
application.MessageBox('大厦不能为空!','提示',mb_ok);
abort;
end;
if dbcomboboxeh1.Value='' then
begin
application.MessageBox('年份不能为空!','提示',mb_ok);
abort;
end;
if dbcomboboxeh2.Value='' then
begin
application.MessageBox('月份不能为空!','提示',mb_ok);
abort;
end;
//初始化单价
datamodule1.insertcustom.SQL.clear;
datamodule1.insertcustom.SQL.Add('select * from company where floor=:mf');
datamodule1.insertcustom.ParamByName('mf').Value:=dbcomboboxeh5.Value;
datamodule1.insertcustom.Open;
datamodule1.insertcustom.First;
while not datamodule1.insertcustom.Eof do
begin
datamodule1.insertsd.SQL.clear;
datamodule1.insertsd.SQL.Add('select * from sd where years=:my and months=:mm and floor=:mf and customno=:mc');
datamodule1.insertsd.ParamByName('my').Value:=dbcomboboxeh1.Value;
datamodule1.insertsd.ParamByName('mf').Value:=dbcomboboxeh5.Value;
datamodule1.insertsd.ParamByName('mm').Value:=dbcomboboxeh2.Value;
datamodule1.insertsd.ParamByName('mc').Value:=datamodule1.insertcustom.fieldbyname('customno').Value;
datamodule1.insertsd.Open;
//showmessage('fdghfgdh');
if datamodule1.insertsd.RecordCount<=0 then
begin
datamodule1.sdpriceq.sql.clear;
datamodule1.sdpriceq.sql.add('insert into sd(customno,custom,floor,years,months,sprice,dprice)');
datamodule1.sdpriceQ.SQL.Add('values(:mc,:cm,:mf,:my,:mm,:msp,:mdp)');
datamodule1.sdpriceq.ParamByName('my').Value:=dbcomboboxeh1.Value;
datamodule1.sdpriceq.ParamByName('mm').Value:=dbcomboboxeh2.Value;
datamodule1.sdpriceq.ParamByName('mf').Value:=dbcomboboxeh5.Value;
datamodule1.sdpriceq.ParamByName('mc').value:=datamodule1.insertcustom.fieldbyname('customno').value;
datamodule1.sdpriceq.ParamByName('cm').Value:=datamodule1.insertcustom.fieldbyname('custom').Value;
datamodule1.sdpriceq.ParamByName('msp').Value:=dbnumberEditEh1.Value;
datamodule1.sdpriceq.ParamByName('mdp').Value:=dbnumberEditEh2.Value;
// showmessage(datamodule1.sdpriceq.SQL.GetText );
datamodule1.sdpriceq.execsql;
datamodule1.insertfloor.SQL.Clear;
datamodule1.insertfloor.SQL.Add('select * from sd where years=:my and months=:mm and floor=:mf and customno=:mc');
datamodule1.insertfloor.ParamByName('my').Value:=dbcomboboxeh1.Value;
datamodule1.insertfloor.ParamByName('mf').Value:=dbcomboboxeh5.Value;
datamodule1.insertfloor.ParamByName('mm').Value:=dbcomboboxeh2.Value-1;
datamodule1.insertfloor.ParamByName('mc').Value:=datamodule1.insertcustom.fieldbyname('customno').Value;
datamodule1.insertfloor.Open;
if datamodule1.insertfloor.RecordCount>0 then
begin
datamodule1.sdpriceQ.sql.clear;
datamodule1.sdpriceQ.sql.add('update sd set ls=:mp,ld=:mp2 where years=:my and months=:mm and customno=:mc and floor=:mf');
datamodule1.sdpriceq.ParamByName('my').Value:=dbcomboboxeh1.Value;
datamodule1.sdpriceq.ParamByName('mm').Value:=dbcomboboxeh2.Value;
datamodule1.sdpriceq.ParamByName('mf').Value:=dbcomboboxeh5.Value;
datamodule1.sdpriceq.ParamByName('mc').Value:=datamodule1.insertfloor.fieldbyname('customno').Value;
datamodule1.sdpriceq.ParamByName('mp').Value:=datamodule1.insertfloor.fieldbyname('bs').Value;
datamodule1.sdpriceq.ParamByName('mp2').Value:=datamodule1.insertfloor.fieldbyname('bd').Value;
datamodule1.sdpriceq.execsql;
end;
end
else
begin
datamodule1.sdpriceQ.sql.clear;
datamodule1.sdpriceQ.sql.add('update sd set sprice=:mp,dprice=:mp2 where years=:my and months=:mm and customno=:mc and floor=:mf');
datamodule1.sdpriceq.ParamByName('my').Value:=dbcomboboxeh1.Value;
datamodule1.sdpriceq.ParamByName('mm').Value:=dbcomboboxeh2.Value;
datamodule1.sdpriceq.ParamByName('mf').Value:=dbcomboboxeh5.Value;
datamodule1.sdpriceq.ParamByName('mc').Value:=datamodule1.insertsd.fieldbyname('customno').Value;
datamodule1.sdpriceq.ParamByName('mp').Value:=dbnumberediteh1.Value;
datamodule1.sdpriceq.ParamByName('mp2').Value:=dbnumberediteh2.Value;
//showmessage('00002'+datamodule1.sdpriceq.SQL.GetText );
datamodule1.sdpriceq.execsql;
end;
datamodule1.insertcustom.next;
end;
application.MessageBox('更新完毕!','提示',mb_ok);
end;
procedure TForm4.BitBtn2Click(Sender: TObject);
var
roomyear,glfyear,xzlyear,artyear:real;
begin
datamodule1.insertsd.sql.Clear;
datamodule1.insertsd.SQL.add('select * from ht');
datamodule1.insertsd.Open;
datamodule1.insertsd.first;
while not datamodule1.insertsd.Eof do
begin //dbnumberediteh1.Value:=int((strtodate('2004-9-1')-strtodate('2003-9-1'))/365/3);
xzlyear:=int((dbdatetimeEditEh1.Value-datamodule1.insertsd.fieldbyname('jzdate').value)/365/datamodule1.insertsd.fieldbyname('xzlyear').Value);
artyear:=int((dbdatetimeEditEh1.value-datamodule1.insertsd.fieldbyname('jzdate').value)/365/datamodule1.insertsd.fieldbyname('artyear').Value);
roomyear:=int((dbdatetimeEditEh1.value-datamodule1.insertsd.fieldbyname('jzdate').value)/365/datamodule1.insertsd.fieldbyname('roomyear').Value);
glfyear:=int((dbdatetimeEditEh1.value-datamodule1.insertsd.fieldbyname('jzdate').value)/365/datamodule1.insertsd.fieldbyname('glfyear').Value);
if xzlyear>=1 then
begin
datamodule1.insertcustom.SQL.Clear;
datamodule1.insertcustom.SQL.Add('update ht set ssxzl=xzl * :xzlyear,dzf=1');
datamodule1.insertcustom.sql.add('where htno=:htno');
datamodule1.insertcustom.parambyname('xzlyear').Value:=xzlyear;
datamodule1.insertcustom.parambyname('htno').Value:=datamodule1.insertsd.fieldbyname('htno').Value;
datamodule1.insertcustom.Prepare;
datamodule1.insertcustom.ExecSQL;
datamodule1.insertcustom.SQL.Clear;
datamodule1.insertcustom.SQL.Add('update ht set ssxzl=ssxzl+xzl*xzldz');
datamodule1.insertcustom.sql.add('where htno=:htno');
datamodule1.insertcustom.parambyname('htno').Value:=datamodule1.insertsd.fieldbyname('htno').Value;
datamodule1.insertcustom.Prepare;
datamodule1.insertcustom.ExecSQL;
end;
if artyear>=1 then
begin
datamodule1.insertcustom.SQL.Clear;
datamodule1.insertcustom.SQL.Add('update ht set ssart=art * :xzlyear,dzf=1');
datamodule1.insertcustom.sql.add('where htno=:htno');
datamodule1.insertcustom.parambyname('xzlyear').Value:=artyear;
datamodule1.insertcustom.parambyname('htno').Value:=datamodule1.insertsd.fieldbyname('htno').Value;
datamodule1.insertcustom.Prepare;
datamodule1.insertcustom.ExecSQL;
datamodule1.insertcustom.SQL.Clear;
datamodule1.insertcustom.SQL.Add('update ht set ssart=ssart+art*artdz');
datamodule1.insertcustom.sql.add('where htno=:htno');
datamodule1.insertcustom.parambyname('htno').Value:=datamodule1.insertsd.fieldbyname('htno').Value;
datamodule1.insertcustom.Prepare;
datamodule1.insertcustom.ExecSQL;
end;
if roomyear>=1 then
begin
datamodule1.insertcustom.SQL.Clear;
datamodule1.insertcustom.SQL.Add('update ht set ssroom=room * :xzlyear,dzf=1');
datamodule1.insertcustom.sql.add('where htno=:htno');
datamodule1.insertcustom.parambyname('xzlyear').Value:=roomyear;
datamodule1.insertcustom.parambyname('htno').Value:=datamodule1.insertsd.fieldbyname('htno').Value;
datamodule1.insertcustom.Prepare;
datamodule1.insertcustom.ExecSQL;
datamodule1.insertcustom.SQL.Clear;
datamodule1.insertcustom.SQL.Add('update ht set ssroom=ssroom+room*roomdz');
datamodule1.insertcustom.sql.add('where htno=:htno');
datamodule1.insertcustom.parambyname('htno').Value:=datamodule1.insertsd.fieldbyname('htno').Value;
datamodule1.insertcustom.Prepare;
datamodule1.insertcustom.ExecSQL;
end;
if glfyear>=1 then
begin
datamodule1.insertcustom.SQL.Clear;
datamodule1.insertcustom.SQL.Add('update ht set ssglf=glf * :xzlyear,dzf=1');
datamodule1.insertcustom.sql.add('where htno=:htno');
datamodule1.insertcustom.parambyname('xzlyear').Value:=glfyear;
datamodule1.insertcustom.parambyname('htno').Value:=datamodule1.insertsd.fieldbyname('htno').Value;
datamodule1.insertcustom.Prepare;
datamodule1.insertcustom.ExecSQL;
datamodule1.insertcustom.SQL.Clear;
datamodule1.insertcustom.SQL.Add('update ht set ssglf=ssglf+glf*glfdz');
datamodule1.insertcustom.sql.add('where htno=:htno');
datamodule1.insertcustom.parambyname('htno').Value:=datamodule1.insertsd.fieldbyname('htno').Value;
datamodule1.insertcustom.Prepare;
datamodule1.insertcustom.ExecSQL;
end;
datamodule1.insertcustom.SQL.Clear; //计算总计
datamodule1.insertcustom.SQL.Add('update ht set zj=ssxzl+ssart+ssroom+ssglf+yj+otherf+dtf');
datamodule1.insertcustom.sql.add(' where htno=:htno');
datamodule1.insertcustom.parambyname('htno').Value:=datamodule1.insertsd.fieldbyname('htno').Value;
datamodule1.insertcustom.Prepare;
datamodule1.insertcustom.ExecSQL;
datamodule1.insertsd.Next;
end;
application.MessageBox('递增客户资料计算完毕!','提示',mb_ok);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -