⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wageview.cpp

📁 我自己整理的一些VC源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// WageView.cpp : implementation file
//

#include "stdafx.h"
#include "SellMan.h"
#include "WageView.h"
#include "MainFrm.h"

#include "TabXC.h"
#include "TabJJ.h"
#include "TabCS.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWageView

IMPLEMENT_DYNCREATE(CWageView, CView)

CWageView::CWageView()
{
	m_ftTitle.CreatePointFont( 150, "华文新魏" );
	m_ftContent.CreatePointFont( 90, "宋体" );
	m_nOffsetX = 0;
	m_nOffsetY = 0;
	m_bPreview = FALSE;
}

CWageView::~CWageView()
{
	RemoveAlls();
}


BEGIN_MESSAGE_MAP(CWageView, CView)
	//{{AFX_MSG_MAP(CWageView)
	ON_WM_DESTROY()
	ON_WM_KILLFOCUS()
	ON_BN_CLICKED(IDC_BT_QUERY, OnBtQuery)
	ON_BN_CLICKED(IDC_BT_PRINTPREVIEW, OnBtPrintpreview)
	ON_BN_CLICKED(IDC_BT_PRINT, OnBtPrint)
	ON_WM_HSCROLL()
	ON_WM_VSCROLL()
	//}}AFX_MSG_MAP
	ON_COMMAND( ID_FILE_PRINT, CView::OnFilePrint )
	ON_COMMAND( ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview )
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWageView drawing

void CWageView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	
	CRect rcItem;
	int nCount = 0;
	ST_WAGEITEM * pItem = NULL;
	CString strTmp, strDate1, strDate2;
	int obk = pDC->SetBkMode( 0 );
	CFont * pOldFont = pDC->SelectObject( &m_ftTitle );

	strDate1 = m_strStartDate;
	strDate1.Insert( 6, " 月 " );
	strDate1.Insert( 4, " 年 " );
	strDate1 += " 日";
	strDate2 = m_strEndDate;
	strDate2.Insert( 6, " 月 " );
	strDate2.Insert( 4, " 年 " );
	strDate2 += " 日";
	m_strDateTitle.Format( "%s -- %s", strDate1, strDate2 );

	nCount = m_arContent.GetSize();
	if( nCount )
	{
		int cy = -m_nOffsetY;
		for( int i = 0; i < nCount; i ++ )
		{
			pItem = (ST_WAGEITEM *)m_arContent.GetAt( i );
			OutWageItem( -m_nOffsetX, cy, pDC, pItem );
			cy += 110;
		}
	}

	pDC->SelectObject( pOldFont );
	pDC->SetBkMode( obk );
}

