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; }
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); }
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; }
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; }
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 )); } }