superviseprizeview.cpp
来自「我自己整理的一些VC源代码」· C++ 代码 · 共 255 行
CPP
255 行
// SupervisePrizeView.cpp : implementation file
//
#include "stdafx.h"
#include "SellMan.h"
#include "SupervisePrizeView.h"
#include "TreeNode.h"
#include "TabCS.h"
#include "TabJJ.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSupervisePrizeView
extern _ConnectionPtr connection;
extern BOOL bConnected;
IMPLEMENT_DYNCREATE(CSupervisePrizeView, CFormView)
CSupervisePrizeView::CSupervisePrizeView()
: CFormView(CSupervisePrizeView::IDD)
{
//{{AFX_DATA_INIT(CSupervisePrizeView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CSupervisePrizeView::~CSupervisePrizeView()
{
}
void CSupervisePrizeView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSupervisePrizeView)
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(CSupervisePrizeView, CFormView)
//{{AFX_MSG_MAP(CSupervisePrizeView)
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
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSupervisePrizeView diagnostics
#ifdef _DEBUG
void CSupervisePrizeView::AssertValid() const
{
CFormView::AssertValid();
}
void CSupervisePrizeView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSupervisePrizeView message handlers
void CSupervisePrizeView::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, 80 );
m_list_child.InsertColumn( 1, "姓名", LVCFMT_LEFT, 100 );
m_list_child.InsertColumn( 2, "督导津贴", LVCFMT_RIGHT, 100 );
m_list_child.InsertColumn( 3, "品牌维护费", LVCFMT_RIGHT, 100 );
m_list_child.InsertColumn( 4, "福利待遇", LVCFMT_RIGHT, 100 );
SYSTEMTIME sysTime;
memset( &sysTime, 0, sizeof( SYSTEMTIME ) );
CTabCS tabcs;
CString strTmp;
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 );
}
}
catch( _com_error &e )
{
AfxMessageBox( e.ErrorMessage() );
}
catch( ... )
{
}
}
void CSupervisePrizeView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
AfxGetApp()->GetMainWnd()->SendMessage( WM_VIEW_ACTIVE, (WPARAM)this, (LPARAM)this );
CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
void CSupervisePrizeView::OnDestroy()
{
CFormView::OnDestroy();
AfxGetApp()->GetMainWnd()->SendMessage( WM_VIEW_CLOSE, (WPARAM)this, (LPARAM)this );
}
void CSupervisePrizeView::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_bt_calc.SetWindowPos( 0, 375, cy - 40, 100, 30, SWP_NOZORDER );
m_bt_query.SetWindowPos( 0, 485, cy - 40, 100, 30, SWP_NOZORDER );
m_bt_close.SetWindowPos( 0, 595, cy - 40, 100, 30, SWP_NOZORDER );
}
}
void CSupervisePrizeView::OnBtCalc()
{
int nCount = 0;
//char szSQL[ 255 ];
CTwoForkTree twoTree;
CString strStartDate, strEndDate, strDate, strTmp;
CString strID, strSequence, strMoney, strType, strUnit;
SYSTEMTIME sysTime;
memset( &sysTime, 0, sizeof( SYSTEMTIME ) );
CTabCS tabcs;
CTabJJ tabjj;
m_dt_start.GetTime( &sysTime );
strStartDate.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
m_dt_end.GetTime( &sysTime );
strEndDate.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
GetLocalTime( &sysTime );
strDate.Format( "%04d%02d%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay );
if( DecDays( strEndDate, strStartDate ) != 30 )
{
if( AfxMessageBox( "日期范围不等于30天继续计算吗?", MB_YESNO | MB_ICONQUESTION ) == IDNO )
return;
}
try
{
twoTree.ImportPlugger( TRUE );
twoTree.Contraction();
nCount = twoTree.CalcSupervisePrize( strStartDate, strEndDate, &m_list_child );
connection->BeginTrans();
for( int i = 0; i < nCount; i ++ )
{
strSequence.Format( "%ld", (long)m_list_child.GetItemData( i ) );
for( int j = 2; j < 5; j ++ )
{
if( j == 2 ) strUnit = "2";
else if( j == 3 ) strUnit = "1";
else if( j == 4 ) strUnit = "1";
strType.Format( "%d", j );
strMoney = m_list_child.GetItemText( i, j );
if( atof( strMoney ) > 0.00 )
{
strMoney.Format( "%ld", (long)atof( strMoney ) * 100 );
strID.Format( "%ld", tabjj.GetNextID( "JJLSID" ) );
tabjj.JJLSID.strValue = strID;
tabjj.JJYGBH.strValue = strSequence;
tabjj.JJFFRQ.strValue = strDate;
tabjj.JJFFJE.strValue = strMoney;
tabjj.JJJJRX.strValue = strType;
tabjj.JJHSDW.strValue = strUnit;
tabjj.JJJLZT.strValue = "1";
tabjj.JJJSDL.strValue = "0";
tabjj.JJJSQR.strValue = strStartDate;
tabjj.JJJSJR.strValue = strEndDate;
tabjj.JJBZXX.strValue = " ";
tabjj.AppendRecord();
}
}
}
if( tabcs.Open( "where csbmbm = 'DDJLJSRQ' and cszdmc = 'DDJLJSRQ'" ) )
{
tabcs.CSZFQZ.strValue = strEndDate;
tabcs.UpdateRecord();
}
connection->CommitTrans();
}
catch( _com_error &e )
{
connection->RollbackTrans();
AfxMessageBox( e.ErrorMessage() );
}
catch( ... )
{
connection->RollbackTrans();
}
}
void CSupervisePrizeView::OnBtQuery()
{
// TODO: Add your control notification handler code here
}
void CSupervisePrizeView::OnBtClose()
{
GetParentFrame()->SendMessage( WM_CLOSE );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?