📄 hygl_report_dbtj.pas
字号:
unit HYGL_report_dbtj;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, jpeg, ExtCtrls, Buttons;
type
TFrmHYGL_Report_dbtj = class(TForm)
Panel1: TPanel;
Label16: TLabel;
Image1: TImage;
Label1: TLabel;
Panel2: TPanel;
btn_getdata: TSpeedButton;
Btn_exit: TSpeedButton;
Panel3: TPanel;
Panel4: TPanel;
Memo1: TMemo;
Label2: TLabel;
procedure btn_exitClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btn_getdataClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
function GiveMeNum(str_SQL:string):integer;
public
{ Public declarations }
end;
var
FrmHYGL_Report_dbtj: TFrmHYGL_Report_dbtj;
implementation
uses HYGL_DModule, HYGL_main, Umyfunction;
{$R *.dfm}
procedure TFrmHYGL_Report_dbtj.FormShow(Sender: TObject);
begin
memo1.clear;
Image1.Picture:=FRMHYGL_Main.IMG_LOGO.Picture;
end;
procedure TFrmHYGL_Report_dbtj.btn_getdataClick(Sender: TObject);
var
s:string;
num_ALL,num_MAN,num_WOM:integer;//总人数,男,女
age_avg,age_lower30,age_30to39,age_40to49,age_over50:integer;
num_GR,num_JS,num_zg:integer;//工人,管理、技术人员,中干
num_GJ,num_ZJ,num_CJ:integer;//高级职称,中级,初级
num_dy,num_ty,num_qt:integer;//党员,团员,其他
num_db,num_dz,num_gz,num_cz:integer;//大本,大专,高中,初中
begin
memo1.clear;
memo1.lines.Add('开始统计数据......');
dmd.qry_temp.DisableControls;
//先计算并更新职工代表年龄
s:='update 职工代表 set NL='+inttostr(givemedate('year'))+'-int(left(csny,4))';
with dmd.qry_temp do begin
close;
sql.clear;
memo1.Lines.Add(s);
sql.Add(s);
try
open;
except
execsql;
end;
end;
num_all:=GiveMeNum('select count(hyzh) from 职工代表 where hyzh<>""');
num_MAN:=GiveMeNum('select count(xb) from 职工代表 where xb="男"');
num_WOM:=GiveMeNum('select count(xb) from 职工代表 where xb="女"');
age_avg:=GiveMeNum('select avg(nl) from 职工代表 where hyzh<>""');
age_lower30:=GiveMeNum('select count(nl) from 职工代表 where nl<30');
age_30to39:=GiveMeNum('select count(nl) from 职工代表 where nl>=30 and nl<=39');
age_40to49:=GiveMeNum('select count(nl) from 职工代表 where nl>=40 and nl<=49');
age_over50:=GiveMeNum('select count(nl) from 职工代表 where nl>=50');
num_GR:=GiveMeNum('select count(dblb) from 职工代表 where dblb="工人"');
num_JS:=GiveMeNum('select count(dblb) from 职工代表 where dblb="管理"');
num_zg:=GiveMeNum('select count(dblb) from 职工代表 where dblb="中干"');
num_GJ:=GiveMeNum('select count(zclb) from 职工代表 where ZClb="高级"');
num_ZJ:=GiveMeNum('select count(zclb) from 职工代表 where ZClb="中级"');
num_CJ:=GiveMeNum('select count(zclb) from 职工代表 where ZClb="初级"');
num_DY:=GiveMeNum('select count(zzmm) from 职工代表 where zzmm="党员"');
num_TY:=GiveMeNum('select count(zzmm) from 职工代表 where zzmm="团员"');
num_QT:=GiveMeNum('select count(zzmm) from 职工代表 where zzmm="其它"');
num_DB:=GiveMeNum('select count(XL) from 职工代表 where XL="大本"');
num_DZ:=GiveMeNum('select count(XL) from 职工代表 where XL="大专"');
num_GZ:=GiveMeNum('select count(XL) from 职工代表 where XL="高中"');
num_CZ:=GiveMeNum('select count(XL) from 职工代表 where XL="初中"');
dmd.qry_temp.EnableControls;
memo1.lines.Add('统计结束!!!');
memo1.lines.Add('');memo1.lines.Add('');memo1.lines.Add('');
memo1.lines.Add('******统计结果******');
s:=format('职工代表总人数:%d人',[num_ALL])+#13#10;
s:=s+format('男职工代表人数:%d人,占%f%',[num_MAN,(num_MAN/num_ALL)*100])+#13#10;
s:=s+format('女职工代表人数:%d人,占%f%',[num_WOM,(num_WOM/num_ALL)*100])+#13#10;
s:=s+format('平均年龄:%d岁',[age_avg])+#13#10;
s:=s+format('其中:30岁以下代表:%d人,占%f%',[age_lower30,(age_lower30/num_ALL)*100])+#13#10;
s:=s+format(' 30-39岁的代表:%d人,占%f%',[age_30to39,(age_30to39/num_ALL)*100])+#13#10;
s:=s+format(' 40-49岁的代表:%d人,占%f%',[age_40to49,(age_40to49/num_ALL)*100])+#13#10;
s:=s+format(' 50以上代表:%d人,占%f%',[age_over50,(age_over50/num_ALL)*100])+#13#10;
s:=s+format('工人代表:%d人,占%f%',[num_GR,(num_GR/num_ALL)*100])+#13#10;
s:=s+format('管理干部、技术人员代表:%d人,占%f%',[num_JS,(num_JS/num_ALL)*100])+#13#10;
s:=s+format('中层以上干部:%d人,占%f%',[num_ZG,(num_ZG/num_ALL)*100])+#13#10;
s:=s+format('高级工程师(高级技师)代表:%d人,占%f%',[num_GJ,(num_GJ/num_ALL)*100])+#13#10;
s:=s+format('中级职称(工人技师)代表:%d人,占%f%',[num_ZJ,(num_ZJ/num_ALL)*100])+#13#10;
s:=s+format('初级以下职称代表:%d人,占%f%',[num_CJ,(num_CJ/num_ALL)*100])+#13#10;
s:=s+format('党员代表:%d人,占%f%',[num_DY,(num_DY/num_ALL)*100])+#13#10;
s:=s+format('团员代表:%d人,占%f%',[num_TY,(num_TY/num_ALL)*100])+#13#10;
s:=s+format('其他非党、团代表:%d人,占%f%',[num_QT,(num_QT/num_ALL)*100])+#13#10;
s:=s+format('大学本科代表:%d人,占%f%',[num_DB,(num_DB/num_ALL)*100])+#13#10;
s:=s+format('大专代表:%d人,占%f%',[num_DZ,(num_DZ/num_ALL)*100])+#13#10;
s:=s+format('高中(含中专、中技)代表:%d人,占%f%',[num_GZ,(num_GZ/num_ALL)*100])+#13#10;
s:=s+format('初中以下代表:%d人,占%f%',[num_CZ,(num_CZ/num_ALL)*100]);
memo1.Lines.Add(S);
end;
procedure TFrmHYGL_Report_dbtj.btn_exitClick(Sender: TObject);
begin
close;
end;
procedure TFrmHYGL_Report_dbtj.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
dmd.qry_temp.Close;
end;
function TFrmHYGL_Report_dbtj.GiveMeNum(str_SQL: string): integer;
begin
with dmd.qry_temp do begin
close;
sql.clear;
memo1.Lines.Add(str_SQL);
sql.Add(str_SQL);
try
open;
except
execsql;
end;
if recordcount>0 then result:=fields[0].AsInteger;
end;
end;
procedure TFrmHYGL_Report_dbtj.FormCreate(Sender: TObject);
begin
height:=398;
width:=606;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -