www.pudn.com > duanxinfangwei.rar > DbInterface.h


// DbInterface.h: interface for the CDbInterface class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_DBINTERFACE_H__33CCB0D2_898C_4F85_B4BF_44706EF9F0A7__INCLUDED_) 
#define AFX_DBINTERFACE_H__33CCB0D2_898C_4F85_B4BF_44706EF9F0A7__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
#include  
 
//加入ADO支持库 
#import "msado15.dll" \ 
	no_namespace \ 
	rename ("EOF", "adoEOF")  
 
/* 数据库连接宏 */ 
#define DATASOURCE_ACCESS	_T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%sslnsoftsmspre.mdb;Jet OLEDB:Database Password=slnsoft1982") 
#define DATAUSER	_T("") 
#define DATAPWD		_T("") 
 
/* 防伪号有效性 */ 
#define OKCODE				0		//正常防伪号 
#define NGCODE				1		//假冒防伪号 
/* 出厂状态 */ 
#define INFACTORY			0		//未出厂 
#define OUTFACTORY			1		//已出厂 
#define NGFACTORY			-1		//假厂 
/* 显示状态 */ 
#define	DSPED				1		//已显示 
#define UNDSP				0		//未显示 
/* 假冒的产品ID */ 
#define VAILPRODUCT			-1 
 
/* 结构体定义 */ 
//产品信息 
typedef struct  
{ 
	int		productId;		//产品ID 
	CString productName;	//产品名 
	CString entertime;		//进入系统时间 
}PRODUCTINFO, *PPRODUCTINFO; 
 
//防伪号信息 
typedef struct 
{ 
	CString code;			//防伪码 
	int		querytimes;		//查询次数 
	int		productId;		//产品ID 
	int		outflag;		//出厂标志 
	int		stateflag;		//号码状态 
	CString gentime;		//生成批号 
}CODEINFO, *PCODEINFO; 
 
//查询记录 
typedef struct 
{ 
	CString queryer;		//查询者(手机/IP) 
	CString querytime;		//查询时间 
	CString queryinfo;		//查询信息 
	int		dspFlag;		//显示标志 
}QUERYREC, *PQUERYREC; 
 
class CDbInterface   
{ 
public: 
	bool GetInvalidationCodeList(std::list &codeinfolist); 
	bool GetQueryedMulCodeList(std::list &codeinfolist); 
	bool GetProductInfo(int productId, PRODUCTINFO &productInfo); 
	bool GetQueryedCodeList(std::list &codeinfolist); 
	bool GetQueryRecList(std::list& queryRecList, int dspConditon); 
	bool AppendQueryRec(QUERYREC queryrec); 
	bool GetCodeInfo(CODEINFO &codeinfo); 
	bool UpdateCodeQueryTimes(CString code); 
	bool AppendNewCode(CODEINFO codeinfo); 
	bool CheckCodeExist(CString code, bool& existflag); 
	bool GetProductInfo(CString productName, PRODUCTINFO &productInfo); 
	bool GetProductList(std::list &productList); 
	bool CheckProduct(CString productName, bool& existFlag); 
	bool AppendNewProduct(CString productName); 
	CDbInterface(); 
	virtual ~CDbInterface(); 
 
private: 
	CString DATASOURCE; 
protected: 
	bool GetCodeList(CString sql, std::list &codeinfolist); 
}; 
 
#endif // !defined(AFX_DBINTERFACE_H__33CCB0D2_898C_4F85_B4BF_44706EF9F0A7__INCLUDED_)