144 lines
3.4 KiB
C++
144 lines
3.4 KiB
C++
// DLG_Commend_DH.cpp : implementation file
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "corpsms.h"
|
||
#include "DLG_Commend_DH.h"
|
||
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// DLG_Commend_DH dialog
|
||
|
||
|
||
DLG_Commend_DH::DLG_Commend_DH(CWnd* pParent /*=NULL*/)
|
||
: CDialog(DLG_Commend_DH::IDD, pParent)
|
||
{
|
||
//{{AFX_DATA_INIT(DLG_Commend_DH)
|
||
//}}AFX_DATA_INIT
|
||
|
||
m_pCommend = NULL;
|
||
m_pCommendData = NULL;
|
||
memset(&m_RetData, 0 , sizeof(m_RetData));
|
||
}
|
||
|
||
|
||
void DLG_Commend_DH::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(DLG_Commend_DH)
|
||
DDX_Control(pDX, IDC_COMMEND_DH_VIPINT, m_E_VipInt);
|
||
DDX_Control(pDX, IDC_COMMEND_DH_LIST, m_wndList);
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(DLG_Commend_DH, CDialog)
|
||
//{{AFX_MSG_MAP(DLG_Commend_DH)
|
||
ON_NOTIFY(NM_DBLCLK, IDC_COMMEND_DH_LIST, OnDblclkCommendDhList)
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// DLG_Commend_DH message handlers
|
||
|
||
BOOL DLG_Commend_DH::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
|
||
|
||
//初始化列表
|
||
//创建图像列表
|
||
m_Image.Create( 20 , 20 , ILC_COLOR32|ILC_MASK , 5 , 1);
|
||
CBitmap bmp;
|
||
bmp.LoadBitmap( IDB_L_USER_NOR );
|
||
m_Image.Add( &bmp , RGB(193,193,193) ); //设置
|
||
//加入图像列表
|
||
m_wndList.SetImageList(&m_Image,LVSIL_SMALL);
|
||
m_wndList.SetBkColor( RGB(237,238,188) );
|
||
m_wndList.SetTextBkColor( RGB(237,238,188) );
|
||
|
||
m_wndList.SubClassWindow2();
|
||
m_wndList.SetHeadings(_T(" 序号,50;所需积分,70;礼品类型,130;"));
|
||
m_wndList.SetGridLines(true);
|
||
|
||
|
||
RefreshList();
|
||
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// EXCEPTION: OCX Property Pages should return FALSE
|
||
}
|
||
|
||
void DLG_Commend_DH::SetParam(ANS_GetCommend_LP *pCommend, ANS_GetCommend_LPData *pData)
|
||
{
|
||
m_pCommend=pCommend;
|
||
m_pCommendData=pData;
|
||
}
|
||
|
||
void DLG_Commend_DH::RefreshList()
|
||
{
|
||
//m_wndList.SetHeadings(_T(" 序号,60; 类 型,80; 状态,80; 积分,80; 事件,150;"));
|
||
if ( !m_pCommend )
|
||
return;
|
||
if ( !m_pCommendData )
|
||
return;
|
||
|
||
|
||
CString str;
|
||
|
||
str.Format( _T("%d") , m_pCommend->lVipInt);
|
||
m_E_VipInt.SetWindowText(str);
|
||
for ( int i=0 ; i<m_pCommend->lCount ; i++)
|
||
{
|
||
str.Format( _T("%d") , i+1 );
|
||
m_wndList.InsertItem(i , str , 0 );
|
||
|
||
int lTemp11=1;
|
||
|
||
str.Format( _T("%d") , m_pCommendData[i].lVipInt );
|
||
m_wndList.SetItemText(i, lTemp11++ , str);
|
||
|
||
m_wndList.SetItemText(i, lTemp11++ , m_pCommendData[i].szName);
|
||
|
||
m_wndList.SetItemData(i , m_pCommendData[i].lCommendLPID );
|
||
}
|
||
}
|
||
|
||
void DLG_Commend_DH::OnOK()
|
||
{
|
||
long lItem=m_wndList.GetFirstSelectedItem();
|
||
CString str;
|
||
|
||
if ( lItem<0 )
|
||
{
|
||
MessageBox( _T("请先在左边列表选择你要兑换的礼品!") , _T("提示") , MB_ICONINFORMATION );
|
||
return ;
|
||
}
|
||
|
||
if ( m_pCommendData[lItem].lVipInt>m_pCommend->lVipInt )
|
||
{
|
||
str.Format( _T("你选择兑换的礼品需要%d积分,而你的积分余额不足,请重新选择!") , m_pCommendData[lItem].lVipInt );
|
||
MessageBox(str , _T("提示") , MB_ICONINFORMATION );
|
||
return ;
|
||
}
|
||
str.Format( _T("你选择兑换的礼品是[%s]需要扣减%d积分,是否继续!") , m_pCommendData[lItem].szName , m_pCommendData[lItem].lVipInt );
|
||
int iRet = MessageBox(str , _T("提问") , MB_ICONQUESTION|MB_YESNO );
|
||
if ( iRet!=IDYES )
|
||
return ;
|
||
|
||
m_RetData = m_pCommendData[lItem];
|
||
|
||
CDialog::OnOK();
|
||
}
|
||
|
||
void DLG_Commend_DH::OnDblclkCommendDhList(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
|
||
*pResult = 0;
|
||
|
||
OnOK();
|
||
} |