wagecountfview.cpp
来自「我自己整理的一些VC源代码」· C++ 代码 · 共 873 行 · 第 1/2 页
CPP
873 行
// WageCountFView.cpp : implementation file
//
#include "stdafx.h"
#include "SellMan.h"
#include "MainFrm.h"
#include "WageCountFView.h"
#include "TabXC.h"
#include "TabJJ.h"
#include "TabCS.h"
#include "TabGZ.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWageCountFView
extern _ConnectionPtr connection;
extern BOOL bConnected;
IMPLEMENT_DYNCREATE(CWageCountFView, CFormView)
CWageCountFView::CWageCountFView()
: CFormView(CWageCountFView::IDD)
{
//{{AFX_DATA_INIT(CWageCountFView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_ftTitle.CreatePointFont( 150, "宋体" );
m_ftContent.CreatePointFont( 90, "宋体" );
}
CWageCountFView::~CWageCountFView()
{
}
void CWageCountFView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWageCountFView)
DDX_Control(pDX, IDC_STATIC_ISSUE2, m_static_issue2);
DDX_Control(pDX, IDC_STATIC_ISSUE1, m_static_issue1);
DDX_Control(pDX, IDC_CB_ISSUE, m_cb_issue);
DDX_Control(pDX, IDC_BT_QUERY, m_bt_query);
DDX_Control(pDX, IDC_BT_CLOSE, m_bt_close);
DDX_Control(pDX, IDC_BT_CALC, m_bt_calc);
DDX_Control(pDX, IDC_STATIC_START, m_static_start);
DDX_Control(pDX, IDC_STATIC_END, m_static_end);
DDX_Control(pDX, IDC_LIST_CHILD, m_list_child);
DDX_Control(pDX, IDC_DT_START, m_dt_start);
DDX_Control(pDX, IDC_DT_END, m_dt_end);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWageCountFView, CFormView)
//{{AFX_MSG_MAP(CWageCountFView)
ON_WM_DESTROY()
ON_WM_SIZE()
ON_BN_CLICKED(IDC_BT_CALC, OnBtCalc)
ON_BN_CLICKED(IDC_BT_QUERY, OnBtQuery)
ON_BN_CLICKED(IDC_BT_CLOSE, OnBtClose)
//}}AFX_MSG_MAP
ON_COMMAND( ID_FILE_PRINT, OnFilePrint )
ON_COMMAND( ID_FILE_PRINT_PREVIEW, OnFilePrintPreview )
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWageCountFView diagnostics
#ifdef _DEBUG
void CWageCountFView::AssertValid() const
{
CFormView::AssertValid();
}
void CWageCountFView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWageCountFView message handlers
void CWageCountFView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
SetScrollSizes( MM_LOMETRIC, CSize( 0, 0 ) );
m_bt_calc.SetIcon( IDI_NEW );
m_bt_query.SetIcon( IDI_RQINVINFO );
m_bt_close.SetIcon( IDI_EXIT16 );
HICON hIcon;
m_imgList.Create (16, 16, true, 2, 1);
hIcon= AfxGetApp()->LoadIcon ( IDI_MAN );
m_imgList.Add (hIcon);
m_list_child.SetImageList( &m_imgList, LVSIL_SMALL );
m_list_child.SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
m_list_child.SetTextColor( RGB( 0, 0, 128 ) );
m_list_child.InsertColumn( 0, "序号", LVCFMT_LEFT, 60 );
m_list_child.InsertColumn( 1, "姓名", LVCFMT_LEFT, 70 );
m_list_child.InsertColumn( 2, "卡类", LVCFMT_RIGHT, 50 );
m_list_child.InsertColumn( 3, "编号", LVCFMT_RIGHT, 60 );
m_list_child.InsertColumn( 4, "一部合作经费", LVCFMT_RIGHT, 90 );
m_list_child.InsertColumn( 5, "二部合作经费", LVCFMT_RIGHT, 90 );
m_list_child.InsertColumn( 6, "单位数", LVCFMT_RIGHT, 50 );
m_list_child.InsertColumn( 7, "广告费", LVCFMT_RIGHT, 60 );
m_list_child.InsertColumn( 8, "推广费", LVCFMT_RIGHT, 60 );
m_list_child.InsertColumn( 9, "一部余合作经费", LVCFMT_RIGHT, 100 );
m_list_child.InsertColumn( 10, "二部余合作经费", LVCFMT_RIGHT, 100 );
m_list_child.InsertColumn( 11, "督导津贴", LVCFMT_RIGHT, 60 );
m_list_child.InsertColumn( 12, "品牌维护费", LVCFMT_RIGHT, 80 );
m_list_child.InsertColumn( 13, "福利待遇", LVCFMT_RIGHT, 70 );
m_list_child.InsertColumn( 14, "税前应发", LVCFMT_RIGHT, 70 );
m_list_child.InsertColumn( 15, "电脑费", LVCFMT_RIGHT, 70 );
m_list_child.InsertColumn( 16, "所得税", LVCFMT_RIGHT, 70 );
m_list_child.InsertColumn( 17, "税后实发", LVCFMT_RIGHT, 70 );
m_list_child.InsertColumn( 18, "备注", LVCFMT_RIGHT, 100 );
CString strTmp;
for( int i = 1; i < 1000; i ++ )
{
strTmp.Format( "%d", i );
m_cb_issue.SetItemData( m_cb_issue.AddString( strTmp ), i );
}
m_cb_issue.SetCurSel( 0 );
SYSTEMTIME sysTime;
memset( &sysTime, 0, sizeof( SYSTEMTIME ) );
CTabCS tabcs;
_RecordsetPtr recordset;
Fields * fields = NULL;
HRESULT hr;
VARIANT var_value;
try
{
if( tabcs.Open( "where csbmbm = 'DDJLJSRQ' and cszdmc = 'DDJLJSRQ'" ) )
{
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 ) );
m_dt_start.SetTime( &sysTime );
}
hr = recordset.CreateInstance( _uuidof( Recordset ) );
if( SUCCEEDED(hr) )
{
_bstr_t query( "select max( gzffqb ) from gz" );
hr = recordset->Open( query, _variant_t((IDispatch*)connection, true),
adOpenDynamic, adLockUnspecified, adCmdText );
if( SUCCEEDED(hr) )
{
recordset->get_Fields( &fields );
int count = fields->GetCount();
m_strQb = "";
if( count )
{
fields->Item[ (long)0 ]->get_Value( &var_value );
strTmp = VariantToString( var_value );
}
strTmp.Format( "%d", atoi( m_strQb ) + 1 );
}
recordset.Release();
m_cb_issue.SetWindowText( strTmp );
}
}
catch( _com_error &e )
{
AfxMessageBox( e.ErrorMessage() );
}
catch( ... )
{
}
}
void CWageCountFView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
AfxGetApp()->GetMainWnd()->SendMessage( WM_VIEW_ACTIVE, (WPARAM)this, (LPARAM)this );
CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
void CWageCountFView::OnDestroy()
{
CFormView::OnDestroy();
AfxGetApp()->GetMainWnd()->SendMessage( WM_VIEW_CLOSE, (WPARAM)this, (LPARAM)this );
}
void CWageCountFView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
if( m_list_child.GetSafeHwnd() )
{
m_list_child.SetWindowPos( 0, 0, 0, cx, cy - 50, SWP_NOZORDER );
m_static_start.SetWindowPos( 0, 10, cy - 30, 15, 20, SWP_NOZORDER );
m_dt_start.SetWindowPos( 0, 35, cy - 35, 150, 20, SWP_NOZORDER );
m_static_end.SetWindowPos( 0, 190, cy - 30, 15, 20, SWP_NOZORDER );
m_dt_end.SetWindowPos( 0, 215, cy - 35, 150, 20, SWP_NOZORDER );
m_static_issue1.SetWindowPos( 0, 375, cy - 30, 15, 20, SWP_NOZORDER );
m_cb_issue.SetWindowPos( 0, 395, cy - 35, 50, 300, SWP_NOZORDER );
m_static_issue2.SetWindowPos( 0, 450, cy - 30, 15, 20, SWP_NOZORDER );
m_bt_calc.SetWindowPos( 0, 470, cy - 40, 100, 30, SWP_NOZORDER );
m_bt_query.SetWindowPos( 0, 575, cy - 40, 100, 30, SWP_NOZORDER );
m_bt_close.SetWindowPos( 0, 690, cy - 40, 100, 30, SWP_NOZORDER );
}
}
void CWageCountFView::OnBtCalc()
{
CTabXC tabxc;
CTabJJ tabjj;
CTabGZ tabgz;
CTabCS tabcs;
char szSQL[ 255 ];
int nCount = 0;
int nGrade = 0;
int nType = 0;
long nAdRate1 = 0;
long nAdRate2 = 0;
long nSpareAdRate1 = 0;
long nSpareAdRate2 = 0;
long nFlack = 0;
long nExtend = 0;
long nSubsidy = 0;
long nAegis = 0;
long nWelfare = 0;
CString strTmp, strQb;
SYSTEMTIME sysTime;
memset( &sysTime, 0, sizeof( SYSTEMTIME ) );
m_dt_start.GetTime( &sysTime );
m_strStartDate.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
m_dt_end.GetTime( &sysTime );
m_strEndDate.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
if( DecDays( m_strEndDate, m_strStartDate ) != 30 )
{
if( AfxMessageBox( "日期范围不等于30天继续计算吗?", MB_YESNO | MB_ICONQUESTION ) == IDNO )
return;
}
m_list_child.DeleteAllItems();
m_cb_issue.GetWindowText( strQb );
if( strQb.IsEmpty() )
{
AfxMessageBox( "期别不能为空!" );
return;
}
try
{
tabxc.Open( "where xcjlzt <> 0" );
while( tabxc.IsOpen() && !tabxc.IsEOF() )
{
nAdRate1 = 0;
nAdRate2 = 0;
nSpareAdRate1 = 0;
nSpareAdRate2 = 0;
nFlack = 0;
nExtend = 0;
nSubsidy = 0;
nAegis = 0;
nWelfare = 0;
strTmp.Format( "%d", nCount + 1 );
m_list_child.InsertItem( nCount, strTmp, 0 );
m_list_child.SetItemData( nCount, atol( tabxc.XCYGID.GetValue() ) );
m_list_child.SetItemText( nCount, 1, tabxc.XCYGMC.GetValue() );
nGrade = atoi( tabxc.XCTZKH.GetValue() );
if( nGrade == 1 ) strTmp = "金";
else if( nGrade == 2 ) strTmp = "银";
else if( nGrade == 3 ) strTmp = "优惠";
m_list_child.SetItemText( nCount, 2, strTmp );
m_list_child.SetItemText( nCount, 3, tabxc.XCYGBH.GetValue() );
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();
}
nSpareAdRate1 = atoi( tabxc.XCYBYE.GetValue() );
nSpareAdRate2 = atoi( tabxc.XCEBYE.GetValue() );
nAdRate1 = nFlack / 50 * 200 + nSpareAdRate1;
nAdRate2 = nFlack / 50 * 200 + nSpareAdRate2;
strTmp.Format( "%d", nAdRate1 / 100 );
m_list_child.SetItemText( nCount, 4, strTmp ); // 一部合作经费
strTmp.Format( "%d", nAdRate2 / 100 );
m_list_child.SetItemText( nCount, 5, strTmp ); // 二部合作经费
strTmp.Format( "%d", nFlack / 50 );
m_list_child.SetItemText( nCount, 6, strTmp ); // 单位数
strTmp.Format( "%d", nFlack / 100 );
m_list_child.SetItemText( nCount, 7, strTmp ); // 广告费
strTmp.Format( "%d", nExtend / 100 );
m_list_child.SetItemText( nCount, 8, strTmp ); // 推广费
strTmp.Format( "%d", nSpareAdRate1 / 100 );
m_list_child.SetItemText( nCount, 9, strTmp ); // 一部余合作经费
strTmp.Format( "%d", nSpareAdRate2 / 100 );
m_list_child.SetItemText( nCount, 10, strTmp ); // 二部余合作经费
strTmp.Format( "%d", nSubsidy / 100 );
m_list_child.SetItemText( nCount, 11, strTmp ); // 督导津贴
strTmp.Format( "%d", nAegis / 100 );
m_list_child.SetItemText( nCount, 12, strTmp ); // 品牌维护费
strTmp.Format( "%d", nWelfare / 100 );
m_list_child.SetItemText( nCount, 13, strTmp ); // 福利待遇
nCount ++;
tabxc.MoveNext();
}
connection->BeginTrans();
for( int i = 0; i < nCount; i ++ )
{
strTmp.Format( "%d", tabgz.GetNextID( "GZGZID" ) );
tabgz.GZGZID.strValue = strTmp;
strTmp.Format( "%ld", (long)m_list_child.GetItemData( i ) );
tabgz.GZYGHM.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 4 ) ) * 100 );
tabgz.GZYBJF.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 5 ) ) * 100 );
tabgz.GZEBJF.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 6 ) ) * 100 );
tabgz.GZDWSL.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 7 ) ) * 100 );
tabgz.GZXCFY.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 8 ) ) * 100 );
tabgz.GZTGFY.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 9 ) ) * 100 );
tabgz.GZYBYE.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 10 ) ) * 100 );
tabgz.GZEBYE.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 11 ) ) * 100 );
tabgz.GZDDJT.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 12 ) ) * 100 );
tabgz.GZPPWH.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 13 ) ) * 100 );
tabgz.GZFLDY.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 14 ) ) * 100 );
tabgz.GZSQYF.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 15 ) ) * 100 );
tabgz.GZSJJE.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 16 ) ) * 100 );
tabgz.GZDNFY.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 17 ) ) * 100 );
tabgz.GZSDSE.strValue = strTmp;
strTmp.Format( "%.f", atof( m_list_child.GetItemText( i, 18 ) ) * 100 );
tabgz.GZSHSF.strValue = strTmp;
tabgz.GZFFQB.strValue = strQb;
tabgz.GZJSQR.strValue = m_strStartDate;
tabgz.GZJSJR.strValue = m_strEndDate;
tabgz.GZLKRQ.strValue = " ";
tabgz.GZLKBZ.strValue = "0";
tabgz.GZCZRY.strValue = "0";
tabgz.GZBZXX.strValue = " ";
tabgz.AppendRecord();
}
if( tabcs.Open( "where csbmbm = 'DDJLJSRQ' and cszdmc = 'DDJLJSRQ'" ) )
{
tabcs.CSZFQZ.strValue = m_strEndDate;
tabcs.UpdateRecord();
}
connection->CommitTrans();
}
catch( _com_error &e )
{
connection->RollbackTrans();
AfxMessageBox( e.ErrorMessage() );
}
catch( ... )
{
}
}
void CWageCountFView::OnBtQuery()
{
char szSQL[ 255 ];
CTabXC tabxc;
CTabGZ tabgz;
int index = 0;
int nType = 0;
int nValue = 0;
CString strTmp;
m_list_child.DeleteAllItems();
try
{
m_cb_issue.GetWindowText( m_strQb );
sprintf( szSQL, "where gzffqb = %s", m_strQb );
tabgz.Open( szSQL );
while( tabgz.IsOpen() && !tabgz.IsEOF() )
{
strTmp.Format( "%d", index + 1 );
m_list_child.InsertItem( index, strTmp );
m_list_child.SetItemData( index, atol( tabgz.GZYGHM.GetValue() ) );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?