BOOL Maxthon3PlugIn::IsWorked()
{
	BOOL bRet = FALSE;

	if (m_pMemFavoriteDB)
	{
		CppSQLite3DB  objSqliteDatabase;

		objSqliteDatabase.openmem(m_pMemFavoriteDB, "");

		bRet = objSqliteDatabase.tableExists("MyFavNodes");

		if (bRet)
		{
			CppSQLite3Table objSqliteTable = objSqliteDatabase.getTable("select * from MyFavNodes");

			if (14 != objSqliteTable.numFields())
			{
				bRet = FALSE;
			}
		}
	}

	return bRet;
}
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();
        }
    }
}
Exemple #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();
}
Exemple #5
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;

}
Exemple #6
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();
}
Exemple #7
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();
		}
	}        
}
std::string CWRecorder::dump()
{
	using namespace boost;
	format day_fmt("%04d/%02d/%02d");
	format time_fmt("%02d:%02d:%02d");
	format table_name_fmt("%s_%04d%02d%02d_%02d%02d%02d");

	// get current time
	time_t raw_time;
	tm* ptm;
	time(&raw_time);
	ptm = localtime(&raw_time);

	day_fmt%(ptm->tm_year+1900)%(ptm->tm_mon+1)%(ptm->tm_mday);
	time_fmt%(ptm->tm_hour)%(ptm->tm_min)%(ptm->tm_sec);
	table_name_fmt%name()%(ptm->tm_year+1900)%(ptm->tm_mon+1)%(ptm->tm_mday)%(ptm->tm_hour)%(ptm->tm_min)%(ptm->tm_sec);

	// add a record to RecordSummary table
	CppSQLite3DB* db = MyDatabase::shared_output_database();
	if(!db->tableExists("RecordSummary"))
	{
		throw HException("RecordSummary does not exist in output database");
	}
	format value_fmt("insert into RecordSummary values('%s','%s','%s')");
	value_fmt%day_fmt.str()%time_fmt.str()%table_name_fmt.str();
	db->execDML(value_fmt.str().c_str());

	return table_name_fmt.str();
}
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();
}
Exemple #10
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;
}
// xian modify so that save faster
std::string VehicleStateRecorder::dump()
{
	using namespace boost;
	string table = BaseT::dump();
	
	CppSQLite3DB* db = MyDatabase::shared_output_database();

	format fmt = format("create table %s (i int, elapsed_time double,x double, y double, z double)")%table;
	// creat a new record table
	db->execDML(
		fmt.str().c_str()
	);

	// using the table name as the fle name to generate a data file
	 fmt = format(CommandOption::Option().OutDir+"\\%s")%table;
	ofstream outf(fmt.str().c_str());


	// record the stuff
	unsigned int i=0;
	BOOST_FOREACH(BaseItemPtrT& p_record,m_Records)
	{
		ItemPtrT p = static_pointer_cast<ItemT>(p_record);
		if(p)
		{
			Point3D& pos = p->m_State.m_Ref.Position;
			//format fmt = format("insert into %s values(%d, %f, %f, %f, %f)")%table%i%(p->m_TimeElapse)%pos.x()%pos.y()%pos.z();
			//db->execDML(fmt.str().c_str());  db saving too slow, direct save
			format fmt = format("%d, %f, %f, %f, %f")%i%(p->m_TimeElapse)%pos.x()%pos.y()%pos.z();
			outf<<fmt.str().c_str()<<endl;
			++i;
		}
	}
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());
	}



}
Exemple #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;
}
Exemple #14
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 #15
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);
	*/
}
Exemple #16
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;
}
Exemple #17
0
bool CheckCreateLogTable(CppSQLite3DB &dbTask)
{
	try{
		//如果表格不存在,则创建表格
		if (!dbTask.tableExists("T_log"))                //创建事件日志表
		{
			//数据库字段:任务id,任务类型,任务时间,上次提示时间,提示语句等。
			//last_run_time可以用来辅助确定提示是否已经执行,避免重复
			dbTask.execDML("Create table T_log("
				"id integer PRIMARY KEY AUTOINCREMENT, "	//唯一id
				"modal char[128],"
				"time_log integer, "		//时间
				"type integer, "		//状态
				"value1 integer, "		//值1
				"value2 integer, "		//值2
				"message char[1024]);"	//提示语句
				);

			//为类型字段建立索引
			dbTask.execDML("create index idx_time on T_log(time_log);");
		}
		return true;
	}
	catch(CppSQLite3Exception &exp)
	{
		exp;
		ATLTRACE("error:%s\n",exp.errorMessage());
		ATLASSERT(FALSE);
		return false;
	}
}
Exemple #18
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;
	}
}
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 CEditTrainDialog::OnCancel() 
{
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    try { pDB->execDML("DROP TABLE _TL;"); } catch (...) {}
    try { pDB->execDML("DROP TABLE _TI;"); } catch (...) {}
	CDialog::OnCancel();
}
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 #22
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;
}
Exemple #23
0
bool CheckCreateSettingTable(CppSQLite3DB &dbTask)
{
	try{
		//如果表格不存在,则创建表格
		if (!dbTask.tableExists("T_Setting"))                //创建事件日志表
		{
			//数据库字段:任务id,任务类型,任务时间,上次提示时间,提示语句等。
			//last_run_time可以用来辅助确定提示是否已经执行,避免重复
			dbTask.execDML("Create table T_Setting("
				"key integer , "		//key
				"value char[1024]);"	//value
				);

			//为类型字段建立索引
			dbTask.execDML("create index idx_id on T_Setting(key);");
		}
		return true;
	}
	catch(CppSQLite3Exception &exp)
	{
		exp;
		ATLTRACE("error:%s\n",exp.errorMessage());
		ATLASSERT(FALSE);
		return false;
	}
}
Exemple #24
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;
}
void CEditTrainDialog::OnLocalswitcher() 
{
    UpdateData();
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    CString sSQL;
    int iLocationID = m_ctlRouteLocationList.GetItemData(m_ctlRouteLocationList.GetCurSel());
    sSQL.Format("UPDATE _TL SET localswitcher=%d WHERE Location_FK=%d;",m_bLocalSwitcher?1:0,iLocationID);
    pDB->execDML(sSQL);
}
void CEditTrainDialog::OnChangeMaxMoves() 
{
    UpdateData();
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    int iLocationID = m_ctlRouteLocationList.GetItemData(m_ctlRouteLocationList.GetCurSel());
    CString sSQL;
    sSQL.Format("UPDATE _TL SET max_moves=%d WHERE Location_FK=%d;",m_iMaxMoves,iLocationID);
    pDB->execDML(sSQL);
}
Exemple #27
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
}
Exemple #28
0
CppSQLite3DB& GetWorldDB(const TCHAR* DB)
{
	static CppSQLite3DB  __World;
	if(DB){
		__World.close();
		tstring DBDir = DB;
		__World.open(DBDir);
	}
	return __World;
}
void CEditTrainDialog::OnInterchangeCheck() 
{
    UpdateData();
    //
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    CString sSQL;
    int iLocationID = m_ctlRouteLocationList.GetItemData(m_ctlRouteLocationList.GetCurSel());
    sSQL.Format("UPDATE _TL SET switch_interchanges=%d WHERE Location_FK=%d;",m_bSwitchInterchanges?1:0,iLocationID);
    pDB->execDML(sSQL);
}
//##ModelId=474D30760272
bool CClip_ImportExport::ExportToSqliteDB(CppSQLite3DB &db)
{
	bool bRet = false;
	try
	{
		//Add to Main Table
		m_Desc.Replace(_T("'"), _T("''"));
		db.execDMLEx(_T("insert into Main values(NULL, %d, '%s');"), CURRENT_EXPORT_VERSION, m_Desc);
		long lId = (long)db.lastRowId();

		//Add to Data table
		CClipFormat* pCF;
		CppSQLite3Statement stmt = db.compileStatement(_T("insert into Data values (NULL, ?, ?, ?, ?);"));

		for(int i = m_Formats.GetSize()-1; i >= 0 ; i--)
		{
			pCF = & m_Formats.ElementAt(i);

			stmt.bind(1, lId);
			stmt.bind(2, GetFormatName(pCF->m_cfType));
			long lOriginalSize = GlobalSize(pCF->m_hgData);
			stmt.bind(3, lOriginalSize);

			const unsigned char *Data = (const unsigned char *)GlobalLock(pCF->m_hgData);
			if(Data)
			{
				//First compress the data
				long lZippedSize = compressBound(lOriginalSize);
				Bytef *pZipped = new Bytef[lZippedSize];
				if(pZipped)
				{				
					int nZipReturn = compress(pZipped, (uLongf *)&lZippedSize, (const Bytef *)Data, lOriginalSize);
					if(nZipReturn == Z_OK)
					{
						stmt.bind(4, pZipped, lZippedSize);
					}

					delete []pZipped;
					pZipped = NULL;
				}
			}
			GlobalUnlock(pCF->m_hgData);

			stmt.execDML();
			stmt.reset();

			m_Formats.RemoveAt(i);
		}

		bRet = true;
	}
	CATCH_SQLITE_EXCEPTION_AND_RETURN(false)

	return bRet;
}