📄 uform_advice.pas
字号:
unit Uform_advice;
//查询各个部门受评价的情况
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ImgList, DB, ADODB, StdCtrls, Buttons, ComCtrls, ExtCtrls;
type
Tform_advice = class(TForm)
Panel1: TPanel;
Image1: TImage;
Label2: TLabel;
Label1: TLabel;
Bevel1: TBevel;
Image2: TImage;
Label23: TLabel;
Label24: TLabel;
Panel2: TPanel;
ListView1: TListView;
Panel3: TPanel;
Panel4: TPanel;
BitBtn3: TBitBtn;
BitBtn2: TBitBtn;
BitBtn1: TBitBtn;
recordset_temp: TADOQuery;
ImageList1: TImageList;
recordset_temp2: TADOQuery;
Label3: TLabel;
Label4: TLabel;
procedure BitBtn3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
sdate:tdate;
edate:tdate;
end;
var
form_advice: Tform_advice;
implementation
uses Uform_fw_limit, Uform_advice_inf;
{$R *.dfm}
procedure Tform_advice.BitBtn3Click(Sender: TObject);
//关闭窗口
begin
close;
end;
procedure Tform_advice.FormShow(Sender: TObject);
//初始化窗口显示
var
i:integer;
ListItem: TListItem;
p:^integer;
intcount:integer;
begin
//查询数据库
sdate:=now;
edate:=now;
listview1.Items.Clear ;
label4.Caption :='未限定';
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add('select * from [APART]');
recordset_temp.Open ;
//显示窗口内容
intCount:=recordset_temp.RecordCount ;
Label24.Caption :=inttostr(intCount) + '个部门';
for i:=1 to recordset_temp.RecordCount do
begin
listitem:=listview1.Items.Add ;
listitem.Caption :=recordset_temp.Fields[1].AsString ;
listitem.ImageIndex :=0;
listitem.SubItems.Add('0');
listitem.SubItems.Add('0');
listitem.SubItems.Add('0');
listitem.SubItems.Add('0');
new(p);
p^ := recordset_temp.Fields[0].AsInteger ;
listitem.Data :=p;
recordset_temp.Next;
end;
recordset_temp.Close;
end;
procedure Tform_advice.BitBtn2Click(Sender: TObject);
//选定消费查询的限定条件
var
i:integer;
ListItem: TListItem;
p:^integer;
intcount:integer;
c1:integer;
c2:integer;
c3:integer;
begin
//显示消费查询限定窗口
form_fw_limit.ShowModal ;
//是否选择了限定条件
if form_fw_limit.yesno =false then exit;
//按限定条件在数据库中查询
sdate:=form_fw_limit.sdate;
edate:=form_fw_limit.edate;
listview1.Items.Clear ;
label4.Caption :=datetostr(sdate) + ' - ' + datetostr(edate);
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add('select * from [APART]');
recordset_temp.Open ;
intCount:=recordset_temp.RecordCount ;
Label24.Caption :=inttostr(intCount) + '个部门';
//将查询结果显示在窗口中
for i:=1 to recordset_temp.RecordCount do
begin
listitem:=listview1.Items.Add ;
listitem.Caption :=recordset_temp.Fields[1].AsString ;
listitem.ImageIndex :=0;
recordset_temp2.SQL.Clear ;
recordset_temp2.SQL.Add('select count([PJ_ID]) from [PJ] where [PJ_APART_ID]='
+ inttostr(recordset_temp.Fields[0].asinteger)
+ 'and [PJ_OK]=0 and [PJ_DATE]>=#' + datetostr(sdate) + '# and [PJ_DATE]<=#' + datetostr(edate+1) +'#');
recordset_temp2.Open ;
if recordset_temp2.RecordCount <>0 then
begin
c1:=recordset_temp2.Fields[0].AsInteger ;
end
else
begin
c1:=0
end;
recordset_temp2.Close;
recordset_temp2.SQL.Clear ;
recordset_temp2.SQL.Add('select count([PJ_ID]) from [PJ] where [PJ_APART_ID]='
+ inttostr(recordset_temp.Fields[0].asinteger)
+ 'and [PJ_OK]=1 and [PJ_DATE]>=#' + datetostr(sdate) + '# and [PJ_DATE]<=#' + datetostr(edate+1) +'#');
recordset_temp2.Open ;
if recordset_temp2.RecordCount <>0 then
begin
c2:=recordset_temp2.Fields[0].AsInteger ;
end
else
begin
c2:=0
end;
recordset_temp2.Close;
recordset_temp2.SQL.Clear ;
recordset_temp2.SQL.Add('select count([PJ_ID]) from [PJ] where [PJ_APART_ID]='
+ inttostr(recordset_temp.Fields[0].asinteger)
+ 'and [PJ_OK]=2 and [PJ_DATE]>=#' + datetostr(sdate) + '# and [PJ_DATE]<=#' + datetostr(edate+1) +'#');
recordset_temp2.Open ;
if recordset_temp2.RecordCount <>0 then
begin
c3:=recordset_temp2.Fields[0].AsInteger ;
end
else
begin
c3:=0
end;
recordset_temp2.Close;
listitem.SubItems.Add(inttostr(c1));
listitem.SubItems.Add(inttostr(c2));
listitem.SubItems.Add(inttostr(c3));
listitem.SubItems.Add(inttostr(c1+ c3 + c2));
new(p);
p^ := recordset_temp.Fields[0].AsInteger ;
listitem.Data :=p;
recordset_temp.Next;
end;
recordset_temp.Close;
end;
procedure Tform_advice.BitBtn1Click(Sender: TObject);
//查看某个部门评价的详细信息
var
p:^integer;
begin
//是否选中某部门
if listview1.Selected=nil then exit;
//设置标志变量
p:=listview1.Selected.Data;
form_advice_inf.partid :=p^;
form_advice_inf.partname :=listview1.Selected.Caption ;
form_advice_inf.sdate :=sdate;
form_advice_inf.edate :=edate;
//显示部门评价的详细信息窗口
form_advice_inf.ShowModal ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -