📄 housecontract.~pas
字号:
unit houseContract;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ToolWin, ComCtrls, Grids, DBGrids;
type
TForm_hC = class(TForm)
Label10: TLabel;
DBGrid_fd: TDBGrid;
ToolBar1: TToolBar;
select: TSpeedButton;
cb_house: TComboBox;
DBGrid_kh: TDBGrid;
Label1: TLabel;
Label2: TLabel;
DBGrid_fdht: TDBGrid;
DBGrid_khht: TDBGrid;
DBGrid_fdJK: TDBGrid;
DBGrid_khjk: TDBGrid;
DBGrid_fdsz: TDBGrid;
DBGrid_khsz: TDBGrid;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure cb_houseDropDown(Sender: TObject);
procedure selectClick(Sender: TObject);
procedure DBGrid_fdhtDblClick(Sender: TObject);
procedure DBGrid_fdhtCellClick(Column: TColumn);
procedure DBGrid_khhtCellClick(Column: TColumn);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_hC: TForm_hC;
implementation
uses pas_dm3;
{$R *.dfm}
procedure TForm_hC.cb_houseDropDown(Sender: TObject);
var
s:string;
begin
try
with dm3.aq1 do
begin
close;
sql.Clear;
s:='select h_no from house ';
sql.Add(s);
open;
cb_house.Items.Clear;
while not dm3.aq1.Eof do
begin
cb_house.Items.Add(fields.Fields[0].asstring);
next;
end;
end;
except
end;
end;
procedure TForm_hC.selectClick(Sender: TObject);
var
s:string;
kh:string;
begin
if (cb_house.Text='')then
begin
showmessage('房子不能为空');
exit;
end;
s:= ' where h_landlord=l_no and h_no like ''%'+trim(cb_house.Text)+'%'' ';
with pas_dm3.dm3.query_fd do
begin
close;
sql.Clear;
sql.Add(' select l_no as 房东编号,'+
' l_name as 房东姓名 ,'+
' l_phone as 手机,'+
' l_tel as 电话,'+
' l_credit as 信用卡号,'+
' l_addr as 地址,'+
' l_remarks as 备注,h_no 房子编号'+
' from landlord,house '+s);
open;
end;
try
with dm3.query_fdht do
begin
close;
sql.clear;
sql.Text:='select ho_contractno 合同编号,'+
' ho_landlord 房东编号,'+
' ho_depart 部门,'+
' ho_rent 参考租金,ho_rentunit 租金单位,'+
' ho_starttime 开始时间,ho_leavetime 结束时间,'+
' ho_remarks 备注 from house_histry'+
' where ho_no like ''%'+
cb_house.Text+'%'' and ho_client is null';
open;
if dm3.query_fdht.RecordCount=0 then
begin
showmessage('没有这个合同');
exit;
end;
DBGrid_fdht.OnCellClick(dbgrid_fdht.Columns[0]);
end;
except
showmessage('查询失败');
exit;
end;
//客户信息
kh:= ' where c_no=ho_client and ho_no like ''%'+trim(cb_house.Text)+'%'' ';
with pas_dm3.DM3.Query_kh do
begin
close;
sql.Clear;
sql.Add(' select c_no as 客户编号,'+
' c_name as 客户姓名 ,'+
' c_phone as 手机,'+
' c_tel as 电话,'+
' c_addr as 地址,'+
' c_remarks as 备注'+
' from client,house_histry'+kh);
open;
end;
try
with dm3.query_khht do
begin
close;
sql.clear;
sql.Text:='select ho_contractno 合同编号,'+
' ho_client 客户编号,'+
' ho_rent 租金,ho_rentunit 租金单位,'+
' ho_starttime 开始时间,ho_leavetime 结束时间,'+
' ho_remarks 备注 from house_histry'+
' where ho_no like ''%'+
cb_house.Text+'%'' and ho_landlord is null';
open;
if dm3.query_fdht.RecordCount=0 then
begin
showmessage('没有这个合同');
exit;
end;
DBGrid_khht.OnCellClick(dbgrid_khht.Columns[0]);
end;
except
showmessage('查询失败');
exit;
end;
end;
procedure TForm_hC.DBGrid_fdhtDblClick(Sender: TObject);
var
s:string;
begin
s:='合同编号:'+dbgrid_fdht.Fields[0].AsString+#13+
'房东编号:'+dbgrid_fdht.Fields[1].AsString+#13+
'参考租金:'+dbgrid_fdht.Fields[2].AsString+#13+
'租金单位:'+dbgrid_fdht.Fields[3].AsString+#13+
'开始时间:'+dbgrid_fdht.Fields[4].AsString+#13+
'结束时间:'+dbgrid_fdht.Fields[5].AsString+#13+
'代理人号:'+dbgrid_fdht.Fields[6].AsString+#13+
'备 注:'+dbgrid_fdht.Fields[7].AsString+#13;
showmessage(s);
end;
procedure TForm_hC.DBGrid_fdhtCellClick(Column: TColumn);
var
s:string;
s1:string;
i:integer;
begin
with pas_dm3.DM3.Query_fdjk do
begin
close;
sql.Clear;
s:='select hi_cno 合同编号,hi_times 付款次数,p_paymoney 付款金额,hi_fktime 应该付款时间,p_time 实际付款时间,'+
' hi_fkorno 付款没有,hi_days 提前天数,P_remarks 备注 from hint left OUTER JOIN pay on hi_cno=p_cno and p_paytimes=hi_times where hi_cno = ''' +
dbgrid_fdht.Fields[0].AsString+'''';
sql.Add(s);
open;
if dm3.query_fdjk.RecordCount = 0 then
begin
showmessage('这个合同的付款时间未设置');
end;
end;
s1:= ' where hp_cno = '''+trim(dbgrid_fdht.Fields[0].AsString)+''' ';
with pas_dm3.DM3.query_fdsz do
begin
close;
sql.Clear;
sql.Add(' select hp_cno 合同编号,'+
' hp_thing as 事情,'+
' hp_cost as 花费,'+
' hp_occurtime as 发生时间,'+
' hp_remarks as 备注'+
' from housepay '+s1);
open;
end;
i:=0;
dm3.query_fdsz.First;
while not dm3.query_fdsz.Eof do
begin
i:=i+dm3.query_fdsz.Fields.Fields[2].asinteger;
dm3.query_fdsz.Next;
end;
label4.Caption:=inttostr(i)+'元';
end;
procedure TForm_hC.DBGrid_khhtCellClick(Column: TColumn);
var
s:string;
s1:string;
i:integer;
begin
with pas_dm3.DM3.Query_khjk do
begin
close;
sql.Clear;
s:='select hi_cno 合同编号,hi_times 付款次数,p_paymoney 付款金额,hi_fktime 应该付款时间,p_time 实际付款时间,'+
' hi_fkorno 付款没有,hi_days 提前天数,P_remarks 备注 from hint left OUTER JOIN pay on hi_cno=p_cno and p_paytimes=hi_times where hi_cno = ''' +
dbgrid_khht.Fields[0].AsString+'''';
sql.Add(s);
open;
if dm3.query_khjk.RecordCount = 0 then
begin
showmessage('这个合同的付款时间未设置');
end;
end;
s1:= ' where hp_cno = '''+trim(dbgrid_khht.Fields[0].AsString)+''' ';
with pas_dm3.DM3.query_khsz do
begin
close;
sql.Clear;
sql.Add(' select hp_cno 合同编号,'+
' hp_thing as 事情,'+
' hp_cost as 花费,'+
' hp_occurtime as 发生时间,'+
' hp_remarks as 备注'+
' from housepay '+s1);
open;
end;
i:=0;
dm3.query_khsz.First;
while not dm3.query_khsz.Eof do
begin
i:=i+dm3.query_khsz.Fields.Fields[2].asinteger;
dm3.query_khsz.Next;
end;
label6.Caption:=inttostr(i)+'元';
end;
procedure TForm_hC.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_F1 then
begin
select.Click;
Key := 0;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -