⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqldatebase.cpp

📁 用vc编写的视频采集端口编成
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	if(strlen(lpstrServerName) < 20){
		strcpy(lpszServerName, lpstrServerName);
		if(RegOpenKeyEx(HKEY_CURRENT_USER, "software\\doggle\\AirGuard\\DataBase", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS){
			MessageBox(NULL, "Calling RegOpenKeyEx error", "error", MB_OK | MB_ICONERROR);
			return 0;
		}
		RegSetValueEx(hKey, "ServerName", NULL, REG_SZ, (BYTE*)lpszServerName, strlen(lpszServerName));
		RegCloseKey(hKey);
		return 1;
	}
	else return 0;

}
bool CSQLDatebase::DBSetHostName(LPSTR lpstrHostName)
{
	HKEY hKey;
	if(strlen(lpstrHostName) < 20){
		strcpy(lpszHostName, lpstrHostName);
		if(RegOpenKeyEx(HKEY_CURRENT_USER, "software\\doggle\\AirGuard\\DataBase", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS){
			MessageBox(NULL, "Calling RegOpenKeyEx error", "error", MB_OK | MB_ICONERROR);
			return 0;
		}
		RegSetValueEx(hKey, "WorkStation", NULL, REG_SZ, (BYTE*)lpszHostName, strlen(lpszHostName));
		RegCloseKey(hKey);
		return 1;
	}
	else return 0;

}

bool CSQLDatebase::DBSetUserName(LPSTR lpstrUserName)
{
	HKEY hKey;
	if(strlen(lpstrUserName) < 20){
		strcpy(lpszUserName, lpstrUserName);
		if(RegOpenKeyEx(HKEY_CURRENT_USER, "software\\doggle\\AirGuard\\DataBase", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
			MessageBox(NULL, "Calling RegOpenKeyEx error", "error", MB_OK | MB_ICONERROR);
		RegSetValueEx(hKey, "UserName", NULL, REG_SZ, (BYTE*)lpszUserName, strlen(lpszUserName));
		RegCloseKey(hKey);
		return 1;
	}
	else return 0;

}

bool CSQLDatebase::DBSetPassword(LPSTR lpstrPassword)
{
	HKEY hKey;
	if(strlen(lpstrPassword) < 20){
		strcpy(lpszPassword, lpstrPassword);
		if(RegOpenKeyEx(HKEY_CURRENT_USER, "software\\doggle\\AirGuard\\DataBase", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS){
			MessageBox(NULL, "Calling RegOpenKeyEx error", "error", MB_OK | MB_ICONERROR);
			return 0;
		}
		RegSetValueEx(hKey, "Password", NULL, REG_SZ, (BYTE*)lpszPassword, strlen(lpszPassword));
		RegCloseKey(hKey);
		return 1;
	}
	else return 0;

}

bool CSQLDatebase::DBSetTimeLimit(LPSTR lpstrTimeLimit)
{
	HKEY hKey;
	if(strlen(lpstrTimeLimit) < 20){
		strcpy(lpszTimeLimit, lpstrTimeLimit);
		dwTimeLimit = atoi(lpszTimeLimit);
		if(RegOpenKeyEx(HKEY_CURRENT_USER, "software\\doggle\\AirGuard\\DataBase", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS){
			MessageBox(NULL, "Calling RegOpenKeyEx error", "error", MB_OK | MB_ICONERROR);
			return 0;
		}
		RegSetValueEx(hKey, "TimeLimit", NULL, REG_SZ, (BYTE*)lpszTimeLimit, strlen(lpszTimeLimit));
		RegCloseKey(hKey);
		return 1;
	}
	else return 0;

}

bool CSQLDatebase::DBSetDBManager(LPSTR lpstrDBManager)
{
	HKEY hKey;
	if(strlen(lpstrDBManager) < 30){
		strcpy(lpszDataBaseManagerPath, lpstrDBManager);
		
		if(RegOpenKeyEx(HKEY_CURRENT_USER, "software\\doggle\\AirGuard\\DataBase", 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS){
			MessageBox(NULL, "Calling RegOpenKeyEx error", "error", MB_OK | MB_ICONERROR);
			return 0;
		}
		RegSetValueEx(hKey, "DataBaseManager", NULL, REG_SZ, (BYTE*)lpszDataBaseManagerPath, strlen(lpszDataBaseManagerPath));
		RegCloseKey(hKey);
		return 1;
	}
	else return 0;

}

bool CSQLDatebase::SaveTemplateInfo(CTemplateInDatebase *tid)
// Function: Save template information in database.
{
	LOGINREC* login;
	DBPROCESS* dbproc;
	DBCHAR mbid[10] = "abc";
	DBDATETIME jcsj = {2000, 1111};
	DBREAL hdz = 5;
	DBREAL mld = 10;
	RETCODE row_code;

	if(!dbinit())
		MessageBox(NULL, "dbinit() error", "Datebase error", MB_OK | MB_ICONSTOP);
//	dberrhandle(error_handler);
//	dbmsghandle(message_handler);
	if((login = dblogin()) == NULL)
		MessageBox(NULL, "dbinit() error", "Datebase error", MB_OK | MB_ICONSTOP);
	DBSETLUSER(login, "hd");
	DBSETLPWD(login, "hd");

	if((dbproc = dbopen(login, lpszServerName)) == NULL){
		MessageBox(NULL, "dbinit() error", "Datebase error", MB_OK | MB_ICONSTOP);
		return 0;
	}

	dbcmd(dbproc, "INSERT templateinfo(camera_id,chimney_id,stablish_time,b_simple,n_hornum,n_minhorlen,n_maxhorlen,");
	dbcmd(dbproc, "n_verleftlen,n_VerRightLen,f_slopeLeft,f_SlopeRight,f_LeftRadio,n_Lstartx,n_Lstarty,");
	dbcmd(dbproc, "n_LEndX,n_LEndY,n_RstartX,n_RstartY,n_REndX,n_REndY) ");
	dbfcmd(dbproc, "VALUES('%d','%d','2001/1/1 10:30 AM','%d','%d','%d','%d','%d','%d','%f','%f','%f','%d','%d','%d','%d','%d','%d','%d','%d')",
		tid->nCameraID,
		tid->nChimneyID, (int)tid->bSimple, tid->TemplateInfo.m_nHorNum,
		tid->TemplateInfo.m_nMinHorLen, tid->TemplateInfo.m_nMaxHorLen, tid->TemplateInfo.m_nVerLeftLen,
		tid->TemplateInfo.m_nVerRightLen, tid->TemplateInfo.m_slopeLeft, tid->TemplateInfo.m_slopeRight,
		tid->TemplateInfo.m_leftRadio, tid->TemplateInfo.m_nLStartX, tid->TemplateInfo.m_nLStartY,
		tid->TemplateInfo.m_nLEndX, tid->TemplateInfo.m_nLEndY, tid->TemplateInfo.m_nRStartX,
		tid->TemplateInfo.m_nRStartY, tid->TemplateInfo.m_nREndX, tid->TemplateInfo.m_nREndY);

	//SELECT tx FROM jcqk");
	dbsqlexec(dbproc);

	// read results to make sure the following operations will do successfully
	while(dbresults(dbproc) != NO_MORE_RESULTS)
		while((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS){
			//pImage = ((char*)dbdata(dbproc, 1));
		}
	

	dbexit();



	return 1;
}

bool CSQLDatebase::GetTemplateInfo(CTemplateInDatebase *tid)
{
	// Function:	Get template info of certain chimney designated by camera_id and chimney_id.
	//				These info can be used to recognize corresponding chimney.
	LOGINREC* login;
	DBPROCESS* dbproc;
	DBCHAR mbid[10] = "abc";
	DBDATETIME jcsj = {2000, 1111};
	DBREAL hdz = 5;
	DBREAL mld = 10;
	RETCODE row_code;
	RETCODE rc;
	DBDATETIME dt;

	if(!dbinit())
		MessageBox(NULL, "dbinit() error", "Datebase error", MB_OK | MB_ICONSTOP);
//	dberrhandle(error_handler);
//	dbmsghandle(message_handler);
	if((login = dblogin()) == NULL)
		MessageBox(NULL, "dbinit() error", "Datebase error", MB_OK | MB_ICONSTOP);
	DBSETLUSER(login, "hd");
	DBSETLPWD(login, "hd");

	if((dbproc = dbopen(login, lpszServerName)) == NULL){
		MessageBox(NULL, "dbinit() error", "Datebase error", MB_OK | MB_ICONSTOP);
		return 0;
	}

	dbcmd(dbproc, "SELECT camera_id,chimney_id,stablish_time,b_simple,n_hornum,n_minhorlen,n_maxhorlen,");
	dbcmd(dbproc, "n_verleftlen,n_VerRightLen,f_slopeLeft,f_SlopeRight,f_LeftRadio,n_Lstartx,n_Lstarty,");
	dbcmd(dbproc, "n_LEndX,n_LEndY,n_RstartX,n_RstartY,n_REndX,n_REndY FROM templateinfo ");
	dbfcmd(dbproc, "WHERE chimney_id=%d AND camera_id=%d", tid->nChimneyID, tid->nCameraID);

	
	


	dbsqlexec(dbproc);

	// read results to make sure the following operations will do successfully
	while((rc = dbresults(dbproc)) != NO_MORE_RESULTS){
		if(rc == SUCCEED){
			dbbind(dbproc, 1, INTBIND, (DBINT)0, (BYTE*)&(tid->nCameraID));
			dbbind(dbproc, 2, INTBIND, (DBINT)0, (BYTE*)&(tid->nChimneyID));
			dbbind(dbproc, 3, DATETIMEBIND, (DBINT)0, (BYTE*)&(dt));
			dbbind(dbproc, 4, INTBIND, (DBINT)0, (BYTE*)&(tid->bSimple));
			dbbind(dbproc, 5, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nHorNum));
			dbbind(dbproc, 6, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nMinHorLen));
			dbbind(dbproc, 7, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nMaxHorLen));
			dbbind(dbproc, 8, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nVerLeftLen));
			dbbind(dbproc, 9, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nVerRightLen));
			dbbind(dbproc, 10, FLT8BIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_slopeLeft));
			dbbind(dbproc, 11, FLT8BIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_slopeRight));
			dbbind(dbproc, 12, FLT8BIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_leftRadio));
			dbbind(dbproc, 13, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nLStartX));
			dbbind(dbproc, 14, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nLStartY));
			dbbind(dbproc, 15, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nLEndX));
			dbbind(dbproc, 16, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nLEndY));
			dbbind(dbproc, 17, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nRStartX));
			dbbind(dbproc, 18, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nRStartY));
			dbbind(dbproc, 19, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nREndX));
			dbbind(dbproc, 20, INTBIND, (DBINT)0, (BYTE*)&(tid->TemplateInfo.m_nREndY));

			while((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS){
				if(row_code == REG_ROW){
				}
			//pImage = ((char*)dbdata(dbproc, 1));
			}
		}
	}

	dbexit();

	return 1;
}

