📄 schdb.c
字号:
* Input Parameters : .....
* Output Parameters: None
* Return Value : boolean
* Date : 2007/04/14
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
extern boolean ScheDB_AddEventItem( Schedule* pMe,EventData *data)
{
/*记录字段*/
IDBRecord* pRecord;
/*记录中的字段*/
AEEDBField pFieldArray[ NUM_DB_RECORD_FIELDS ];
ScheDB* pScheDB = NULL;
pScheDB=pMe->m_pScheDB;
/*初始化记录中的字段*/
ScheDB_InitEventFieldStruct( pFieldArray, data );
/*创建一条新记录*/
pRecord = IDATABASE_CreateRecord( pScheDB->m_pDatabase, pFieldArray, NUM_DB_RECORD_FIELDS );
/*创建不成功返回FALSE*/
if( !pRecord )
return FALSE;
/*关闭记录*/
IDBRECORD_Release( pRecord );
return TRUE;
}
/**************************************************************************
* Function Name : ScheDB_AddEventItem
* Description : ParseEventRecord return the data
* Input Parameters : .....
* Output Parameters: None
* Return Value : boolean
* Date : 2007/04/14
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
extern boolean ScheDB_UpdateEventItem( Schedule* pMe,EventData *data )
{
/*记录字段*/
IDBRecord* pRecord;
/*记录中的字段*/
AEEDBField pFieldArray[ NUM_DB_RECORD_FIELDS ];
/*根据ID得到数据记录字段*/
if(( pRecord = IDATABASE_GetRecordByID( pMe->m_pScheDB->m_pDatabase, data->index )) == NULL)
return FALSE;
/*初始化记录中的字段*/
ScheDB_InitEventFieldStruct( pFieldArray, data );
/*更新记录*/
IDBRECORD_Update( pRecord, (AEEDBField*) pFieldArray, NUM_DB_RECORD_FIELDS );
/*关闭记录*/
IDBRECORD_Release( pRecord );
return TRUE;
}
/**************************************************************************
* Function Name : ScheDB_DeleteEventItem
* Description : ParseEventRecord return the data
* Input Parameters : .....
* Output Parameters: None
* Return Value : boolean
* Date : 2007/04/14
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
extern boolean ScheDB_DeleteEventItem( Schedule* pMe, uint16 nRecordID )
{
/*记录字段*/
IDBRecord* pRecord;
/*根据ID得到数据记录字段*/
if(( pRecord = IDATABASE_GetRecordByID( pMe->m_pScheDB->m_pDatabase, nRecordID )) == NULL)
return FALSE;
/*删除记录*/
if( IDBRECORD_Remove( pRecord ) != SUCCESS )
{
/*删除失败关闭记录并返回FALSE*/
IDBRECORD_Release( pRecord );
return FALSE;
}
/*删除成功 关闭记录*/
IDBRECORD_Release( pRecord );
return TRUE;
}
/**************************************************************************
* Function Name : ScheDB_DeleteEventItem
* Description : ParseEventRecord return the data
* Input Parameters : .....
* Output Parameters: None
* Return Value : boolean
* Date : 2007/04/14
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
extern boolean ScheDB_GetEventItem( Schedule* pMe, EventData *data )
{
IDBRecord* pRecord;
/*根据ID得到数据记录字段*/
if(( pRecord = IDATABASE_GetRecordByID( pMe->m_pScheDB->m_pDatabase, data->index )) == NULL)
return FALSE;
/*解析记录中各个字段的数据保存到系列参数*/
ScheDB_ParseEventRecord( pRecord, data );
/*关闭记录*/
IDBRECORD_Release( pRecord );
return TRUE;
}
/**************************************************************************
* Function Name : ScheDB_DeleteEventItem
* Description : ParseEventRecord return the data
* Input Parameters : .....
* Output Parameters: None
* Return Value : boolean
* Date : 2007/04/14
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
extern boolean ScheDB_GetEventByDate(Schedule* pme, EventData *data )
{
IDBRecord *pRecord = NULL;
EventData *curr_node = NULL;
EventData *previous = NULL;
EventData *m_pTemp = data;
EventData *m_pGetData = NULL;
boolean hasEvts = FALSE;
if( data == NULL )
return FALSE;
m_pGetData = (EventData*)MALLOC(sizeof(EventData));
if( m_pGetData == NULL)
return FALSE;
/*初始化 重置数据库 -1*/
IDATABASE_Reset( pme->m_pScheDB->m_pDatabase );
while( (pRecord = IDATABASE_GetNextRecord( pme->m_pScheDB->m_pDatabase )) != NULL )
{
// Parse the date/time, transaction type and amount from the current record
ScheDB_ParseEventRecord( pRecord, m_pGetData );
DBGPRINTF("%s",m_pGetData->eDate);
if( WSTRCMP( m_pGetData->eDate,data->eDate ) == 0 )
{
m_pTemp->eAlarm = m_pGetData->eAlarm;
m_pTemp->eType = m_pGetData->eType;
m_pTemp->index = m_pGetData->index;
WSTRCPY( m_pTemp->eContent, m_pGetData->eContent );
WSTRCPY( m_pTemp->eDate, m_pGetData->eDate );
WSTRCPY( m_pTemp->eName, m_pGetData->eName );
WSTRCPY( m_pTemp->eTelNo, m_pGetData->eTelNo );
WSTRCPY( m_pTemp->eTime, m_pGetData->eTime );
/*创建下一个事件空间*/
m_pTemp->next = (EventData*)MALLOC(sizeof(EventData));
m_pTemp = m_pTemp->next;
m_pTemp->next = NULL;
hasEvts = TRUE;
}
IDBRECORD_Release( pRecord );
}
FREEIF( m_pGetData );
if( !hasEvts )
{
/*没有当前日期事件*/
FREEIF( data );
return FALSE;
}
m_pTemp = data;
while(m_pTemp != NULL)
{
previous = m_pTemp;
m_pTemp = m_pTemp->next;
if( m_pTemp->index == 0)
{
previous->next = NULL;
FREEIF(m_pTemp);
}
}
return TRUE;
}
/**************************************************************************
* Function Name : ScheDB_EmptyEventDatabase
* Description : 删除数据库中的所有记录
* Input Parameters : .....
* Output Parameters: None
* Return Value : boolean
* Date : 2007/04/14
* Author : ZhongNingLin@neusoft.com
***************************************************************************/
extern void ScheDB_EmptyEventDatabase( ScheDB* pDB)
{
IDBRecord* pRecord;
/*重置数据库*/
IDATABASE_Reset( pDB->m_pDatabase );
/*逐个删除记录*/
while((pRecord = IDATABASE_GetNextRecord( pDB->m_pDatabase )) != NULL)
{
IDBRECORD_Remove( pRecord );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -