Kaynağa Gözat

修改部分函数顺序,服务器表、分支表可弃用。

sat23 4 yıl önce
ebeveyn
işleme
231777e163

+ 172 - 286
CTSManager/CTSManager/Database.cpp

@@ -139,119 +139,6 @@ BOOL CDatabase::ExcuteSQL(std::string sql)
 	return TRUE;
 }
 
-#if DEPRECATED
-BOOL CDatabase::InserProvider(const STProvider& provider)
-{
-	CHECKDB;
-	TCHAR szSql[MAX_PATH] = {0};
-	_stprintf_s(szSql, INSER_PROVIDER, provider.name.c_str(), provider.note.c_str());
-	if (0 != mysql_query(m_pConn, szSql)) {
-#ifdef _DEBUG
-		_dprintf(_T("InserProvider error=%s\n"), m_pError ? m_pError : "");
-#endif
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-BOOL CDatabase::InserProvider(std::string name, std::string note)
-{
-	CHECKDB;
-	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, INSER_PROVIDER, name.c_str(), note.c_str());
-	if (0 != mysql_query(m_pConn, szSql)) {
-#ifdef _DEBUG
-		_dprintf(_T("InserProvider error=%s\n"), m_pError ? m_pError : "");
-#endif
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-BOOL CDatabase::DeleteProvider(std::string name)
-{
-	CHECKDB;
-	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, DEL_PROVIDER, name.c_str());
-	if (0 != mysql_query(m_pConn, szSql)) {
-#ifdef _DEBUG
-		_dprintf(_T("DeleteProvider error=%s\n"), m_pError ? m_pError : "");
-#endif
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-BOOL CDatabase::UpdateProvider(std::string name, const STProvider& provider)
-{
-	CHECKDB;
-	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, MOD_PROVIDER, provider.name.c_str(), provider.note.c_str(), name.c_str());
-	if (0 != mysql_query(m_pConn, szSql)) {
-#ifdef _DEBUG
-		_dprintf(_T("DeleteProvider error=%s\n"), m_pError ? m_pError : "");
-#endif
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-BOOL CDatabase::QueryProvider(std::vector<STProvider>& vtProvider)
-{
-	CHECKDB;
-	if (0 != mysql_query(m_pConn, QUERY_PROVIDER)) {
-#ifdef _DEBUG
-		_dprintf(_T("QueryProvider error=%s\n"), m_pError ? m_pError : "");
-#endif
-		return FALSE;
-	}
-
-	// 获取表数据;
-	MYSQL_RES* pData = mysql_store_result(m_pConn);
-	if ( pData == NULL ) {
-#ifdef _DEBUG
-		_dprintf(_T("QueryProvider error=%s\n"), m_pError ? m_pError : "");
-#endif
-		return FALSE;
-	}
-
-#ifdef _DEBUG
-	// 统计表字段;
-	unsigned int nLen = mysql_num_fields(pData);
-	// 字段长度是否一致;
-	if (nLen != 2) {
-		mysql_free_result(pData);
-		return FALSE;
-	}
-
-	// 打印出字段名称;
-	TCHAR szLog[MAX_PATH] = {0};
-	for ( int i = 0; i < nLen; i++ ) {
-		_stprintf_s(szLog, _T("字段名称:%s\n"), mysql_fetch_field(pData)->name);
-		OutputDebugString(szLog);
-	}
-#endif
-
-	// 遍历数据;
-	MYSQL_ROW row;
-	while ( (row = mysql_fetch_row(pData)) != NULL ) {
-		STProvider provider;
-		provider.name = row[0];
-		provider.note = row[1];
-		vtProvider.push_back(provider);
-	}
-
-	// 释放内存;
-	mysql_free_result(pData);
-
-	return TRUE;
-}
-#endif
-
 BOOL CDatabase::InserSoc(const STSOC& soc)
 {
 	CHECKDB;
@@ -476,7 +363,6 @@ BOOL CDatabase::QuerySoc(std::vector<STSOC>& vtSoc)
 	return TRUE;
 }
 
-
 BOOL CDatabase::InsertBrand(const STBrand& brand)
 {
 	CHECKDB;
@@ -745,7 +631,7 @@ BOOL CDatabase::QueryQuarter(std::vector<STQuarter>& vtQuarter)
 		STQuarter quarter;
 		quarter.name = row[0];
 		quarter.scp = row[1] == NULL ? _T("") : row[1];
-		quarter.note = row[2] == NULL ? _T("") : row[1];
+		quarter.note = row[2] == NULL ? _T("") : row[2];
 		vtQuarter.push_back(quarter);
 	}
 
@@ -755,14 +641,20 @@ BOOL CDatabase::QueryQuarter(std::vector<STQuarter>& vtQuarter)
 	return TRUE;
 }
 
-BOOL CDatabase::InsertServer(const STServer& Server)
+BOOL CDatabase::InsertQBrand(const STQbrand& QBrand)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, INSER_SERVER, Server.name.c_str(), Server.ip.c_str(), Server.type.c_str(), Server.user.c_str(), Server.password.c_str(),Server.note.c_str());
+	_stprintf_s(szSql, INSER_QBRAND, QBrand.soc.c_str(), QBrand.brand.c_str(), QBrand.quarter.c_str(),
+		QBrand.whitelist.c_str(), QBrand.version.c_str(),
+		QBrand.oemkey.c_str(), QBrand.approved.c_str(),
+		QBrand.approveddate.c_str(), QBrand.fingerprint.c_str(),
+		QBrand.builddate.c_str(), QBrand.gtvs.c_str(),
+		QBrand.ftpdir.c_str(), QBrand.codedir.c_str(),
+		QBrand.note.c_str(), QBrand.status.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("InsertServer error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("InsertQBrand error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -770,14 +662,14 @@ BOOL CDatabase::InsertServer(const STServer& Server)
 	return TRUE;
 }
 
-BOOL CDatabase::InsertServer(std::string name, std::string ip, std::string type, std::string user, std::string password, std::string note)
+BOOL CDatabase::DeleteQBrand(std::string soc, std::string quarter, std::string brand)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, INSER_SERVER, name.c_str(), ip.c_str(), type.c_str(), user.c_str(), password.c_str(), note.c_str());
+	_stprintf_s(szSql, DEL_QBRAND, soc.c_str(), brand.c_str(), quarter.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("InsertServer error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("DeleteQBrand error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -785,14 +677,23 @@ BOOL CDatabase::InsertServer(std::string name, std::string ip, std::string type,
 	return TRUE;
 }
 
-BOOL CDatabase::DeleteServer(std::string name)
+BOOL CDatabase::UpdateQBrand(std::string brand, STQbrand& QBrand)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, DEL_SERVER, name.c_str());
+	_stprintf_s(szSql, MOD_QBRAND, QBrand.soc.c_str(), QBrand.quarter.c_str(),
+		QBrand.brand.c_str(), QBrand.whitelist.c_str(),
+		QBrand.version.c_str(), QBrand.approved.c_str(),
+		QBrand.oemkey.c_str(), QBrand.approveddate.c_str(),
+		QBrand.fingerprint.c_str(), QBrand.builddate.c_str(),
+		QBrand.gtvs.c_str(), QBrand.note.c_str(),
+		QBrand.apps_cfg.c_str(), QBrand.fav_cfg.c_str(),
+		QBrand.local_cfg.c_str(), QBrand.ftpdir.c_str(),
+		QBrand.codedir.c_str(), QBrand.status.c_str(),
+		brand.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("DeleteServer error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("UpdateQBrand error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -800,14 +701,21 @@ BOOL CDatabase::DeleteServer(std::string name)
 	return TRUE;
 }
 
-BOOL CDatabase::UpdateServer(std::string name, const STServer& Server)
+BOOL CDatabase::UpdateQBrand(std::string soc, std::string quarter, std::string brand, STQbrand& QBrand)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, MOD_SERVER, Server.name.c_str(), Server.ip.c_str(), Server.type.c_str(), Server.user.c_str(), Server.password.c_str(), Server.note.c_str(), name.c_str());
+	_stprintf_s(szSql, MOD_QBRAND,
+		QBrand.soc.c_str(), QBrand.quarter.c_str(), QBrand.brand.c_str(),
+		QBrand.whitelist.c_str(), QBrand.version.c_str(), QBrand.approved.c_str(),
+		QBrand.oemkey.c_str(), QBrand.approveddate.c_str(), QBrand.fingerprint.c_str(),
+		QBrand.builddate.c_str(), QBrand.gtvs.c_str(), QBrand.note.c_str(),
+		QBrand.apps_cfg.c_str(), QBrand.fav_cfg.c_str(), QBrand.local_cfg.c_str(),
+		QBrand.ftpdir.c_str(), QBrand.codedir.c_str(), QBrand.status.c_str(),
+		brand.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("UpdateServer error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("UpdateQBrand error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -815,10 +723,10 @@ BOOL CDatabase::UpdateServer(std::string name, const STServer& Server)
 	return TRUE;
 }
 
-BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
+BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
 {
 	CHECKDB;
-	if (0 != mysql_query(m_pConn, QUERY_SERVER)) {
+	if (0 != mysql_query(m_pConn, QUERY_QBRAND)) {
 #ifdef _DEBUG
 		_dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
 #endif
@@ -838,7 +746,7 @@ BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
 	// 统计表字段;
 	unsigned int nLen = mysql_num_fields(pData);
 	// 字段长度是否一致;
-	if (nLen != 6) {
+	if (nLen != 19) {
 		mysql_free_result(pData);
 		return FALSE;
 	}
@@ -854,14 +762,26 @@ BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
 	// 遍历数据;
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
-		STServer server;
-		server.name = row[0];
-		server.ip = row[1];
-		server.type = row[2];
-		server.user = row[3];
-		server.password = row[4];
-		server.note = row[5];
-		vtServer.push_back(server);
+		STQbrand QBrand;
+		QBrand.soc = row[0];
+		QBrand.quarter = row[1];
+		QBrand.brand = row[2];
+		QBrand.whitelist = row[3];
+		QBrand.version = row[4];
+		QBrand.oemkey = row[5];
+		QBrand.approved = row[6];
+		QBrand.approveddate = row[7];
+		QBrand.fingerprint = row[8];
+		QBrand.builddate = row[9];
+		QBrand.gtvs = row[10];
+		QBrand.note = row[11];
+		QBrand.apps_cfg = row[12];
+		QBrand.fav_cfg = row[13];
+		QBrand.local_cfg = row[14];
+		QBrand.ftpdir = row[15];
+		QBrand.codedir = row[16];
+		QBrand.status = row[17];
+		vtQBrand.push_back(QBrand);
 	}
 
 	// 释放内存;
@@ -870,6 +790,55 @@ BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
 	return TRUE;
 }
 
+BOOL CDatabase::ImportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter)
+{
+	if (!PathFileExists(file.c_str()))
+		return FALSE;
+
+	// 读出图片;
+	CFile cfile;
+	if (!cfile.Open(file.c_str(), CFile::modeRead, NULL))
+		return FALSE;
+
+	ULONGLONG ulLength = cfile.GetLength();
+	char* pData = new char[ulLength];
+	cfile.Read(pData, ulLength);
+	cfile.Close();
+
+	TCHAR szSql[MAX_PATH] = { 0 };
+	_stprintf_s(szSql, _T("update qbrand set logo = ? where `soc` = '%s' and `quarter`='%s' and `brand`='%s';"), soc.c_str(), quarter.c_str(), brand.c_str());
+
+	BOOL bResult = SetBinaryField(szSql, pData, ulLength);
+	if (pData)
+		delete[]pData;
+	pData = NULL;
+
+	return bResult;
+}
+
+BOOL CDatabase::ExportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter)
+{
+	char* pData = NULL;
+	unsigned long ulLength = 0;
+	TCHAR szSql[MAX_PATH] = { 0 };
+	_stprintf_s(szSql, _T("select logo from qbrand where `soc` = '%s' and `quarter`='%s' and `brand`='%s';"), soc.c_str(), quarter.c_str(), brand.c_str());
+	BOOL bResult = GetBinaryField(szSql, (void**)&pData, ulLength);
+	if (bResult && pData)
+	{
+		CFile cfile;
+		if (cfile.Open(file.c_str(), CFile::modeCreate | CFile::modeWrite))
+		{
+			cfile.Write(pData, ulLength);
+			cfile.Close();
+		}
+
+		delete[]pData;
+		pData = NULL;
+	}
+
+	return bResult;
+}
+
 BOOL CDatabase::InsertUser(const STUser& user)
 {
 	CHECKDB;
@@ -982,16 +951,14 @@ BOOL CDatabase::QueryUser(std::vector<STUser>& vtUser)
 	return TRUE;
 }
 
-BOOL CDatabase::InsertBranch(const STBranch& branch)
+BOOL CDatabase::InsertServer(const STServer& Server)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, INSER_BRANCH, branch.name.c_str(), branch.quarter.c_str(), 
-		branch.address.c_str(), branch.provider.c_str(), branch.chip.c_str(), 
-		branch.type.c_str(), branch.status.c_str(), branch.note.c_str());
+	_stprintf_s(szSql, INSER_SERVER, Server.name.c_str(), Server.ip.c_str(), Server.type.c_str(), Server.user.c_str(), Server.password.c_str(),Server.note.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("InsertBranch error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("InsertServer error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -999,14 +966,14 @@ BOOL CDatabase::InsertBranch(const STBranch& branch)
 	return TRUE;
 }
 
-BOOL CDatabase::DeleteBranch(std::string branch)
+BOOL CDatabase::InsertServer(std::string name, std::string ip, std::string type, std::string user, std::string password, std::string note)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, DEL_BRANCH, branch.c_str());
+	_stprintf_s(szSql, INSER_SERVER, name.c_str(), ip.c_str(), type.c_str(), user.c_str(), password.c_str(), note.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("DeleteBranch error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("InsertServer error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -1014,16 +981,14 @@ BOOL CDatabase::DeleteBranch(std::string branch)
 	return TRUE;
 }
 
-BOOL CDatabase::UpdateBranch(std::string branch, const STBranch& stBranch)
+BOOL CDatabase::DeleteServer(std::string name)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, MOD_BRANCH, stBranch.quarter.c_str(), stBranch.address.c_str(), 
-		stBranch.provider.c_str(), stBranch.chip.c_str(), stBranch.type.c_str(), 
-		stBranch.status.c_str(), stBranch.note.c_str(),branch.c_str());
+	_stprintf_s(szSql, DEL_SERVER, name.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("UpdateBranch error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("DeleteServer error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -1031,12 +996,27 @@ BOOL CDatabase::UpdateBranch(std::string branch, const STBranch& stBranch)
 	return TRUE;
 }
 
-BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
+BOOL CDatabase::UpdateServer(std::string name, const STServer& Server)
 {
 	CHECKDB;
-	if (0 != mysql_query(m_pConn, QUERY_BRANCH)) {
+	TCHAR szSql[MAX_PATH] = { 0 };
+	_stprintf_s(szSql, MOD_SERVER, Server.name.c_str(), Server.ip.c_str(), Server.type.c_str(), Server.user.c_str(), Server.password.c_str(), Server.note.c_str(), name.c_str());
+	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("QueryBranch error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("UpdateServer error=%s\n"), m_pError ? m_pError : "");
+#endif
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+BOOL CDatabase::QueryServer(std::vector<STServer>& vtServer)
+{
+	CHECKDB;
+	if (0 != mysql_query(m_pConn, QUERY_SERVER)) {
+#ifdef _DEBUG
+		_dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -1045,7 +1025,7 @@ BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
 	MYSQL_RES* pData = mysql_store_result(m_pConn);
 	if (pData == NULL) {
 #ifdef _DEBUG
-		_dprintf(_T("QueryBranch error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -1054,7 +1034,7 @@ BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
 	// 统计表字段;
 	unsigned int nLen = mysql_num_fields(pData);
 	// 字段长度是否一致;
-	if (nLen != 8) {
+	if (nLen != 6) {
 		mysql_free_result(pData);
 		return FALSE;
 	}
@@ -1070,16 +1050,14 @@ BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
 	// 遍历数据;
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
-		STBranch stBranch;
-		stBranch.name = row[0];
-		stBranch.quarter = row[1];
-		stBranch.address = row[2];
-		stBranch.provider = row[3];
-		stBranch.chip = row[4];
-		stBranch.type = row[5];
-		stBranch.status = row[6];
-		stBranch.note = row[7];
-		vtBranch.push_back(stBranch);
+		STServer server;
+		server.name = row[0];
+		server.ip = row[1];
+		server.type = row[2];
+		server.user = row[3];
+		server.password = row[4];
+		server.note = row[5];
+		vtServer.push_back(server);
 	}
 
 	// 释放内存;
@@ -1088,35 +1066,16 @@ BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
 	return TRUE;
 }
 
-BOOL CDatabase::InsertQBrand(const STQbrand& QBrand)
-{
-	CHECKDB;
-	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, INSER_QBRAND, QBrand.soc.c_str(), QBrand.brand.c_str(), QBrand.quarter.c_str(),
-		QBrand.whitelist.c_str(), QBrand.version.c_str(),
-		QBrand.oemkey.c_str(), QBrand.approved.c_str(),
-		QBrand.approveddate.c_str(), QBrand.fingerprint.c_str(),
-		QBrand.builddate.c_str(), QBrand.gtvs.c_str(),
-		QBrand.ftpdir.c_str(), QBrand.codedir.c_str(),
-		QBrand.note.c_str(), QBrand.status.c_str());
-	if (0 != mysql_query(m_pConn, szSql)) {
-#ifdef _DEBUG
-		_dprintf(_T("InsertQBrand error=%s\n"), m_pError ? m_pError : "");
-#endif
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-BOOL CDatabase::DeleteQBrand(std::string soc, std::string quarter, std::string brand)
+BOOL CDatabase::InsertBranch(const STBranch& branch)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, DEL_QBRAND, soc.c_str(), brand.c_str(), quarter.c_str());
+	_stprintf_s(szSql, INSER_BRANCH, branch.name.c_str(), branch.quarter.c_str(), 
+		branch.address.c_str(), branch.provider.c_str(), branch.chip.c_str(), 
+		branch.type.c_str(), branch.status.c_str(), branch.note.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("DeleteQBrand error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("InsertBranch error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -1124,23 +1083,14 @@ BOOL CDatabase::DeleteQBrand(std::string soc, std::string quarter, std::string b
 	return TRUE;
 }
 
-BOOL CDatabase::UpdateQBrand(std::string brand, STQbrand& QBrand)
+BOOL CDatabase::DeleteBranch(std::string branch)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, MOD_QBRAND, QBrand.soc.c_str(), QBrand.quarter.c_str(),
-		QBrand.brand.c_str(), QBrand.whitelist.c_str(),
-		QBrand.version.c_str(), QBrand.approved.c_str(),
-		QBrand.oemkey.c_str(), QBrand.approveddate.c_str(),
-		QBrand.fingerprint.c_str(), QBrand.builddate.c_str(),
-		QBrand.gtvs.c_str(), QBrand.note.c_str(),
-		QBrand.apps_cfg.c_str(), QBrand.fav_cfg.c_str(),
-		QBrand.local_cfg.c_str(), QBrand.ftpdir.c_str(),
-		QBrand.codedir.c_str(), QBrand.status.c_str(),
-		brand.c_str());
+	_stprintf_s(szSql, DEL_BRANCH, branch.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("UpdateQBrand error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("DeleteBranch error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -1148,21 +1098,16 @@ BOOL CDatabase::UpdateQBrand(std::string brand, STQbrand& QBrand)
 	return TRUE;
 }
 
-BOOL CDatabase::UpdateQBrand(std::string soc, std::string quarter, std::string brand, STQbrand& QBrand)
+BOOL CDatabase::UpdateBranch(std::string branch, const STBranch& stBranch)
 {
 	CHECKDB;
 	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, MOD_QBRAND, 
-		QBrand.soc.c_str(), QBrand.quarter.c_str(), QBrand.brand.c_str(),
-		QBrand.whitelist.c_str(), QBrand.version.c_str(), QBrand.approved.c_str(),
-		QBrand.oemkey.c_str(), QBrand.approveddate.c_str(), QBrand.fingerprint.c_str(),
-		QBrand.builddate.c_str(), QBrand.gtvs.c_str(), QBrand.note.c_str(),
-		QBrand.apps_cfg.c_str(), QBrand.fav_cfg.c_str(), QBrand.local_cfg.c_str(),
-		QBrand.ftpdir.c_str(), QBrand.codedir.c_str(), QBrand.status.c_str(),
-		brand.c_str());
+	_stprintf_s(szSql, MOD_BRANCH, stBranch.quarter.c_str(), stBranch.address.c_str(), 
+		stBranch.provider.c_str(), stBranch.chip.c_str(), stBranch.type.c_str(), 
+		stBranch.status.c_str(), stBranch.note.c_str(),branch.c_str());
 	if (0 != mysql_query(m_pConn, szSql)) {
 #ifdef _DEBUG
-		_dprintf(_T("UpdateQBrand error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("UpdateBranch error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -1170,12 +1115,12 @@ BOOL CDatabase::UpdateQBrand(std::string soc, std::string quarter, std::string b
 	return TRUE;
 }
 
-BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
+BOOL CDatabase::QueryBranch(std::vector<STBranch>& vtBranch)
 {
 	CHECKDB;
-	if (0 != mysql_query(m_pConn, QUERY_QBRAND)) {
+	if (0 != mysql_query(m_pConn, QUERY_BRANCH)) {
 #ifdef _DEBUG
-		_dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("QueryBranch error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -1184,7 +1129,7 @@ BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
 	MYSQL_RES* pData = mysql_store_result(m_pConn);
 	if (pData == NULL) {
 #ifdef _DEBUG
-		_dprintf(_T("QueryServer error=%s\n"), m_pError ? m_pError : "");
+		_dprintf(_T("QueryBranch error=%s\n"), m_pError ? m_pError : "");
 #endif
 		return FALSE;
 	}
@@ -1193,7 +1138,7 @@ BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
 	// 统计表字段;
 	unsigned int nLen = mysql_num_fields(pData);
 	// 字段长度是否一致;
-	if (nLen != 19) {
+	if (nLen != 8) {
 		mysql_free_result(pData);
 		return FALSE;
 	}
@@ -1209,26 +1154,16 @@ BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
 	// 遍历数据;
 	MYSQL_ROW row;
 	while ((row = mysql_fetch_row(pData)) != NULL) {
-		STQbrand QBrand;
-		QBrand.soc = row[0];
-		QBrand.quarter = row[1];
-		QBrand.brand = row[2];
-		QBrand.whitelist = row[3];
-		QBrand.version = row[4];
-		QBrand.oemkey = row[5];
-		QBrand.approved = row[6];
-		QBrand.approveddate = row[7];
-		QBrand.fingerprint = row[8];
-		QBrand.builddate = row[9];
-		QBrand.gtvs = row[10];
-		QBrand.note = row[11];
-		QBrand.apps_cfg = row[12];
-		QBrand.fav_cfg = row[13];
-		QBrand.local_cfg = row[14];
-		QBrand.ftpdir = row[15];
-		QBrand.codedir = row[16];
-		QBrand.status = row[17];
-		vtQBrand.push_back(QBrand);
+		STBranch stBranch;
+		stBranch.name = row[0];
+		stBranch.quarter = row[1];
+		stBranch.address = row[2];
+		stBranch.provider = row[3];
+		stBranch.chip = row[4];
+		stBranch.type = row[5];
+		stBranch.status = row[6];
+		stBranch.note = row[7];
+		vtBranch.push_back(stBranch);
 	}
 
 	// 释放内存;
@@ -1237,55 +1172,6 @@ BOOL CDatabase::QueryQBrand(std::vector<STQbrand>& vtQBrand)
 	return TRUE;
 }
 
-BOOL CDatabase::ImportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter)
-{
-	if (!PathFileExists(file.c_str()))
-		return FALSE;
-
-	// 读出图片;
-	CFile cfile;
-	if (!cfile.Open(file.c_str(), CFile::modeRead, NULL))
-		return FALSE;
-
-	ULONGLONG ulLength = cfile.GetLength();
-	char* pData = new char[ulLength];
-	cfile.Read(pData, ulLength);
-	cfile.Close();
-
-	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, _T("update qbrand set logo = ? where `soc` = '%s' and `quarter`='%s' and `brand`='%s';"), soc.c_str(), quarter.c_str(), brand.c_str());
-
-	BOOL bResult = SetBinaryField(szSql, pData, ulLength);
-	if (pData)
-		delete[]pData;
-	pData = NULL;
-
-	return bResult;
-}
-
-BOOL CDatabase::ExportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter)
-{
-	char* pData = NULL;
-	unsigned long ulLength = 0;
-	TCHAR szSql[MAX_PATH] = { 0 };
-	_stprintf_s(szSql, _T("select logo from qbrand where `soc` = '%s' and `quarter`='%s' and `brand`='%s';"), soc.c_str(), quarter.c_str(), brand.c_str());
-	BOOL bResult = GetBinaryField(szSql, (void**)&pData, ulLength);
-	if (bResult && pData)
-	{
-		CFile cfile;
-		if (cfile.Open(file.c_str(), CFile::modeCreate | CFile::modeWrite))
-		{
-			cfile.Write(pData, ulLength);
-			cfile.Close();
-		}
-
-		delete[]pData;
-		pData = NULL;
-	}
-
-	return bResult;
-}
-
 // 示例;
 void test(MYSQL* mysql)
 {

+ 18 - 25
CTSManager/CTSManager/Database.h

@@ -73,15 +73,6 @@ public:
 	// 执行语句;
 	BOOL ExcuteSQL(std::string sql);
 
-#if DEPRECATED
-	// 供应商表;
-	BOOL InserProvider(const STProvider& provider);
-	BOOL InserProvider(std::string name, std::string note);
-	BOOL DeleteProvider(std::string name);
-	BOOL UpdateProvider(std::string name, const STProvider &provider);
-	BOOL QueryProvider(std::vector<STProvider>& vtProvider);
-#endif
-
 	// 机芯表;
 	BOOL InserSoc(const STSOC& soc);
 	BOOL InserSoc(std::string name, std::string provider, std::string note);
@@ -106,35 +97,37 @@ public:
 	BOOL UpdateQuarter(std::string name, const STQuarter& quarter);
 	BOOL QueryQuarter(std::vector<STQuarter>& vtQuarter);
 
-	// 服务器表;
-	BOOL InsertServer(const STServer& Server);
-	BOOL InsertServer(std::string name, std::string ip, std::string type, std::string user, std::string password, std::string note);
-	BOOL DeleteServer(std::string name);
-	BOOL UpdateServer(std::string name, const STServer& Server);
-	BOOL QueryServer(std::vector<STServer>& vtServer);
+	// 季度品牌表;
+	BOOL InsertQBrand(const STQbrand& QBrand);
+	BOOL DeleteQBrand(std::string soc, std::string quarter, std::string brand);
+	BOOL UpdateQBrand(std::string brand, STQbrand& QBrand);
+	BOOL UpdateQBrand(std::string soc, std::string quarter, std::string brand, STQbrand &QBrand);
+	BOOL QueryQBrand(std::vector<STQbrand>& vtQBrand);
+	// 导入/导出品牌logo;
+	BOOL ImportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter);
+	BOOL ExportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter);
 
 	// 用户表;
-	BOOL InsertUser(const STUser &user);
+	BOOL InsertUser(const STUser& user);
 	BOOL InsertUser(std::string user, std::string password, std::string permission);
 	BOOL DeleteUser(std::string user);
 	BOOL UpdateUser(std::string user, const STUser& stUser);
 	BOOL QueryUser(std::vector<STUser>& vtUser);
 
+	// 服务器表;
+	BOOL InsertServer(const STServer& Server);
+	BOOL InsertServer(std::string name, std::string ip, std::string type, std::string user, std::string password, std::string note);
+	BOOL DeleteServer(std::string name);
+	BOOL UpdateServer(std::string name, const STServer& Server);
+	BOOL QueryServer(std::vector<STServer>& vtServer);
+
 	// 分支表;
 	BOOL InsertBranch(const STBranch& branch);
 	BOOL DeleteBranch(std::string branch);
 	BOOL UpdateBranch(std::string branch, const STBranch& stBranch);
 	BOOL QueryBranch(std::vector<STBranch>& vtBranch);
 
-	// 季度品牌表;
-	BOOL InsertQBrand(const STQbrand& QBrand);
-	BOOL DeleteQBrand(std::string soc, std::string quarter, std::string brand);
-	BOOL UpdateQBrand(std::string brand, STQbrand& QBrand);
-	BOOL UpdateQBrand(std::string soc, std::string quarter, std::string brand, STQbrand &QBrand);
-	BOOL QueryQBrand(std::vector<STQbrand>& vtQBrand);
-	// 导入/导出品牌logo;
-	BOOL ImportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter);
-	BOOL ExportQBrandLogo(std::string file, std::string brand, std::string soc, std::string quarter);
+
 };
 
 

+ 3 - 11
CTSManager/CTSManager/NavListCtrl.cpp

@@ -113,13 +113,7 @@ void CNavListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
 	GetItem(&lvi);
 
 	// Should the item be highlighted
-	BOOL bHighlight = ((lvi.state & LVIS_DROPHILITED)
-		|| ((lvi.state & LVIS_SELECTED)
-			&& ((GetFocus() == this)
-				|| (GetStyle() & LVS_SHOWSELALWAYS)
-				)
-			)
-		);
+	BOOL bHighlight = ((lvi.state & LVIS_DROPHILITED) || ((lvi.state & LVIS_SELECTED) && ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS))));
 
 	// Get rectangles for drawing
 	CRect rcClient;
@@ -213,8 +207,7 @@ void CNavListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
 	rcLabel.left += offset / 2 + 7;
 	rcLabel.right -= offset;
 
-	pDC->DrawText(sLabel, -1, rcLabel, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP
-		| DT_END_ELLIPSIS);
+	pDC->DrawText(sLabel, -1, rcLabel, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS);
 
 	LUSERITEM userInfo;
 	GetUserItemInfo(sLabel, &userInfo);
@@ -315,8 +308,7 @@ void CNavListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
 		rcLabel.left += offset;
 		rcLabel.right -= offset;
 
-		pDC->DrawText(sLabel, -1, rcLabel, nJustify | DT_SINGLELINE |
-			DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS);
+		pDC->DrawText(sLabel, -1, rcLabel, nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS);
 	}
 
 	// Restore dc

+ 68 - 87
CTSManager/CTSManager/table.h

@@ -10,72 +10,28 @@
 #define _STR_PASSWD_	"123456"
 #define _STR_DBNAME_	"scbc_cts"
 
-// 插入数据;
-//#define INSER_PROVIDER _T("INSERT INTO `provider` (`name`,`note`) VALUES ('%s', '%s');")
-#define INSER_SOC _T("INSERT INTO `soc` (`name`,`provider`,`note`) VALUES ('%s', '%s', '%s');")
-#define INSER_QUARTER _T("INSERT INTO `quarter` (`name`,`scp`,`note`) VALUES ('%s', '%s', '%s');")
-#define INSER_BRAND _T("INSERT INTO `brand` (`name`, `fav_cfg`, `local_cfg`, `apps_cfg`, `note`) VALUES ('%s', '%s', '%s', '%s', '%s');")
-#define INSER_SERVER _T("INSERT INTO `server` (`name`,`ip`,`type`,`user`,`password`,`note`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s');")
-#define INSER_BRANCH _T("INSERT INTO `branch` (`name` ,`quarter`,`address`,`provider`,`chip`,`type`,`status`,`note`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');")
-#define INSER_USER _T("INSERT INTO `user` (`user`,`password`,`permission`) VALUES ('%s', '%s', '%s');")
-#define INSER_QBRAND _T("INSERT INTO `qbrand` \
-(`soc`,`brand`,`quarter`,`whitelist`,`version`,`oemkey`,`approved`,`approveddate`,`fingerprint`,`builddate`,`gtvs`,`ftpdir`,`codedir`,`note`, `status`)\
- VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');")
-#define INSER_LOG _T("INSERT INTO `log` (`user`,`datetime`,`content`) VALUES ('%s', 'datetime', '%s');")
-
-
-// 删除数据;
-//#define DEL_PROVIDER _T("DELETE FROM `provider` WHERE `name` = '%s';")
-#define DEL_SOC _T("DELETE FROM `soc` WHERE `name` = '%s';")
-#define DEL_BRAND _T("DELETE FROM `brand` WHERE `name` = '%s';")
-#define DEL_QUARTER _T("DELETE FROM `quarter` where `name` = '%s';")
-#define DEL_SERVER _T("DELETE FROM `server` where `name` = '%s';")
-#define DEL_USER _T("DELETE FROM `user` where `user` = '%s';")
-#define DEL_QBRAND _T("DELETE FROM `qbrand` where `soc` = '%s' and `brand`='%s' and`quarter`='%s';")
-#define DEL_BRANCH _T("DELETE FROM `brach` where `name` = '%s';")
-#define DEL_LOG _T("DELETE FROM `log` where `id` = '%s';")
-
-// 更新数据;
-//#define MOD_PROVIDER _T("UPDATE `provider` SET `name`='%s',`note`='%s' WHERE `name`='%s';")
-#define MOD_SOC _T("UPDATE `soc` SET `name`='%s', `provider`='%s', `note`='%s' WHERE `name`='%s';")
-#define MOD_BRAND _T("UPDATE `brand` SET `name`='%s',`fav_cfg`='%s',`local_cfg`='%s',`apps_cfg`='%s',`note`='%s' WHERE `name`='%s';")
-#define MOD_QUARTER _T("UPDATE `quarter` SET `name`='%s', `scp` = '%s' ,`note`='%s' WHERE `name`='%s';")
-#define MOD_SERVER _T("UPDATE `server` SET `name`='%s', `ip` = '%s', `type`='%s', `user`='%s', `password`='%s', `note`='%s' WHERE `name`='%s';")
-#define MOD_USER _T("UPDATE `user` SET `user`='%s', `password` = '%s', `permission`='%s' WHERE `user`='%s';")
-#define MOD_QBRAND _T("UPDATE qbrand SET soc='%s', `quarter` = '%s', brand = '%s', whitelist = '%s', version = '%s', approved = '%s', oemkey = '%s', approveddate = '%s', fingerprint = '%s', builddate = '%s', gtvs = '%s', note = '%s', apps_cfg = '%s', fav_cfg = '%s', local_cfg = '%s', ftpdir = '%s', codedir = '%s', `status` = '%s' FROM qbrand WHERE `brand` = '%s'")
-#define MOD_BRANCH _T("UPDATE `branch` SET `quater`='%s', `address`='%s', `provider`='%s', `chip`='%s', `type`='%s', `status`='%s', `note`='%s' WHERE `name`='%s';")
-
-// 查询数据;
-//#define QUERY_PROVIDER _T("SELECT `name`, `note` FROM `provider`;")
-#define QUERY_SOC _T("SELECT `name`, `provider`, `note` FROM `soc`;")
-#define QUERY_BRAND _T("SELECT `name`, `fav_cfg`, `local_cfg`, `apps_cfg`, `note` FROM `brand`;")
-#define QUERY_QUARTER _T("SELECT `name`,`scp`, `note` FROM `quarter`;")
-#define QUERY_SERVER _T("SELECT `name`, `ip`, `type`, `user`, `password`, `note` FROM `server`;")
-#define QUERY_USER _T("SELECT `user`, `password`, `permission` FROM `user`;")
-#define QUERY_QBRAND _T("SELECT soc, `quarter`, brand, whitelist, version, oemkey, approved, approveddate, fingerprint, builddate, gtvs, note, apps_cfg, fav_cfg, local_cfg, ftpdir, codedir, `status` FROM qbrand;")
-#define QUERY_BRANCH _T("SELECT `name`, `quarter`, `address`, `provider`, `chip`, `type`, `status`, `note` FROM `branch`;")
-#define QUERY_LOG _T("SELECT `id`, `user`,`content`,`datetime` FROM `log`;")
-
-#if DEPRECATED
-// 供应商表;
-typedef struct {
-	std::string name;						// 供应商名称;
-	std::string note;						// 供应商备注;
-}STProvider, *pSTProvider;
-#endif
-
+// 机芯方案商表;
 typedef struct {
-	std::string name;						// 机芯名称;
+	std::string name;						// 机芯名称(唯一键值);
 	std::string provider;					// 供应商名称
 	std::string note;						// 供应商备注;
 }STSOC, * pSTSOC;
+#define INSER_SOC _T("INSERT INTO `soc` (`name`,`provider`,`note`) VALUES ('%s', '%s', '%s');")
+#define DEL_SOC _T("DELETE FROM `soc` WHERE `name` = '%s';")
+#define MOD_SOC _T("UPDATE `soc` SET `name`='%s', `provider`='%s', `note`='%s' WHERE `name`='%s';")
+#define QUERY_SOC _T("SELECT `name`, `provider`, `note` FROM `soc`;")
 
 // 季度表;
 typedef struct {
 	std::string name;						// 季度名称;
 	std::string scp;						// SecurityPatch;
 	std::string note;						// 季度备注;
+	// 实际开始和结束时间;
 }STQuarter, *pSTQuarter;
+#define INSER_QUARTER _T("INSERT INTO `quarter` (`name`,`scp`,`note`) VALUES ('%s', '%s', '%s');")
+#define DEL_QUARTER _T("DELETE FROM `quarter` where `name` = '%s';")
+#define MOD_QUARTER _T("UPDATE `quarter` SET `name`='%s', `scp` = '%s' ,`note`='%s' WHERE `name`='%s';")
+#define QUERY_QUARTER _T("SELECT `name`,`scp`, `note` FROM `quarter`;")
 
 // 品牌表;
 typedef struct {
@@ -86,35 +42,10 @@ typedef struct {
 	std::string local_cfg;
 	std::string apps_cfg;
 }STBrand, *pSTBrand;
-
-// 服务器表;
-typedef struct {
-	std::string name;						// 服务器名称;
-	std::string ip;							// 服务器IP;
-	std::string type;						// 服务器类型:ftp、ssh2;
-	std::string user;						// 服务器用户;
-	std::string password;					// 服务器用户密码;
-	std::string note;						// 服务器备注;
-}STServer, *pSTServer;
-
-// 分支表;
-typedef struct {
-	std::string name;						// 分支名称;
-	std::string quarter;					// 分支所属季度;
-	std::string address;					// 分支gerrit地址;
-	std::string provider;					// 分支供应商;
-	std::string chip;						// 分支机芯;
-	std::string type;						// 分支类型:主干、CTS、量产、ODF
-	std::string status;						// 分支状态:在线、停用;
-	std::string note;						// 分支备注;
-}STBranch, *pSTBranch;
-
-// 用户表(权限表);
-typedef struct {
-	std::string user;						// 用户账号;
-	std::string password;					// 用户密码;
-	std::string permission;					// 用户权限;
-}STUser, *pSTUser;
+#define INSER_BRAND _T("INSERT INTO `brand` (`name`, `fav_cfg`, `local_cfg`, `apps_cfg`, `note`) VALUES ('%s', '%s', '%s', '%s', '%s');")
+#define DEL_BRAND _T("DELETE FROM `brand` WHERE `name` = '%s';")
+#define MOD_BRAND _T("UPDATE `brand` SET `name`='%s',`fav_cfg`='%s',`local_cfg`='%s',`apps_cfg`='%s',`note`='%s' WHERE `name`='%s';")
+#define QUERY_BRAND _T("SELECT `name`, `fav_cfg`, `local_cfg`, `apps_cfg`, `note` FROM `brand`;")
 
 // 季度品牌表;
 typedef struct {
@@ -129,7 +60,7 @@ typedef struct {
 	// 图片不在此显示;
 	void* pLogo = NULL;							// logo;
 	void* pPic1 = NULL;
-	void* pPic2 = NULL;		
+	void* pPic2 = NULL;
 	std::string fav_cfg;
 	std::string apps_cfg;
 	std::string local_cfg;
@@ -141,7 +72,24 @@ typedef struct {
 	std::string codedir;					// 代码路径,只对admin可见;
 	std::string note;						// 备注;
 	std::string status;						// 状态:提醒要修改脚本;
-}STQbrand, *pSTQbrand;
+}STQbrand, * pSTQbrand;
+#define INSER_QBRAND _T("INSERT INTO `qbrand` \
+(`soc`,`brand`,`quarter`,`whitelist`,`version`,`oemkey`,`approved`,`approveddate`,`fingerprint`,`builddate`,`gtvs`,`ftpdir`,`codedir`,`note`, `status`)\
+ VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');")
+#define DEL_QBRAND _T("DELETE FROM `qbrand` where `soc` = '%s' and `brand`='%s' and`quarter`='%s';")
+#define MOD_QBRAND _T("UPDATE qbrand SET soc='%s', `quarter` = '%s', brand = '%s', whitelist = '%s', version = '%s', approved = '%s', oemkey = '%s', approveddate = '%s', fingerprint = '%s', builddate = '%s', gtvs = '%s', note = '%s', apps_cfg = '%s', fav_cfg = '%s', local_cfg = '%s', ftpdir = '%s', codedir = '%s', `status` = '%s' FROM qbrand WHERE `brand` = '%s'")
+#define QUERY_QBRAND _T("SELECT soc, `quarter`, brand, whitelist, version, oemkey, approved, approveddate, fingerprint, builddate, gtvs, note, apps_cfg, fav_cfg, local_cfg, ftpdir, codedir, `status` FROM qbrand;")
+
+// 用户表(权限表);
+typedef struct {
+	std::string user;						// 用户账号;
+	std::string password;					// 用户密码;
+	std::string permission;					// 用户权限;
+}STUser, * pSTUser;
+#define INSER_USER _T("INSERT INTO `user` (`user`,`password`,`permission`) VALUES ('%s', '%s', '%s');")
+#define DEL_USER _T("DELETE FROM `user` where `user` = '%s';")
+#define MOD_USER _T("UPDATE `user` SET `user`='%s', `password` = '%s', `permission`='%s' WHERE `user`='%s';")
+#define QUERY_USER _T("SELECT `user`, `password`, `permission` FROM `user`;")
 
 // 日志表;
 typedef struct {
@@ -149,6 +97,39 @@ typedef struct {
 	std::string datetime;					// 发生时间;
 	std::string user;						// 操作用户;
 	std::string content;					// 操作内容;
-}STLog, *pSTLog;
+}STLog, * pSTLog;
+#define INSER_LOG _T("INSERT INTO `log` (`user`,`datetime`,`content`) VALUES ('%s', 'datetime', '%s');")
+#define DEL_LOG _T("DELETE FROM `log` where `id` = '%s';")
+#define QUERY_LOG _T("SELECT `id`, `user`,`content`,`datetime` FROM `log`;")
+
+// 服务器表;
+typedef struct {
+	std::string name;						// 服务器名称;
+	std::string ip;							// 服务器IP;
+	std::string type;						// 服务器类型:ftp、ssh2;
+	std::string user;						// 服务器用户;
+	std::string password;					// 服务器用户密码;
+	std::string note;						// 服务器备注;
+}STServer, *pSTServer;
+#define INSER_SERVER _T("INSERT INTO `server` (`name`,`ip`,`type`,`user`,`password`,`note`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s');")
+#define DEL_SERVER _T("DELETE FROM `server` where `name` = '%s';")
+#define MOD_SERVER _T("UPDATE `server` SET `name`='%s', `ip` = '%s', `type`='%s', `user`='%s', `password`='%s', `note`='%s' WHERE `name`='%s';")
+#define QUERY_SERVER _T("SELECT `name`, `ip`, `type`, `user`, `password`, `note` FROM `server`;")
+
+// 分支表;
+typedef struct {
+	std::string name;						// 分支名称;
+	std::string quarter;					// 分支所属季度;
+	std::string address;					// 分支gerrit地址;
+	std::string provider;					// 分支供应商;
+	std::string chip;						// 分支机芯;
+	std::string type;						// 分支类型:主干、CTS、量产、ODF
+	std::string status;						// 分支状态:在线、停用;
+	std::string note;						// 分支备注;
+}STBranch, *pSTBranch;
+#define INSER_BRANCH _T("INSERT INTO `branch` (`name` ,`quarter`,`address`,`provider`,`chip`,`type`,`status`,`note`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');")
+#define DEL_BRANCH _T("DELETE FROM `brach` where `name` = '%s';")
+#define MOD_BRANCH _T("UPDATE `branch` SET `quater`='%s', `address`='%s', `provider`='%s', `chip`='%s', `type`='%s', `status`='%s', `note`='%s' WHERE `name`='%s';")
+#define QUERY_BRANCH _T("SELECT `name`, `quarter`, `address`, `provider`, `chip`, `type`, `status`, `note` FROM `branch`;")
 
 #endif