📄 dbreportview.cpp
字号:
// SampleReportView.cpp : implementation of the CDBReportView class
//
#include "stdafx.h"
#include "../WT.h"
#include "../DataRecordSet.h"
#include "DBReportView.h"
#include "../MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*static CEasyReport::CColInfo s_Cols[] = {
{"局 编 号:", 50, CEasyReport::CColInfo::eLeft},
{"生产厂家:", 50, CEasyReport::CColInfo::eLeft }
};*/
static CEasyReport::CColInfo s_2Cols[] = {
{"", 40, CEasyReport::CColInfo::eLeft},
{"", 60, CEasyReport::CColInfo::eLeft }
};
static CEasyReport::CColInfo s_4Cols[] = {
{"", 2, CEasyReport::CColInfo::eCenter},
{"", 10, CEasyReport::CColInfo::eLeft },
{"", 15, CEasyReport::CColInfo::eLeft },
{"", 10, CEasyReport::CColInfo::eLeft },
{"", 15, CEasyReport::CColInfo::eLeft },
{"", 10, CEasyReport::CColInfo::eLeft },
{"", 15, CEasyReport::CColInfo::eLeft },
{"", 10, CEasyReport::CColInfo::eLeft },
{"", 15, CEasyReport::CColInfo::eLeft }
};
static CEasyReport::CColInfo t_Cols[] = {
{"", 85, CEasyReport::CColInfo::eLeft}
};
/////////////////////////////////////////////////////////////////////////////
// CDBReportView
IMPLEMENT_DYNCREATE(CDBReportView, CScrollView)
BEGIN_MESSAGE_MAP(CDBReportView, CScrollView)
//{{AFX_MSG_MAP(CDBReportView)
// NOTE - the ClassWizard will add and remove mapping macros here.
ON_WM_DESTROY()
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDBReportView construction/destruction
CDBReportView::CDBReportView()
{
// TODO: add construction code here
}
CDBReportView::~CDBReportView()
{
}
BOOL CDBReportView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDBReportView drawing
void CDBReportView::OnDraw(CDC* pDC)
{
m_Report.DrawCurrentPage(pDC);
}
void CDBReportView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
// For this sample app, the page defaults to 8.5 x 11 inches.
// Also, remember to set the mode to LO_METRIC, which is used
// by the report. However, this view is not WISWIG in that the
// printer resolution is different from the screen resolution.
// However, if you print-preview the report, you will see the
// report in all it's glory !
sizeTotal.cx = (int)(8.5*254);
sizeTotal.cy = (int)(11*245);
SetScrollSizes(MM_LOMETRIC, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CDBReportView printing
BOOL CDBReportView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDBReportView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* pInfo)
{
// pInfo->SetMaxPage( GetDocument()->GetPageCount());
pInfo->SetMaxPage( 1 );
}
void CDBReportView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDBReportView diagnostics
#ifdef _DEBUG
void CDBReportView::AssertValid() const
{
CScrollView::AssertValid();
}
void CDBReportView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDBReportView message handlers
void CDBReportView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// GetDocument()->GotoPage( pInfo->m_nCurPage - 1); // we use 0-based indexing, hence the -1
CScrollView::OnPrint(pDC, pInfo);
}
void CDBReportView::OnDestroy()
{
CScrollView::OnDestroy();
/* if(m_rRes.IsOpen())
m_rRes.Close();*/
// TODO: Add your message handler code here
((CMainFrame*)AfxGetMainWnd())->m_pdbRpt=NULL; // 清空窗口指针
}
void CDBReportView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
m_Report.SetPage();
CDataRecordset aList;
CString aTemp;
if(!aList.IsOpen())
{
try
{
aList.Open();
}
catch(CDaoException *ex)
{
AfxMessageBox(ex->m_pErrorInfo->m_strDescription);
throw ex;
}
}
// aList.MoveFirst();
aTemp.Format("JBH='%s'",((CMainFrame*)AfxGetMainWnd())->m_sJbh);
aList.FindFirst(aTemp);
// m_Report.m_bFont=false;
m_Report.SetCompanyName("电能表现场效验记录");
aTemp.Format("户名:%s 地址:%s");
m_Report.SetReportTitle(aTemp);
m_Report.Start();
m_Report.NextRow();
#if 1
try
{
if(!aList.IsEOF())
{
// Initalize all totals etc at the start of a group
//m_Report.SetDataCols(NULL);
//m_Report.AtTab(0,aTemp);
// Set up a tabular section for the main section
m_Report.SetDataCols(s_4Cols,9);
m_Report.AtTab(0,"被");
m_Report.NextRow();
m_Report.AtTab(0,"测");
m_Report.NextRow();
m_Report.AtTab(0,"电");
m_Report.NextRow();
m_Report.AtTab(0,"表");
m_Report.NextRow();
m_Report.AtTab(0,"参");
m_Report.NextRow();
m_Report.AtTab(0,"数");
m_Report.PreRow();
m_Report.PreRow();
m_Report.PreRow();
m_Report.PreRow();
m_Report.PreRow();
aTemp.Format("生产厂家");
m_Report.AtTab(1,aTemp);
aTemp.Format("%s",aList.m_SCCJ);
m_Report.AtTab(2,aTemp);
aTemp.Format("出厂编号");
m_Report.AtTab(3,aTemp);
aTemp.Format("%s",aList.m_CCBH);
m_Report.AtTab(4,aTemp);
aTemp.Format("型号");
m_Report.AtTab(5,aTemp);
aTemp.Format("%s",aList.m_DBXH);
m_Report.AtTab(6,aTemp);
aTemp.Format("局编号");
m_Report.AtTab(7,aTemp);
aTemp.Format("%s",aList.m_JBH);
m_Report.AtTab(8,aTemp);
m_Report.NextRow();
m_Report.NextRow();
aTemp.Format("电压");
m_Report.AtTab(1,aTemp);
aTemp.Format("%.2f",aList.m_EDDY);
m_Report.AtTab(2,aTemp);
aTemp.Format("电流");
m_Report.AtTab(3,aTemp);
aTemp.Format("%.2f",aList.m_EDDL);
m_Report.AtTab(4,aTemp);
aTemp.Format("频率");
m_Report.AtTab(5,aTemp);
aTemp.Format("%.2f",aList.m_F);
m_Report.AtTab(6,aTemp);
aTemp.Format("电表常数");
m_Report.AtTab(7,aTemp);
aTemp.Format("%.0f",aList.m_DBCS);
m_Report.AtTab(8,aTemp);
/* aTemp.Format("生产日期: %04d-%02d-%02d",aList.m_CCRQ.GetYear(),aList.m_CCRQ.GetMonth(),aList.m_CCRQ.GetDay());
m_Report.AtTab(3,aTemp);*/
m_Report.NextRow();
m_Report.NextRow();
aTemp.Format("接线方式");
m_Report.AtTab(1,aTemp);
aTemp.Format("%s",aList.m_JXFS);
m_Report.AtTab(2,aTemp);
aTemp.Format("本局编号:");
m_Report.AtTab(5,aTemp);
/* aTemp.Format("本局编号:");
m_Report.AtTab(6,aTemp);*/
aTemp.Format("比例数");
m_Report.AtTab(7,aTemp);
aTemp.Format("%d",aList.m_BL);
m_Report.AtTab(8,aTemp);
m_Report.NextRow();
m_Report.NextRow();
m_Report.NextRow();
m_Report.SetDataCols(s_2Cols,2);
aTemp.Format("效表原因:");
m_Report.AtTab(0,aTemp);
m_Report.NextRow();
m_Report.NextRow();
aTemp.Format("电流互感器");
m_Report.AtTab(0,aTemp);
/* aTemp.Format("电压变比: %s",aList.m_PTBB);
m_Report.AtTab(0,aTemp);
aTemp.Format("安装单位: %s",aList.m_AZDW);
m_Report.AtTab(1,aTemp);
m_Report.NextRow();
m_Report.NextRow();
aTemp.Format("电流变比: %s",aList.m_CTBB);
m_Report.AtTab(0,aTemp);
aTemp.Format("安装地址: %s",aList.m_AZDZ);
m_Report.AtTab(1,aTemp);
m_Report.NextRow();
m_Report.NextRow();
aTemp.Format("电表常数: %.2f",aList.m_DBCS);
m_Report.AtTab(0,aTemp);
aTemp.Format("安装日期: %s",aList.m_AZRQ);
m_Report.AtTab(1,aTemp);
m_Report.NextRow();
m_Report.NextRow();
aTemp.Format("精度等级: %.4f",aList.m_JDDJ);
m_Report.AtTab(0,aTemp);
aTemp.Format("台帐编号: %s",aList.m_TZBH);
m_Report.AtTab(1,aTemp);
m_Report.NextRow();
m_Report.NextRow();
aTemp.Format("倍 率: %d",aList.m_BL);
m_Report.AtTab(0,aTemp);
aTemp.Format("所属用电号: %s",aList.m_BWYDH);
m_Report.AtTab(1,aTemp);
m_Report.NextRow();
m_Report.NextRow();
m_Report.SetDataCols(t_Cols,1);
m_Report.AtTab(0,
"备注:中华人民共和国,河南省郑州市高新技术开发区,");
m_Report.NextRow();
m_Report.AtTab(0,
" 万特电气有限责任公司");*/
}
}
catch(CDaoException *ex)
{
AfxMessageBox(ex->m_pErrorInfo->m_strDescription);
// throw ex;
}
catch(CException *zex)
{
//AfxMessageBox(zex-);
throw zex;
}
#endif
m_Report.End(); // close report
aList.Close(); // close database
m_Report.GotoPage(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -