?? mc_fczycx.~pas
字號(hào):
unit MC_FCZYCX;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Db, Grids, DBGrids, DBTables, DBCtrls, Mask, ExtCtrls,
TeeProcs, TeEngine, Chart, Buttons, Series;
type
TFCZYCX = class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
DBLookupComboBox1: TDBLookupComboBox;
Table1: TTable;
Table1BDEDesigner: TStringField;
Table1BDEDesigner2: TStringField;
Table1BDEDesigner3: TStringField;
Table1BDEDesigner4: TStringField;
Table1BDEDesigner5: TIntegerField;
Table1BDEDesigner6: TStringField;
Table1BDEDesigner7: TMemoField;
Table1BDEDesigner8: TBlobField;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Table2: TTable;
Table2BDEDesigner: TStringField;
Table2BDEDesigner2: TStringField;
Table2BDEDesigner3: TStringField;
Table2BDEDesigner4: TStringField;
Table2BDEDesigner5: TIntegerField;
Table2BDEDesigner6: TStringField;
Table2BDEDesigner7: TStringField;
Chart1: TChart;
Series1: TPieSeries;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
DataSource2: TDataSource;
Query1: TQuery;
BitBtn3: TBitBtn;
Label1: TLabel;
ComboBox1: TComboBox;
StringGrid1: TStringGrid;
Label2: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure DBGrid1DblClick(Sender: TObject);
procedure StringGrid1DblClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
a,b,c:Integer;
{ Private declarations }
public
{ Public declarations }
end;
var
FCZYCX: TFCZYCX;
implementation
{$R *.DFM}
procedure TFCZYCX.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FCZYCX.Release;
FCZYCX:=Nil;
end;
procedure TFCZYCX.FormShow(Sender: TObject);
begin
DBLookupComboBox1.KeyValue:=Table1.FieldByName('小區(qū)名').AsString;
ComboBox1.ItemIndex:=0;
StringGrid1.Cells[1,0]:='編號(hào)';
StringGrid1.Cells[2,0]:='大樓名';
StringGrid1.Cells[3,0]:='負(fù)責(zé)人';
end;
procedure TFCZYCX.DBGrid1DblClick(Sender: TObject);
var a,b:integer;
begin
if Table2.RecordCount<>0 then
begin
For a:=1 to StringGrid1.RowCount-1 do
begin
if StringGrid1.Cells[1,a]=Table2.FieldByName('大樓編號(hào)').AsString then
Exit;
end;
For a:=1 to StringGrid1.RowCount-1 do
begin
if Length(StringGrid1.Cells[1,a])=0 then
begin
B:=a;
Break;
end
else
b:=0;
end;
//showMessage(InttoStr(B));
if b=0 then
begin
StringGrid1.RowCount:=StringGrid1.RowCount+1;
StringGrid1.Cells[1,StringGrid1.RowCount-1]:=Table2.FieldByName('大樓編號(hào)').AsString;
StringGrid1.Cells[2,StringGrid1.RowCount-1]:=Table2.FieldByName('大樓名稱(chēng)').AsString;
StringGrid1.Cells[3,StringGrid1.RowCount-1]:=Table2.FieldByName('負(fù)責(zé)人').AsString;
end
else
begin
StringGrid1.Cells[1,b]:=Table2.FieldByName('大樓編號(hào)').AsString;
StringGrid1.Cells[2,b]:=Table2.FieldByName('大樓名稱(chēng)').AsString;
StringGrid1.Cells[3,b]:=Table2.FieldByName('負(fù)責(zé)人').AsString;
end;
end;
end;
procedure TFCZYCX.StringGrid1DblClick(Sender: TObject);
var a,b: Integer;
begin
b:=StringGrid1.Row;
if StringGrid1.RowCount<>2 then
begin
For a:=b 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];
end;
StringGrid1.RowCount:=stringGrid1.RowCount-1;
end;
end;
procedure TFCZYCX.BitBtn1Click(Sender: TObject);
var a,b,C: Integer;
ZT: array of String;
begin
//'〖房產(chǎn)資源比例圖〗'
//'〖房屋出租比例圖〗'
//'〖投訴狀態(tài)比例圖〗'
if Length(StringGrid1.Cells[1,1])<>0 then
case ComboBox1.ItemIndex of
0: begin
Series1.Clear;
Label2.Caption:='男女人口各占總?cè)丝诘陌俜直?#039;;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select Count(人口編號(hào)) From 人口信息');
Query1.SQL.Add('Where 房間代號(hào) in (Select 房間編號(hào) From 房屋信息表 where 大樓編號(hào)=:A');
Query1.ParamByName('A').AsString:=StringGrid1.Cells[1,1];
For b:=1 to StringGrid1.RowCount-1 do
begin
Query1.SQL.Add('or 大樓編號(hào) = '''+StringGrid1.Cells[1,b]+'''');
end;
Query1.SQL.Add(')');
Query1.SQL.Add(' And 性別=''男''');
Query1.Open;
Series1.AddPie(Query1.Fields[0].AsInteger,'男性人口數(shù)',clRed);
//-------------------------------------------------------------
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select Count(人口編號(hào)) From 人口信息');
Query1.SQL.Add('Where 房間代號(hào) in (Select 房間編號(hào) From 房屋信息表 where 大樓編號(hào)=:A');
Query1.ParamByName('A').AsString:=StringGrid1.Cells[1,1];
For b:=1 to StringGrid1.RowCount-1 do
begin
Query1.SQL.Add('or 大樓編號(hào) = '''+StringGrid1.Cells[1,b]+'''');
end;
Query1.SQL.Add(')');
Query1.SQL.Add(' And 性別=''女''');
Query1.Open;
Series1.AddPie(Query1.Fields[0].AsInteger,'女性人口數(shù)',clBlue);
end;
1: begin
Label2.caption:='現(xiàn)簽約住戶數(shù)、現(xiàn)空閑房屋數(shù)各占總房數(shù)的百分比';
Series1.Clear;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select Count(業(yè)主代號(hào)) From 業(yè)主信息表');
Query1.SQL.Add('Where 業(yè)主代號(hào) in ( Select 房間編號(hào) From 房屋信息表 Where 大樓編號(hào)=:A');
Query1.ParamByName('A').AsString:=StringGrid1.Cells[1,1];
For b:=1 to StringGrid1.RowCount-1 do
begin
Query1.SQL.Add('or 大樓編號(hào) = '''+StringGrid1.Cells[1,b]+'''');
end;
Query1.SQL.Add(')');
Query1.Open;
C:=Query1.Fields[0].AsInteger;
Series1.AddPie(Query1.Fields[0].AsInteger,'已簽約房屋',ClBlue);
//-------------------------------------------------------------
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select Count(房間編號(hào)) From 房屋信息表');
Query1.SQL.Add('Where 大樓編號(hào)=:A');
Query1.ParamByName('A').AsString:=StringGrid1.Cells[1,1];
For b:=1 to StringGrid1.RowCount-1 do
begin
Query1.SQL.Add('or 大樓編號(hào) = '''+StringGrid1.Cells[1,b]+'''');
end;
Query1.Open;
Series1.AddPie(Query1.Fields[0].AsInteger-c,'未簽約房屋',ClRed);
end;
2: begin
Label2.Caption:='已出租房屋數(shù)量、空閑可出租房屋數(shù)量各占總出租房屋數(shù)的百分比';
Series1.Clear;
Query1.Close;
Query1.SQL.clear;
Query1.SQL.Add('Select Count(房間代號(hào)) From 房租費(fèi)用表');
Query1.SQL.Add('where 房間代號(hào) in ( Select 房間編號(hào) From 房屋信息表 Where 大樓編號(hào)=:A');
Query1.ParamByName('A').AsString:=StringGrid1.Cells[1,1];
For B:=1 to StringGrid1.RowCount-1 do
begin
Query1.SQL.Add('or 大樓編號(hào) = '''+StringGrid1.Cells[1,b]+'''');
end;
Query1.SQL.Add(')');
Query1.Open;
C:=Query1.FieldS[0].AsInteger;
Series1.AddPie(C,'已出租數(shù)',ClRed);
//-------------------------------------------------------------
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select Count(房間編號(hào)) From 房屋出租信息表');
Query1.SQL.Add('where 房間編號(hào) in (Select 房間編號(hào) From 房屋信息表 Where 大樓編號(hào)=:A');
Query1.ParamByName('A').AsString:=StringGrid1.Cells[1,1];
For B:=1 to StringGrid1.RowCount-1 do
begin
Query1.SQL.Add('or 大樓編號(hào) = '''+StringGrid1.Cells[1,b]+'''');
end;
Query1.SQL.Add(')');
Query1.Open;
Series1.AddPie(Query1.Fields[0].AsInteger-c,'空閑房屋數(shù)',clBlue);
end;
3: begin
Label2.Caption:='各個(gè)狀態(tài)占總投訴數(shù)的百分比';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select Distinct 狀況描述 From 投訴信息表');
Query1.Open;
SetLength(ZT,Query1.RecordCount);
For c:=0 to Query1.RecordCount-1 do
begin
ZT[c]:=Query1.Fields[0].AsString;
Query1.Next;
end;
a:=Query1.RecordCount;
For c:=0 to a-1 do
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select Count(投訴編號(hào)) From 投訴信息表 where 狀況描述='''+ZT[C]+'''');
Query1.Open;
Series1.AddPie(Query1.Fields[0].AsInteger,'狀態(tài)為['+ZT[C]+']',clteecolor);
end;
end;
end;
end;
procedure TFCZYCX.BitBtn2Click(Sender: TObject);
begin
Close;
end;
end.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -