📄 mc_xzhzdy.pas
字号:
unit MC_XZHZDY;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, DBTables, Grids, DBGrids, DBCtrls, StdCtrls, Buttons;
type
TXZHZDY = class(TForm)
GroupBox1: TGroupBox;
StringGrid1: TStringGrid;
GroupBox2: TGroupBox;
Table1: TTable;
Table1BDEDesigner: TStringField;
Table1BDEDesigner2: TStringField;
DataSource1: TDataSource;
DBLookupComboBox1: TDBLookupComboBox;
DBGrid1: TDBGrid;
Table2: TTable;
Table2BDEDesigner: TStringField;
Table2BDEDesigner2: TStringField;
Table2BDEDesigner3: TStringField;
Table2BDEDesigner4: TStringField;
DataSource2: TDataSource;
Table3: TTable;
Table3BDEDesigner: TStringField;
Table3BDEDesigner2: TStringField;
Table3BDEDesigner3: TStringField;
Table3BDEDesigner4: TStringField;
Table3BDEDesigner5: TStringField;
Table3BDEDesigner8: TStringField;
DataSource3: TDataSource;
DBGrid2: TDBGrid;
Query1: TQuery;
ComboBox1: TComboBox;
Label1: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
Query2: TQuery;
Table3BDEDesigner6: TStringField;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Table2AfterScroll(DataSet: TDataSet);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
XZHZDY: TXZHZDY;
implementation
uses MC_XZTJKM;
{$R *.DFM}
procedure TXZHZDY.FormClose(Sender: TObject; var Action: TCloseAction);
begin
XZHZDY.Release;
XZHZDY:=Nil;
end;
procedure TXZHZDY.Table2AfterScroll(DataSet: TDataSet);
begin
if Table2.RecordCount<>0 then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select DISTINCT 单元 From 房屋信息表');
Query1.Open;
ComboBox1.Items.Clear;
While Not Query1.Eof do
begin
ComboBox1.Items.Add(Query1.FieldByName('单元').AsString);
Query1.Next;
end;
ComboBox1.ItemIndex:=0;
end;
Table3.Filtered:=False;
end;
procedure TXZHZDY.FormShow(Sender: TObject);
begin
DBLookupComboBox1.KeyValue:=Table1.FieldByname('小区名').AsString;
StringGrid1.Cells[1,0]:='房间编号';
StringGrid1.Cells[2,0]:='户主姓名';
StringGrid1.Cells[3,0]:='单元';
StringGrid1.Cells[4,0]:='大楼名';
StringGrid1.Cells[5,0]:='小区名';
end;
procedure TXZHZDY.BitBtn1Click(Sender: TObject);
var x: Integer;
begin
X:=StringGrid1.RowCount-1;
if Table3.ReCordCount<>0 then
begin
if StringGrid1.RowCount=2 then
begin
if Length(StringGrid1.Cells[1,1])=0 then
begin
StringGrid1.Cells[1,1]:=Table3.FieldByName('房间编号').AsString;
StringGrid1.Cells[2,1]:=Table3.FieldByName('房主姓名').AsString;
StringGrid1.Cells[3,1]:=Table3.FieldByName('单元').AsString;
StringGrid1.Cells[4,1]:=Table3.FieldByName('大楼名').AsString;
StringGrid1.Cells[5,1]:=Table3.FieldByName('区名').AsString;
end
else
begin
StringGrid1.RowCount:=StringGrid1.RowCount+1;
StringGrid1.Cells[1,x+1]:=Table3.FieldByName('房间编号').AsString;
StringGrid1.Cells[2,x+1]:=Table3.FieldByName('房主姓名').AsString;
StringGrid1.Cells[3,x+1]:=Table3.FieldByName('单元').AsString;
StringGrid1.Cells[4,x+1]:=Table3.FieldByName('大楼名').AsString;
StringGrid1.Cells[5,x+1]:=Table3.FieldByName('区名').AsString;
end;
end
else
begin
StringGrid1.RowCount:=StringGrid1.RowCount+1;
StringGrid1.Cells[1,x+1]:=Table3.FieldByName('房间编号').AsString;
StringGrid1.Cells[2,x+1]:=Table3.FieldByName('房主姓名').AsString;
StringGrid1.Cells[3,x+1]:=Table3.FieldByName('单元').AsString;
StringGrid1.Cells[4,x+1]:=Table3.FieldByName('大楼名').AsString;
StringGrid1.Cells[5,x+1]:=Table3.FieldByName('区名').AsString;
end;
end;
end;
procedure TXZHZDY.ComboBox1Change(Sender: TObject);
begin
Table3.Filter:='单元 ='''+ComboBox1.Items[ComboBox1.ItemIndex]+'''';
Table3.Filtered:=true;
end;
procedure TXZHZDY.BitBtn3Click(Sender: TObject);
var x: Integer;
begin
if MessageDlg('确认将['+Table1.FieldByName('小区名').AsString+
']区['+Table2.FieldByName('大楼名称').AsString+
']号大楼里的房间加道右边的列表中吗?',mtCustom,[mbYes,mbNo],0)=mrYes then
begin
with Query2 do
begin
Close;
SQL.Clear;
SQL.Add('Select * From 房屋信息表');
SQL.Add('Where 区名=:A and 大楼名=:B');
paramByname('A').AsString:=table1.FieldByName('小区名').AsString;
ParamByName('B').AsString:=Table2.FieldByName('大楼名称').AsString;
Open;
While not Eof do
begin
x:=StringGrid1.RowCount-1;
StringGrid1.Cells[1,x]:=Query2.FieldByName('房间编号').AsString;
StringGrid1.Cells[2,x]:=Query2.FieldByName('房主姓名').AsString;
StringGrid1.Cells[3,x]:=Query2.FieldByName('单元').AsString;
StringGrid1.Cells[4,x]:=Query2.FieldByName('大楼名').AsString;
StringGrid1.Cells[5,x]:=Query2.FieldByName('区名').AsString;
StringGrid1.RowCount:=StringGrid1.RowCount+1;
Next;
end;
if Length(StringGrid1.Cells[1,StringGrid1.RowCount-1])=0 then StringGrid1.RowCount:=StringGrid1.RowCount-1;
end;
end;
Query2.Close;
end;
procedure TXZHZDY.BitBtn2Click(Sender: TObject);
var a,x,y:integer;
begin
x:=StringGrid1.Row;
y:=StringGrid1.Col;
if StringGrid1.RowCount<>2 then
begin
For a:=x to StringGrid1.RowCount-2 do
begin
StringGrid1.Cells[1,a]:=StringGrid1.Cells[1,a+1];
StringGrid1.Cells[2,a]:=StringGrid1.Cells[2,a+1];
StringGrid1.Cells[3,a]:=StringGrid1.Cells[3,a+1];
StringGrid1.Cells[4,a]:=StringGrid1.Cells[4,a+1];
StringGrid1.Cells[5,a]:=StringGrid1.Cells[5,a+1];
end;
StringGrid1.RowCount:=StringGrid1.RowCount-1;
end
else
begin
StringGrid1.Cells[1,1]:='';
StringGrid1.Cells[2,1]:='';
StringGrid1.Cells[3,1]:='';
StringGrid1.Cells[4,1]:='';
StringGrid1.Cells[5,1]:='';
end;
end;
procedure TXZHZDY.BitBtn4Click(Sender: TObject);
begin
if Length(StringGrid1.Cells[1,1])<>0 then
if Not Assigned(XZTJKM) then
begin
XZTJKM:=TXZTJKM.Create(Self);
XZTJKM.ShowModal;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -