【delphi开源代码栏目提醒】:网学会员,鉴于大家对delphi开源代码十分关注,论文会员在此为大家搜集整理了“MC_FCZYCX.pas”一文,供大家参考学习!
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('小区名').AsString;
ComboBox1.ItemIndex:=0;
StringGrid1.Cells[1,0]:='编号';
StringGrid1.Cells[2,0]:='大楼名';
StringGrid1.Cells[3,0]:='负责人';
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('大楼编号').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('大楼编号').AsString;
StringGrid1.Cells[2,StringGrid1.RowCount-1]:=Table2.FieldByName('大楼名称').AsString;
StringGrid1.Cells[3,StringGrid1.RowCount-1]:=Table2.FieldByName('负责人').AsString;
end
else
begin
StringGrid1.Cells[1,b]:=Table2.FieldByName('大楼编号').AsString;
StringGrid1.Cells[2,b]:=Table2.FieldByName('大楼名称').AsString;
StringGrid1.Cells[3,b]:=Table2.FieldByName('负责人').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
//'〖房产资源比例图〗'
//'〖房屋出租比例图〗'
//'〖投诉状态比例图〗'
if Length(StringGrid1.Cells[1,1])<>0 then
case ComboBox1.ItemIndex of
0: begin
Series1.Clear;
Label2.Caption:='男女人口各占总人口的百分比';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select Count(人口编号) From 人口信息');
Query1.SQL.Add('Where 房间代号 in (Select 房间编号 From 房屋信息表 where 大楼编号=:A');
Query1.ParamByName('A').AsString:=StringGrid1.Cells[1,1];
For b:=1 to StringGrid1.RowCount-1 do
begin
Query1.SQL.Add('or 大楼编号 = '''+StringGrid1.Cells[1,b]+'''');
end;
Query1.SQL.Add(')');
Query1.SQL.Add(' And 性别=''男''');
Query1.Open;
Series1.AddPie(Query1.Fields[0].AsInteger,'男性人口数',clRed);
//-------------------------------------------------------------
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(