- // SaioSqlce.cpp: implementation of the CDBManage class.
- //
- //
- #ifndef SAIOSQLCE_DLL_FILE
- #define SAIOSQLCE_DLL_FILE
- #endif
- #include "stdafx.h"
- #include "SAIOSQLCEDBManage.h"
- #include "SaioSqlce.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //本机数据库文件
- #define CUP_DB_FILE _T("//Saio//User Programs//WIC//WICDB.sdf")
- #define CUP_DB_TEMP _T("//Saio//User Programs//WIC//WICDB.sd2")
- //
- // Construction/Destruction
- //
- CDBManage::CDBManage()
- {
- }
- CDBManage::~CDBManage()
- {
- }
- //打开数据库
- BOOL CDBManage::OpenDB()
- {
- InitConnectvariable(_T("//Saio//User Programs//WIC//WICDB.sdf"));
- return OpenConnection();
- }
- //关闭数据库
- BOOL CDBManage::CloseDB()
- {
- BOOL bRet = TRUE;
- bRet = CloseRecordset();
- bRet &= CloseConnection();
- return bRet;
- }
- //收缩数据库
- BOOL CDBManage::ShrinkDB() //需要修改
- {
- CloseDB();
- TCHAR szDbPwd[] = _T(""); //如果有密码需要填入
- BOOL bRet = TRUE, bDelRet=FALSE;
- DWORD dwErr = 0;
- HRESULT hr = NOERROR;
- DBPROPSET dbpropset[2];
- DBPROP dbprop[2];
- IDBProperties *pIDBProperties = NULL;
- IDBCreateSession *pIDBCreateSession = NULL;
- ISSCECompact *pISSCECompact = NULL;
- IDBSchemaRowset *pIDBSchemaRowset = NULL;
- VariantInit(&dbprop[0].vValue);
- hr = CoCreateInstance(CLSID_SQLSERVERCE_2_0, 0, CLSCTX_INPROC_SERVER, IID_IDBProperties, (void**) &pIDBProperties);
- if(FAILED(hr))
- {
- dwErr = GetLastError();
- bRet = FALSE;
- goto Exit;
- }
- dbprop[0].dwPropertyID = DBPROP_INIT_DATASOURCE;
- dbprop[0].dwOptions = DBPROPOPTIONS_REQUIRED;
- dbprop[0].vValue.vt = VT_BSTR;
- dbprop[0].vValue.bstrVal = SysAllocString(CUP_DB_FILE);
- if(NULL == dbprop[0].vValue.bstrVal)
- {
- hr = E_OUTOFMEMORY;
- dwErr = GetLastError();
- bRet = FALSE;
- goto Exit;
- }
- dbprop[1].dwPropertyID = DBPROP_SSCE_DBPASSWORD;
- dbprop[1].dwOptions = DBPROPOPTIONS_REQUIRED;
- dbprop[1].vValue.vt = VT_BSTR;
- dbprop[1].vValue.bstrVal = SysAllocString(szDbPwd);
- dbpropset[0].guidPropertySet = DBPROPSET_DBINIT;
- dbpropset[0].rgProperties = dbprop;
- dbpropset[0].cProperties = 1;
- ;
- dbpropset[1].guidPropertySet = DBPROPSET_SSCE_DBINIT;
- dbpropset[1].rgProperties = &dbprop[1];
- dbpropset[1].cProperties = 1;
- hr = pIDBProperties->SetProperties(2, dbpropset);
- if(FAILED(hr))
- {
- dwErr = GetLastError();
- bRet = FALSE;
- goto Exit;
- }
- hr = pIDBProperties->QueryInterface(IID_ISSCECompact, (void **) &pISSCECompact);
- if(FAILED(hr))
- {
- dwErr = GetLastError();
- bRet = FALSE;
- goto Exit;
- }
- bDelRet = DeleteFile(CUP_DB_TEMP);
- SysFreeString(dbprop[0].vValue.bstrVal);
- dbprop[0].vValue.bstrVal = SysAllocString(CUP_DB_TEMP);
- if(NULL == dbprop[0].vValue.bstrVal)
- {
- hr = E_OUTOFMEMORY;
- dwErr = GetLastError();
- bRet = FALSE;
- goto Exit;
- }
- hr = pISSCECompact->Compact(1, dbpropset);
- if(FAILED(hr))
- {
- dwErr = GetLastError();
- bRet = FALSE;
- goto Exit;
- }
- bDelRet = CopyFile(CUP_DB_TEMP, CUP_DB_FILE, FALSE);
- if(bDelRet)
- {
- bDelRet = DeleteFile(CUP_DB_TEMP);
- }
- Exit:
- VariantClear(&dbprop[0].vValue);
- if(NULL != pISSCECompact)
- {
- pISSCECompact->Release();
- }
- if(NULL != pIDBSchemaRowset)
- {
- pIDBSchemaRowset->Release();
- }
- if(NULL != pIDBCreateSession)
- {
- pIDBCreateSession->Release();
- }
- if(NULL != pIDBProperties)
- {
- pIDBProperties->Release();
- }
- return bRet;
- }
- //初始化系统数据库
- BOOL CDBManage::InitDB()
- {
- BOOL bRet = TRUE;
- //关闭记录
- CloseRecordset();
- //用户表
- bRet &= InitUserTable();
- //参数表
- bRet &= InitParamTable();
- //APL表
- bRet &= InitAPLTable();
- //价格表
- bRet &= InitPriceTable();
- //传输表
- bRet &= InitTransTable();
- //更新表
- bRet &= InitUpdateTable();
- return bRet;
- }
- //初始化用户表
- BOOL CDBManage::InitUserTable()//ok
- {
- BOOL bRet = TRUE;
- //删除用户表
- CString csSql = _T("DROP Table UserTb");
- ExecuteSQL(csSql);
- //新建用户表
- csSql = _T("CREATE TABLE UserTb(uid nvarchar(6) PRIMARY KEY, pwd nvarchar(6) NOT NULL, privilege nchar(1) NOT NULL);");
- bRet &= ExecuteSQL(csSql);
- // CString csPwd = CMd5::Encrypt(_T("1234"));
- // csSql.Format(_T("INSERT INTO UserTb(uid, pwd, privilege) VALUES('1234', '%s', '1');"), csPwd);
- //如果需要加密采取以上的方法(:~
- //添加普通用户 Cashier (1234/1234/1)
- csSql = _T("INSERT INTO UserTb(uid, pwd, privilege) VALUES('1234', '1234', '1');");
- bRet &= ExecuteSQL(csSql);
- // csPwd = CMd5::Encrypt(_T("123456"));
- // csSql.Format(_T("INSERT INTO UserTb(uid, pwd, privilege) VALUES(123456, '%s', 2);"), csPwd);
- //如果需要加密采取以上的方法(:~
- //添加主管操作员 Admin (123456/123456/2)
- csSql = _T("INSERT INTO UserTb(uid, pwd, privilege) VALUES('123456', '123456', '2');");
- bRet &= ExecuteSQL(csSql);
- return bRet;
- }
- BOOL CDBManage::InitParamTable()//ok
- {
- BOOL bRet = TRUE;
- //删除Param表
- CString csSql = _T("DROP Table ParamTb");
- ExecuteSQL(csSql);
- //新建APL表
- csSql = _T("CREATE TABLE ParamTb (pid smallint PRIMARY KEY, pname nvarchar(30), pvalue nvarchar(40));");
- bRet &= ExecuteSQL(csSql);
- return bRet;
- }
- BOOL CDBManage::InitAPLTable()//ok
- {
- BOOL bRet = TRUE;
- //删除APL表
- CString csSql = _T("DROP Table APLTb");
- ExecuteSQL(csSql);
- //新建APL表
- csSql = _T("CREATE TABLE APLTb(upc nvarchar(17) PRIMARY KEY, description nvarchar(50), category nchar(2), subcategory nchar(3), punit nvarchar(10), maxprice nchar(6), ptype nchar(2));");
- bRet &= ExecuteSQL(csSql);
- //--------------------------临时插入测试数据 jacky 2008-10-18-----------
- csSql = _T("INSERT INTO APLTb VALUES('TestUPC1', 'JustForTest1', '1', '1-1', 'Unit1', '40.25', '1');");
- bRet &= ExecuteSQL(csSql);
- csSql = _T("INSERT INTO APLTb VALUES('TestUPC2', 'JustForTest2', '2', '2-1', 'Unit2', '2.01', '2');");
- bRet &= ExecuteSQL(csSql);
- csSql = _T("INSERT INTO APLTb VALUES('TestUPC3', 'JustForTest3', '3', '3-1', 'Unit3','1.2', '1');");
- bRet &= ExecuteSQL(csSql);
- //---------------------------End 插入测试数据--------------------------
- return bRet;
- }
- BOOL CDBManage::InitPriceTable()//ok
- {
- BOOL bRet = TRUE;
- //删除Price表
- CString csSql = _T("DROP Table PriceTb");
- ExecuteSQL(csSql);
- //新建Price表
- csSql = _T("CREATE TABLE PriceTb (upc nchar(17) PRIMARY KEY, price nchar(6));");
- bRet &= ExecuteSQL(csSql);
- //--------------------------临时插入测试数据 jacky 2008-10-18-----------
- //MessageBox(NULL, _T("Init PriceTb Data"), _T("OpenRecordset"), MB_OK);
- csSql = _T("INSERT INTO PriceTb VALUES('a1b2c3d4', '12.34');");
- bRet &= ExecuteSQL(csSql);
- csSql = _T("INSERT INTO PriceTb VALUES('TestUPC1', '34.45');");
- bRet &= ExecuteSQL(csSql);
- csSql = _T("INSERT INTO PriceTb VALUES('TestUPC2', '0.45');");
- bRet &= ExecuteSQL(csSql);
- //---------------------------End 插入测试数据--------------------------
- return bRet;
- }
- BOOL CDBManage::InitTransTable()//ok
- {
- BOOL bRet = TRUE;
- //删除Trans表
- CString csSql = _T("DROP Table TransTb");
- ExecuteSQL(csSql);
- //新建Trans表
- csSql = _T("CREATE TABLE TransTb (traceid nchar(6) PRIMARY KEY, msgtype nchar(4), amount nchar(12), uid nchar(4), transdate nchar(6), transtime nchar(6), aiicode nvarchar(12));");
- bRet &= ExecuteSQL(csSql);
- //--------------------------临时插入测试数据 jacky 2008-10-18-----------
- csSql = _T("INSERT INTO TransTb VALUES('001', '1', '10', '1234', '081018', '143302', '0810181433');");
- bRet &= ExecuteSQL(csSql);
- csSql = _T("INSERT INTO TransTb VALUES('002', '2', '20', '1234', '061018', '143366', '0610181433');");
- bRet &= ExecuteSQL(csSql);
- csSql = _T("INSERT INTO TransTb VALUES('003', '3', '30', '1234', '081018', '143100', '0810181431');");
- bRet &= ExecuteSQL(csSql);
- // //---------------------------End 插入测试数据--------------------------
- return bRet;
- }
- BOOL CDBManage::InitUpdateTable()//ok
- {
- BOOL bRet = TRUE;
- //删除Update表
- CString csSql = _T("DROP Table UpdateTb");
- ExecuteSQL(csSql);
- //新建Update表
- csSql = _T("CREATE TABLE UpdateTb (tid nchar(2) PRIMARY KEY, tname nvarchar(20), lupdate nchar(6), luptime nchar(6));");
- bRet &= ExecuteSQL(csSql);
- return bRet;
- }
- BOOL CDBManage::AnalyzeBalance(BIItem biInput, Balance *balOutput)
- {
- // 1 根据byCategory bySubCategory
- // 2 ==>获得 upc
- // 3 ==> 让后查询APLTb,获取相关信息
- CString csSQL;
- WCHAR wcCategory[2];
- WCHAR wcSubCategory[3];
- VARIANT varUPC;
- VARIANT varUnit;
- VARIANT varDescription;
- VariantInit (&varUPC);
- VariantInit (&varUnit);
- VariantInit (&varDescription);
- BOOL bRet = TRUE;
- DWORD dwNum;
- char TempArray[50];
- if (balOutput == NULL)
- return FALSE;
- memcpy (TempArray, biInput.byCategory, sizeof(biInput.byCategory));
- dwNum = MultiByteToWideChar (CP_ACP, 0, TempArray, -1, NULL, 0);
- MultiByteToWideChar (CP_ACP, 0, TempArray, -1, wcCategory, dwNum);
- memcpy (TempArray, biInput.bySubCategory, sizeof(biInput.bySubCategory));
- dwNum = MultiByteToWideChar (CP_ACP, 0, TempArray, -1, NULL, 0);
- MultiByteToWideChar (CP_ACP, 0, TempArray, -1, wcSubCategory, dwNum);
- csSQL.Format(_T("SELECT * FROM APLTb WHERE category='%s' AND subcategory ='%s';"), wcCategory, wcSubCategory);
- MessageBox(NULL, csSQL, _T("OpenRecordset"), MB_OK);
- // bRet &= ExecuteSQL(csSQL);
- bRet &= OpenRecordset(csSQL);
- if(GetRecordCount(csSQL) == 0)//无法匹配
- {
- return (bRet &= FALSE);
- }
- else
- {
- MoveFirst();
- varUPC = GetCollect(_T("upc"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, varUPC.bstrVal, -1, NULL, 0, NULL, FALSE);
- WideCharToMultiByte (CP_OEMCP, NULL, varUPC.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- //strcpy(balOutput->szItemUPC, "hello");
- //Errorr ???? Jacky 2008-10-11
- //memcpy (balOutput->szItemUPC, "1234", 4);
- memcpy (balOutput->szItemUPC, TempArray, dwNum);
- // for ( int iUPC = 0; iUPC < (int)dwNum ; iUPC++)
- // {
- // balOutput->szItemUPC[iUPC] = TempArray[iUPC];
- // }s
- MessageBox(NULL, varUPC.bstrVal, _T("OpenRecordset"), MB_OK);
- varUnit = GetCollect(_T("punit"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, varUnit.bstrVal, -1, NULL, 0, NULL, FALSE);
- WideCharToMultiByte (CP_OEMCP, NULL, varUnit.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- //memcpy (balOutput->szUnit, TempArray, dwNum);
- //strncpy(balOutput->szUnit, TempArray, dwNum);
- MessageBox(NULL, varUnit.bstrVal, _T("OpenRecordset"), MB_OK);
- varDescription = GetCollect(_T("description"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, varDescription.bstrVal, -1, NULL, 0, NULL, FALSE);
- WideCharToMultiByte (CP_OEMCP, NULL, varDescription.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- //memcpy (balOutput->szItemDesc, TempArray, dwNum);
- //strncpy(balOutput->szItemDesc, TempArray, dwNum);
- MessageBox(NULL, varDescription.bstrVal, _T("OpenRecordset"), MB_OK);
- // for (int i = 0; i < sizeof(biInput.byBenefitQuantity); i++)
- // {
- // balOutput->szBenefitQuantity[i] = biInput.byBenefitQuantity[i];
- // }
- //memcpy (balOutput->szBenefitQuantity, biInput.byBenefitQuantity, sizeof(balOutput->szBenefitQuantity));
- }
- return bRet;
- }
- BOOL CDBManage::GetItemFromUPC(CString csUPC, ItemList *ilOutput)
- {
- CString csSql;
- BOOL bRet = TRUE;
- if (csUPC.GetLength() >= 17) //UPC长度过长
- {
- return FALSE;
- }
- csSql.Format(_T("SELECT * FROM APLTb,PriceTb WHERE APLTB.upc=PriceTb.upc AND APLTB.upc ='%s';"), csUPC);
- bRet &= OpenRecordset(csSql);
- if (GetRecordCount(csSql) == 0)
- {
- return FALSE;
- }
- else
- {
- //++ 添加向ItemList保存数据的过程 jacky 2008-10-20
- }
- return bRet;
- }
- BOOL CDBManage::GetItemFromCategory(CString csCategory, CString csSubcategory, Balance *balOutput, EndBalance *ebalOutput)
- {
- BOOL bRet = TRUE;
- return bRet;
- }
- BOOL CDBManage::SetItemPrice(CString csUpc,CString csPrice) //测试完毕
- {
- BOOL bRet = TRUE;
- CString csSQL;
- if ( (csUpc.GetLength()>17) || (csPrice.GetLength()>6) )//字符长度过长
- {
- return FALSE;
- }
- // if () //检查价格格式的合法性?? 如果有必要的话
- // {
- // }
- //Update Field
- csSQL.Format (_T("UPDATE PriceTb SET price='%s' WHERE upc='%s';"), csPrice, csUpc);
- bRet &= ExecuteSQL(csSQL);
- //Make sure that field is updated,Checkit
- csSQL.Format (_T("SELECT * FROM PriceTb WHERE upc='%s' AND price='%s';"), csUpc, csPrice);
- if (GetRecordCount(csSQL) == 0)//The record doesn't exist
- {
- bRet &= FALSE;
- }
- return bRet;
- }
- BOOL CDBManage::CheckPwdData(CString csUid, CString csPwd)//测试完毕
- {
- BOOL bRet = TRUE;
- CString csSql;
- if ( (csUid.GetLength()>6) || (csPwd.GetLength()>6) )//字符长度过长
- {
- return FALSE;
- }
- csSql.Format (_T("SELECT uid FROM UserTb WHERE uid='%s'AND pwd='%s';"), csUid, csPwd);
- //bRet &= ExecuteSQL(csSql);
- if (GetRecordCount(csSql) == 0)//记录不存在
- {
- bRet &= FALSE;
- }
- return bRet;
- }
- BOOL CDBManage::CheckParamData(){BOOL bRet = TRUE;return bRet;}
- BOOL CDBManage::CheckCardData(){BOOL bRet = TRUE;return bRet;}
- BOOL CDBManage::CheckResponseCode(){BOOL bRet = TRUE;return bRet;}
- BOOL CDBManage::CheckUPC(){BOOL bRet = TRUE;return bRet;}
- BOOL CDBManage::CheckNSF(){BOOL bRet = TRUE;return bRet;}
- BOOL CDBManage::CheckAmountData(){BOOL bRet = TRUE;return bRet;}
- BOOL CDBManage::CheckCountData(){BOOL bRet = TRUE;return bRet;}
- BOOL CDBManage::GetLastTransData(LastTransaction *ltGet)
- {
- VARIANT vTraceid;
- VARIANT vMsgtype;
- VARIANT vAmount;
- VARIANT vUid;
- VARIANT vTransdate;
- VARIANT vTranstime;
- VARIANT vAiicode;
- VariantInit (&vTraceid);
- VariantInit (&vMsgtype);
- VariantInit (&vAmount);
- VariantInit (&vUid);
- VariantInit (&vTransdate);
- VariantInit (&vTranstime);
- VariantInit (&vAiicode);
- BOOL bRet = TRUE;
- char TempArray[20]; //将Unicode转换为ASCII
- LONG lRcdSize;
- CString csSql = _T("SELECT * FROM TransTb;");
- DWORD dwNum;
- if (ltGet == NULL)
- return FALSE;
- // bRet &= ExecuteSQL(csSql);
- // bRet &= MoveFirst();
- // MessageBox(NULL, csSql, _T("OpenRecordset"), MB_OK);
- bRet &= OpenRecordset(csSql);
- if ((lRcdSize=GetRecordCount(csSql)) == 0)//如果当前数据记录为空
- {
- return (bRet &= FALSE);
- }
- else
- {
- MoveFirst();
- for (long i = 0; i < lRcdSize-1; i++)
- /* while(!IsEOF())//移动到最后一条记录*/
- {
- MoveNext();
- }
- // vTranstime = GetCollect(_T("transtime"));
- // MessageBox(NULL, vTranstime.bstrVal, _T("transtime"), MB_OK);
- vTraceid = GetCollect (_T("traceid"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, vTraceid.bstrVal, -1, NULL, 0, NULL, FALSE); //确定转换字节大小
- WideCharToMultiByte (CP_OEMCP, NULL, vTraceid.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- memcpy (ltGet->TraceNum, TempArray, dwNum);
- vMsgtype = GetCollect(_T("msgtype"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, vMsgtype.bstrVal, -1, NULL, 0, NULL, FALSE);
- WideCharToMultiByte (CP_OEMCP, NULL, vMsgtype.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- memcpy (ltGet->byMsgType, TempArray, dwNum);
- vAmount = GetCollect(_T("amount"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, vAmount.bstrVal, -1, NULL, 0, NULL, FALSE);
- WideCharToMultiByte (CP_OEMCP, NULL, vAmount.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- memcpy (ltGet->byTransAmount, TempArray, dwNum);
- vUid = GetCollect(_T("uid"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, vUid.bstrVal, -1, NULL, 0, NULL, FALSE);
- WideCharToMultiByte (CP_OEMCP, NULL, vUid.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- memcpy (ltGet->byCashierID, TempArray, dwNum);
- vTransdate = GetCollect(_T("transdate"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, vTransdate.bstrVal, -1, NULL, 0, NULL, FALSE);
- WideCharToMultiByte (CP_OEMCP, NULL, vTransdate.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- memcpy (ltGet->byLocalTransDate, TempArray, dwNum);
- vTranstime = GetCollect(_T("transtime"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, vTranstime.bstrVal, -1, NULL, 0, NULL, FALSE);
- WideCharToMultiByte (CP_OEMCP, NULL, vTranstime.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- memcpy (ltGet->byLocalTransTime, TempArray, dwNum);
- vAiicode = GetCollect(_T("aiicode"));
- dwNum = WideCharToMultiByte (CP_OEMCP, NULL, vAiicode.bstrVal, -1, NULL, 0, NULL, FALSE);
- WideCharToMultiByte (CP_OEMCP, NULL, vAiicode.bstrVal, -1, TempArray, dwNum, NULL, FALSE);
- memcpy (ltGet->byAcquirerCode, TempArray, dwNum);
- }
- return bRet;
- }
- //LastTransaction ltExample={"004", "4", "40", "123", "08102", "11111", "08102011111"};
- //LastTransaction ltExample={"004", "4", "40", "1234", "081020", "111111", "081020111111"};
- BOOL CDBManage::SetLastTransData(LastTransaction ltSet)//OK,但是LastTransaction初始化并没有达到实际的大小
- {
- WCHAR wcTraceNum[6];
- WCHAR wcMsgType[4];
- WCHAR wcTransAmount[12];
- WCHAR wcCashierID[4];
- WCHAR wcLTDate[6];
- WCHAR wcLTTime[6];
- WCHAR wcAcquirerCode[12];
- // CString strTraceNum = ltSet.TraceNum;
- // CString strMsgType = ltSet.byMsgType;
- // CString strTransAmount = ltSet.byTransAmount;
- // CString strCashierID = ltSet.byCashierID;
- // CString strLTDate = ltSet.byLocalTransDate;
- // CString strLTTime = ltSet.byLocalTransTime;
- // CString strAcquirerCode = ltSet.byAcquirerCode;
- char TempArray[20];
- BOOL bRet = TRUE;
- CString csSQL;
- DWORD dwNum ;
- memcpy (TempArray, ltSet.TraceNum, sizeof(ltSet.TraceNum));
- dwNum = MultiByteToWideChar (CP_ACP, 0, TempArray, -1, NULL, 0);
- MultiByteToWideChar (CP_ACP, 0, TempArray, -1, wcTraceNum, dwNum);
- memcpy (TempArray, ltSet.byMsgType, sizeof(ltSet.byMsgType));
- dwNum = MultiByteToWideChar (CP_ACP, 0, TempArray, -1, NULL, 0);
- MultiByteToWideChar (CP_ACP, 0, TempArray, -1, wcMsgType, dwNum);
- memcpy (TempArray, ltSet.byTransAmount, sizeof(ltSet.byTransAmount));
- dwNum = MultiByteToWideChar (CP_ACP, 0, TempArray, -1, NULL, 0);
- MultiByteToWideChar (CP_ACP, 0, TempArray, -1, wcTransAmount, dwNum);
- memcpy (TempArray, ltSet.byCashierID, sizeof(ltSet.byCashierID));
- dwNum = MultiByteToWideChar (CP_ACP, 0, TempArray, -1, NULL, 0);
- MultiByteToWideChar (CP_ACP, 0, TempArray, -1, wcCashierID, dwNum);
- memcpy (TempArray, ltSet.byLocalTransDate, sizeof(ltSet.byLocalTransDate));
- dwNum = MultiByteToWideChar (CP_ACP, 0, TempArray, -1, NULL, 0);
- MultiByteToWideChar (CP_ACP, 0, TempArray, -1, wcLTDate, dwNum);
- memcpy (TempArray, ltSet.byLocalTransTime, sizeof(ltSet.byLocalTransTime));
- dwNum = MultiByteToWideChar (CP_ACP, 0, TempArray, -1, NULL, 0);
- MultiByteToWideChar (CP_ACP, 0, TempArray, -1, wcLTTime, dwNum);
- memcpy (TempArray, ltSet.byAcquirerCode, sizeof(ltSet.byAcquirerCode));
- dwNum = MultiByteToWideChar (CP_ACP, 0, TempArray, -1, NULL, 0);
- MultiByteToWideChar (CP_ACP, 0, TempArray, -1, wcAcquirerCode, dwNum);
- csSQL.Format(_T("INSERT INTO TransTb VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s');"),
- wcTraceNum,
- wcMsgType,
- wcTransAmount,
- wcCashierID,
- wcLTDate,
- wcLTTime,
- wcAcquirerCode);
- bRet &= ExecuteSQL(csSQL);
- //查找一下,看是否真的已经插入数据库的表
- csSQL.Format(_T("SELECT * FROM TransTb WHERE traceid = '%s';"),wcTraceNum);
- if(GetRecordCount(csSQL) == 0)//记录不存在
- {
- bRet &= FALSE;
- }
- return bRet;
- }
DBManager.h
最新推荐文章于 2021-03-24 12:24:51 发布