?? mc_xzhzdy.~pas
字號(hào):
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;
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('小區(qū)名').AsString;
StringGrid1.Cells[1,0]:='房間編號(hào)';
StringGrid1.Cells[2,0]:='戶主姓名';
StringGrid1.Cells[3,0]:='單元';
StringGrid1.Cells[4,0]:='大樓名';
StringGrid1.Cells[5,0]:='小區(qū)名';
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('房間編號(hào)').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('區(qū)名').AsString;
end
else
begin
StringGrid1.RowCount:=StringGrid1.RowCount+1;
StringGrid1.Cells[1,x+1]:=Table3.FieldByName('房間編號(hào)').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('區(qū)名').AsString;
end;
end
else
begin
StringGrid1.RowCount:=StringGrid1.RowCount+1;
StringGrid1.Cells[1,x+1]:=Table3.FieldByName('房間編號(hào)').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('區(qū)名').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('確認(rèn)將['+Table1.FieldByName('小區(qū)名').AsString+
']區(qū)['+Table2.FieldByName('大樓名稱').AsString+
']號(hào)大樓里的房間加道右邊的列表中嗎?',mtCustom,[mbYes,mbNo],0)=mrYes then
begin
with Query2 do
begin
Close;
SQL.Clear;
SQL.Add('Select * From 房屋信息表');
SQL.Add('Where 區(qū)名=:A and 大樓名=:B');
paramByname('A').AsString:=table1.FieldByName('小區(qū)名').AsString;
ParamByName('B').AsString:=Table2.FieldByName('大樓名稱').AsString;
Open;
While not Eof do
begin
x:=StringGrid1.RowCount-1;
StringGrid1.Cells[1,x]:=Query2.FieldByName('房間編號(hào)').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('區(qū)名').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.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -