📄 wageview.cpp
字号:
pItem = (ST_WAGEITEM *)m_arContent.GetAt( i );
OutWageItem( 0, cy, pDC, pItem );
cy += 115;
}
int obk = pDC->SetBkMode( 0 );
CFont *pOldFont = pDC->SelectObject( &m_ftContent );
strTmp.Format( "第 %d 页", nCurPage );
pDC->TextOut( 350, 1060, strTmp );
pDC->SetBkMode( obk );
pDC->SelectObject( pOldFont );
//CView::OnPrint(pDC, pInfo);
}
void CWageView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
AfxGetApp()->GetMainWnd()->SendMessage( WM_VIEW_ACTIVE, (WPARAM)this, (LPARAM)this );
CMainFrame *pFrame = (CMainFrame *)AfxGetApp()->GetMainWnd();
CDialogBar *pBar = (CDialogBar *)pFrame->GetDlgItem( AFX_IDW_DIALOGBAR );
if( pBar ) pFrame->ShowControlBar( pBar, TRUE, TRUE );
CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
void CWageView::OnDestroy()
{
CView::OnDestroy();
CMainFrame *pFrame = (CMainFrame *)AfxGetApp()->GetMainWnd();
CDialogBar *pBar = (CDialogBar *)pFrame->GetDlgItem( AFX_IDW_DIALOGBAR );
if( pBar ) pFrame->ShowControlBar( pBar, FALSE, FALSE );
AfxGetApp()->GetMainWnd()->SendMessage( WM_VIEW_CLOSE, (WPARAM)this, (LPARAM)this );
}
void CWageView::OnKillFocus(CWnd* pNewWnd)
{
CView::OnKillFocus(pNewWnd);
/*
CMainFrame *pFrame = (CMainFrame *)AfxGetApp()->GetMainWnd();
CDialogBar *pBar = (CDialogBar *)pFrame->GetDlgItem( AFX_IDW_DIALOGBAR );
if( pBar ) pFrame->ShowControlBar( pBar, FALSE, FALSE );*/
}
void CWageView::OnBtQuery()
{
CTabXC tabxc;
CTabJJ tabjj;
char szSQL[ 255 ];
int nCount = 0;
int nGrade = 0;
int nType = 0;
long nAdRate1 = 0;
long nAdRate2 = 0;
long nFlack = 0;
long nExtend = 0;
long nSubsidy = 0;
long nAegis = 0;
long nWelfare = 0;
CDateTimeCtrl * pDataTimeStart = NULL;
CDateTimeCtrl * pDataTimeEnd = NULL;
ST_WAGEITEM * pWageItem = NULL;
CString strTmp;
SYSTEMTIME sysTime;
memset( &sysTime, 0, sizeof( SYSTEMTIME ) );
CMainFrame *pFrame = (CMainFrame *)AfxGetApp()->GetMainWnd();
CDialogBar *pBar = (CDialogBar *)pFrame->GetDlgItem( AFX_IDW_DIALOGBAR );
if( pBar )
{
pDataTimeStart = (CDateTimeCtrl *)pBar->GetDlgItem( IDC_DT_START );
pDataTimeEnd = (CDateTimeCtrl *)pBar->GetDlgItem( IDC_DT_END );
pDataTimeStart->GetTime( &sysTime );
m_strStartDate.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
pDataTimeEnd->GetTime( &sysTime );
m_strEndDate.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
RemoveAlls();
try
{
tabxc.Open( "where xcjlzt <> 0" );
while( tabxc.IsOpen() && !tabxc.IsEOF() )
{
nAdRate1 = 0;
nAdRate2 = 0;
nFlack = 0;
nExtend = 0;
nSubsidy = 0;
nAegis = 0;
nWelfare = 0;
pWageItem = new ST_WAGEITEM;
pWageItem->strName = tabxc.XCYGMC.GetValue();
pWageItem->strCode = tabxc.XCYGBH.GetValue();
nGrade = atoi( tabxc.XCTZKH.GetValue() );
if( nGrade == 1 ) pWageItem->strGrade = "金";
else if( nGrade == 2 ) pWageItem->strGrade = "银";
else if( nGrade == 3 ) pWageItem->strGrade = "优惠";
if( atoi( tabxc.XCYBYE.GetValue() ) )
pWageItem->strSpareRate1.Format( "%.f", atof( tabxc.XCYBYE.GetValue() ) / 100 );
else
pWageItem->strSpareRate1 = " ";
if( atoi( tabxc.XCEBYE.GetValue() ) )
pWageItem->strSpareRate2.Format( "%.f", atof( tabxc.XCEBYE.GetValue() ) / 100 );
else
pWageItem->strSpareRate2 = " ";
pWageItem->strAdRate1 = " ";
pWageItem->strAdRate2 = " ";
pWageItem->strAfterTax = " ";
pWageItem->strComputer = " ";
pWageItem->strFrontTax = " ";
pWageItem->strTax = " ";
pWageItem->strRemark = " ";
sprintf( szSQL, "where jjygbh = %s and jjjsqr between '%s' and '%s' and jjjsjr between '%s' and '%s'",
tabxc.XCYGID.GetValue(), m_strStartDate, m_strEndDate, m_strStartDate, m_strEndDate );
tabjj.Open( szSQL );
while( tabjj.IsOpen() && !tabjj.IsEOF() )
{
nType = atoi( tabjj.JJJJRX.GetValue() );
switch( nType )
{
case 1: // 宣传奖励
nFlack += atoi( tabjj.JJFFJE.GetValue() );
break;
case 2: // 督导津贴
nSubsidy += atoi( tabjj.JJFFJE.GetValue() );
break;
case 3: // 品牌维护费
nAegis += atoi( tabjj.JJFFJE.GetValue() );
break;
case 4: // 福利待遇
nWelfare += atoi( tabjj.JJFFJE.GetValue() );
break;
case 5: // 推广费
nExtend += atoi( tabjj.JJFFJE.GetValue() );
break;
}
tabjj.MoveNext();
}
if( nFlack ) pWageItem->strFlack.Format( "%.f", ((double)nFlack) / 100 );
else pWageItem->strFlack = " ";
if( nSubsidy ) pWageItem->strSubsidy.Format( "%.f", ((double)nSubsidy) / 100 );
else pWageItem->strSubsidy = " ";
if( nAegis ) pWageItem->strAegis.Format( "%.f", ((double)nAegis) / 100 );
else pWageItem->strAegis = " ";
if( nWelfare ) pWageItem->strWelfare.Format( "%.f", ((double)nWelfare) / 100 );
else pWageItem->strWelfare = " ";
if( nExtend ) pWageItem->strExtend.Format( "%.f", ((double)nExtend) / 100 );
else pWageItem->strExtend = " ";
m_arContent.Add( pWageItem );
nCount ++;
tabxc.MoveNext();
}
CalcScroll();
Invalidate();
}
catch( _com_error &e )
{
AfxMessageBox( e.ErrorMessage() );
}
catch( ... )
{
}
}
}
void CWageView::OnBtPrintpreview()
{
if( !m_bPreview )
{
m_bPreview = TRUE;
CView::OnFilePrintPreview();
}
}
void CWageView::OnBtPrint()
{
CView::OnFilePrint();
}
void CWageView::RemoveAlls()
{
ST_WAGEITEM * pItem = NULL;
int nCount = m_arContent.GetSize();
for( int i = 0; i < nCount; i ++ )
{
pItem = (ST_WAGEITEM *)m_arContent.GetAt( i );
delete pItem;
}
m_arContent.RemoveAll();
}
void CWageView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
/*TEXTMETRIC tm;
CClientDC dc( this );
dc.SelectObject( &font );
dc.GetTextMetrics( &tm );
CRect rc;
GetClientRect( &rc );
rc.left += offsetLeft;
int tmp;*/
switch( nSBCode )
{
case SB_LEFT:
break;
case SB_ENDSCROLL:
break;
case SB_LINELEFT:
/*hOffset -= tm.tmAveCharWidth;
if( hOffset >= 0 )
ScrollWindow( tm.tmAveCharWidth,0,&rc,&rc );
if( hOffset < 0 )
hOffset = 0;*/
break;
case SB_LINERIGHT:
//if( hOffset < 4000 )
//{
// hOffset += tm.tmAveCharWidth;
// ScrollWindow( -tm.tmAveCharWidth,0,&rc,&rc );
//}
break;
case SB_PAGELEFT:
//tmp = hOffset;
//hOffset -= rc.Width();
//if( hOffset < 0 )
// hOffset = 0;
//if( tmp > hOffset )
// ScrollWindow( tmp - hOffset,0,&rc,&rc );
break;
case SB_PAGERIGHT:
//tmp = hOffset;
//hOffset += rc.Width();
//ScrollWindow( tmp - hOffset,0,&rc,&rc );
break;
case SB_RIGHT:
break;
case SB_THUMBPOSITION:
break;
case SB_THUMBTRACK:
/*if( hOffset - (int)nPos > tm.tmAveCharWidth )
{
int tmp = ((hOffset - (int)nPos)/tm.tmAveCharWidth) * tm.tmAveCharWidth;
hOffset -= tmp;
if( hOffset < 0 )
hOffset = 0;
ScrollWindow( tmp,0,&rc,&rc );
}
else if( (int)nPos - hOffset > tm.tmAveCharWidth && hOffset < 4000 )
{
int tmp = (((int)nPos - hOffset)/tm.tmAveCharWidth) * tm.tmAveCharWidth;
hOffset += tmp;
ScrollWindow( -tmp,0,&rc,&rc );
}*/
break;
}
//SetScrollPos( SB_HORZ ,hOffset );
CView::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CWageView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
/*TEXTMETRIC tm;
CClientDC dc( this );
dc.SelectObject( &font );
dc.GetTextMetrics( &tm );*/
CRect rc;
GetClientRect( &rc );
//rc.left += offsetLeft;
//int tmp,minRange,maxRange;*/
int nScr = 0;
int nMax = m_arContent.GetSize() * 130;
switch( nSBCode )
{
case SB_BOTTOM:
break;
case SB_ENDSCROLL:
break;
case SB_LINEDOWN:
m_nOffsetY += 10;
if( m_nOffsetY > nMax ) m_nOffsetY = nMax;
else nScr = -10;
break;
case SB_LINEUP:
m_nOffsetY -= 10;
if( m_nOffsetY < 0 ) m_nOffsetY = 0;
else nScr = 10;
break;
case SB_PAGEDOWN:
m_nOffsetY += rc.Height();
if( m_nOffsetY > nMax )
{
m_nOffsetY = nMax;
}
else nScr = -rc.Height();
break;
case SB_PAGEUP:
m_nOffsetY -= rc.Height();
if( m_nOffsetY < 0 )
{
nScr = rc.Height() - m_nOffsetY;
m_nOffsetY = 0;
}
else nScr = rc.Height();
break;
case SB_THUMBPOSITION:
break;
case SB_THUMBTRACK:
if( ( (int)nPos - m_nOffsetY > 0 ) || (int)nPos < 0 )
{
nScr = -((int)nPos - m_nOffsetY);
m_nOffsetY += -nScr;
}
else if( m_nOffsetY - (int)nPos > 0 )
{
nScr = m_nOffsetY - (int)nPos;
m_nOffsetY -= nScr;
}
break;
case SB_TOP:
break;
}
ScrollWindow( 0,nScr,&rc,&rc );
SetScrollPos( SB_VERT ,m_nOffsetY );
CView::OnVScroll(nSBCode, nPos, pScrollBar);
}
void CWageView::CalcScroll()
{
SCROLLINFO scrollInfo;
CRect rc,rcClient;
GetClientRect( rcClient );
int nCount = m_arContent.GetSize();
scrollInfo.cbSize = rcClient.Width();
scrollInfo.fMask = SIF_ALL;
scrollInfo.nMax = 1000;
scrollInfo.nMin = 0;
scrollInfo.nPage = rcClient.Width();
scrollInfo.nPos = m_nOffsetX;
scrollInfo.nTrackPos = 10;
SetScrollInfo( SB_HORZ,&scrollInfo );
scrollInfo.nMax = nCount * 130;
scrollInfo.nPage = rcClient.Height();
scrollInfo.nPos = m_nOffsetY;
scrollInfo.nTrackPos = 10;
SetScrollInfo( SB_VERT,&scrollInfo );
}
void CWageView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView)
{
m_bPreview = FALSE;
CView::OnEndPrintPreview(pDC, pInfo, point, pView);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -