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(); }
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(); } } }
//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; }
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(); }
//##ModelId=474D307602CF bool CClip_ImportExport::ImportFromSqliteDB(CppSQLite3DB &db, bool bAddToDB, bool bPutOnClipboard) { bool bRet = false; CStringA csCF_TEXT; CStringW csCF_UNICODETEXT; try { CppSQLite3Query q = db.execQuery(_T("Select * from Main")); while(q.eof() == false) { Clear(); int nVersion = q.getIntField(_T("lVersion")); if(nVersion == 1) { if(ImportFromSqliteV1(db, q)) { if(bAddToDB) { MakeLatestTime(); AddToDB(true); bRet = true; } else if(bPutOnClipboard) { bRet = true; } } } m_lImportCount++; //If putting on the clipboard and there are multiple //then append cf_text and cf_unicodetext if(bPutOnClipboard) { Append_CF_TEXT_AND_CF_UNICODETEXT(csCF_TEXT, csCF_UNICODETEXT); } q.nextRow(); } if(bRet && bAddToDB) { theApp.RefreshView(); } else if(bRet && m_lImportCount == 1 && bPutOnClipboard) { PlaceFormatsOnclipboard(); } else if(bRet && bPutOnClipboard) { PlaceCF_TEXT_AND_CF_UNICODETEXT_OnClipboard(csCF_TEXT, csCF_UNICODETEXT); } } CATCH_SQLITE_EXCEPTION_AND_RETURN(false) return bRet; }
char* CreateInfoByid(int id) { static char buffer[1024]={0}; static char querybuf[1024]={0}; char* str = "%s 体力%s 武力%s 智力%s 魅力%s 年龄%s 类型 %s"; memset(querybuf,0,1024); try { db.open("database/infodata.db"); sprintf(querybuf,"select heroinfo.name,ti,wu,zhi,mei,age,herotype.name from " " heroinfo,herotype where heroinfo.id=%d and heroinfo.type=herotype.id;",id); CppSQLite3Query q = db.execQuery(querybuf); //nge_charsets_utf8_to_gbk((uint8*)str, (uint8*)querybuf, strlen(str), 1024); if (!q.eof()) { sprintf(buffer,str, q.fieldValue(0),q.fieldValue(1),q.fieldValue(2),q.fieldValue(3), q.fieldValue(4),q.fieldValue(5),q.fieldValue(6)); } db.close(); }catch (CppSQLite3Exception& e){ printf("%s\n",e.errorMessage()); } return buffer; }
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; }
int CDbMeter::JoinTableDelete(const char* dbfilename, char* szID) { try { CppSQLite3DB db; db.open(dbfilename); CppSQLite3Buffer bufSQL; CppSQLite3Table t; db.execDML("CREATE TABLE IF NOT EXISTS jointable (joinkey INTEGER PRIMARY KEY, EUI64ID CHAR(17), jointry INTEGER);"); bufSQL.format("SELECT * FROM jointable WHERE EUI64ID=%Q", szID); t = db.getTable(bufSQL); if( t.numRows() == 0 ) { XDEBUG("Failure: Don't have JoinTable %s\r\n", szID); } else { bufSQL.clear(); bufSQL.format("DELETE FROM jointable WHERE EUI64ID=%Q;", szID); db.execQuery(bufSQL); } } catch( CppSQLite3Exception& e ) { XDEBUG("%s\r\n",e.errorMessage()); return e.errorCode(); } return SQLITE_OK; }
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 }
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; }
BOOL CCarTypesDetailDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here if( m_iCarTypeFK != -1 ) { CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CString sSQL; sSQL.Format("SELECT * FROM CarTypes WHERE id=%d",m_iCarTypeFK); CppSQLite3Query q = pDB->execQuery((LPCTSTR)sSQL); if( !q.eof() ) { m_sCarTypeDescription = q.getStringField("description"); m_sCarTypeID = q.getStringField("type_id"); m_bPassenger = q.getIntField("passenger")==1?TRUE:FALSE; } q.finalize(); } UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
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()); } }
BOOL CDlgMemoAdd::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 在此添加额外的初始化 //SetBackgroundColor(DialogSubBackgroundColor,TRUE); m_DateTime_ctlTime.SetFormat(_T("yyyy-MM-dd HH:mm")); SetBackgroundColor(DialogSubBackgroundColor,TRUE); m_Button_ctlSave.LoadStdImage(IDB_PNG_SAVE, _T("PNG")); m_Button_ctlCancel.LoadStdImage(IDB_PNG_CANCEL, _T("PNG")); m_Static_ctl1.SetBackgroundColor(DialogSubBackgroundColor,TRUE); //m_Static_ctl1.SetTextColor(StaticCaptionColor,TRUE); m_Static_ctl2.SetBackgroundColor(DialogSubBackgroundColor,TRUE); //m_Static_ctl2.SetTextColor(StaticCaptionColor,TRUE); m_Static_ctl3.SetBackgroundColor(DialogSubBackgroundColor,TRUE); //m_Static_ctl3.SetTextColor(StaticCaptionColor,TRUE); m_Static_ctl4.SetBackgroundColor(DialogSubBackgroundColor,TRUE); //m_Static_ctl4.SetTextColor(StaticCaptionColor,TRUE);*/ /*m_Static_ctl5.SetBackgroundColor(DialogSubBackgroundColor,TRUE); m_Static_ctl5.SetTextColor(StaticCaptionColor,TRUE);*/ try{ CppSQLite3DB db; db.open(CBoBoDingApp::g_strDatabasePath); CString strSQL=_T("select distinct * from CategoryMemo order by ID asc;"); CppSQLite3Query q = db.execQuery(strSQL); CString strCategoryName; while(!q.eof()) { strCategoryName=(q.fieldValue(_T("CategoryName"))); if (strCategoryName.Compare(_T("+"))!=0) { m_Combo_ctlCategory.AddString(strCategoryName); } q.nextRow(); } } catch (CppSQLite3Exception& e) { //AfxMessageBox(e.errorMessage()); } m_Combo_ctlCategory.SetCurSel(0); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
int CDbMeter::GroupDelete(const char* dbfilename, int nGroupKey) { try { CppSQLite3DB db; db.open(dbfilename); // 그룹테이블에 그룹이름이 있느지 확인 CppSQLite3Buffer bufSQL; //CppSQLite3Query q; CppSQLite3Table t; bufSQL.format("SELECT GroupKey FROM groups WHERE GroupKey=%d;", nGroupKey); t = db.getTable(bufSQL); if( t.numRows() == 0 ) { XDEBUG("ERROR: %d GroupKey doesn't exist in Groups Table!!\r\n", nGroupKey); return IF4ERR_GROUP_NAME_NOT_EXIST; } else { bufSQL.clear(); bufSQL.format("DELETE FROM groups WHERE GroupKey=%d;", nGroupKey); db.execDML(bufSQL); XDEBUG("%d GroupKey deleted in Groups Table!!\r\n", nGroupKey); //bufSQL.format("SELECT Groups.GroupName FROM groupmember LEFT OUTER JOIN groups ON groupmember.GroupKey=groups.GroupKey LEFT OUTER JOIN member ON groupmember.EUI64ID=member.EUI64ID WHERE groups.GroupName = %s;", szGroupName); } bufSQL.clear(); bufSQL.format("SELECT GroupKey FROM groupmember WHERE GroupKey=%d;", nGroupKey); t = db.getTable(bufSQL); if( t.numRows() == 0 ) { XDEBUG("ERROR: %d GroupKey doesn't exist!! in Groupmember Table!!\r\n", nGroupKey); return IF4ERR_GROUP_NAME_NOT_EXIST; } else { bufSQL.clear(); bufSQL.format("DELETE FROM groupmember WHERE GroupKey=%d;", nGroupKey); db.execQuery(bufSQL); XDEBUG("%d GroupKey deleted in Groupmember Table!!\r\n", nGroupKey); } db.close(); } catch( CppSQLite3Exception& e ) { XDEBUG("%s\r\n",e.errorMessage()); return e.errorCode(); } return SQLITE_OK; }
CString CEquipmentLocationDialog::GetCarType(int iCarTypeFK) { CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CString sSQL; sSQL.Format("SELECT description FROM CarTypes WHERE id=%d;",iCarTypeFK); CppSQLite3Query q = pDB->execQuery(sSQL); CString sType(""); if( !q.eof() ) sType = q.getStringField("description"); q.finalize(); return sType; }
void CLocationDetailDialog::OnOK() { // TODO: Add extra validation here UpdateData(); // CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CString sSQL; if( m_iLocationID == -1 ) sSQL.Format("INSERT INTO Locations (name,notes) VALUES (\"%s\",\"%s\")",m_sLocationName,m_sLocalInstructions); else sSQL.Format("UPDATE Locations SET name=\"%s\", notes=\"%s\" WHERE id=%d",m_sLocationName,m_sLocalInstructions,m_iLocationID); pDB->execQuery(sSQL); CDialog::OnOK(); }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector* pDirector = CCDirector::sharedDirector(); CCEGLView* pEGLView = CCEGLView::sharedOpenGLView(); pDirector->setOpenGLView(pEGLView); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionShowAll); // turn on display FPS pDirector->setDisplayStats(false); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); //将数据库复制到可写目录 string dbSrc = CCFileUtils::sharedFileUtils()->fullPathForFilename(GAME_SYS_DB); string dbDes = CCFileUtils::sharedFileUtils()->getWritablePath(); dbDes.append(GAME_SYS_DB); if(!OzgFileUtility::fileExists(dbDes)) OzgFileUtility::copyFile(dbSrc.c_str(), dbDes.c_str()); CCLog("%s", dbDes.c_str()); //记录检查,如果没有记录则生成 CppSQLite3DB db; db.open(dbDes.c_str()); CppSQLite3Query query = db.execQuery("select count(id) from save_data"); // CCLog("%i", query.getIntField(0)); if(query.getIntField(0) == 0) db.execDML(GAME_INIT_SQL); query.finalize(); db.close(); //初始化背景音乐和效果音的默认大小值 SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(CCUserDefault::sharedUserDefault()->getFloatForKey(GAME_BG_AUDIO_VOLUME, 1.0)); SimpleAudioEngine::sharedEngine()->setEffectsVolume(CCUserDefault::sharedUserDefault()->getFloatForKey(GAME_EFFECT_AUDIO_VOLUME, 1.0)); // create a scene. it's an autorelease object CCScene *pScene = RPGStartSceneLayer::scene(); // run pDirector->runWithScene(pScene); return true; }
void CLocationDialog::OnAddbutton() { CLocationDetailDialog pDlg; if( pDlg.DoModal() != IDOK ) return; CString sLocationName = pDlg.GetLocationName(); m_ctlLocationList.InsertItem(m_ctlLocationList.GetItemCount(),sLocationName); // // insert into database // CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CString sSQL; sSQL.Format("INSERT INTO Locations (name) VALUES (\"%s\")",sLocationName); pDB->execQuery(sSQL); // ReadDB(); }
void CDlgEventList::ShowPage(int nPageIndex) { CString str; int i = 0; int nStartIndex = 0; int nOffset = 0; CppSQLite3DB db; db.open(PATH_SQLITE_DB_808); //打开数据库 //查询记录总数量 m_nRecordCount = db.execScalar("SELECT count(*) FROM event_info;"); //计算总页数 if(m_nRecordCount > 0) m_nPageCount = (m_nRecordCount-1)/elist_count+1; else m_nPageCount = 1; //在数据库中查询第nPageIndex页的elist_count条数据 char szSqlBuffer[512]; sprintf(szSqlBuffer, "SELECT * FROM event_info ORDER BY event_ID DESC LIMIT %d, %d;", nPageIndex*elist_count, elist_count); CppSQLite3Query q = db.execQuery(szSqlBuffer); for( i = 0; i < elist_count; i++ ) { if ( !q.eof() ) //数据行 { m_nEvent_ID[i] = q.getIntField("event_ID"); m_list[i].chChar = q.fieldValue("event_content"); m_list[i].nState = BTN_STATE_NORMAL; q.nextRow(); } else //空白行 { m_ItemState[i] = 0; m_list[i].chChar = _T(""); m_list[i].nState = BTN_STATE_DISABLE; } } //释放statement q.finalize(); db.close(); //关闭数据库 return; }
void Char::save(){ Uint16 x,y,z; Location& loc = getPosition(); loc.getXYZ(x,y,z); try{ CppSQLite3DB accDb; accDb.open(DB_ACCOUNTS); std::string query = "UPDATE characters SET name=\""+getName() +"\", x_position="+ boost::lexical_cast< std::string >(x)+", y_position="+ boost::lexical_cast< std::string >(y)+", z_position="+ boost::lexical_cast< std::string >(z)+" WHERE id="+ boost::lexical_cast< std::string >(myId)+";"; accDb.execQuery(query.c_str()); accDb.close(); } catch(CppSQLite3Exception e){ std::string error = "Error saving Character with ID "+boost::lexical_cast< std::string >(myId)+ ", SQLite says: "+ e.errorMessage(); Logger::getInstance()->log(error, LOGMODE_DB); myClient.getServer().getConsole().printMsg(error, CONSOLE_ERROR); } }
int GetInfoCount() { int count = 0; try { db.open("database/infodata.db"); CppSQLite3Query q = db.execQuery("select count(*) from heroinfo;"); if (!q.eof()) { count = atoi(q.fieldValue(0)); } db.close(); }catch (CppSQLite3Exception& e){ printf("%s\n",e.errorMessage()); } return count; }
BOOL CTerminateNewLocationDialog::OnInitDialog() { CDialog::OnInitDialog(); CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CppSQLite3Query q = pDB->execQuery("SELECT id,name FROM Locations;"); // while (!q.eof()) { int nIndex = m_ctlLocationList.AddString(q.getStringField("name")); m_ctlLocationList.SetItemData(nIndex,q.getIntField("id")); q.nextRow(); } q.finalize(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CDlgWebsiteAdd::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 在此添加额外的初始化 //SetBackgroundColor(DialogBackgroundColor,TRUE); SetBackgroundColor(DialogSubBackgroundColor,TRUE); m_Button_ctlSave.LoadStdImage(IDB_PNG_SAVE, _T("PNG")); m_Button_ctlCancel.LoadStdImage(IDB_PNG_CANCEL, _T("PNG")); //m_Button_ctlSave.SetSkin(IDB_BITMAP_BUTTON_MID_NORMAL,IDB_BITMAP_BUTTON_MID_PRESSED,IDB_BITMAP_BUTTON_MID_ON,0,0,0,0,1,0); //m_Button_ctlCancel.SetSkin(IDB_BITMAP_BUTTON_MID_NORMAL,IDB_BITMAP_BUTTON_MID_PRESSED,IDB_BITMAP_BUTTON_MID_ON,0,0,0,0,1,0); try{ CppSQLite3DB db; db.open(CBoBoDingApp::g_strDatabasePath); CString strSQL=_T("select distinct * from CategoryWebsite order by ID asc;"); CppSQLite3Query q = db.execQuery(strSQL); CString strCategoryName; while(!q.eof()) { strCategoryName=(q.fieldValue(_T("CategoryName"))); if (strCategoryName.Compare(_T("+"))!=0) { m_Combo_ctlCategory.AddString(strCategoryName); } q.nextRow(); } } catch (CppSQLite3Exception& e) { //AfxMessageBox(e.errorMessage()); } m_Combo_ctlCategory.SetCurSel(0); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
void CMainTableFunctions::LoadAcceleratorKeys(CAccels& accels, CppSQLite3DB &db) { try { CppSQLite3Query q = db.execQuery(_T("SELECT lID, lShortCut FROM Main WHERE lShortCut > 0")); CAccel a; while(q.eof() == false) { a.Cmd = q.getIntField(_T("lID")); a.Key = q.getIntField(_T("lShortCut")); accels.AddAccel(a); q.nextRow(); } } CATCH_SQLITE_EXCEPTION }
Char::Char(Uint64 serial, Uint16 type, Uint32 dbId, Client& client) :IMoveableObject(serial, type), myId(dbId), myClient(client) { if (dbId != 0) {// The account has a valid character attached. try{ CppSQLite3DB accDb; accDb.open(DB_ACCOUNTS); std::string query = "SELECT * FROM characters WHERE id = \""+boost::lexical_cast< std::string >(myId)+"\";"; CppSQLite3Query q = accDb.execQuery(query.c_str()); if (!q.eof()){ setName(q.fieldValue(2)); setPosition(Location(q.getIntField(3),q.getIntField(4),q.getIntField(5))); mDestPos = mPos; // We set our destination to our actual location. // Since everything went fine we add the client to the list of active clients. (client.getServer()).addClient(&client); } else{ Logger::getInstance()->log("Error creating Character with ID "+boost::lexical_cast< std::string >(myId) +" no such character in DB!", LOGMODE_DB); } accDb.close(); } catch(CppSQLite3Exception e){ std::string error = "Error creating Character with ID "+boost::lexical_cast< std::string >(myId)+ ", SQLite says: "+ e.errorMessage(); Logger::getInstance()->log(error, LOGMODE_DB); (myClient.getServer()).getConsole().printMsg(error, CONSOLE_ERROR); } } else{ // Create a dummy char setName("Dummy"); setPosition(Location(0,0,0)); mDestPos = mPos; (client.getServer()).addClient(&client); } }
void CTroubleShootDlg::SaveNewIPAddress(CString newip,CString oldip){ CppSQLite3DB SqliteDBBuilding; CppSQLite3Table table; CppSQLite3Query q; SqliteDBBuilding.open((UTF8MBSTR)g_strCurBuildingDatabasefilePath); try { CString strSql; //////////////////////////////////////////////////////////////////////////////////////////// //获取数据库名称及路径 ///////////////////////////////////////////////////////////////////////////////////////////////// //连接数据库 strSql.Format(_T("select * from ALL_NODE where Bautrate='%s' "),oldip); //m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText); q = SqliteDBBuilding.execQuery((UTF8MBSTR)strSql); while(!q.eof()) { strSql.Format(_T("update ALL_NODE set Bautrate='%s' where Bautrate='%s'"),newip,oldip); SqliteDBBuilding.execDML((UTF8MBSTR)strSql); q.nextRow(); } CMainFrame* pFrame=(CMainFrame*)(AfxGetApp()->m_pMainWnd); ::PostMessage(pFrame->m_hWnd, WM_MYMSG_REFRESHBUILDING,0,0); } catch(_com_error e) { /* AfxMessageBox(e.Description());*/ //MessageBox(m_name_new+_T(" has been here\n Please change another name!")); //m_pCon->Close(); SqliteDBBuilding.closedb(); } //m_pCon->Close(); SqliteDBBuilding.closedb(); }
bool DBSetting::SetValue(long lKey,const std::string &strValue) { //打开数据库 CppSQLite3DB dbTask; dbTask.open(m_strDB.c_str()); CheckCreateSettingTable(dbTask); CppSQLite3Buffer strSql; try{ strSql.format("select count(*) from T_Setting where key=%d;",lKey); CppSQLite3Query q = dbTask.execQuery(strSql); if (0==q.getIntField(0)) { strSql.format("insert into T_Setting(key,value) values(%d,'%q');",lKey,strValue.c_str()); if(1!=dbTask.execDML(strSql)) { ATLASSERT(FALSE); return false; } } else { strSql.format("update T_Setting set value = '%q' where key=%d;",strValue.c_str(),lKey); if(1!=dbTask.execDML(strSql)) { ATLASSERT(FALSE); return false; } } } catch(CppSQLite3Exception &exp) { exp; ATLTRACE("error:%s\n",exp.errorMessage()); ATLASSERT(FALSE); return false; } return true; }
void CLocationDialog::ReadDB() { m_ctlLocationList.DeleteAllItems(); // // Read data // CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CppSQLite3Query q = pDB->execQuery("select id,name from Locations;"); // while (!q.eof()) { TRACE("%s %s\n",q.fieldValue(0),q.fieldValue(1)); int nIndex = m_ctlLocationList.InsertItem(1,q.fieldValue(1)); m_ctlLocationList.SetItemData(nIndex,atoi(q.fieldValue(0))); q.nextRow(); } q.finalize(); m_ctlEditButton.EnableWindow(FALSE); m_ctlDeleteButton.EnableWindow(FALSE); }
void CLocationDialog::OnDblclkLocationlist(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here int iSel = m_ctlLocationList.GetSelectionMark(); if( iSel >= 0 ) { CLocationDetailDialog pDlg; int iID = m_ctlLocationList.GetItemData(iSel); // pDlg.SetLocationName(m_ctlLocationList.GetItemText(iSel,0)); if( pDlg.DoModal() != IDOK ) return; CString sLocationName = pDlg.GetLocationName(); CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB; CString sSQL; sSQL.Format("update Locations set name=\"%s\" where id=%d",sLocationName,iID,0); pDB->execQuery(sSQL); // ReadDB(); } *pResult = 0; }
BOOL CDBObject::isFileInRecord(const char* file) { try { char szSql[MAX_PATH]= {}; sprintf_s(szSql, "SELECT * from Record Where FileName = '%s'", file); string strSql = szSql; strSql= ASCII2UTF_8(strSql); CppSQLite3DB database; database.open(g_szFile); CppSQLite3Query query = database.execQuery(strSql.c_str()); if(!query.eof()) { return TRUE; } } catch(...) { g_pLog->WriteLog("数据库查询异常 getFirstFile\n"); } return FALSE; }