void CIndustryDetailDialog_Commodities::Save()
{
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    //
    for( int i=0;i<m_ctlCommodityListIn.GetItemCount();i++ )
    {
        if( m_ctlCommodityListIn.GetCheck(i) )
        {
            int iCommodityFK = m_ctlCommodityListIn.GetItemData(i);
            int iLoadEmpty = atoi(m_ctlCommodityListIn.GetItemText(i,1));
            int iQuanHigh = atoi(m_ctlCommodityListIn.GetItemText(i,2));
            int iQuanLow = atoi(m_ctlCommodityListIn.GetItemText(i,3));
            int iPercent = atoi(m_ctlCommodityListIn.GetItemText(i,4));
            CString sSQL;
            sSQL.Format("INSERT INTO Industries_Commodities (Industries_FK,Commodities_FK,InOut,LoadEmptyDays,Quantity_low,Quantity_high,Quantity_percentage) VALUES (%d,%d,0,%d,%d,%d,%d);",m_iIndustryID,iCommodityFK,iLoadEmpty,iQuanLow,iQuanHigh,iPercent);
            CppSQLite3Query q = pDB->execQuery(sSQL);
            q.finalize();
        }
    }
    for( i=0;i<m_ctlCommodityListOut.GetItemCount();i++ )
    {
        if( m_ctlCommodityListOut.GetCheck(i) )
        {
            int iCommodityFK = m_ctlCommodityListOut.GetItemData(i);
            int iLoadEmpty = atoi(m_ctlCommodityListOut.GetItemText(i,1));
            int iQuanHigh = atoi(m_ctlCommodityListOut.GetItemText(i,2));
            int iQuanLow = atoi(m_ctlCommodityListOut.GetItemText(i,3));
            int iPercent = atoi(m_ctlCommodityListOut.GetItemText(i,4));
            CString sSQL;
            sSQL.Format("INSERT INTO Industries_Commodities (Industries_FK,Commodities_FK,InOut,LoadEmptyDays,Quantity_low,Quantity_high,Quantity_percentage) VALUES (%d,%d,1,%d,%d,%d,%d);",m_iIndustryID,iCommodityFK,iLoadEmpty,iQuanLow,iQuanHigh,iPercent);
            CppSQLite3Query q = pDB->execQuery(sSQL);
            q.finalize();
        }
    }
}
Exemple #2
0
void CVoxSQLite::GetGroups( const char* username, Groups& rList )
{
	CppSQLite3Buffer buf;
	buf.format( "SELECT * from [Group] WHERE [username] = %Q;", username );

	try
	{
		CppSQLite3Statement stmt = m_db.compileStatement( (const char*)buf );

		int				nContactId	= 0;
		std::string		type		= "";
		CppSQLite3Query q			= stmt.execQuery();
		Group			grp;

		//Process record set.
        while (!q.eof())
        {
			grp.setUsername( q.getStringField( 0 ) );
			grp.setName    ( q.getStringField( 1 ) );

			rList.Add( &grp );

			q.nextRow();
        }

		stmt.reset();
	}

	catch (CppSQLite3Exception& e)
	{
		e.errorCode();
	}
}
void CCarTypesDetailDialog::OnOK() 
{
	// TODO: Add extra validation here

    UpdateData();
    //
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    CString sSQL;
    //
    //  add?
    //
    if( m_iCarTypeFK == -1 )
    {
        sSQL.Format("SELECT 1 FROM CarTypes WHERE type_id=\"%s\"",m_sCarTypeID);
        CppSQLite3Query q = pDB->execQuery((LPCTSTR)sSQL);
        //
        if(!q.eof())
        {
            MessageBox("Duplcate Type ID!","LSC TrainOps Error",MB_ICONSTOP|MB_OK);
            return;
        }
        sSQL.Format("INSERT INTO CarTypes (id,type_id,description,active,passenger) VALUES (NULL,\"%s\",\"%s\",1,%d)",m_sCarTypeID,m_sCarTypeDescription,m_bPassenger?1:0);
    }
    else
    {
        sSQL.Format("UPDATE CarTypes SET type_id=\"%s\",description=\"%s\",passenger=%d WHERE id=%d",m_sCarTypeID,m_sCarTypeDescription,m_bPassenger?1:0,m_iCarTypeFK);
    }
    pDB->execDML((LPCTSTR)sSQL);
    
	CDialog::OnOK();
}
BOOL CLocationDetailDialog::OnInitDialog()
{
    CDialog::OnInitDialog();

    if( m_iLocationID == -1 )
        m_ctlOK.EnableWindow(FALSE);
    else
    {
        CString sSQL;
        sSQL.Format("SELECT name,notes FROM Locations WHERE id=%d;",m_iLocationID);
        CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
        CppSQLite3Query q = pDB->execQuery(sSQL);
        //
        if (!q.eof())
        {
            m_sLocationName = q.getStringField("name");
            m_sLocalInstructions = q.getStringField("notes");
        }
        q.finalize();
        UpdateData(FALSE);
    }

    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}
Exemple #5
0
// Allocates a new CClipTypes
CClipTypes* CCP_MainApp::LoadTypesFromDB()
{
	CClipTypes* pTypes = new CClipTypes;

	try
	{
		CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT TypeText FROM Types"));			
		while(q.eof() == false)
		{
			pTypes->Add(GetFormatID(q.getStringField(_T("TypeText"))));

			q.nextRow();
		}
	}
	CATCH_SQLITE_EXCEPTION

	if(pTypes->GetSize() <= 0)
	{
		pTypes->Add(CF_TEXT);
		pTypes->Add(RegisterClipboardFormat(CF_RTF));
		pTypes->Add(CF_UNICODETEXT);
		pTypes->Add(CF_HDROP);

		if(g_Opt.m_bU3 == false)
		{
			pTypes->Add(CF_DIB);
		}
	}

	return pTypes;
}
Exemple #6
0
//必须在加载任务列表之后
int CPersistencManager::LoadReadyTaskQueue(CT_DEQUE &ready_list,const CT_MAP& task_map){
	if(m_useLevelDB)
	{
		string value;
		leveldb::ReadOptions ro;
		leveldb::Status s;
		int ready_count = 0;

		s = m_LevelDB->Get(ro, TASK_RUN_COUNT, &value);
		if(s.ok())
			ready_count = *(int*)value.data();
		CLog::Log(LOG_LEVEL_DEBUG, "LoadReadyTaskQueue: count=%d\n", ready_count);

		for(int i = 0; i < ready_count; i++)
		{
			s = m_LevelDB->Get(ro, TASK_IDX(TASK_RUN_KEY, i), &value);
			if(s.ok())
			{
				if(task_map.find((char*)value.c_str()) == task_map.end()){
					CLog::Log(LOG_LEVEL_WARNING, "Task List and Ready Task List is not Matched\n");
					continue;
				}

				ready_list.push_back(value);
				CLog::Log(LOG_LEVEL_DEBUG, "Ready task %d:%s\n", i, value.c_str());
			}
		}


		return 0;
	}
	
	int ret = 0;
	
	CT_MAP::const_iterator cur_iter ;
	CT_MAP::const_iterator end_iter  = task_map.end();

	CppSQLite3Query query = m_SQLite3DB.execQuery("select * from ReadyTask");

    while (!query.eof())
    {
		
		cur_iter = task_map.find((char *)query.fieldValue("taskid"));
		if (cur_iter == end_iter){

			CLog::Log(LOG_LEVEL_ERROR,"Task List and Ready Task List is not Matched\n");
			query.nextRow();
			continue;
		}

		ready_list.push_back(cur_iter->first);
      
        query.nextRow();

    }


	return ret;

}
BOOL FireFox3PlugIn::ExportFavoriteData( PFAVORITELINEDATA* ppData, int32& nDataNum )
{
	memset(ppData,0x0, nDataNum*sizeof(PFAVORITELINEDATA));

	if (ppData == NULL || *ppData == NULL || nDataNum == 0)
	{
		return FALSE;
	}

	string strSql = "select marks.* from moz_bookmarks as marks where marks.id in (2,3,4,5)";
	CppSQLite3Query Query = m_pSqliteDatabase->execQuery(strSql.c_str());

	// 当前插入的位置
	int nCurrentIndex = 0;
	while(!Query.eof())
	{
		int nId = Query.getIntField("id", 0);
		ExportFavoriteData(nId,ppData,nCurrentIndex);

		Query.nextRow();
	}

	nDataNum = nCurrentIndex;

	return TRUE;
}
int CStorageUnitInfoTable::GetCapacityInfo(const char* buf, sCapacityInfo *pInfo)
{
    if(!m_pDB) 
    {
        cout<<"Invalid Sqlite"<<endl;
        return -1;
    }    

    try
    {
        CppSQLite3Query q = m_pDB->execQuery(buf);
        if(!q.eof())
        {
            pInfo->m_sumCap = q.getInt64Field("sumCapacity");
            pInfo->m_declaredCap = q.getInt64Field("declaredCapacity");
            pInfo->m_usedCap = q.getInt64Field("usedCapacity");
        }
        else
           return -1; 

    }

    catch(CppSQLite3Exception e)
    {
        cerr<<"CStorageUnitInfoTable::GetCapacityInfo:"<<e.errorCode()<<" "<<e.errorMessage()<<endl;
    }

    return 0;
}
int CStorageUnitInfoTable::GetSysCapacityInfo(sCapacityInfo *pInfo)
{
    char buf[MAX_BUF_LEN];
    memset(buf, 0, MAX_BUF_LEN);
    sprintf(buf, "select sum(sumCapacity), sum(declaredCapacity), sum(usedCapacity) from %s", m_strTableName.c_str());
    if(!m_pDB) 
    {
        cout<<"Invalid Sqlite"<<endl;
        return -1;
    }    

    try
    {
        CppSQLite3Query q = m_pDB->execQuery(buf);
        if(!q.eof())
        {
            pInfo->m_sumCap = q.getInt64Field(0);
            pInfo->m_declaredCap = q.getInt64Field(1);
            pInfo->m_usedCap = q.getInt64Field(2);
        }
        else
           return -1; 

    }

    catch(CppSQLite3Exception e)
    {
        cerr<<"CStorageUnitInfoTable::GetSysCapacityInfo:"<<e.errorCode()<<" "<<e.errorMessage()<<endl;
    }


    return 0;
}
Exemple #10
0
/*
int32 CBrainMemory::GetAllMeaning(int64 ID, map<int64,int64> 
&MeaningList){

	   CppSQLite3Buffer SQL;
	   CppSQLite3Query  Result;
       char a[30];
	   char b[30];
      
       MeaningList.clear();
	
//	   if(!RBrainHasTable(ID))return 0;
	   
	   ToRBrain(ID);
	   SQL.format("select %s, %s  from \"%s\" where %s=\"%s\" ;",
						RB_SPACE_ID,
		                RB_SPACE_VALUE,
			            _i64toa(ID,a,10),
						RB_SPACE_TYPE,
						_i64toa(MEMORY_TYPE_MEANING,b,10)                  
						);
	   Result = BrainDB.execQuery(SQL);
       
	   while(!Result.eof())
	   {
          MeaningList[Result.getInt64Field(1)] = Result.getInt64Field(0);
		  Result.nextRow();
	   }
	   return MeaningList.size();
}
*/	
int32 CBrainMemory::GetAllMeaningRoomID(int64 ID, deque<int64>& MeaningRoomIDList){
	   CppSQLite3Buffer SQL;
	   CppSQLite3Query  Result;
       char a[30],b[30];      
       MeaningRoomIDList.clear();
	
//	   if(!RBrainHasTable(ID))return 0;
	   
	   ToRBrain(ID);

	   int64toa(ID,a);
	   int64toa(MEMORY_BODY,b);
	   SQL.format("select %s  from \"%s\" where %s > \"%s\";",
						RB_SPACE_ID,
			            a, 
						RB_SPACE_TYPE,
						b                   
						);
	   Result = BrainDB.execQuery(SQL);
       
	   while(!Result.eof())
	   {
          MeaningRoomIDList.push_back(Result.getInt64Field(0));
		  Result.nextRow();
	   }
	   return MeaningRoomIDList.size();
}
Exemple #11
0
void   CBrainMemory::SetSystemItem(int64 Item,AnsiString Info){
	CppSQLite3Buffer SQL;
	CppSQLite3Query  Result;
	char a[30],b[30];
     int64toa(ROOM_SYSTEM,a);
	 int64toa(Item,b);

    SQL.format("select b from \"%s\" where a = \"%s\";",a,b);				
	Result = BrainDB.execQuery(SQL);
	bool Find = !Result.eof();
    Result.finalize();

	if(!Find){
		SQL.format("insert into \"%s\" values (\"%s\", ?)",
			a,
			b);
	}else{
		SQL.format("update \"%s\" set b = ? where a = \"%s\";",
			a,
			b
			);
	}

	CppSQLite3Statement State = BrainDB.compileStatement(SQL);
	State.bind(1,Info.c_str()); //替换第一个问号
	State.execDML();

}
Exemple #12
0
int64 CBrainMemory::GetChildType(int64 ParentRoomID,int64 ChildRoomID){
	ToRBrain(ParentRoomID);
 	 	
	if(!RBrainHasTable(ParentRoomID))return 0;

	CppSQLite3Buffer SQL;
	CppSQLite3Query  Result;
	char a[30],b[30];
   
	assert(ChildRoomID != 0 );
	int64toa(ParentRoomID,a);
	int64toa(ChildRoomID,b);

	SQL.format("select \"%s\" from \"%s\" where \"%s\" = \"%s\" ",
				RB_SPACE_TYPE,
				a,
				RB_SPACE_ID,
				b
				);
				
	Result = BrainDB.execQuery(SQL);
    if(Result.eof())return 0;  

	int64 ChildType = Result.getInt64Field(0);
	return ChildType;
};
Exemple #13
0
int64 CBrainMemory::GetChildID(int64 ParentRoom,int64 ChildRoomValue,int64 ChildRoomType)
{
	ToRBrain(ParentRoom);
    int64 ChildID;
	 
	
	if(!RBrainHasTable(ParentRoom))return 0;

	CppSQLite3Buffer SQL;
	CppSQLite3Query  Result;
	char a[30],b[30],c[30];
   
	assert(ChildRoomValue != 0 || ChildRoomType != 0);

	int64toa(ParentRoom,a);
	int64toa(ChildRoomValue,b);
	int64toa(ChildRoomType,c);

	SQL.format("select \"%s\" from \"%s\" where \"%s\" = \"%s\" and \"%s\" = %s;",
				RB_SPACE_ID,
				a,
				RB_SPACE_VALUE,
				b,				
				RB_SPACE_TYPE,
				c
				);
				
	Result = BrainDB.execQuery(SQL);
    if(Result.eof())return 0;  

	ChildID = Result.getInt64Field(0);
	return ChildID;
}
Exemple #14
0
tstring CBrainMemory::RetrieveToken(int64 RoomID){
	int64 CurrentRoomValue,RoomType; 
    int64  CurrentID = RoomID;
	
	//首先得到意义空间的信息
	if(!GetRoomInfo(RoomID,CurrentRoomValue,RoomType)){
		return NULL;
	}
	
	deque<int64> BodyList;
	while(1)
	{
		//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
		CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
		if(Result.eof())return 0;
		CurrentID = Result.getInt64Field(0);  //fatherID
		if(CurrentID == ROOT_SPACE)break;;
		CurrentRoomValue = Result.getInt64Field(1); //fatherValuse
        BodyList.push_front(CurrentRoomValue);
	}	

	tstring s;
	for (int i=0; i<BodyList.size(); i++)
	{
		int64 ID = BodyList[i];
		TCHAR ch = (TCHAR)ID;
		s += ch;
	}
	return s;
}
void UNotifySummaryList::loadDataSource()
{
    CppSQLite3Query src;
    UNotifySummaryDataSource::queryData(src);

    while(!src.eof()){
        UNotifySummaryDataField dest;
        UNotifySummaryDataSource::parseDataField(src, dest);

        UNotifySummary* info = new UNotifySummary;
        quint8 type = dest.notifyType;
        Mi::NotifyCategory notifyType = (Mi::NotifyCategory)type;

       info->setNotifyType(notifyType);
       info->setNotifyID(dest.notifyID);
       info->setNotifyName(dest.notifyName);
       info->setNotifyContent(dest.notifyContent);
       info->setNotifyTime(dest.notifyTime);
       info->setUnreadCount(dest.unreadCount);
       info->setNotifyImg(dest.portraitPath);

       this->insertList(info);
       src.nextRow();
    }
}
Exemple #16
0
vector<lip> limitIP::GetIPList()
{
	vector<lip> lips;
	__try
	{

	CppSQLite3Query query = m_pDB.execQuery(_T("SELECT IP,Remark FROM IPfliter"));

	while (!query.eof())
	{
		lip l;
		l.szIP = query.getStringField(_T("IP"));
		l.remark = query.getStringField(_T("Remark"));
		lips.push_back(l);

		query.nextRow();
	}

	return lips;
	}
	__except (Global::MyUnhandledExceptionFilter(GetExceptionInformation()))
	{
		return lips;
	}
}
void CUserAcessSetDlg::InserSingleSetConfig()
{

	CppSQLite3Table table;
	CppSQLite3Query q;

	CppSQLite3DB SqliteDBBuilding;
	SqliteDBBuilding.open((UTF8MBSTR)g_strCurBuildingDatabasefilePath);

	CString strSql;
	strSql.Format(_T("select * from UserLevelSingleSet where MainBuilding_Name='%s' and Building_Name='%s' and username='******'"),m_strMainBuilding,m_strSubNetName,m_strUserName);
	q = SqliteDBBuilding.execQuery((UTF8MBSTR)strSql);
	_variant_t temp_variant;
	BOOL b_useLogin=false;

	try
	{

		if(q.eof())
		{
			strSql.Format(_T("insert into UserLevelSingleSet values('%s','%s','%s',%i,%i)"),m_strMainBuilding,m_strSubNetName,m_strUserName,0,0);		
			SqliteDBBuilding.execDML((UTF8MBSTR)strSql); 
		}

		SqliteDBBuilding.closedb();
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}



}
void CTerminateNewLocationDialog::OnSelchangeLocationlist() 
{
    int iLocationID = m_ctlLocationList.GetItemData(m_ctlLocationList.GetCurSel());
    CString sSQL;
    sSQL.Format("SELECT Industries.id,Industries.name FROM Industries,Sidings WHERE Industries.Sidings_FK=Sidings.id AND Sidings.Locations_FK=%d",iLocationID);
    TRACE(sSQL);
    //
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    CppSQLite3Query q = pDB->execQuery(sSQL);
    //
    while( m_ctlIndustryList.GetCount() > 0 )
        m_ctlIndustryList.DeleteString(0);
    //
    while (!q.eof())
    {
        int nIndex = m_ctlIndustryList.AddString(q.getStringField("name"));
        m_ctlIndustryList.SetItemData(nIndex,q.getIntField("id"));
        q.nextRow();
    }
    //
    sSQL.Format("SELECT id,name FROM Sidings WHERE Locations_FK=%d;",iLocationID);
    q = pDB->execQuery(sSQL);
    //
    while( m_ctlSidingList.GetCount() > 0 )
        m_ctlSidingList.DeleteString(0);
    //
    while (!q.eof())
    {
        int nIndex = m_ctlSidingList.AddString(q.getStringField("name"));
        m_ctlSidingList.SetItemData(nIndex,q.getIntField("id"));
        q.nextRow();
    }
    q.finalize();
}
Exemple #19
0
EXPORT_C gint32 CContactDb::GetEntityById(guint32 nId, CDbEntity** ppEntity)
	{
	char sql[128] = {0};
	*ppEntity = NULL;
	
	OpenDatabase();
	sprintf(sql, "select * from contact where cid = %d;", nId);
	CppSQLite3Query query = m_dbBeluga.execQuery(sql);
	
	if (query.eof())
		{
		CloseDatabase();
		return ERROR(ESide_Client, EModule_Db, ECode_Not_Exist);
		}
	
	if (ContactType_Phone == query.getIntField(ContactField_Type))
		*ppEntity = new CPhoneContact(this, FALSE);
	else
		*ppEntity = new CIMContact(this);
	if (NULL == *ppEntity)
		{
		CloseDatabase();
		return ERROR(ESide_Client, EModule_Db, ECode_No_Memory);
		}
	
	for (int i=0; i<query.numFields(); i++)
		{
		GString * fieldValue = g_string_new(query.fieldValue(i));
		(*ppEntity)->SetFieldValue(i, fieldValue);
		g_string_free(fieldValue, TRUE);
		}
		
	CloseDatabase();
	return 0;
	}