bool CSQLDatebase::GetCmnInfoByID(CChimneyInfo* cmninfo)
// Function: Get a smaple description of a chimney, including name and telephone number
//				designated by CameraID & ChimneyID.
{
	LOGINREC* login;
	DBPROCESS* dbproc;
	DBCHAR mbid[10] = "abc";
	DBDATETIME jcsj = {2000, 1111};
	DBREAL hdz = 5;
	DBREAL mld = 10;
	RETCODE row_code;
	RETCODE rc;

	if(!dbinit())
		MessageBox(NULL, "dbinit() error", "Datebase error", MB_OK | MB_ICONSTOP);
//	dberrhandle(error_handler);
//	dbmsghandle(message_handler);
	if((login = dblogin()) == NULL)
		MessageBox(NULL, "dbinit() error", "Datebase error", MB_OK | MB_ICONSTOP);
	DBSETLUSER(login, "hd");
	DBSETLPWD(login, "hd");

	if((dbproc = dbopen(login, lpszServerName)) == NULL){
		MessageBox(NULL, "dbinit() error", "Datebase error", MB_OK | MB_ICONSTOP);
		return 0;
	}

	dbcmd(dbproc, "SELECT qymc, qydh FROM qyjs,mbqk ");
	dbfcmd(dbproc, "WHERE mbid=%d AND camera_id=%d AND qyjs.qyid=mbqk.qyid", cmninfo->nChimneyID, cmninfo->nCameraID);

	dbsqlexec(dbproc);

	// read results to make sure the following operations will do successfully
	while((rc = dbresults(dbproc)) != NO_MORE_RESULTS){
		if(rc == SUCCEED){
			dbbind(dbproc, 1, NTBSTRINGBIND, (DBINT)100, (BYTE*)(cmninfo->lpszEnterpriseName));
			dbbind(dbproc, 2, NTBSTRINGBIND, (DBINT)20, (BYTE*)(cmninfo->lpszTelephoneNum));

			while((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS){
				if(row_code == REG_ROW){
				}
			//pImage = ((char*)dbdata(dbproc, 1));
			}
		}
	}

	dbexit();

	return 1;
}

CSQLDatebase::~CSQLDatebase()
{

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -