📄 reportdlg.cpp
字号:
// ReportDlg.cpp : implementation file
//
#include "stdafx.h"
#include "pro.h"
#include "ReportDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// ReportDlg dialog
ReportDlg::ReportDlg(CWnd* pParent /*=NULL*/)
: CDialog(ReportDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(ReportDlg)
m_title = _T("");
m_ps = _T("");
m_isps = FALSE;
//}}AFX_DATA_INIT
}
void ReportDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ReportDlg)
DDX_Control(pDX, IDC_AREP, m_arep);
DDX_Control(pDX, IDC_TITLE, m_titlec);
DDX_Text(pDX, IDC_TITLE, m_title);
DDX_Text(pDX, IDC_EDIT3, m_ps);
DDX_Check(pDX, IDC_CHECK1, m_isps);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(ReportDlg, CDialog)
//{{AFX_MSG_MAP(ReportDlg)
ON_BN_CLICKED(IDOK2, OnOk2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ReportDlg message handlers
BOOL ReportDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString str=tot1+"\n"+tot2;
m_arep.SetWindowText (str);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void ReportDlg::OnOK()
{
// TODO: Add extra validation here
FILE *fp;
CString fname;
SYSTEMTIME stime;
GetLocalTime(&stime);
fname.Format ("report\\%02d%02d%02d%02d%02d%02d.htm",stime.wYear ,stime.wMonth ,stime.wDay ,stime.wHour ,stime.wMinute ,stime.wSecond);
if((fp=fopen(fname,"wt"))==NULL)
{
MessageBox("文件生成失败");
return;
}
UpdateData();
if(!m_title.GetLength ())
{
MessageBox("请输入标题");
m_titlec.SetFocus ();
return;
}
//align="center"
fprintf(fp,"<HTML>\n<body>\n");
fprintf(fp,"<head><title>-文记摩托车行-</title></head>");
if(m_ps.GetLength ())fprintf(fp,"<p>注:%s</p>",m_ps);
fprintf(fp,"<table border=\"1\" align=\"center\">\n<caption><p><font size=\"6\" face=\"verdana\">%s</font></p></caption>",m_title);
fprintf(fp,"<tr><th>序号</th><th>车型</th><th>发动机号</th><th>出售日期</th><th>价格</th>");
fprintf(fp,"<th>配送</th><th>税费</th><th>入库时间</th>");
if(m_isps)fprintf(fp,"<th>备注</th></tr>");
else fprintf(fp,"</tr>");
int i=0,j=0;
CString str;
for(i=0;i<plist->GetItemCount ();i++)
{
fprintf(fp,"<tr>\n");
for(j=0;j<10;j++)
{
if(j==7)continue;
if(!m_isps&&j==9)continue;
str=plist->GetItemText (i,j);
fprintf(fp,"<td align=\"center\">%s</td>\n",str);
}
fprintf(fp,"</tr>\n");
}
fprintf(fp,"</table><p align=\"center\">%s<br>%s</p>",tot1,tot2);
fprintf(fp,"</table><p align=\"right\">*报表生成于%02d-%02d-%02d %02d:%02d:%02d [By WJCX Manager]</p></body></html>",stime.wYear ,stime.wMonth ,stime.wDay ,stime.wHour ,stime.wMinute ,stime.wSecond);
fclose(fp);
CString msg;
msg.Format ("报表\"%s\"生成在\n %s\n 请查证.",m_title,fname);
MessageBox(msg);
msg.Format("explorer %s",fname);
WinExec(msg,SW_SHOW);
CDialog::OnOK();
}
/*
BOOL ReportDlg::OpenRep()
{
BOOL ret=TRUE;
HKEY hkRoot,hSubKey; //定义注册表根关键字及子关键字
char ValueName[256];
unsigned char DataValue[256];
unsigned long cbValueName=256;
unsigned long cbDataValue=256;
char ShellChar[256]; //定义命令行
DWORD dwType;
//打开注册表根关键字
if(RegOpenKey(HKEY_CLASSES_ROOT,NULL,&hkRoot)==ERROR_SUCCESS)
{
//打开子关键字
if(RegOpenKeyEx(hkRoot,
"htmlfile\\shell\\open\\command",
0,
KEY_ALL_ACCESS,
&hSubKey)==ERROR_SUCCESS)
{
//读取注册表,获取默认浏览器的命令行
RegEnumValue(hSubKey,
0,
ValueName,
&cbValueName,
NULL,
&dwType,
DataValue,
&cbDataValue);
// 调用参数(主页地址)赋值
strcpy(ShellChar,(char *)DataValue);
strcat(ShellChar,"www.baidu.com");
// 启动浏览器
WinExec(ShellChar,SW_SHOW);
}
else
{
MessageBox("WEB浏览器打开错误!","错误",MB_OK);
ret=FALSE;
}
}
else
{
ret=FALSE;
MessageBox("WEB浏览器打开错误!","错误",MB_OK);
}
//关闭注册表
RegCloseKey(hSubKey);
RegCloseKey(hkRoot);
return ret;
}
*/
void ReportDlg::OnOk2()
{
// TODO: Add your control notification handler code here
WinExec("explorer .\\report",SW_SHOW);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -