INT32 CJSKDeclareProc::DelUploadInv()
{
	CDataInvHead dataInvHead;
	CInvServ invServ;
	INT8 sqlbuf[128];
	string strErr("");
	INT32 retcode = 0;
	
	retcode = CJSKInfoFunc::GetFirstOffInvInfo(&dataInvHead, strErr);
	if(retcode == JSK_SUCCESS)
	{
		if(dataInvHead.m_fphm != 0)
		{
			memset(sqlbuf, 0, sizeof(sqlbuf));
			sprintf(sqlbuf, "where FPDM='%s' and FPHM=%u ", dataInvHead.m_fpdm.c_str(), dataInvHead.m_fphm);
			DBG_PRINT(("sqlbuf = %s", sqlbuf));
			invServ.m_filter.append(sqlbuf);
			invServ.Requery();
			if(invServ.LoadOneRecord() == SQLITE_OK)
			{
				memset(sqlbuf, 0, sizeof(sqlbuf));
				sprintf(sqlbuf, "where NO < %u ", invServ.m_no);
				DBG_PRINT(("sqlbuf = %s", sqlbuf));
				invServ.m_filter.append(sqlbuf);
				invServ.Delete();
			}
		}
		else
		{
			invServ.Delete();
		}
	}
	
	return JSK_SUCCESS;
}
Пример #2
0
INT32 CJSKMakeInvoice::FPGX_Proc(string scqrbw, string &strErr)
{
	INT32 retcode = JSK_SUCCESS;
	string mxjgmw("");

	if( ParseFpscjg(scqrbw, mxjgmw, strErr) != JSK_SUCCESS )
	{
		//return JSK_FAILURE;
		return JSK_SUCCESS;
	}

	UINT8 upInfo[JSK_LXXXMW_LEN+1];
	memset(upInfo, 0, sizeof(upInfo));
	sprintf((INT8 *)upInfo, "%s", mxjgmw.c_str());
	DBG_PRINT(("upInfo = %s", upInfo));

	int nLen = mxjgmw.length();
	DBG_PRINT(("nLen = %d", nLen));
	Base64_Decode_2((INT8 *)upInfo, &nLen);
	DBG_PRINT(("nLen = %d", nLen));

	retcode = CJSKInfoFunc::SetUpLoadFlag(upInfo, nLen, strErr);
	if(retcode != JSK_SUCCESS)
	{
		return retcode;
	}

	//删除INV_SERV中已上传的发票信息
	INT8 sqlbuf[128];
	CInvServ invServ;
	memset(sqlbuf, 0, sizeof(sqlbuf));
	sprintf(sqlbuf, "where UP_FLAG=1 ");
	DBG_PRINT(("sqlbuf = %s", sqlbuf));
	invServ.m_filter.append(sqlbuf);
	invServ.Requery();
	invServ.LoadOneRecord();

	invServ.m_filter.append(sqlbuf);
	retcode = invServ.Delete();
	if(retcode != SQLITE_OK)
	{
		retcode = JSK_COMMON_ERR_NO;
		strErr = "删除已上传发票信息错误";
		//return retcode;
	}
	else
	{
		g_globalArgLib->m_InvServNum--;
		if(invServ.m_issuetype == NORMAL_INV)
		g_globalArgLib->m_InvServSum -= invServ.m_moneySum;
	}

	return JSK_SUCCESS;
}
int CMaintenanceMenu::ProcEvent(int iEvent,unsigned char *pEventData, int iDataLen)
{
	if (LOCKED_KEY == iEvent || ESC_KEY == iEvent)
	{
		CaMsgBox msgBox("退出当前操作员?",CaMsgBox::MB_YESNO);
		msgBox.ShowBox();	
		if (msgBox.m_iStatus == OK_PRESSED)
		{	
			ChangeWin(LOGIN_WIN);
			return SUCCESS;
		}
	}

#if (0 == RELEASE_VER)
	CInvServ invServ;
	INT32 nErrCode;
	INT8 chValue[64];
	memset((void*)chValue, 0, sizeof(chValue));
	if(DISCOUNT_KEY == iEvent)
	{
		invServ.Requery();
		invServ.LoadOneRecord();

		sprintf(chValue, "where no = %u", invServ.m_no);
		invServ.m_filter = chValue;
		nErrCode = invServ.Delete();
		if (SQLITE_OK != nErrCode)
		{
			CaMsgBox::ShowMsg("删除第一条失败");
			return FAILURE;
		}
		CaMsgBox::ShowMsg("删除第一条成功");
		
		if(0 != g_globalArg->m_InvServNum)
		{
          g_globalArg->m_InvServNum--;
		}
		DBG_PRINT(("m_InvServNum = %u", g_globalArg->m_InvServNum ));
		return SUCCESS;
	}

#endif

	return CMultiBtnCommonWin::ProcEvent(iEvent,pEventData,iDataLen);
}
Пример #4
0
INT32 CJSKMakeInvoice::GetErrUpInv(CDataInvServ *pDataInvServ, UINT32 &nCount, string &strErr)
{
	CInvServ invServ;
	INT8 sqlbuf[128];
	UINT32 i = 0;

	memset(sqlbuf, 0, sizeof(sqlbuf));
	sprintf(sqlbuf, "where UP_FLAG = %d", INV_UPLOAD_FLAG2);
	invServ.m_filter.append(sqlbuf);
	nCount = invServ.GetRecordNum();
	DBG_PRINT(("nCount = %u", nCount));

	if(nCount > MAX_ERR_INV_COUNT)
		nCount = MAX_ERR_INV_COUNT;

	invServ.m_filter.append(sqlbuf);
	invServ.Requery();
	UINT32 retCode = invServ.MoveFirst();
	while(retCode == SQLITE_ROW)
	{
		pDataInvServ[i].m_fpdm = invServ.m_code;
		pDataInvServ[i].m_fphm = invServ.m_InvNo;
		pDataInvServ[i].m_errMsg = invServ.m_errMsg;

		i++;
		if(i >= nCount)
			break;
		retCode = invServ.MoveNext();
	}
	invServ.MoveEnd();

	return JSK_SUCCESS;
}
Пример #5
0
INT32 CJSKMakeInvoice::ParseFpscjg(string scqrbw, string &mxjgmw, string &strErr)
{
	UINT8 upInfo[JSK_MAKE_INV_SIGN_LEN];
	
	memset(upInfo, 0, sizeof(upInfo));
	sprintf((INT8 *)upInfo, "%s", scqrbw.c_str());
	
	int nLen = scqrbw.length();
	DBG_PRINT(("nLen = %d", nLen));
	Base64_Decode_2((INT8 *)upInfo, &nLen);
	DBG_PRINT(("nLen = %d", nLen));
	DBG_PRINT(("upInfo = %s", upInfo));
	
	//接收数据写文件
	FILE *fp;	
	if( (fp = fopen(XML_FPSCJGHQ_FILE, "wb")) == NULL )
	{
		strErr = "解析发票上传结果错误!";
		return JSK_FAILURE;
	}
	fwrite( (void *)upInfo, nLen, 1, fp);
	fclose(fp);
	

	XMLParse xmlParse;
	int res = 0;
	string tmpCode("");
	string strFphm("");

	res = xmlParse.XMLParseBegin(XML_FPSCJGHQ_FILE);
	xmlParse.LocateNodeByName(xmlParse.m_RootElement, "OUTPUT");
	xmlParse.m_parentElement[1] = xmlParse.m_Child;

	xmlParse.LocateNodeByName(xmlParse.m_parentElement[1], "CODE");
	tmpCode = xmlParse.GetText();
	if(tmpCode != "0000")
	{
		xmlParse.LocateNodeByName(xmlParse.m_parentElement[1], "MESS");
		strErr = xmlParse.GetText();

		xmlParse.XMLParseEnd();
		return JSK_FAILURE;
	}
	
	xmlParse.LocateNodeByName(xmlParse.m_parentElement[1], "DATA");
	xmlParse.m_parentElement[2] = xmlParse.m_Child;
	
	res = xmlParse.LocateNodeByName(xmlParse.m_parentElement[2], "FP_SUCC");
	xmlParse.m_parentElement[3] = xmlParse.m_Child;
		
	string tempStr;
	xmlParse.LocateNodeByName(xmlParse.m_parentElement[3], "FPXX");
	tempStr = xmlParse.GetText();
	DBG_PRINT(("FPXX = %s", tempStr.c_str()));

	xmlParse.LocateNodeByName(xmlParse.m_parentElement[3], "FLAG");
	mxjgmw = xmlParse.GetText();
	DBG_PRINT(("mxjgmw = %s", mxjgmw.c_str()));
	if(mxjgmw != "")
	{
		return JSK_SUCCESS;
	}

	xmlParse.LocateNodeByName(xmlParse.m_parentElement[2], "FP_ERR");
	xmlParse.m_parentElement[3] = xmlParse.m_Child;
	
	xmlParse.LocateNodeByName(xmlParse.m_parentElement[3], "FP");
	xmlParse.m_parentElement[4] = xmlParse.m_Child;
	
	xmlParse.LocateNodeByName(xmlParse.m_parentElement[4], "FPDM");
	string tmpfpdm = xmlParse.GetText();
	DBG_PRINT(("tmpfpdm = %s", tmpfpdm.c_str()));

	xmlParse.LocateNodeByName(xmlParse.m_parentElement[4], "FPHM");
	strFphm = xmlParse.GetText();
	UINT32 tmpfphm = atoi(xmlParse.GetText().c_str());
	DBG_PRINT(("tmpfphm = %u", tmpfphm));

	xmlParse.LocateNodeByName(xmlParse.m_parentElement[4], "CODE");
	tmpCode = xmlParse.GetText();
	
	xmlParse.LocateNodeByName(xmlParse.m_parentElement[4], "MESS");
	strErr = xmlParse.GetText();
//	strErr = strFphm + ":" + strErr;
	DBG_PRINT(("strErr = %s", strErr.c_str()));

	xmlParse.XMLParseEnd();

	INT8 sqlbuf[128];
	memset(sqlbuf, 0, sizeof(sqlbuf));
	sprintf(sqlbuf, "where FPDM='%s' and FPHM=%u ", tmpfpdm.c_str(), tmpfphm);
	CInvServ invServ;
	invServ.m_upFlag = INV_UPLOAD_FLAG2;		//上传错误
	if(strErr.length() > MAX_ERR_MSG_LEN)
		strErr.erase(MAX_ERR_MSG_LEN, strErr.length()-MAX_ERR_MSG_LEN);
	invServ.m_errMsg = tmpCode + ":" + strErr;
	DBG_PRINT(("m_errMsg = %s", invServ.m_errMsg.c_str()));
	invServ.Update(sqlbuf, &invServ.m_upFlag, &invServ.m_errMsg, NULL);

	return JSK_FAILURE;
}
Пример #6
0
INT32 CJSKMakeInvoice::FPKJ_Proc(CInvHead *pInvhead, string &strErr, UINT8 wasteflag)
{
	DBG_PRINT(("===== FPKJ_Proc Begin() ======"));
	DBG_ASSERT_EXIT((pInvhead != NULL), (" pInvhead == NULL!"));
	INT32 retcode = JSK_SUCCESS;
	UINT8 tmpBuf[16];
	INT8 sqlbuf[128];

	//获取可滚动表的记录数
    UINT8 nIfRolled=0;
	retcode = g_globalArgLib->RollData(nIfRolled);
	if(retcode!= SUCCESS)
	{
		strErr = "中间件数据库滚动失败!";
		DBG_PRINT((" Roll() error !"));
		return JSK_FAILURE;	
	}

	if(wasteflag == 0)
	{
		DBG_PRINT(("kplx = %u", pInvhead->m_kplx));
		if(pInvhead->m_kplx == 0)
		{
			DBG_PRINT(("m_maxSign = %lld", g_globalArgLib->m_invKind->m_maxSign));
			DBG_PRINT(("pInvhead->m_kphjje = %lld", pInvhead->m_kphjje));
			if(pInvhead->m_kphjje > g_globalArgLib->m_invKind->m_maxSign)
			{
				strErr = "开票单张金额超限!";
				return JSK_FAILURE;
			}
			
			if(pInvhead->m_kphjje <= 0)
			{
				strErr = "正数发票金额不能为零";
				return JSK_FAILURE;
			}
			
			pInvhead->m_kplx = JSK_NORMAL_INV;
		}
		else if(pInvhead->m_kplx == 1)
		{
			pInvhead->m_kplx = JSK_RETURN_INV;
		}
		else
		{
			strErr = "发票类型错误!";
			return JSK_FAILURE;
		}
	}
	else
	{
		if(pInvhead->m_kplx != JSK_WASTE_INV)
		{
			strErr = "发票类型错误!";
			return JSK_FAILURE;
		}
	}
	
	//当前开票时间
	UINT8 curTime[MAX_DATETIME_LEN+1];
	retcode = CJSKInfoFunc::GetJSPCurDate(curTime, strErr);
	if( retcode != JSK_SUCCESS )
	{
		return retcode;
	}
	TDateTime tmpDateTime((INT8 *)curTime, DATETIME_POS);
	pInvhead->m_kprq = tmpDateTime.FormatInt(YYYYMMDD);
	pInvhead->m_kpsj = tmpDateTime.FormatInt(HHMMSS);
	pInvhead->m_CurTime = tmpDateTime.FormatString(YYYYMMDDHHMMSS, "%u%02u%02u%02u%02u%02u");
	if(pInvhead->m_kplx == JSK_WASTE_INV)
	{
		pInvhead->m_zfsj = (INT8 *)curTime;
	}

	//权限控制
	retcode = MakeInvAuthority(pInvhead, strErr);
	if( retcode != JSK_SUCCESS )
	{
		//retcode = JSK_COMMON_ERR_NO;
		return retcode;
	}

	CJSKInvManageProc::fplxdm2fplx(pInvhead->m_fplxdm, pInvhead->m_fplb);

	pInvhead->m_xfyhzh = g_globalArgLib->m_corpInfo->m_Khzh;		//销方银行账号
	DBG_PRINT(("pInvhead->fplb = %u", pInvhead->m_fplb));

	//取发票代码、号码
	CInvVol invVol;
	retcode = CJSKInfoFunc::GetCurInvInfo(&invVol, strErr);
	if( retcode != JSK_SUCCESS )
	{
		return retcode;
	}
	pInvhead->m_fpdm = invVol.m_code;
	pInvhead->m_fphm = invVol.m_curInvNo;


	//调用金税盘函数获取税控码、CA签名、索引号
	retcode = CJSKInfoFunc::MakeInvHandInfo(pInvhead, strErr);
	DBG_PRINT(("retcode = %d", retcode));
	if( retcode != JSK_SUCCESS )
	{
		return retcode;
	}

	//数据库事务开始
	pInvhead->BeginTransaction();

	//存数据库
	UINT32  errorcode;
	errorcode = pInvhead->Save();
	if (errorcode != SUCCESS)
	{
// 		retcode = JSK_COMMON_ERR_NO;
// 		DBG_PRINT(("pInvhead->Save() wrong"));
// 		return retcode;
	}
	DBG_PRINT(("pInvhead->Save() SUCCESS"));

	
	//将该发票记录存储到DB的INV_SERV
	CInvServ invServ;
	DBG_PRINT(("m_InvServNum = %lu, m_InvServSum = %lld", g_globalArgLib->m_InvServNum, g_globalArgLib->m_InvServSum));
	errorcode = invServ.Save(pInvhead, g_globalArgLib->m_InvServNum, g_globalArgLib->m_InvServSum, strErr);	
	DBG_PRINT(("存储到DB的INV_SERV, errorcode = %u", errorcode));

	//更新RT_INV表
	if(pInvhead->m_kplx == JSK_RETURN_INV )
	{
		DBG_PRINT(("更新RT_INV表"));
		CRtInv curRtInv;
		CRtInv *pRtInv = &curRtInv;

		pRtInv-> m_fpdm = pInvhead->m_yfpdm;					
		pRtInv-> m_fphm = pInvhead->m_yfphm;
		errorcode = pRtInv->AddNew();				//写已退发票信息表
		if( errorcode != SQLITE_OK )
		{
			DBG_PRINT((" pRtInv->AddNew() error!"));
			//retcode = JSK_COMMON_ERR_NO;
			//return retcode;
		}
	}
	//数据库事务结束
	pInvhead->EndTransaction();

	return JSK_SUCCESS;
}
Пример #7
0
INT32 CJSKMakeInvoice::FPSC_Proc(UINT8 czlx, UINT32 &fpzx, string &strInvInfo, string &strErr)
{
	INT8 sqlbuf[128];
	CInvServ invServ;
	CInvHead invHead;
	INT32 retcode = JSK_SUCCESS;
	INT32 errcode = 0;
	string tmpErr("");

//	CJSKDeclareProc::DelUploadInv();

	memset(sqlbuf, 0, sizeof(sqlbuf));
	sprintf(sqlbuf, "where UP_FLAG=0 or UP_FLAG=1 ");
	invServ.m_filter.append(sqlbuf);
	invServ.Requery();
	errcode = invServ.LoadOneRecord();
	DBG_PRINT(("errcode = %d", errcode));
	if(errcode == SQLITE_OK)
	{
		if((invServ.m_code=="") || (invServ.m_InvNo==0))
			errcode = SQLITE_DONE;
	}
	if(errcode != SQLITE_OK)
	{
		retcode = CJSKInfoFunc::GetFirstOffInvInfo(&invHead, tmpErr);
		if((invHead.m_fpdm=="") || (invHead.m_fphm==0))
			retcode = JSK_FAILURE;
		if(retcode != JSK_SUCCESS)
		{
			g_globalArgLib->m_pthreadFlag = 0;
			g_globalArgLib->m_InvServNum = 0;
			retcode = JSK_COMMON_ERR_NO;
			strErr = "所有发票都已上传!";
			return retcode;
		}
		memset(sqlbuf, 0, sizeof(sqlbuf));
		sprintf(sqlbuf, "where FPDM='%s' and FPHM=%u ", invHead.m_fpdm.c_str(), invHead.m_fphm);
		DBG_PRINT(("sqlbuf = %s", sqlbuf));
		invServ.m_filter.append(sqlbuf);
		invServ.Requery();
		if(invServ.LoadOneRecord() == SQLITE_OK)
		{
			if(invServ.m_upFlag == INV_UPLOAD_FLAG2)
			{
				g_globalArgLib->m_pthreadFlag = 0;
				retcode = JSK_COMMON_ERR_NO;
				strErr = "发票上传错误,请核对!";
				return retcode;
			}
		}

		invServ.m_code = invHead.m_fpdm;
		invServ.m_InvNo = invHead.m_fphm;
		invServ.m_fpsyh = invHead.m_fpsyh;
	}

	UINT32 invLen = 0;
	fpzx = 1;		//发票张数
	memset(sqlbuf, 0, sizeof(sqlbuf));
	sprintf(sqlbuf, "where FPDM='%s' and FPHM=%u ", invServ.m_code.c_str(), invServ.m_InvNo);
	DBG_PRINT(("sqlbuf = %s", sqlbuf));
	invHead.m_filter.append(sqlbuf);
	retcode = invHead.Load();
	if(retcode != SQLITE_OK)
	{
		DBG_PRINT(("here query from JSK"));
		invHead.m_fpdm = invServ.m_code;
		invHead.m_fphm = invServ.m_InvNo;
		invHead.m_fpsyh = invServ.m_fpsyh;
		retcode = CJSKInfoFunc::GetInvDetailInfoNO(&invHead, g_invInfo, invLen, strErr);
		if(retcode != JSK_SUCCESS)
		{
			return retcode;
		}
		
// 		if(invHead.Save() != SQLITE_OK)
// 		{
// 			retcode = JSK_COMMON_ERR_NO;
// 			strErr = "发票信息保存数据库错误";
// 			return retcode;
// 		}
	}
	else
	{
		DBG_PRINT(("here query from DB success"));
		//将invHead类转换成string类型输出
		CJSKInfoFunc::MutexLock();
		CJSKInfoFunc::InvDetail2Data(&invHead, g_invInfo, invLen);
		CJSKInfoFunc::MutexUnlock();
		DBG_PRINT(("invLen = %u", invLen));
	}

	DBG_PRINT(("invLen = %u", invLen));
	AddInvDetail2Data(&invHead, g_invInfo, invLen);
	strInvInfo.append((INT8 *)g_invInfo);
	DBG_PRINT(("invLen = %u", invLen));


	//更新上传标志
	invServ.m_upFlag = INV_UPLOAD_FLAG1;
	DBG_PRINT(("sqlbuf = %s", sqlbuf));
	invServ.Update(sqlbuf, &invServ.m_upFlag, NULL);
	
	return JSK_SUCCESS;
}
Пример #8
0
INT32 CJSKMakeInvoice::FPCX_Proc(UINT8 cxfs, string cxtj, UINT32 &invNum, CInvHead *pInvhead, string &strErr)
{
	DBG_ASSERT_EXIT((pInvhead != NULL), (" pInvhead == NULL!"));
	INT32 retcode = JSK_SUCCESS;

	INT8 sqlbuf[128];
	string fpdm("");
	UINT32 fphm = 0;
	string tmpStr;
	INT32 errcode = 0;

	invNum = 1;
	//cxfs为0时:12发票代码+8位起始号码+8位终止号码; cxfs
	if(cxfs == 0)
	{
		fpdm = cxtj.substr(0, 12);
		tmpStr = cxtj.substr(12, 8);
		fphm = atoi(tmpStr.c_str());

		memset(sqlbuf, 0, sizeof(sqlbuf));
		sprintf(sqlbuf, "where FPDM='%s' and FPHM=%u", fpdm.c_str(), fphm);
		DBG_PRINT(("sqlbuf = %s", sqlbuf));
		pInvhead->m_filter.append(sqlbuf);
		errcode = pInvhead->Load();
		if(errcode != SQLITE_OK)
		{
			DBG_PRINT(("here search JSK========="));
			pInvhead->m_fpdm = fpdm;
			pInvhead->m_fphm = fphm;
			retcode = CJSKInfoFunc::GetInvDetailInfoNO(pInvhead, strErr);
			if(retcode != JSK_SUCCESS)
			{
				return retcode;
			}
			
			if(pInvhead->Save() != SUCCESS)
			{
				DBG_PRINT(("InvHead Save Error!"));
				//retcode = JSK_COMMON_ERR_NO;
				//strErr = "发票信息保存数据库错误";
				//return retcode;
			}

			if(pInvhead->m_kplx == JSK_RETURN_INV)
			{
				DBG_PRINT(("更新RT_INV表"));
				CRtInv curRtInv;
				CRtInv *pRtInv = &curRtInv;
				
				pRtInv-> m_fpdm = pInvhead->m_yfpdm;					
				pRtInv-> m_fphm = pInvhead->m_yfphm;
				if( pRtInv->AddNew() != SQLITE_OK )
				{
					DBG_PRINT((" pRtInv->AddNew() error!"));
				}
			}
		}

		CInvServ invServ;
		DBG_PRINT(("sqlbuf = %s", sqlbuf));
		invServ.m_filter.append(sqlbuf);
		invServ.Requery();
		if(invServ.LoadOneRecord() != SQLITE_OK)
			pInvhead->m_scbz = 1;
		else
		{
			if(invServ.m_upFlag == INV_UPLOAD_FLAG2)
			{
				invServ.m_upFlag = INV_UPLOAD_FLAG0;
				DBG_PRINT(("sqlbuf = %s", sqlbuf));
				invServ.Update(sqlbuf, &invServ.m_upFlag, NULL);
			}
		}
	}
	//为1是:起始日期(YYYYMMDD)+终止日期(YYYYMMDD)
	else if(cxfs == 1)
	{
		retcode = JSK_COMMON_ERR_NO;
		strErr = "不支持时间段查询方式!";
		return retcode;
	}
	else
	{
		retcode = JSK_COMMON_ERR_NO;
		strErr = "非法查询方式!";
		return retcode;
	}
	
	return JSK_SUCCESS;
}
Пример #9
0
INT32 CJSKMakeInvoice::FPZF_Proc(CInvHead *pInvhead, UINT8 zflx, string &strErr)
{
	DBG_PRINT(("===== FPZF_Proc Begin() ======"));
	DBG_ASSERT_EXIT((pInvhead != NULL), (" pInvhead == NULL!"));
	INT32 retcode = JSK_SUCCESS;

	if(zflx == 0)	//空白票作废
	{
		pInvhead->m_kplx = JSK_WASTE_INV;
		pInvhead->m_xfmc = g_globalArgLib->m_corpInfo->m_Nsrmc;
		retcode = FPKJ_Proc(pInvhead, strErr, 1);

		return retcode;
	}

	//////////////////////////////////////////////////////////////////////////
	if(zflx != 1)
	{
		strErr = "发票作废类型错误!";
		return JSK_FAILURE;
	}
	CJSKInvManageProc::fplxdm2fplx(pInvhead->m_fplxdm, pInvhead->m_fplb);
	//已开票作废
	//查询数据库中已开发票信息
	INT8 sqlbuf[256];
	UINT32  errorcode;
	CInvHead tmpInvHead;
	memset(sqlbuf, 0, sizeof(sqlbuf));
	sprintf(sqlbuf, "where FPDM='%s' and FPHM=%u", pInvhead->m_fpdm.c_str(), pInvhead->m_fphm);
	DBG_PRINT(("sqlbuf = %s", sqlbuf));
	pInvhead->m_filter.append(sqlbuf);
	if(pInvhead->Load() != SQLITE_OK)
	{
		DBG_PRINT(("here find by jsp"));
		//数据库查询不到,从盘中查询
		retcode = CJSKInfoFunc::GetInvDetailInfoNO(pInvhead, strErr);
		if(retcode != JSK_SUCCESS)
		{
			return retcode;
		}

		pInvhead->Save();
	}

	//已开发票作废控制
	if(pInvhead->m_kplx == JSK_NORMAL_INV)
	{
		pInvhead->m_kplx = JSK_WASTE_NOR;
	}
	else if(pInvhead->m_kplx == JSK_RETURN_INV)
	{
		pInvhead->m_kplx = JSK_WASTE_RET;
	}
	else
	{
		retcode = JSK_COMMON_ERR_NO;
		strErr = "废票不能再次作废!";
		return retcode;
	}

	//权限控制
	retcode = MakeInvAuthority(pInvhead, strErr);
	if( retcode != JSK_SUCCESS )
	{
		return retcode;
	}

	retcode = CJSKInfoFunc::WasteInvHandInfo(pInvhead, strErr);
	if( retcode != JSK_SUCCESS )
	{
		return retcode;
	}

	//数据库事务开始
	pInvhead->BeginTransaction();

	//修改数据库对应信息
	tmpInvHead.m_kplx = pInvhead->m_kplx;
	tmpInvHead.m_fpsyh = pInvhead->m_fpsyh;
	tmpInvHead.m_casign = pInvhead->m_casign;
	tmpInvHead.m_zfsj = pInvhead->m_zfsj;
	retcode = tmpInvHead.Update(sqlbuf, &tmpInvHead.m_kplx, &tmpInvHead.m_fpsyh, &tmpInvHead.m_zfsj, &tmpInvHead.m_casign, NULL);
	DBG_PRINT(("更新DB的INV_HEAD:retcode = %d", retcode));
	CInvDet invDet;
	invDet.m_kplx = pInvhead->m_kplx;
	retcode = invDet.Update(sqlbuf, &invDet.m_kplx, NULL);
	DBG_PRINT(("更新DB的INV_DET:retcode = %d", retcode));

	if(pInvhead->m_kplx == JSK_WASTE_RET )
	{
		DBG_PRINT(("更新RT_INV表"));
		CRtInv curRtInv;
		CRtInv *pRtInv = &curRtInv;
		memset(sqlbuf, 0, sizeof(sqlbuf));
		sprintf(sqlbuf, "where FPDM='%s' and FPHM=%u ", pInvhead->m_yfpdm.c_str(), pInvhead->m_yfphm);
		DBG_PRINT(("sqlbuf = %s", sqlbuf));
		pRtInv->m_filter.append(sqlbuf);
		pRtInv->Delete();
	}

	//处理INV_SERV表,如果已上传发票,需要重新记录INV_SERV???
	CInvServ invServ;
	errorcode = invServ.Save(pInvhead, g_globalArgLib->m_InvServNum, g_globalArgLib->m_InvServSum, strErr);	
	DBG_PRINT(("存储到DB的INV_SERV, errorcode = %u", errorcode));
	
	//数据库事务结束
	pInvhead->EndTransaction();

	return JSK_SUCCESS;
}
void CMaintenanceMenu::OnButton9(int iEvent, unsigned char * pEventData, int iDataLen)
{
	if (g_globalArg->m_initFlag == 0)
	{
		CaMsgBox::ShowMsg("机器未初始化");
		return ;
	}

	CInvServ invServ;
	CInvHead invHead;
	CInvDet  invDet;
	INT32 nErrCode;
	INT8 chValue[128];

	invServ.Requery();
	nErrCode = invServ.LoadOneRecord();
   DBG_PRINT(("nErrCode= %u",nErrCode));
	if( nErrCode != SQLITE_OK )
	{
		CaMsgBox::ShowMsg("无缓存记录");
		return;
	}

	memset(chValue, 0, sizeof(chValue));
	sprintf(chValue,"代码:'%s' 号码:%u 确认删除?", invServ.m_code.c_str(), invServ.m_InvNo);
	CaMsgBox msgBox(chValue,CaMsgBox::MB_YESNO);
	msgBox.ShowBox();	
	if (msgBox.m_iStatus == OK_PRESSED)
	{
		memset((void*)chValue, 0, sizeof(chValue));
		//sprintf(chValue, "where CODE = '%s' and INV_NO = %u", invServ.m_code.c_str(), invServ.m_InvNo);
		// 更改inv_serv中的两个字段
		sprintf(chValue, "where FPDM = '%s' and FPHM = %u", invServ.m_code.c_str(), invServ.m_InvNo);
		invHead.m_filter = chValue;
		nErrCode = invHead.Delete();
		if (SQLITE_OK != nErrCode)
		{
			CaMsgBox::ShowMsg("删除失败");
			return;
		}
		invDet.m_filter = chValue;
		nErrCode = invDet.Delete();
		if (SQLITE_OK != nErrCode)
		{
			CaMsgBox::ShowMsg("删除失败");
			return;
		}
		
		sprintf(chValue, "where CODE = '%s' and INV_NO = %u", invServ.m_code.c_str(), invServ.m_InvNo);
		invServ.m_filter = chValue;
		nErrCode = invServ.Delete();
		if (SQLITE_OK != nErrCode)
		{
	
			CaMsgBox::ShowMsg("删除失败");
			return;
		}
		CaMsgBox::ShowMsg("删除成功");

		if(0 != g_globalArg->m_InvServNum)
		{
			g_globalArg->m_InvServNum--;
		}
		DBG_PRINT(("m_InvServNum = %u", g_globalArg->m_InvServNum ));
	}
}