?? dbreportview.cpp
字號(hào):
// 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[] = {
{"局 編 號(hào):", 50, CEasyReport::CColInfo::eLeft},
{"生產(chǎn)廠家:", 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("電能表現(xiàn)場(chǎng)效驗(yàn)記錄");
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,"測(cè)");
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,"數(shù)");
m_Report.PreRow();
m_Report.PreRow();
m_Report.PreRow();
m_Report.PreRow();
m_Report.PreRow();
aTemp.Format("生產(chǎn)廠家");
m_Report.AtTab(1,aTemp);
aTemp.Format("%s",aList.m_SCCJ);
m_Report.AtTab(2,aTemp);
aTemp.Format("出廠編號(hào)");
m_Report.AtTab(3,aTemp);
aTemp.Format("%s",aList.m_CCBH);
m_Report.AtTab(4,aTemp);
aTemp.Format("型號(hào)");
m_Report.AtTab(5,aTemp);
aTemp.Format("%s",aList.m_DBXH);
m_Report.AtTab(6,aTemp);
aTemp.Format("局編號(hào)");
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("電表常數(shù)");
m_Report.AtTab(7,aTemp);
aTemp.Format("%.0f",aList.m_DBCS);
m_Report.AtTab(8,aTemp);
/* aTemp.Format("生產(chǎn)日期: %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("本局編號(hào):");
m_Report.AtTab(5,aTemp);
/* aTemp.Format("本局編號(hào):");
m_Report.AtTab(6,aTemp);*/
aTemp.Format("比例數(shù)");
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("電表常數(shù): %.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("精度等級(jí): %.4f",aList.m_JDDJ);
m_Report.AtTab(0,aTemp);
aTemp.Format("臺(tái)帳編號(hào): %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("所屬用電號(hào): %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,
"備注:中華人民共和國,河南省鄭州市高新技術(shù)開發(fā)區(qū),");
m_Report.NextRow();
m_Report.AtTab(0,
" 萬特電氣有限責(zé)任公司");*/
}
}
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);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -