📄 realtyc121.pas
字号:
unit RealtyC121;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, dbcgrids, Grids, DBGrids, DB, ADODB, StdCtrls, Buttons, ExtCtrls,
StrUtils, ExtDlgs, ComCtrls, math, Menus, ImgList, ToolWin;
type
Tf_RealtyC121 = class(TForm)
L1: TLabel;
L2: TLabel;
L3: TLabel;
L4: TLabel;
Label2: TLabel;
Label10: TLabel;
Edit2: TEdit;
Edit4: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label5: TLabel;
Edit5: TEdit;
Label6: TLabel;
Edit6: TEdit;
datetimepicker1: TDateTimePicker;
datetimepicker2: TDateTimePicker;
Button5: TButton;
Button7: TButton;
Edit1: TEdit;
Button1: TButton;
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
procedure ToolButton10Click(Sender: TObject);
procedure NN6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
bOK:bool;
end;
var
f_RealtyC121: Tf_RealtyC121;
sNum:string;
implementation
uses data, main, RealtyC12;
{$R *.dfm}
procedure Tf_RealtyC121.FormCreate(Sender: TObject);
var
query:TADOquery;
s,stemp:string;
i:integer;
begin
If f_RealtyC12.bMod = True Then
begin
datetimepicker1.date:=date;
datetimepicker2.date:=date;
end;
If f_RealtyC12.bMod = True Then
begin
query:=TADOQuery.Create(nil);
query.Connection:=DataModuleADO.ADOConnection1;
s:='select * from 房间抄表 where 编号='''+mainform.t1+'''';
query.sql.clear;
query.sql.add(s);
query.Open;
if query.RecordCount>0 then
begin
edit1.Text:=query.fieldbyname('房间仪表').Value;
datetimepicker1.Date:=strtodate(query.fieldbyname('读数日期').Value);
datetimepicker2.Date:=strtodate(query.fieldbyname('上次读数日期').Value);
edit2.Text:=query.fieldbyname('上次读数').Value;
edit3.Text:=query.fieldbyname('本次读数').Value;
edit4.Text:=query.fieldbyname('上次行度').Value;
edit5.Text:=query.fieldbyname('上上次行度').Value;
edit6.Text:=query.fieldbyname('备注').Value;
end;
end;
query.Close;
query.free;
end;
//Tab
procedure Tf_RealtyC121.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then
Begin
key:=0;
perform(WM_NEXTDLGCTL,0,0);
end
else if key=VK_ESCAPE then close;
end;
procedure Tf_RealtyC121.ToolButton10Click(Sender: TObject);
begin
NN6Click(Sender);
end;
procedure Tf_RealtyC121.NN6Click(Sender: TObject);
begin
close;
end;
procedure Tf_RealtyC121.Button7Click(Sender: TObject);
Var
query,query1:TADOQuery;
s,stemp,stemp1,stemp2:String;
i:integer;
d1,d2:double;
begin
if edit1.Text='' then
begin
showmessage('请输入房间仪表!');
edit1.SetFocus;
exit;
end;
edit2.Text:=mainform.StdDou2(edit2.text);
edit3.Text:=mainform.StdDou2(edit3.text);
edit4.Text:=mainform.StdDou2(edit4.text);
edit5.Text:=mainform.StdDou2(edit5.text);
if edit6.Text='' then edit6.Text:='-';
query:=TADOQuery.Create(nil);
query.Connection:=DataModuleADO.ADOConnection1;
query1:=TADOQuery.Create(nil);
query1.Connection:=DataModuleADO.ADOConnection1;
if f_RealtyC12.bMod then
begin
s:='update 房间抄表 set 房间仪表='''+edit1.Text;
s:=s+''',读数日期='''+datetostr(datetimepicker1.date);
s:=s+''',上次读数日期='''+datetostr(datetimepicker2.date);
s:=s+''',上次读数='+edit2.Text;
s:=s+',本次读数='+edit3.Text;
s:=s+',上次行度='+edit4.Text;
s:=s+',上上次行度='+edit5.Text;
s:=s+',实际行度='+floattostr(strtofloat(edit3.Text)-strtofloat(edit2.Text));
s:=s+',备注='''+edit6.Text;
s:=s+''' where 编号='''+mainform.t1+'''';
query.SQL.Clear;
query.sql.Add(s);
DataModuleADO.ADOConnection1.BeginTrans;
query.ExecSQL;
DataModuleADO.ADOConnection1.CommitTrans;
s:='select * from 房间抄表 where 编号= '''+mainform.t1+'''';
query.sql.clear;
query.sql.add(s);
query.Open;
if query.RecordCount>0 then
begin
query1.sql.clear;
query1.SQL.add('select * from 房间 where 编号='''+query.fieldbyname('编号').Value+'''');
query1.Open;
if query1.RecordCount>0 then
begin
stemp:=query1.fieldbyname('管理处').Value;
stemp1:=query1.fieldbyname('管理区').Value;
stemp2:=query1.fieldbyname('楼宇').Value;
end;
with f_RealtyC12.ListView1.Selected do
begin
Caption:=mainform.getName('组织机构',stemp);
SubItems[0]:=mainform.getName('管理区',stemp1);
SubItems[1]:=mainform.getName('楼宇',stemp2);
SubItems[2]:=mainform.getName('房间',query.fieldbyname('编号').Value);
SubItems[3]:=Query.FieldByName('房间仪表').Value;
SubItems[4]:=Query.FieldByName('本次读数').Value;
SubItems[5]:=Query.FieldByName('上次读数').Value;
SubItems[6]:=Query.FieldByName('读数日期').Value;
SubItems[7]:=Query.FieldByName('上次读数日期').Value;
SubItems[8]:=Query.FieldByName('实际行度').Value;
SubItems[9]:=Query.FieldByName('上次行度').Value;
SubItems[10]:=Query.FieldByName('上上次行度').Value;
SubItems[11]:=Query.FieldByName('备注').Value;
end;
end;
query1.Close;
query1.Free;
query.Close;
query.Free;
close;
end
else
begin
s:='select * from 房间抄表 where 编号 = '''+mainform.t1+'''';
query.SQL.Add(s);
query.Open;
if query.RecordCount>0 then
begin
showmessage('名称重复!,请重新输入!');
edit1.SetFocus;
exit;
end;
d1:=strtofloat(edit2.Text);
d2:=strtofloat(edit3.Text);
s:='insert into 房间抄表(编号,房间仪表,读数日期,上次读数日期,上次读数,';
s:=s+'本次读数,上次行度,上上次行度,实际行度,备注)';
s:=s+' Values(:s1,:s2,:s3,:s4,:s5,';
s:=s+':s6,:s7,:s8,:s9,:s10)';
query.SQL.Clear;
query.SQL.Add(s);
query.Parameters.ParamByName('s1').Value:=mainform.t1;
query.Parameters.ParamByName('s2').Value:=edit1.text;
query.Parameters.ParamByName('s3').Value:=datetostr(datetimepicker1.Date);
query.Parameters.ParamByName('s4').Value:=datetostr(datetimepicker2.date);
query.Parameters.ParamByName('s5').Value:=d1;
query.Parameters.ParamByName('s6').Value:=d2;
query.Parameters.ParamByName('s7').Value:=strtofloat(edit4.Text);
query.Parameters.ParamByName('s8').Value:=strtofloat(edit5.text);
query.Parameters.ParamByName('s9').Value:=d1-d2;
query.Parameters.ParamByName('s10').Value:=edit6.text;
DataModuleADO.ADOConnection1.BeginTrans;
query.ExecSQL;
DataModuleADO.ADOConnection1.CommitTrans;
s:='select * from 房间抄表 where 编号 = '''+mainform.t1+'%''';
query.sql.clear;
query.sql.add(s);
query.Open;
if query.RecordCount>0 then
begin
query1.sql.clear;
query1.SQL.add('select * from 房间 where 编号='''+query.fieldbyname('编号').Value+'''');
query1.Open;
if query1.RecordCount>0 then
begin
stemp:=query1.fieldbyname('管理处').Value;
stemp1:=query1.fieldbyname('管理区').Value;
stemp2:=query1.fieldbyname('楼宇').Value;
end;
with f_RealtyC12.ListView1.Items.Add do
begin
Caption:=mainform.getName('组织机构',stemp);
SubItems.add(mainform.getName('管理区',stemp1));
SubItems.add(mainform.getName('楼宇',stemp2));
SubItems.add(mainform.getName('房间',query.fieldbyname('编号').Value));
SubItems.add(Query.FieldByName('房间仪表').Value);
SubItems.add(Query.FieldByName('本次读数').Value);
SubItems.add(Query.FieldByName('上次读数').Value);
SubItems.add(Query.FieldByName('读数日期').Value);
SubItems.add(Query.FieldByName('上次读数日期').Value);
SubItems.add(Query.FieldByName('实际行度').Value);
SubItems.add(Query.FieldByName('上次行度').Value);
SubItems.add(Query.FieldByName('上上次行度').Value);
SubItems.add(Query.FieldByName('备注').Value);
end;
end;
query1.Close;
query1.Free;
query.Close;
query.Free;
end;
end;
procedure Tf_RealtyC121.Button5Click(Sender: TObject);
begin
close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -