www.pudn.com > duanxinfangwei.rar > FormView_CodeList.cpp


// FormView_CodeList.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "smspreventforgery.h" 
#include "FormView_CodeList.h" 
#include "DbInterface.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CFormView_CodeList 
 
IMPLEMENT_DYNCREATE(CFormView_CodeList, CListView) 
 
CFormView_CodeList::CFormView_CodeList() 
{ 
} 
 
CFormView_CodeList::~CFormView_CodeList() 
{ 
} 
 
 
BEGIN_MESSAGE_MAP(CFormView_CodeList, CListView) 
	//{{AFX_MSG_MAP(CFormView_CodeList) 
		// NOTE - the ClassWizard will add and remove mapping macros here. 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CFormView_CodeList drawing 
 
void CFormView_CodeList::OnDraw(CDC* pDC) 
{ 
	CDocument* pDoc = GetDocument(); 
	// TODO: add draw code here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CFormView_CodeList diagnostics 
 
#ifdef _DEBUG 
void CFormView_CodeList::AssertValid() const 
{ 
	CListView::AssertValid(); 
} 
 
void CFormView_CodeList::Dump(CDumpContext& dc) const 
{ 
	CListView::Dump(dc); 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CFormView_CodeList message handlers 
 
void CFormView_CodeList::OnInitialUpdate()  
{ 
	CListView::OnInitialUpdate(); 
	 
	/* 改变列表风格 */ 
	CListCtrl &listctrl = GetListCtrl(); 
 
	listctrl.ModifyStyle(0, LVS_REPORT); 
	listctrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); 
 
	listctrl.InsertColumn(1, "防伪号", LVCFMT_LEFT, 150); 
	listctrl.InsertColumn(2, "查询次数", LVCFMT_LEFT, 80); 
	listctrl.InsertColumn(3, "产品名", LVCFMT_LEFT, 150); 
 
	/* 取得要显示的信息 */ 
	extern CODEVIEWFLAG g_codeListView;			//当前号码列表视图标志 
	CDbInterface db;					//数据库操作接口 
	std::list codeinfolist;	//防伪号信息列表 
	CODEINFO singleCodeinfo; 
	PRODUCTINFO productinfo; 
	char buff[128]; 
	switch(g_codeListView) 
	{ 
	case QUERYEDLIST:			//已被查询过的号列表 
		if(!db.GetQueryedCodeList(codeinfolist)) 
		{ 
			MessageBox("数据库操作错误", "错误", MB_OK | MB_ICONERROR); 
			return; 
		} 
		break; 
	case MULQUERYEDLIST:		//被多次查询号列表 
		if(!db.GetQueryedMulCodeList(codeinfolist)) 
		{ 
			MessageBox("数据库操作错误", "错误", MB_OK | MB_ICONERROR); 
			return; 
		} 
		break; 
	case INVALIDATIONLIST:		//假冒号列表 
		if(!db.GetInvalidationCodeList(codeinfolist)) 
		{ 
			MessageBox("数据库操作错误", "错误", MB_OK | MB_ICONERROR); 
			return; 
		} 
		break; 
	} 
 
	/* 显示列表信息 */ 
	while(codeinfolist.size() > 0) 
	{ 
		singleCodeinfo = codeinfolist.front(); 
		codeinfolist.pop_front(); 
 
		listctrl.InsertItem(LVIF_TEXT | LVIF_STATE, 0, 0, 0, 0, 0, 0); 
		listctrl.SetItemText(0, 0, singleCodeinfo.code); 
		memset(buff, 0, sizeof(buff)); 
		itoa(singleCodeinfo.querytimes, buff, 10); 
		listctrl.SetItemText(0, 1, buff); 
		if(!db.GetProductInfo(singleCodeinfo.productId, productinfo)) 
		{ 
			productinfo.productName = "未成功取得"; 
		} 
		listctrl.SetItemText(0, 2, productinfo.productName); 
	} 
}