Exemple #20
0
bool CWizIndexBase::SQLToStyleDataArray(const CString& strSQL, CWizStyleDataArray& arrayStyle)
{
    try
    {
        CppSQLite3Query query = m_db.execQuery(strSQL);
        while (!query.eof())
        {
            WIZSTYLEDATA data;
            data.strKbGUID = kbGUID();
            data.strGUID = query.getStringField(styleSTYLE_GUID);
            data.strName = query.getStringField(styleSTYLE_NAME);
            data.strDescription = query.getStringField(styleSTYLE_DESCRIPTION);
            data.crTextColor = query.getColorField(styleSTYLE_TEXT_COLOR);
            data.crBackColor = query.getColorField(styleSTYLE_BACK_COLOR);
            data.bTextBold = query.getBoolField(styleSTYLE_TEXT_BOLD);
            data.nFlagIndex = query.getIntField(styleSTYLE_FLAG_INDEX);
            data.tModified = query.getTimeField(styleDT_MODIFIED);
            data.nVersion = query.getInt64Field(styleVersion);

            arrayStyle.push_back(data);
            query.nextRow();
        }

        std::sort(arrayStyle.begin(), arrayStyle.end());
        return true;
    }
    catch (const CppSQLite3Exception& e)
    {
        return LogSQLException(e, strSQL);
    }
}
Exemple #21
0
bool DBSetting::GetValue(long lKey,std::string &strValue)
{
	//打开数据库
	CppSQLite3DB dbTask;
	dbTask.open(m_strDB.c_str());
	CheckCreateSettingTable(dbTask);
	CppSQLite3Buffer strSql;

	try{
		strSql.format("select value from T_Setting where key=%d;",lKey);
		CppSQLite3Query q = dbTask.execQuery(strSql);
		if (q.eof())
		{
			return false;
		}
		strValue = q.getStringField(0);
	}
	catch(CppSQLite3Exception &exp)
	{
		exp;
		ATLTRACE("error:%s\n",exp.errorMessage());
		ATLASSERT(FALSE);
		return false;
	}
	return true;
}
Exemple #22
0
bool CThumbIndex::AbstractIsExist(const CString& guid, const CString& type)
{
    if(!m_dbThumb.IsOpened())
        return false;
    CString sql = CString("select ") + "ABSTRACT_GUID" + " from " +TABLE_NAME_ABSTRACT+" where ABSTRACT_GUID='"
    +guid+ ("' AND ABSTRACT_TYPE=")
    +STR2SQL(type)
    +(";");
    try {
        CppSQLite3Query query = m_dbThumb.execQuery(sql);
        while (!query.eof()) {
            return true;
        }
		return false;
	}
	catch (const CppSQLite3Exception& e)
	{
		TOLOG(e.errorMessage());
        TOLOG(sql);
		return false;
	}
	catch (...) {
		TOLOG("Unknown exception while close DB");
		return false;
	}
}
Exemple #23
0
BOOL CCP_MainApp::GetClipData(long lID, CClipFormat &Clip)
{
	BOOL bRet = FALSE;

	try
	{
		CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT ooData FROM Data WHERE lParentID = %d AND strClipboardFormat = '%s'"), lID, GetFormatName(Clip.m_cfType));
		if(q.eof() == false)
		{
			int nDataLen = 0;
			const unsigned char *cData = q.getBlobField(_T("ooData"), nDataLen);
			if(cData != NULL)
			{
				Clip.m_hgData = NewGlobal(nDataLen);

				::CopyToGlobalHP(Clip.m_hgData, (LPVOID)cData, nDataLen);

				bRet = TRUE;
			}
		}
	}
	CATCH_SQLITE_EXCEPTION

	return bRet;
}
Exemple #24
0
int CDBObject::getFirstFile(char* name)
{
	try
	{
		if(name != NULL)
		{
			char szSql[]= {"SELECT * from Record"};
			CppSQLite3DB database;
			database.open(g_szFile);
			CppSQLite3Query query = database.execQuery(szSql);
			if(!query.eof())
			{
				string path = query.getStringField(8);
				string file= query.getStringField(7);
				sprintf(name, "%s\\%s", UTF_82ASCII(path).c_str(), UTF_82ASCII(file).c_str());
				return query.getIntField(0);
			}
		}
	}
	catch(...)
	{
		g_pLog->WriteLog("数据库查询异常 getFirstFile\n");
	}
	return -1;
}
Exemple #25
0
void CVoxSQLite::GetMergedContacts( const char* parent_username, MergedContacts& rList )
{
	CppSQLite3Buffer buf;
	buf.format( "SELECT * from [MergedContact] WHERE [parent_username] = %Q;", parent_username );

	try
	{
		CppSQLite3Statement stmt = m_db.compileStatement( (const char*)buf );

		int				nContactId	= 0;
		std::string		type		= "";
		CppSQLite3Query q			= stmt.execQuery();
		MergedContact	mc;

		//Process record set.
        while (!q.eof())
        {
			mc.setParentUsername( q.getStringField( 0 ) );
			mc.setUsername      ( q.getStringField( 1 ) );

			rList.Add( &mc );

			q.nextRow();
        }

		stmt.reset();
	}

	catch (CppSQLite3Exception& e)
	{
		e.errorCode();
	}
}
Exemple #26
0
BOOL CStaticDataMgr::ProcessDBFile( std::string strDbFile )
{
	try
	{
		m_DBConnection.open(strDbFile.c_str());
	}
	catch(CppSQLite3Exception& e)  
	{  
		printf("%s",e.errorMessage());  
		return FALSE;
	}  

	CppSQLite3Query TableNames = m_DBConnection.execQuery("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name");
	while(!TableNames.eof())
	{
		std::string strSql ="SELECT * from ";
		std::string strTbName = TableNames.getStringField("name", NULL);
		strSql += strTbName;

		CppSQLite3Query Tabledatas = m_DBConnection.execQuery(strSql.c_str());

		ProcessTable(strTbName, Tabledatas);
		
		TableNames.nextRow();
	}
	
	m_DBConnection.close();

	return TRUE;
}
bool CDittoCopyBuffer::PutClipOnDittoCopyBuffer(long lClipId, long lBuffer)
{
	try
	{
		//enclose in brackets so the query closes before we update below
		{
			CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID FROM CopyBuffers WHERE lCopyBuffer = %d"), lBuffer);
			if(q.eof())
			{
				theApp.m_db.execDMLEx(_T("INSERT INTO CopyBuffers VALUES(NULL, -1, %d);"), lBuffer);
			}
		}

		theApp.m_db.execDMLEx(_T("UPDATE CopyBuffers SET lClipID = %d WHERE lCopyBuffer = %d"), lClipId, lBuffer);

		CCopyBufferItem Item;
		g_Opt.GetCopyBufferItem(lBuffer, Item);
		if(Item.m_bPlaySoundOnCopy)
		{
			PlaySound(_T("ding.wav"), NULL, SND_FILENAME|SND_ASYNC);
		}

		return true;
	}
	CATCH_SQLITE_EXCEPTION

	return false;
}
Exemple #28
0
bool CDittoCopyBuffer::PastCopyBuffer(long lCopyBuffer)
{
	//Can't paste while another is still active
	if(WaitForSingleObject(m_Pasting, 1) == WAIT_TIMEOUT)
	{
		Log(_T("Copy Buffer pasted to fast"));
		return false;
	}

	m_RestoreTimer.ResetEvent();
	m_Pasting.ResetEvent();
	bool bRet = false;

	Log(StrF(_T("Start - PastCopyBuffer buffer = %d"), m_lCurrentDittoBuffer));

	try
	{
		CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT Main.lID FROM Main ")
													_T("INNER JOIN CopyBuffers ON CopyBuffers.lClipID = Main.lID ")
													_T("WHERE CopyBuffers.lCopyBuffer = %d"), lCopyBuffer);

		if(q.eof() == false)
		{
			m_pClipboard = new CClipboardSaveRestoreCopyBuffer;
			if(m_pClipboard)
			{
				//Save the clipboard, 
				//then put the new data on the clipboard
				//then send a paste
				//then wait a little and restore the original clipboard data
				if(m_pClipboard->Save())
				{
					CProcessPaste paste;
					paste.m_bSendPaste = true;
					paste.m_bActivateTarget = false;
					paste.GetClipIDs().Add(q.getIntField(_T("lID")));
					paste.DoPaste();

					m_pClipboard->m_lRestoreDelay = g_Opt.GetDittoRestoreClipboardDelay();

					Log(StrF(_T("PastCopyBuffer sent paste, starting thread to restore clipboard, Delay = %d"), m_pClipboard->m_lRestoreDelay));

					AfxBeginThread(CDittoCopyBuffer::DelayRestoreClipboard, (LPVOID)this, THREAD_PRIORITY_LOWEST);

					bRet = true;
				}
				else
				{
					Log(_T("PastCopyBuffer failed to save clipboard"));
				}
			}
		}
	}
	CATCH_SQLITE_EXCEPTION

	if(bRet == false)
		m_Pasting.SetEvent();

	return bRet;
}
void DeviceTransNotifyList::loadDataSource()
{
    CppSQLite3Query src;
    DeviceTransNotifyDataSource::queryData(src);

    while(!src.eof()){
       DeviceTransNotifyDataField dest;
       DeviceTransNotifyDataSource::parseDataField(src, dest);

       DeviceTransNotify* info = new DeviceTransNotify;
       info->setTransUserID(dest.srcUserID);
       info->setTransUserName(dest.srcUserName);
       info->setSrcClusterID(dest.srcClusterID);
       info->setSrcClusterName(dest.srcClusterName);
       info->setDestClusterID(dest.destClusterID);
       info->setDestClusterName(dest.destClusterName);
       info->setNotifyContent(dest.notifyContent);
       info->setNotifyVerify(dest.notifyVerify);
       info->setNotifyTime(dest.notifyTime);

       int reStatus = dest.status;
       Mi::MsgStatus status = (Mi::MsgStatus)reStatus;
       info->setReviewStatus(status);

       this->insertList(info);
       src.nextRow();
    }
}
Exemple #30
0
//void CDlgProjectNew::OnBnClickedButtonCancel()
//{
//	// TODO: 在此添加控件通知处理程序代码
//	m_bIsSave=false;
//	OnOK();
//}
bool CDlgProjectNew::IsExistProjectName(CString strProjectName)//该产品名称是否存在库存表中 true 存在 false 不存在
{

	CString strSQL;
	strSQL.Format(_T("select count(ProjectName) as COUNTProjectName from Project where ProjectName='%s';"),	strProjectName);
	int nCount=0;
	try
	{

		CppSQLite3DB db;
		db.open(CBoBoDingApp::g_strDatabasePath);
		CppSQLite3Query q = db.execQuery(strSQL);//销售单历史表

		if (!q.eof())
		{
			//nCount=q.fieldValue(_T("COUNTPinMingGuiGe"));
			nCount=q.getIntField(_T("COUNTProjectName"));
		}
	}
	catch (CppSQLite3Exception& e)
	{

		AfxMessageBox(e.errorMessage());
	}
	if(nCount>0) 
		return true;
	else
		return false;

}