Example #1
0
void CParamDB::InsertPKGParam(PARAM_ITEM param)
{
	CppSQLite3DB db;

	try
	{
		if (FileExists(_sFilePath) == true)
		{
			db.open(AnsiString(_sFilePath).c_str());

			String szSQL =
				" insert into RecipeParameter "
				" ( "
				" group_idx, recipe_idx, parameter_idx , value "
				" ) "
				" values "
				" ("
				" '" + IntToStr(param.nGroup_idx) + "', "
				" '" + IntToStr(param.nRecipe_idx) + "', "
				" '" + IntToStr(param.nParameter_idx) + "', "
				" '" + FloatToStr(param.dValue) + "') ";

			db.execDML( "begin transaction;" );
			db.execDML(AnsiString(szSQL).c_str());
			db.execDML( "commit transaction;" );

			db.close();
		}
	}
	catch (Exception &e)
	{
		db.close();
	}
}
Example #2
0
void CParamDB::UpdatePKGParam(PARAM_ITEM param)
{
	CppSQLite3DB db;

	try
	{
		if (FileExists(_sFilePath) == true)
		{
			db.open(AnsiString(_sFilePath).c_str());

			String szSQL = 	" update RecipeParameter "
							" set "
							" Value = '" + FloatToStr(param.dValue) + "'"
							" where group_idx = '" + IntToStr(param.nGroup_idx) + "'"
							" and recipe_idx = '" + IntToStr(param.nRecipe_idx) + "'"
							" and parameter_idx = '" + IntToStr(param.nParameter_idx) + "'";

			db.execDML( "begin transaction;" );
			db.execDML(AnsiString(szSQL).c_str());
			db.execDML( "commit transaction;" );

			db.close();
		}
	}
	catch (Exception &e)
	{
		db.close();
	}
}
Example #3
0
void CDlgMemoAdd::OnBnClickedButtonSave()
{
	// TODO: 在此添加控件通知处理程序代码
	UpdateData(TRUE);
	try{
		CString strTime;
		strTime =m_DateTime_valTime.Format(_T("%Y-%m-%d %H:%M")); 
		CString strSQL;
		CppSQLite3DB db;


		db.open(CBoBoDingApp::g_strDatabasePath);//打开数据库
		strSQL.Format(_T("INSERT INTO Memo(MemoTime,Title,Content,CategoryName) VALUES('%s','%s','%s','%s');"),DealWithValue(strTime),DealWithValue(m_Edit_strTitle),DealWithValue(m_Edit_strContent),DealWithValue(m_Combo_strCategory));
		db.execDML(strSQL);
		

	}
	catch (CppSQLite3Exception& e)
	{

		AfxMessageBox(e.errorMessage());
	}
	m_bIsSave=true;
	OnOK();
}
Example #4
0
void CDlgProjectNew::OnBnClickedButtonSave()
{
	// TODO: 在此添加控件通知处理程序代码
	UpdateData(TRUE);
	if (m_Edit_strProjectName.IsEmpty())
	{
		AfxMessageBox(_T("项目名称不能为空。"));
		return;
	}

	if(IsExistProjectName(m_Edit_strProjectName)==true)
	{
		AfxMessageBox(_T("项目名称已存在,请重新输入。"));
		return;
	}
	try{
		CString strSQL;
		CppSQLite3DB db;
		db.open(CBoBoDingApp::g_strDatabasePath);//打开数据库
		strSQL.Format(_T("INSERT INTO Project(ProjectName,AccountType,ShuoMing) VALUES('%s','%s','%s');"),m_Edit_strProjectName,m_Combo_strProjectClass,m_Edit_strInstruction);
		db.execDML(strSQL);


	}
	catch (CppSQLite3Exception& e)
	{

		AfxMessageBox(e.errorMessage());
	}
	m_bIsSave=true;
	OnOK();
}
Example #5
0
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;
}
Example #6
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;
}
Example #7
0
bool CParamDB::DeletePKGParam(int nGroup_no, int nRecipe_no)
{
	CppSQLite3DB db;
	bool bResult = false;

	try
	{
		if (FileExists(_sFilePath) == true)
		{
			db.open(AnsiString(_sFilePath).c_str());

			String szSQL =
				" delete from RecipeParameter "
				" where group_idx = '" + IntToStr(nGroup_no) + "'"
				" and recipe_idx = '" + IntToStr(nRecipe_no) + "'";

			db.execDML( "begin transaction;" );
			bResult = db.execDML(AnsiString(szSQL).c_str());
			db.execDML( "commit transaction;" );

			db.close();

			return bResult;
		}
	}
	catch (Exception &e)
	{
		db.close();
		return false;
	}
}
Example #8
0
void __fastcall TFrmAlarmDetailList::grdErrorDetailSelectCell(TObject *Sender, int ACol,
          int ARow, bool &CanSelect)
{

	TStringGrid* pGrid = ( TStringGrid* )Sender;

    MemoSolution->Clear();
    MemoCause->Clear();

	if(CanSelect = true)
	{
		if(pGrid->Cells[ 1 ][ ARow ] != "" &&
           pGrid->Cells[ 1 ][ ARow ] != "0" )
		{
            AnsiString szQuery = "SELECT * FROM " + g_szDBList[_nTableIndex];

            INT nErrCode = pGrid->Cells[ 1 ][ ARow ].ToInt();

            CppSQLite3DB dbMain;
            dbMain.open( AnsiString( g_MainDBPath ).c_str() );
			CppSQLite3Table tblAlarm = dbMain.getTable( szQuery.c_str() );
			tblAlarm.setRow( nErrCode-1 );

			const char* szCause = tblAlarm.getStringField( "cause", "" );
			const char* szSolution = tblAlarm.getStringField( "solution", "" );

            MemoCause->Lines->Add( szCause );
            MemoSolution->Lines->Add( szSolution );

            dbMain.close();

			pGrid->Refresh();
		}
	}        
}
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());
	}



}
Example #10
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;

}
Example #11
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;
}
Example #12
0
//////////////////////////////////////////////////////////////////////////
//  [3/21/2011 DHKim]
//  그룹 테이블 생성 Table( GroupKey PrimaryKey, GroupName TEXT) 
//////////////////////////////////////////////////////////////////////////
int CDbMeter::db_Group_Create(const char* dbfilename)
{
	try
	{
		CppSQLite3DB db;

		db.open(dbfilename);
		db.execDML("CREATE TABLE IF NOT EXISTS groups (GroupKey INTEGER PRIMARY KEY, GroupName TEXT);");
		db.close();
	}
	catch ( CppSQLite3Exception& e )
	{
		return e.errorCode();
	}

	return SQLITE_OK;
	/*
	sqlite3* db = NULL;

	if(sqlite3_open(dbfilename, &db) != SQLITE_OK)
	{
		XDEBUG("SQLite open failed: %s\r\n", sqlite3_errmsg(db));
		return sqlite3_errcode(db);
	}
	if(sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS groups (GroupKey) INTEGER PRIMARY KEY, GroupName TEXT", NULL, NULL, NULL) != SQLITE_OK)
	{
		XDEBUG("SQLite create failed: %s\r\n", sqlite3_errmsg(db));
		return sqlite3_errcode(db);
	}

	sqlite3_close(db);

	return sqlite3_errcode(db);
	*/
}
Example #13
0
int CDbMeter::JoinTableDelete(const char* dbfilename)
{
	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;");
		t = db.getTable(bufSQL);

		if( t.numRows() == 0 )
		{
			XDEBUG("Failure: Don't have JoinTable\r\n");
		}
		else
		{
			db.execDML("DROP TABLE joinTable;");
		}
	}
	catch( CppSQLite3Exception& e )
	{
		XDEBUG("%s\r\n",e.errorMessage());
		return e.errorCode();
	}
	return SQLITE_OK;
}
Example #14
0
int CDbMeter::JoinTableShow(const char* dbfilename)
{
	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;");

		t = db.getTable(bufSQL);

		for ( int row = 0; row < t.numRows(); row++)
		{
			t.setRow(row);
			for (int fld=0; fld<t.numFields(); fld++)
			{
				if( !t.fieldIsNull(fld))
					XDEBUG("%s | ", t.fieldValue(fld));
			}
			XDEBUG("\r\n");
		}

	}
	catch( CppSQLite3Exception& e )
	{
		XDEBUG("%s\r\n",e.errorMessage());
		return e.errorCode();
	}
	return SQLITE_OK;
}
Example #15
0
int CDbMeter::JoinTableAdd(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 )
		{
			bufSQL.clear();
			bufSQL.format("INSERT INTO jointable(EUI64ID, jointry) VALUES(%Q, %d);", szID, 0);
			db.execDML(bufSQL);
		}
		else
			XDEBUG("Jointable ID Duplicate!!\r\n");

		db.close();
	}
	catch( CppSQLite3Exception& e )
	{
		XDEBUG("%s\r\n",e.errorMessage());
		return e.errorCode();
	}
	return SQLITE_OK;
}
Example #16
0
// ---------------------------------------------------------------------------
CppSQLite3Table CParamDB::LoadParameter(int nCategory)
{
	CppSQLite3DB db;
	CppSQLite3Table qryTable;

	try
	{
		if (FileExists(_sFilePath) == true)
		{
			db.open(AnsiString(_sFilePath).c_str());

			String szSQL = " select * from Parameter "
						   " where name <> ''"
//							" where category = '" + GetCategory(nCategory) + "'"
//							" or category = '3'"
							" order by idx ";

			qryTable = db.getTable(AnsiString(szSQL).c_str());
		}
	}
	catch (Exception &e)
	{

	}

	db.close();
	return qryTable;
}
Example #17
0
void DBLog::Log( const char *pModel,int code,int value1,int value2, const char *pMessage )
{
	//打开数据库
	CppSQLite3DB dbTask;
	dbTask.open(m_strDB.c_str());
	CheckCreateLogTable(dbTask);

	CppSQLite3Buffer strSql;
	strSql.format("insert into T_Log values(NULL,'%q',%d,%d,%d,%d,'%q');",
		pModel,GlobeFuns::TimeToInt(CTime::GetCurrentTime()),code,value1,value2,pMessage
		);

	try{
		if(1!=dbTask.execDML(strSql))
		{
			ATLASSERT(FALSE);
			return;
		}
	}
	catch(CppSQLite3Exception &exp)
	{
		exp;
		ATLTRACE("error:%s\n",exp.errorMessage());
		ATLASSERT(FALSE);
		return;
	}
}
Example #18
0
void Chat::init()
{
    string strDbPath = strRunningDir+"minho_chat.db";
    //MessageBoxA(NULL, strDbPath.c_str(), "", MB_OK);
    //sqlite3_open(strDbPath.c_str(), &mpDB);
    db.open(strDbPath.c_str());
}
Example #19
0
bool CppSQLite3DB::repair(const CString& strDBFileName, const CString& strRetFileName)
{
	try
	{
		CString strTempFileName = ::WizGlobal()->GetTempPath() + WizIntToStr(GetTickCount()) + _T(".tmp");
		//
		CppSQLite3DB dbSrc;
        dbSrc.open(strDBFileName);
		//
		if (!dbSrc.dump(strTempFileName))
		{
			throw CppSQLite3Exception(-1, "Failed to dump database!");
		}
		//
		dbSrc.close();
		//
        if (PathFileExists(strRetFileName))
		{
            DeleteFile(strRetFileName);
		}
		//
		CppSQLite3DB dbDest;
        dbDest.open(strRetFileName);
		//
		if (!dbDest.read(strTempFileName))
		{
			throw CppSQLite3Exception(-1, "Failed to rebuild database form index!");
		}
		//
		dbDest.close();
		//
#ifdef Q_OS_WIN32
                _flushall();
#endif
		//
		return true;
	}
	catch (CppSQLite3Exception& e)
	{
                TOLOG(e.errorMessage());
		return false;
	}
	//
	return false;
}
Example #20
0
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
}
Example #21
0
File: Space.cpp Project: GMIS/GMIS
CppSQLite3DB& GetWorldDB(const TCHAR* DB)
{
	static CppSQLite3DB  __World;
	if(DB){
		__World.close();
		tstring DBDir = DB;
		__World.open(DBDir);
	}
	return __World;
}
Example #22
0
void CMissedCallsDlg::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	CppSQLite3DB db;
	db.open(CStringA(OUTCALL_DB));
	try {
		db.execDML("update MissedCalls set NewCall=0 where NewCall=2");
	} catch (CppSQLite3Exception& e) { }

	OnOK();
}
Example #23
0
void CMissedCallsDlg::OnCancel()
{
	CppSQLite3DB db;
	db.open(CStringA(OUTCALL_DB));

	try {
		db.execDML("update MissedCalls set NewCall=0 where NewCall=2");	
	} catch (CppSQLite3Exception& e) { }

	CDialog::OnCancel();
}
Example #24
0
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;
}
void T3000_Default_MainView::OnCbnKillfocusBaudratecombo()
{
	if (product_register_value[MODBUS_BAUDRATE] == m_brandrate_combox.GetCurSel())	//Add this to judge weather this value need to change.
		return;

	/* Post_Thread_Message(MY_WRITE_ONE,g_tstat_id,MODBUS_BAUDRATE,m_baudRateCombox.GetCurSel(),
	product_register_value[MODBUS_BAUDRATE],this->m_hWnd,IDC_BAUDRATECOMBO,_T("BAUDRATE"));*/

	int ret = write_one(g_tstat_id, MODBUS_BAUDRATE, m_brandrate_combox.GetCurSel());

	int index_brandrate = m_brandrate_combox.GetCurSel();
	int brandrate = 19200;

	if (index_brandrate == 0)
	{
		brandrate = 9600;
	}
	else if (index_brandrate == 1)
	{
		brandrate = 19200;
	}
	else if (index_brandrate == 2)
	{
		brandrate = 38400;
	}
	else if (index_brandrate == 3)
	{
		brandrate = 57600;
	}
	else if (index_brandrate == 4)
	{
		brandrate = 115200;
	}
	if (GetCommunicationType() == 1)
	{
		return;
	}
	CString SqlText;

	SqlText.Format(_T("update ALL_NODE set Bautrate = '%d' where Serial_ID='%d'"), brandrate, get_serialnumber());
	Change_BaudRate(brandrate);


	CppSQLite3DB SqliteDBBuilding;
	CppSQLite3Table table;
	CppSQLite3Query q;
	SqliteDBBuilding.open((UTF8MBSTR)g_strCurBuildingDatabasefilePath);

	SqliteDBBuilding.execDML((UTF8MBSTR)SqlText);
	SqliteDBBuilding.closedb();
	CMainFrame* pFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd);
	pFrame->ScanTstatInDB();
}
void CUserAcessSetDlg::OnCbnSelchangeSinglesetcombo()
{
	
	if(m_nCurRow2==0)
		return;
	if(m_nCurCol2==0)
		return;
	CString strValue;
	strValue=m_FlexGrid2.get_TextMatrix(m_nCurRow2,m_nCurCol2);
	CString strSelect;
	int nIdext=m_singleLevelSetCombox.GetCurSel();
	if(nIdext>=0)
	{
		m_singleLevelSetCombox.GetLBText(nIdext,strSelect);
		if(strSelect.CompareNoCase(strValue)==0)
		{
			return;
		}
		else
		{
			int nNewValue=nIdext;
			m_FlexGrid2.put_TextMatrix(m_nCurRow2,m_nCurCol2,strSelect);

			CString strField;
			if(m_nCurCol2==2)
				strField="networkcontroller";
			if(m_nCurCol2==3)
				strField="database_limition";
	
			try
			{

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

			CString strSql;

			strSql.Format(_T("update UserLevelSingleSet set "+strField+" = %i where username ='******' and MainBuilding_Name='%s' and Building_Name='%s'"),nNewValue,m_strUserName,m_strMainBuilding,m_strSubNetName);
			 
              SqliteDBBuilding.execDML((UTF8MBSTR)strSql);
			SqliteDBBuilding.closedb();
			}
			catch(_com_error *e)
			{
				AfxMessageBox(e->ErrorMessage());
			}

		}
	}
	
}
Example #27
0
//////////////////////////////////////////////////////////////////////////
//  [3/23/2011 DHKim]
//  성공적으로 그룹테이블에 그룹이 추가되면 GroupKey를 리턴한다. 실패시 -1을 리턴
//////////////////////////////////////////////////////////////////////////
int CDbMeter::GroupAdd(const char* dbfilename, char* szGroupName)
{
	int nGroupKey = -1;
	try
	{
		CppSQLite3DB db;
		db.open(dbfilename);
		CppSQLite3Buffer bufSQL;
		CppSQLite3Table t;

		bufSQL.format("INSERT INTO groups(GroupName) VALUES(%Q);", szGroupName);
		db.execDML(bufSQL);
		XDEBUG("Success: INSERT Command!!\r\n");

		bufSQL.clear();
		bufSQL.format("SELECT GroupKey FROM groups WHERE GroupName=%Q;", szGroupName);
		//CppSQLite3Query q = db.execQuery(bufSQL);
		t = db.getTable(bufSQL);
		
		if( t.numRows() == 0 )
		{
			XDEBUG("Failure: SELECT Command!!\r\n");
			return nGroupKey;
		}
		else
		{
			// 동일 이름시 마지막에 추가된 그룹 키를 리턴한다.
			int nFinalRow = t.numRows() - 1;
			t.setRow(nFinalRow);
			if( !t.fieldIsNull(nFinalRow) )
				nGroupKey = atoi(t.fieldValue(nFinalRow));
			else
			{
				XDEBUG("Error: GroupKey is NULL!!\r\n");
				return nGroupKey;
			}
			XDEBUG("Success: SELECT Command!!\r\n");
		}

		//nGroupKey = q.getIntField("GroupKey", -1);
		
		db.close();
	}
	catch( CppSQLite3Exception& e )
	{
		XDEBUG("%s\r\n",e.errorMessage());
		return -1;
	}

	return nGroupKey;
}
Example #28
0
void CMissedCallsDlg::OnBnClickedButtonRemove()
{
	// TODO: Add your control notification handler code here
	CString sDate, sTime, callee, callerID;
	int nItem = m_list.GetNextItem(-1, LVNI_SELECTED);
	if (nItem==-1)
		return;
	if (MessageBox(_("Are you sure you want to delete the selected items?"), APP_NAME, MB_YESNO | MB_ICONQUESTION)==IDYES) {		
		CppSQLite3DB db;
		db.open(CStringA(OUTCALL_DB));			
		
		CString query, table;
		if (m_cboShow.GetCurSel()==0)
			table="MissedCalls";
		else if (m_cboShow.GetCurSel()==1)
			table="RecivedCalls";
		else
			table="PlacedCalls";		

		int nIndex;

		try {

			db.execDML("begin transaction");

			while (nItem!=-1) { //from to time date
				callerID = m_list.GetItemText(nItem, 0);
				callee = m_list.GetItemText(nItem, 1);
				sDate = m_list.GetItemText(nItem, 2);
				nIndex = sDate.Find(_T(", "));
				sTime = sDate.Mid(nIndex+2);
				sDate = sDate.Mid(0, nIndex);

				query = "delete from " + table + " where (CallerID='" + EscapeSQLString(callerID) + "' and Callee='" + 
					EscapeSQLString(callee) + "' and Date='" + sDate +"' and Time='" + sTime + "')";
				db.execDML(query.GetBuffer());
				
				m_list.DeleteItem(nItem);
				nItem--;
				nItem = m_list.GetNextItem(nItem, LVNI_SELECTED);
			}

			db.execDML("end transaction");		

		} catch (CppSQLite3Exception& e) { }
	}
	BOOL bEnable = (m_list.GetNextItem(-1, LVNI_SELECTED)!=-1)?TRUE:FALSE;
	GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(bEnable);
	GetDlgItem(IDC_BUTTON_CALL)->EnableWindow(bEnable);	
	m_btnAddContact.EnableWindow(bEnable && (::theApp.GetProfileInt("Settings", "OutlookFeatures", 1)==1));
}
Example #29
0
BOOL CDBObject::DeleteRecord(int nId)
{
	char szSql[MAX_PATH] = {0};
	sprintf_s(szSql, "delete from Record where id=%d", nId);

	CppSQLite3DB db;
	db.open(g_szFile);
	int nRet2 = db.execDML("begin transaction;");
	string strSql = szSql;
	nRet2 = db.execDML(ASCII2UTF_8(strSql).c_str());
	nRet2 = db.execDML("commit transaction;");
	
	return TRUE;
}
Example #30
0
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;
}