⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbaccess.cpp

📁 手机编程之接收发送短信
💻 CPP
字号:
// DBAccess.cpp: implementation of the CDBAccess class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DBAccess.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

CDBAccess DBAccess;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CDBAccess::CDBAccess()
{

}

CDBAccess::~CDBAccess()
{
    delete pTable;
}

int CDBAccess::InitDB(char *pszConnStr)
{
    int nRetCode = 0;
    pTable =new CAdoTable(pszConnStr);
    int n = 0;
    while(EV_ERR_OK != (nRetCode = pTable->ConnectDB()))
    {
        if(n > 3) break;
        n++;
        Sleep(1000);
    }
    return nRetCode;
}

int CDBAccess::DBRequest(char *pszSvcCode, char *pszReqStr, char *pszRstStr)
{
    memset(szSql,0,sizeof(szSql));
	_snprintf(szSql, 256, "proc_csgp_get_data_%s %s", pszSvcCode, pszReqStr);
    
	if(!pTable->ExcuteSql(szSql))
    {
        return -1;
    }
    int nRet = pTable->ReadField("RstData", pszRstStr);
    if(nRet != EV_ERR_OK) return -2;

    return 0;
}

int CDBAccess::DealNoteSms(char *pszCallerID,char *pszContent,char *szID)
{
	
	memset(szSql,0,sizeof(szSql));
	CString strSq;
	_snprintf(szSql, 256, "select top 1 id,Phone,Content from OutBox where bSendOut = 0 order by id desc");
	strSq = szSql;
	if(!pTable->ExcuteSql(szSql)){
		return -1;
	}

	int nRet = pTable->ReadField("id", szID);
	if (nRet != EV_ERR_OK) {
		return -1;
	}

	nRet = pTable->ReadField("Phone", pszCallerID);
	if (nRet != EV_ERR_OK) {
		return -1;
	}

	nRet = pTable->ReadField("Content", pszContent);
	if (nRet != EV_ERR_OK) {
		return -1;
	}
	
	memset(szSql,0,sizeof(szSql));

	_snprintf(szSql, 256, "update OutBox set bSendOut =1 where id=%s",szID);
	if(!pTable->ExcuteSql(szSql)){
		return -1;
	}
	return 1;
}


int CDBAccess::InsertRcvdMessge(char *pszPhone, char *pszContent, char *pszTime)
{
	memset(szSql,0,sizeof(szSql));
	CString strSq;
	_snprintf(szSql, 256, "insert into InBox (Phone,Content,ReceiveTime) values(\'%s\',\'%s\',\'%s\')",pszPhone,pszContent,pszTime);
	strSq = szSql;
	if(!pTable->ExcuteSql(szSql)){
		return -1;
	}

	return 1;
}

int CDBAccess::UpdateState(char *szSql)
{
	if(!pTable->ExcuteSql(szSql)){
		return -1;
	}

	return 1;
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -