📄 ccdb.cpp
字号:
DLLSynFuntInterfaceBug(pstrReqParam->nBusID,SYS_ACTION_DEL,(char*)pstrReqParam->pBuf,sizeof(int));
}
#endif
return ERR_BUS_SUCCESS;
}
else
return ERR_BUS_SQLEXE;
}
break;
case BUSINESS_SCENE: // 场景表
{
WCHAR SqlIst[8][150];
//删除日程:先删除定时器
swprintf(SqlIst[0],L"delete from timertable where timerid in(select StartTimerID from scheduletable where objectId=%d and type=%d)",
*((int *)pstrReqParam->pBuf),SCHEDULE_DEV_SCENE);
swprintf(SqlIst[1],L"delete from scheduletable where ObjectId =%d and type=%d ",
*((int *)pstrReqParam->pBuf),SCHEDULE_DEV_SCENE);
swprintf(SqlIst[2],L"delete from SceneDevtable where SceneId =%d ",
*((int *)pstrReqParam->pBuf));
swprintf(SqlIst[3],L"Delete from SceneTable where SceneID=%d",
*((int *)pstrReqParam->pBuf));
if(!g_DataBase.OpenData())
{
return ERR_PROG_NOTOPEN;
}
NodeSql *pFirst,*pNode=NULL,*pNext=NULL;
for(int i=0;i<4;i++)
{
pNext=new NodeSql;
memset(pNext,0,sizeof(NodeSql));
pNext->pSql = SqlIst[i];
if(pNode==NULL)
{
pNode=pNext;
pFirst=pNext;
}else
{
pNode->pNext=pNext;
pNode=pNext;
}
}
BOOL bDel=g_DataBase.ExecuteSql(pFirst);
//删除
while(pFirst)
{
pNode=pFirst;
pFirst=pFirst->pNext;
delete pNode;
}
g_DataBase.CloseData();
if(bDel)
{
//发送同步消息
/* num=sizeof(BusToCmdList)/sizeof(BusToCmdList[0]);
for(int i=0;i<num;i++)
{
if(BusToCmdList[i].nBus== pstrReqParam->nBusID)
break;
}
*/
#ifndef _USEBYLHL
// if(i <num && bSyn)
if( bSyn)
{//??默认都是第一个为主键ID
DLLSynFuntInterfaceBug(pstrReqParam->nBusID,SYS_ACTION_DEL,(char*)pstrReqParam->pBuf,sizeof(int));
}
#endif
return ERR_BUS_SUCCESS;
}
else
return ERR_BUS_SQLEXE;
}
break;
case BUSINESS_HOUSE:
{//删除房间
WCHAR SqlIst[8][300];
//删除该房间下场景的日程的定时器
// swprintf(SqlIst[0],L"delete from timertable where timerid in(select StartTimerID from scheduletable where type=%d and objectId \
// in(select SceneID from scenetable where houseid=%d ))",
swprintf(SqlIst[0],L"delete from timertable where timerid in(select StartTimerID from scheduletable,scenetable where scheduletable.type=%d and objectId =SceneID\
and houseid=%d )",
SCHEDULE_DEV_SCENE,*((int *)pstrReqParam->pBuf));
//删除该房间下场景的日程
swprintf(SqlIst[1],L"delete from scheduletable where type=%d and ObjectId in(select sceneID from scenetable where houseid=%d )",
SCHEDULE_DEV_SCENE,*((int *)pstrReqParam->pBuf));
//删除该房间下的场景设备
swprintf(SqlIst[2],L"delete from SceneDevtable where SceneId in(select sceneID from scenetable where houseid=%d ) ",
*((int *)pstrReqParam->pBuf));
//删除该房间下的场景
swprintf(SqlIst[3],L"Delete from SceneTable where houseid=%d ",
*((int *)pstrReqParam->pBuf));
//删除该房间
swprintf(SqlIst[4],L"Delete from HouseTable where houseid=%d ",
*((int *)pstrReqParam->pBuf));
if(!g_DataBase.OpenData())
{
return ERR_PROG_NOTOPEN;
}
NodeSql *pFirst,*pNode=NULL,*pNext=NULL;
for(int i=0;i<5;i++)
{
pNext=new NodeSql;
memset(pNext,0,sizeof(NodeSql));
pNext->pSql = SqlIst[i];
if(pNode==NULL)
{
pNode=pNext;
pFirst=pNext;
}else
{
pNode->pNext=pNext;
pNode=pNext;
}
}
writebuginfo("file:%s,line:%dbefor exesql\n",__FILE__,__LINE__);
BOOL bDel=g_DataBase.ExecuteSql(pFirst);
writebuginfo("file:%s,line:%dexesql=%d\n",__FILE__,__LINE__,bDel);
//删除
while(pFirst)
{
pNode=pFirst;
pFirst=pFirst->pNext;
delete pNode;
}
g_DataBase.CloseData();
if(bDel)
{
//发送同步消息
/* num=sizeof(BusToCmdList)/sizeof(BusToCmdList[0]);
for(int i=0;i<num;i++)
{
if(BusToCmdList[i].nBus== pstrReqParam->nBusID)
break;
}
*/
#ifndef _USEBYLHL
// if(i <num && bSyn)
if( bSyn)
{//??默认都是第一个为主键ID
writebuginfo("file:%s,line:%dEnter Syn\n",__FILE__,__LINE__);
DLLSynFuntInterfaceBug(pstrReqParam->nBusID,SYS_ACTION_DEL,(char*)pstrReqParam->pBuf,sizeof(int));
writebuginfo("file:%s,line:%dexit Syn\n",__FILE__,__LINE__);
}
#endif
return ERR_BUS_SUCCESS;
}
else
return ERR_BUS_SQLEXE;
}break;
case BUSINESS_SCHEDULE: // 日程表
{
WCHAR SqlIst[3][150];
//删除日程:先删除定时器
swprintf(SqlIst[0],L"delete from timertable where timerid in(select StartTimerID from scheduletable where Id=%d)",
*((int *)pstrReqParam->pBuf));
swprintf(SqlIst[1],L"delete from timertable where timerid in(select EndTimerID from scheduletable where Id=%d)",
*((int *)pstrReqParam->pBuf));
swprintf(SqlIst[2],L"delete from scheduletable where Id =%d ",
*((int *)pstrReqParam->pBuf));
if(!g_DataBase.OpenData())
{
return ERR_PROG_NOTOPEN;
}
NodeSql *pFirst,*pNode=NULL,*pNext=NULL;
for(int i=0;i<3;i++)
{
pNext=new NodeSql;
memset(pNext,0,sizeof(NodeSql));
pNext->pSql = SqlIst[i];
if(pNode==NULL)
{
pNode=pNext;
pFirst=pNext;
}else
{
pNode->pNext=pNext;
pNode=pNext;
}
}
BOOL bDel=g_DataBase.ExecuteSql(pFirst);
//删除
while(pFirst)
{
pNode=pFirst;
pFirst=pFirst->pNext;
delete pNode;
}
g_DataBase.CloseData();
if(bDel)
{
//发送同步消息
/* num=sizeof(BusToCmdList)/sizeof(BusToCmdList[0]);
for(int i=0;i<num;i++)
{
if(BusToCmdList[i].nBus== pstrReqParam->nBusID)
break;
}
*/
#ifndef _USEBYLHL
// if(i <num && bSyn)
if(bSyn)
{//??默认都是第一个为主键ID
DLLSynFuntInterfaceBug(pstrReqParam->nBusID,SYS_ACTION_DEL,(char*)pstrReqParam->pBuf,sizeof(int));
}
#endif
return ERR_BUS_SUCCESS;
}
else
return ERR_BUS_SQLEXE;
}
break;
case BUSINESS_CLOCK: // 闹钟表
{
WCHAR SqlIst[2][150];
//先删除定时器
swprintf(SqlIst[0],L"Delete from timertable where BusType=%d and busId=%d ",TIMER_BUSTYPE_CLOCK,
*((int *)pstrReqParam->pBuf));
swprintf(SqlIst[1],L"delete from clocktable where clockId =%d ",
*((int *)pstrReqParam->pBuf));
if(!g_DataBase.OpenData())
{
return ERR_PROG_NOTOPEN;
}
NodeSql *pFirst,*pNode=NULL,*pNext=NULL;
for(int i=0;i<2;i++)
{
pNext=new NodeSql;
memset(pNext,0,sizeof(NodeSql));
pNext->pSql = SqlIst[i];
if(pNode==NULL)
{
pNode=pNext;
pFirst=pNext;
}else
{
pNode->pNext=pNext;
pNode=pNext;
}
}
BOOL bDel=g_DataBase.ExecuteSql(pFirst);
//删除
while(pFirst)
{
pNode=pFirst;
pFirst=pFirst->pNext;
delete pNode;
}
g_DataBase.CloseData();
if(bDel)
{
//发送同步消息
/* num=sizeof(BusToCmdList)/sizeof(BusToCmdList[0]);
for(int i=0;i<num;i++)
{
if(BusToCmdList[i].nBus== pstrReqParam->nBusID)
break;
}
*/
#ifndef _USEBYLHL
// if(i <num && bSyn)
if(bSyn)
{//??默认都是第一个为主键ID
DLLSynFuntInterfaceBug(pstrReqParam->nBusID,SYS_ACTION_DEL,(char*)pstrReqParam->pBuf,sizeof(int));
}
#endif
return ERR_BUS_SUCCESS;
}
else
return ERR_BUS_SQLEXE;
}break;
case BUSINESS_TICKLER: // 备忘录表
{
WCHAR SqlIst[2][150];
//先删除定时器
swprintf(SqlIst[0],L"Delete from Timertable where TimerID in (select TimerID from TicklerTable where Idx=%d )",
*((int *)pstrReqParam->pBuf));
swprintf(SqlIst[1],L"delete from Ticklertable where Idx =%d ",
*((int *)pstrReqParam->pBuf));
if(!g_DataBase.OpenData())
{
return ERR_PROG_NOTOPEN;
}
NodeSql *pFirst,*pNode=NULL,*pNext=NULL;
for(int i=0;i<2;i++)
{
pNext=new NodeSql;
memset(pNext,0,sizeof(NodeSql));
pNext->pSql = SqlIst[i];
if(pNode==NULL)
{
pNode=pNext;
pFirst=pNext;
}else
{
pNode->pNext=pNext;
pNode=pNext;
}
}
BOOL bDel=g_DataBase.ExecuteSql(pFirst);
//删除
while(pFirst)
{
pNode=pFirst;
pFirst=pFirst->pNext;
delete pNode;
}
g_DataBase.CloseData();
if(bDel)
{
//发送同步消息
/* num=sizeof(BusToCmdList)/sizeof(BusToCmdList[0]);
for(int i=0;i<num;i++)
{
if(BusToCmdList[i].nBus== pstrReqParam->nBusID)
break;
}
*/
#ifndef _USEBYLHL
// if(i <num && bSyn)
if(bSyn)
{//??默认都是第一个为主键ID
DLLSynFuntInterfaceBug(pstrReqParam->nBusID,SYS_ACTION_DEL,(char*)pstrReqParam->pBuf,sizeof(int));
}
#endif
return ERR_BUS_SUCCESS;
}
else
return ERR_BUS_SQLEXE;
}break;
case BUSINESS_CARD: // 卡号(用户
{
WCHAR SqlIst[2][150];
//如果是临时卡,删除时间
swprintf(SqlIst[0],L"Delete from CardTimer where CardId=%d",
*((int *)pstrReqParam->pBuf));
swprintf(SqlIst[1],L"delete from Cardtable where CardId =%d ",
*((int *)pstrReqParam->pBuf));
if(!g_DataBase.OpenData())
{
return ERR_PROG_NOTOPEN;
}
NodeSql *pFirst,*pNode=NULL,*pNext=NULL;
for(int i=0;i<2;i++)
{
pNext=new NodeSql;
memset(pNext,0,sizeof(NodeSql));
pNext->pSql = SqlIst[i];
if(pNode==NULL)
{
pNode=pNext;
pFirst=pNext;
}else
{
pNode->pNext=pNext;
pNode=pNext;
}
}
BOOL bDel=g_DataBase.ExecuteSql(pFirst);
//删除
while(pFirst)
{
pNode=pFirst;
pFirst=pFirst->pNext;
delete pNode;
}
g_DataBase.CloseData();
if(bDel)
{
//发送同步消息
/* num=sizeof(BusToCmdList)/sizeof(BusToCmdList[0]);
for(int i=0;i<num;i++)
{
if(BusToCmdList[i].nBus== pstrReqParam->nBusID)
break;
}
*/
#ifndef _USEBYLHL
// if(i <num && bSyn)
if(bSyn)
{//??默认都是第一个为主键ID
DLLSynFuntInterfaceBug(pstrReqParam->nBusID,SYS_ACTION_DEL,(char*)pstrReqParam->pBuf,sizeof(int));
}
#endif
return ERR_BUS_SUCCESS;
}
else
return ERR_BUS_SQLEXE;
}break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -