agentcountfrm.~pas
来自「一个电力企业的后台管理程序」· ~PAS 代码 · 共 185 行
~PAS
185 行
unit AgentCountFrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ExtCtrls, StdCtrls, DsFancyButton, Spin;
type
TFrm_AgentCount = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Panel1: TPanel;
Label1: TLabel;
RB_ByWorkId: TRadioButton;
RB_ByType: TRadioButton;
Panel2: TPanel;
Panel3: TPanel;
she: TDsFancyButton;
RB_ByDay: TRadioButton;
RB_ByMonth: TRadioButton;
DTP_Date: TDateTimePicker;
SE_Year: TSpinEdit;
SE_Month: TSpinEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
RB_Normal: TRadioButton;
RB_Word: TRadioButton;
Label5: TLabel;
Bevel1: TBevel;
DsFancyButton1: TDsFancyButton;
DsFancyButton2: TDsFancyButton;
DsFancyButton3: TDsFancyButton;
DsFancyButton4: TDsFancyButton;
Panel4: TPanel;
DsFancyButton7: TDsFancyButton;
DsFancyButton8: TDsFancyButton;
DsFancyButton5: TDsFancyButton;
DsFancyButton6: TDsFancyButton;
Bevel2: TBevel;
procedure DsFancyButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RB_ByDayClick(Sender: TObject);
procedure sheClick(Sender: TObject);
procedure DsFancyButton6Click(Sender: TObject);
procedure RB_ByMonthClick(Sender: TObject);
private
{ Private declarations }
function CreateSql : String;
public
{ Public declarations }
end;
var
Frm_AgentCount: TFrm_AgentCount;
implementation
{$R *.DFM}
USES pubReport,CommonFunc, systemDM;
{ TFrm_AgentCount }
function TFrm_AgentCount.CreateSql: String;
var
DateStr : String;
begin
if RB_ByDay.Checked then
begin
DateStr := FormatDateTime('YYYY-MM-DD',DTP_Date.Date);
if RB_ByType.Checked then
Result := Format('SELECT D.DESCRIPTION TYPENAME,C.TYPECOUNT TYPECOUNT FROM '+
'(SELECT B.CHGTYPE TYPE_NO,COUNT(*) TYPECOUNT FROM '+
'(SELECT A.* FROM '+
'(SELECT *,SUBSTRING(CONVERT(CHAR,STARTTIME,120),1,10) TEMPDATE FROM AGENTCHGREC) A '+
'WHERE TEMPDATE = ''%s'')B '+
'GROUP BY B.CHGTYPE) C RIGHT JOIN SERVTYPE D ON C.TYPE_NO = D.SERVTYPE ',[DateStr]);
if RB_ByWorkId.Checked then
begin
Result := Format('SELECT D.WORKID WORKID,C.RECCOUNT FROM '+
'(SELECT B.AGENTWORKID WORKID,COUNT(*) RECCOUNT FROM '+
'(SELECT A.* FROM '+
'(SELECT *,SUBSTRING(CONVERT(CHAR,STARTTIME,120),1,10) TEMPDATE FROM '+
'AGENTCHGREC) A WHERE A.TEMPDATE = ''%S'')B GROUP BY B.AGENTWORKID)C '+
'RIGHT JOIN SYSLOGIN D ON C.WORKID = D.WORKID',[DateStr]);
end;
end;
if RB_ByMonth.Checked then
begin
if SE_Month.Value < 10 then
DateStr := IntToStr(SE_Year.Value) + '-0' + IntToStr(SE_Month.Value)
else
DateStr := IntToStr(SE_Year.Value) + '-' + IntToStr(SE_Month.Value);
if RB_ByType.Checked then
Result := Format('SELECT D.DESCRIPTION TYPENAME,C.TYPECOUNT TYPECOUNT FROM '+
'(SELECT B.CHGTYPE TYPE_NO,COUNT(*) TYPECOUNT FROM '+
'(SELECT A.* FROM '+
'(SELECT *,SUBSTRING(CONVERT(CHAR,STARTTIME,120),1,10) TEMPDATE FROM AGENTCHGREC) A '+
'WHERE TEMPDATE LIKE ''%s'')B '+
'GROUP BY B.CHGTYPE) C RIGHT JOIN SERVTYPE D ON C.TYPE_NO = D.SERVTYPE ',[DateStr + '%']);
if RB_ByWorkId.Checked then
begin
Result := Format('SELECT B.AGENTWORKID WORKID,COUNT(*) RECCOUNT FROM '+
'(SELECT A.* FROM '+
'(SELECT *,SUBSTRING(CONVERT(CHAR,STARTTIME,120),1,10) TEMPDATE FROM AGENTCHGREC) A '+
'WHERE A.TEMPDATE LIKE ''%S'')B ' +
'GROUP BY B.AGENTWORKID',[DateStr + '%']);
end;
end;
end;
procedure TFrm_AgentCount.DsFancyButton1Click(Sender: TObject);
begin
if RB_Normal.Checked then
begin
if RB_ByType.Checked then
PreviewReport('AGENTSERVTYPE',CreateSql,'','','座席业务统计报表');
if RB_ByWorkId.Checked then
PreviewReport('AGENTWORKID',CreateSql,'','','座席业务统计报表');
end;
if RB_word.Checked then
begin
if RB_ByType.Checked then
MakeWordReport(SysDm.WReport,CreateSql,AgentTypeStr,'座席业务统计报表');
if RB_ByWorkId.Checked then
MakeWordReport(SysDm.WReport,CreateSql,AgentWorkIdStr,'座席业务统计报表');
end;
//edit1.text := CreateSql;
close;
end;
procedure TFrm_AgentCount.FormCreate(Sender: TObject);
begin
SE_Year.Enabled := False;
SE_Month.Enabled := False;
DTP_Date.DateTime:=now;
end;
procedure TFrm_AgentCount.RB_ByDayClick(Sender: TObject);
begin
if RB_ByDay.Checked then
begin
DTP_Date.Enabled := True;
SE_Year.Enabled := False;
SE_Month.Enabled := False;
end;
if RB_ByMonth.Checked then
begin
DTP_Date.Enabled := False;
SE_Year.Enabled := True;
SE_Month.Enabled := True;
end;
end;
procedure TFrm_AgentCount.sheClick(Sender: TObject);
begin
if RB_ByType.Checked then
DesignReport('AGENTSERVTYPE',CreateSql,'','','座席业务统计报表');
if RB_ByWorkId.Checked then
DesignReport('AGENTWORKID',CreateSql,'','','座席业务统计报表');
end;
procedure TFrm_AgentCount.DsFancyButton6Click(Sender: TObject);
begin
Close;
end;
procedure TFrm_AgentCount.RB_ByMonthClick(Sender: TObject);
begin
if RB_ByDay.Checked then
begin
DTP_Date.Enabled := True;
SE_Year.Enabled := False;
SE_Month.Enabled := False;
end;
if RB_ByMonth.Checked then
begin
DTP_Date.Enabled := False;
SE_Year.Enabled := True;
SE_Month.Enabled := True;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?