void CWageView::OutWageItem(int cx, int cy, CDC *pDC, ST_WAGEITEM *pItem)
{
	int obk = pDC->SetBkMode( 0 );

	CRect rcItem;
	int x = cx + 80, y = cy + 20;
	CFont * pOldFont = pDC->SelectObject( &m_ftTitle );
	pDC->TextOut( x, y, "南国春宣传推广费明细单" );

	// 日期
	pDC->SelectObject( &m_ftContent );
	pDC->TextOut( cx + 350, cy + 25, m_strDateTitle );

	// 姓名
	rcItem = CRect( cx + 20, cy + 45, cx + 80, cy + 65 );
	pDC->DrawText( "姓名", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 79, cy + 45, cx + 159, cy + 65 );
	pDC->DrawText( pItem->strName, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 编号
	rcItem = CRect( cx + 158, cy + 45, cx + 238, cy + 65 );
	pDC->DrawText( "编号", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 237, cy + 45, cx + 317, cy + 65 );
	pDC->DrawText( pItem->strCode, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 卡号
	rcItem = CRect( cx + 316, cy + 45, cx + 396, cy + 65 );
	pDC->DrawText( "卡号", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 395, cy + 45, cx + 465, cy + 65 );
	pDC->DrawText( pItem->strGrade, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 一部广告费
	rcItem = CRect( cx + 464, cy + 45, cx + 544, cy + 65 );
	pDC->DrawText( "一部广告费", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 543, cy + 45, cx + 613, cy + 65 );
	pDC->DrawText( pItem->strAdRate1, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 二部广告费
	rcItem = CRect( cx + 612, cy + 45, cx + 692, cy + 65 );
	pDC->DrawText( "二部广告费", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 691, cy + 45, cx + 761, cy + 65 );
	pDC->DrawText( pItem->strAdRate2, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 宣传费
	rcItem = CRect( cx + 20, cy + 64, cx + 80, cy + 84 );
	pDC->DrawText( "宣传费", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 79, cy + 64, cx + 159, cy + 84 );
	pDC->DrawText( pItem->strFlack, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 一部余广告费
	rcItem = CRect( cx + 158, cy + 64, cx + 238, cy + 84 );
	pDC->DrawText( "一部余广告费", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 237, cy + 64, cx + 317, cy + 84 );
	pDC->DrawText( pItem->strSpareRate1, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 二部余广告费
	rcItem = CRect( cx + 316, cy + 64, cx + 396, cy + 84 );
	pDC->DrawText( "二部余广告费", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 395, cy + 64, cx + 465, cy + 84 );
	pDC->DrawText( pItem->strSpareRate2, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 推广费
	rcItem = CRect( cx + 464, cy + 64, cx + 544, cy + 84 );
	pDC->DrawText( "推广费", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 543, cy + 64, cx + 613, cy + 84 );
	pDC->DrawText( pItem->strExtend, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 督导津贴
	rcItem = CRect( cx + 612, cy + 64, cx + 692, cy + 84 );
	pDC->DrawText( "督导津贴", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 691, cy + 64, cx + 761, cy + 84 );
	pDC->DrawText( pItem->strSubsidy, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 电脑费
	rcItem = CRect( cx + 20, cy + 83, cx + 80, cy + 103 );
	pDC->DrawText( "电脑费", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 79, cy + 83, cx + 159, cy + 103 );
	pDC->DrawText( pItem->strComputer, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 税前应发
	rcItem = CRect( cx + 158, cy + 83, cx + 238, cy + 103 );
	pDC->DrawText( "税前应发", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 237, cy + 83, cx + 317, cy + 103 );
	pDC->DrawText( pItem->strFrontTax, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 税金
	rcItem = CRect( cx + 316, cy + 83, cx + 396, cy + 103 );
	pDC->DrawText( "税金", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 395, cy + 83, cx + 465, cy + 103 );
	pDC->DrawText( pItem->strTax, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 税后应发
	rcItem = CRect( cx + 464, cy + 83, cx + 544, cy + 103 );
	pDC->DrawText( "税后应发", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 543, cy + 83, cx + 613, cy + 103 );
	pDC->DrawText( pItem->strAfterTax, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 品牌维护费
	rcItem = CRect( cx + 612, cy + 83, cx + 692, cy + 103 );
	pDC->DrawText( "品牌维护费", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 691, cy + 83, cx + 761, cy + 103 );
	pDC->DrawText( pItem->strAegis, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 福利待遇
	rcItem = CRect( cx + 20, cy + 102, cx + 80, cy + 122 );
	pDC->DrawText( "福利待遇", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 79, cy + 102, cx + 159, cy + 122 );
	pDC->DrawText( pItem->strWelfare, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	// 备注
	rcItem = CRect( cx + 158, cy + 102, cx + 238, cy + 122 );
	pDC->DrawText( "备注", &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	rcItem = CRect( cx + 237, cy + 102, cx + 761, cy + 122 );
	pDC->DrawText( pItem->strRemark, &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	pDC->Draw3dRect( &rcItem, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) );

	pDC->SelectObject( pOldFont );
	pDC->SetBkMode( obk );
}

/////////////////////////////////////////////////////////////////////////////
// CWageView diagnostics

#ifdef _DEBUG
void CWageView::AssertValid() const
{
	CView::AssertValid();
}

void CWageView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CWageView message handlers

void CWageView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	
	SYSTEMTIME sysTime;
	memset( &sysTime, 0, sizeof( SYSTEMTIME ) );
	CTabCS tabcs;
	CString strTmp;
	CDateTimeCtrl * pDataTime = NULL;

	try
	{
		CMainFrame *pFrame = (CMainFrame *)AfxGetApp()->GetMainWnd();
		CDialogBar *pBar   = (CDialogBar *)pFrame->GetDlgItem( AFX_IDW_DIALOGBAR );
		if( pBar )
		{
			pDataTime = (CDateTimeCtrl *)pBar->GetDlgItem( IDC_DT_START );
			
			if( tabcs.Open( "where csbmbm = 'YGGZFFRQ' and cszdmc = 'YGGZFFRQ'" ) )
			{
				strTmp = tabcs.CSZFQZ.GetValue();
				strTmp = DateAppendToString( strTmp, 1 );
				sysTime.wYear = atoi( strTmp.Left( 4 ) );
				strTmp.Delete( 0, 4 );
				sysTime.wMonth = atoi( strTmp.Left( 2 ) );
				strTmp.Delete( 0, 2 );
				sysTime.wDay = atoi( strTmp.Left( 2 ) );
				pDataTime->SetTime( &sysTime );
			}
		}
	}
	catch( _com_error &e )
	{
		AfxMessageBox( e.ErrorMessage() );
	}
	catch( ... )
	{
	}
}

void CWageView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CView::OnPrepareDC(pDC, pInfo);
}

BOOL CWageView::OnPreparePrinting(CPrintInfo* pInfo) 
{
	return DoPreparePrinting( pInfo );
	
	//return CView::OnPreparePrinting(pInfo);
}

void CWageView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) 
{
	m_nLinePerPage = 9;
	int nCount = m_arContent.GetSize();
	int nPage  = nCount / m_nLinePerPage + 1;

	pInfo->SetMaxPage( nPage );
	
	//CView::OnBeginPrinting(pDC, pInfo);
}

void CWageView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
	int iSavedPageStart = pInfo->m_rectDraw.top;
    pDC->SetWindowOrg( 0,  0 );
    pDC->SetViewportOrg( pInfo->m_rectDraw.left,  -iSavedPageStart );
	
    // Print the Page
	// Get the View-DC
	CDC* pViewDC = GetDC();
	
	// Set the Mappingmode
	pDC->SetMapMode(MM_ANISOTROPIC);
	
	// Define the Originmapping of the viewport and 
	// the window for Treeoutput
	pDC->SetWindowOrg( 0,  0 );
	pDC->SetViewportOrg( pInfo->m_rectDraw.left,  pInfo->m_rectDraw.top - iSavedPageStart );
	
	// Define the Extentmapping of the viewport and the Window
	pDC->SetViewportExt( pDC->GetDeviceCaps(LOGPIXELSX)
		,pDC->GetDeviceCaps(LOGPIXELSY) );
	
	pDC->SetWindowExt( pViewDC->GetDeviceCaps(LOGPIXELSX)
		,pViewDC->GetDeviceCaps(LOGPIXELSY) );
	
	// Release the View-DC
	ReleaseDC(pViewDC);
	
	int cy = 0;
	CString strTmp;
	ST_WAGEITEM * pItem = NULL;
	int nCount   = m_arContent.GetSize();
	int nCurPage = pInfo->m_nCurPage;
	int nFromLine = (nCurPage - 1) * m_nLinePerPage;
	int nToLine   = nCurPage * m_nLinePerPage;
	for( int i = nFromLine; i < nToLine && i < nCount; i ++ )
	{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -