当前位置: 首页>>代码示例>>C++>>正文


C++ CppSQLite3DB::closedb方法代码示例

本文整理汇总了C++中CppSQLite3DB::closedb方法的典型用法代码示例。如果您正苦于以下问题:C++ CppSQLite3DB::closedb方法的具体用法?C++ CppSQLite3DB::closedb怎么用?C++ CppSQLite3DB::closedb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CppSQLite3DB的用法示例。


在下文中一共展示了CppSQLite3DB::closedb方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InserSingleSetConfig

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='%s'"),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());
	}



}
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:34,代码来源:UserAcessSetDlg.cpp

示例2: if

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();
}
开发者ID:temcocontrols,项目名称:T3000_Building_Automation_System,代码行数:53,代码来源:T3000_Default_MainView.cpp

示例3: OnCbnSelchangeSinglesetcombo

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 ='%s' 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());
			}

		}
	}
	
}
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:52,代码来源:UserAcessSetDlg.cpp

示例4: UpdateDataToDB


//.........这里部分代码省略.........
			CString subnetname=m_TreeCtrl.GetItemText(root);
		   //Floor
			HTREEITEM parentnode=m_TreeCtrl.GetParentItem(m_hSelItem);
			CString Floorname=m_TreeCtrl.GetItemText(parentnode);
			  strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' and Room_name='%s' order by Building_Name"),subnetname,Floorname,m_name_new);
			 // m_pRs->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText);
			 q = SqliteDBBuilding.execQuery((UTF8MBSTR)strSql);
			  while(q.eof())
			  {	   	 str_temp.Empty();
			  str_temp=q.getValuebyName(L"Room_name");
			  if (str_temp.Compare(m_name_new)==0)
			  {	   is_exist=TRUE;
			  break;
			  }			
			  q.nextRow();
			  }
			  

			  if (is_exist)
			  {
			  return FALSE;
			  } 
			  else
			  {
			        strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' and Room_name='%s' order by Building_Name"),subnetname,Floorname,m_name_old);
			        q = SqliteDBBuilding.execQuery((UTF8MBSTR)strSql);
			        while(!q.eof())
			        {
			       	  strSql.Format(_T("update ALL_NODE set Room_name='%s' where Room_name='%s'"),m_name_new,m_name_old);
			       	   SqliteDBBuilding.execDML((UTF8MBSTR)strSql);
			       	   q.nextRow();
			        }
			        
			        return TRUE; 
			  }
			  																				  
			    
		  break;
		 }
		 case 3:		//Device Name Leaf
		 {
			 //Subnet
			 HTREEITEM root=m_TreeCtrl.GetRootItem();
			 CString subnetname=m_TreeCtrl.GetItemText(root);
			 //Room
			 HTREEITEM parentnode=m_TreeCtrl.GetParentItem(m_hSelItem);
			 CString Roomname=m_TreeCtrl.GetItemText(parentnode);
			 //Floor
			 HTREEITEM floornode=m_TreeCtrl.GetParentItem(parentnode);
			 CString Floorname=m_TreeCtrl.GetItemText(floornode);
			 strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' and Room_name='%s' and Product_name='%s' order by Building_Name"),subnetname,Floorname,Roomname,m_name_new);
			 q = SqliteDBBuilding.execQuery((UTF8MBSTR)strSql);
			 while(!q.eof())
			 {	   	 
			     str_temp.Empty();
			     str_temp=q.getValuebyName(L"Product_name");
			     if (str_temp.Compare(m_name_new)==0)
			     {	   is_exist=TRUE;
			     break;
			     }			
			      q.nextRow();
			     }
			 
			 
			 if (is_exist)
			 {
			 return FALSE;
			 }
			 else
			 {
				  strSql.Format(_T("select * from ALL_NODE where Building_Name='%s' and Floor_name='%s' and Room_name='%s' and Product_name='%s' order by Building_Name"),subnetname,Floorname,Roomname,m_name_old);
			 
			 q = SqliteDBBuilding.execQuery((UTF8MBSTR)strSql);
			 while(!q.eof())
			 {
				 strSql.Format(_T("update ALL_NODE set Product_name='%s' where Product_name='%s'"),m_name_new,m_name_old);
				 SqliteDBBuilding.execDML((UTF8MBSTR)strSql);
				 q.nextRow();
			 }
			  
			 return TRUE;
			 }
			 
		 break;
		 }
		 }
	 }
	 catch(_com_error e)
	 {
	 
		 SqliteDBBuilding.closedb();
		 return FALSE;
		 //m_pCon->Close();

	 }
	  SqliteDBBuilding.closedb();
	  SqliteDBT3000.closedb();
 
	return TRUE;
 }
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:101,代码来源:WorkspaceBar.cpp

示例5: ReloadSingleLevelSetDB

void CUserAcessSetDlg::ReloadSingleLevelSetDB()
{
	m_FlexGrid2.Clear();
	m_FlexGrid2.put_Cols(4);	
	m_FlexGrid2.put_TextMatrix(0,1,_T("Grid 1"));
	m_FlexGrid2.put_TextMatrix(0,1,_T("User"));
	m_FlexGrid2.put_TextMatrix(0,2,_T("Network Controller"));
	m_FlexGrid2.put_TextMatrix(0,3,_T("Database"));

	m_FlexGrid2.put_ColWidth(0,1000);
	m_FlexGrid2.put_ColWidth(1,1000);
	m_FlexGrid2.put_ColWidth(2,1500);
	m_FlexGrid2.put_ColWidth(3,1000);
	for(int i=0;i<4;i++)
	{
		m_FlexGrid2.put_ColAlignment(i,4);
	}

	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='%s'"),m_strMainBuilding,m_strSubNetName,m_strUserName);
	q = SqliteDBBuilding.execQuery((UTF8MBSTR)strSql);

	_variant_t temp_variant;
	BOOL b_useLogin=false;
	int temp_row=0;
	CString strTemp;
	int nTemp;
	while(!q.eof())
	{

		++temp_row;
		
		 
			strTemp=q.getValuebyName(L"username");
		m_FlexGrid2.put_TextMatrix(temp_row,1,strTemp);

		 
			nTemp=q.getIntField("networkcontroller");
		switch (nTemp)
		{
			case 0:strTemp=_T("Read & write");break;
			case 1:strTemp=_T("Read only");break;
			default:strTemp=_T("Read & write");
		}
		m_FlexGrid2.put_TextMatrix(temp_row,2,strTemp);

		nTemp=q.getIntField("database_limition");//
	 
		switch (nTemp)
		{
			case 0:strTemp=_T("Read & write");break;
			case 1:strTemp=_T("Read only");break;
			default:strTemp=_T("Read & write");
		}
		m_FlexGrid2.put_TextMatrix(temp_row,3,strTemp);

		q.nextRow();
	}
	SqliteDBBuilding.closedb();
}
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:66,代码来源:UserAcessSetDlg.cpp

示例6: OnCbnSelchangeLevelsetcombo

void CUserAcessSetDlg::OnCbnSelchangeLevelsetcombo()
{
	
	if(m_nCurRow==0)
		return;
	if(m_nCurCol==0)
		return;
	CString strValue;
	strValue=m_FlexGrid.get_TextMatrix(m_nCurRow,m_nCurCol);
	CString strSelect;
	int nIdext=m_userLeveSetBox.GetCurSel();
	if(nIdext>=0)
	{
		m_userLeveSetBox.GetLBText(nIdext,strSelect);
		if(strSelect.CompareNoCase(strValue)==0)
		{
			return;
		}
		else
		{
			int nNewValue=nIdext;
			m_FlexGrid.put_TextMatrix(m_nCurRow,m_nCurCol,strSelect);

			CString strField;
			if(m_nCurCol==6)
				strField="mainscreen_level";
			if(m_nCurCol==7)
				strField="parameter_level";
			if(m_nCurCol==8)
				strField="outputtable_level";
			if(m_nCurCol==9)
				strField="graphic_level";

			//if(m_nCurCol==10)
				//	strField="building_level";
			if(m_nCurCol==10)
				strField="burnhex_level";
			if(m_nCurCol==11)
				strField="loadconfig_level";
			if(m_nCurCol==12)
				strField="allscreen_level";

			CString strSerial=m_FlexGrid.get_TextMatrix(m_nCurRow,2);
			strSerial.TrimLeft();
			strSerial.TrimRight();
			int nSerial=_wtol(strSerial);
			try
			{

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

			CString strSql;

			strSql.Format(_T("update user_level set "+strField+" = %i where serial_number = %i and username ='%s' and MainBuilding_Name='%s' and Building_Name='%s'"),nNewValue,nSerial,m_strUserName,m_strMainBuilding,m_strSubNetName);
			 SqliteDBBuilding.execDML((UTF8MBSTR)strSql);

		     SqliteDBBuilding.closedb();
			}
			catch(_com_error *e)
			{
				AfxMessageBox(e->ErrorMessage());
			}	 

		}
	}

	if(m_nCurCol==12)
	{
		if(nIdext==0)//enable
		{
			for(int k=0;k<=12;k++)
				{
					if (m_nCurRow%2==0)
					{
						m_FlexGrid.put_Row(m_nCurRow);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(COLOR_CELL);
					}
					else
					{
						m_FlexGrid.put_Row(m_nCurRow);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(RGB(255,255,240));

					}
				}
		}
		else//unenable
		{
			for(int k=0;k<12;k++)
			{
			
				m_FlexGrid.put_Row(m_nCurRow);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(RGB(215,215,215));
			}
		}
	}
	//ReloadUserLevelDB();
}
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:95,代码来源:UserAcessSetDlg.cpp

示例7: ReloadUserLevelDB


//.........这里部分代码省略.........
		if(UserLevelV.Allscreen_level==1)
		{
			

			for(int k=0;k<12;k++)
			{
			
				m_FlexGrid.put_Row(temp_row);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(RGB(215,215,215));
			}
		}
		else
		{
				for(int k=0;k<=12;k++)
				{
					if (temp_row%2==0)
					{
						m_FlexGrid.put_Row(temp_row);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(COLOR_CELL);
					}
					else
					{
						m_FlexGrid.put_Row(temp_row);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(RGB(255,255,240));

					}
				}
		}
		

		q.nextRow();


		m_FlexGrid.put_TextMatrix(temp_row,1,UserLevelV.strUserName);
		CString strTemp;;
		strTemp.Format(_T("%d"),UserLevelV.nSerialNumber);
	
		m_FlexGrid.put_TextMatrix(temp_row,2,strTemp);
		strTemp.Format(_T("%d"),UserLevelV.ProductID);
		m_FlexGrid.put_TextMatrix(temp_row,3,strTemp);
		m_FlexGrid.put_TextMatrix(temp_row,4,UserLevelV.strFloorName);
		m_FlexGrid.put_TextMatrix(temp_row,5,UserLevelV.strRoomName);
		switch (UserLevelV.MainLevel)
		{
			case 0:strTemp=_T("Read & write");break;
			case 1:strTemp=_T("Read only");break;
			default:strTemp=_T("Read & write");
		}
		m_FlexGrid.put_TextMatrix(temp_row,6,strTemp);
		switch (UserLevelV.ParamerLevel)
		{
			case 0:strTemp=_T("Read & write");break;
			case 1:strTemp=_T("Read only");break;
			default:strTemp=_T("Read & write");
		}
		m_FlexGrid.put_TextMatrix(temp_row,7,strTemp);
		
		switch (UserLevelV.Outputtable_level)
		{
			case 0:strTemp=_T("Read & write");break;
			case 1:strTemp=_T("Read only");break;
			default:strTemp=_T("Read & write");
		}
		m_FlexGrid.put_TextMatrix(temp_row,8,strTemp);
		switch (UserLevelV.Graphic_level)
		{
			case 0:strTemp=_T("Read & write");break;
			case 1:strTemp=_T("Read only");break;
			default:strTemp=_T("Read & write");
		}
		m_FlexGrid.put_TextMatrix(temp_row,9,strTemp);

		 



		switch (UserLevelV.Burnhex_level)
		{
			case 0:strTemp=_T("Enable");break;
			case 1:strTemp=_T("Unenable");break;
			default:strTemp=_T("Enable");
		}
		m_FlexGrid.put_TextMatrix(temp_row,10,strTemp);
		switch (UserLevelV.Loadconfig_level)
		{
			case 0:strTemp=_T("Enable");break;
			case 1:strTemp=_T("Unenable");break;
			default:strTemp=_T("Enable");
		}
		m_FlexGrid.put_TextMatrix(temp_row,11,strTemp);
		
		switch (UserLevelV.Allscreen_level)
		{
			case 0:strTemp=_T("Enable");break;
			case 1:strTemp=_T("Unenable");break;
			default:strTemp=_T("Enable");
		}
		m_FlexGrid.put_TextMatrix(temp_row,12,strTemp);
	}


	SqliteDBBuilding.closedb();
}
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:101,代码来源:UserAcessSetDlg.cpp

示例8: InserProductToUserSetDB


//.........这里部分代码省略.........
		//veryProduct.strMainBuildingName=m_pRs->GetCollect("MainBuilding_Name");//
		strTemp=q.getValuebyName(L"MainBuilding_Name");//
	 
		veryProduct.strMainBuildingName=strTemp;
		
		//veryProduct.strBuildingName=m_pRs->GetCollect("Building_Name");//
		strTemp=q.getValuebyName(L"Building_Name");//
		 
		veryProduct.strBuildingName=strTemp;

	//	veryProduct.nSerialNumber=m_pRs->GetCollect("Serial_ID");
		strTemp=q.getValuebyName(L"Serial_ID");//
	 
		veryProduct.nSerialNumber=_wtol(strTemp);

		//veryProduct.ProductID=m_pRs->GetCollect("Product_ID");
		strTemp=q.getValuebyName(L"Product_ID");//
		 
		veryProduct.ProductID=_wtoi(strTemp);

		//veryProduct.product_class_id=m_pRs->GetCollect("Product_class_ID");
		strTemp=q.getValuebyName(L"Product_class_ID");//
		 
		veryProduct.product_class_id=_wtoi(strTemp);

		//veryProduct.strFloorName=m_pRs->GetCollect("Floor_name");
		strTemp=q.getValuebyName(L"Floor_name");//
		 
		veryProduct.strFloorName=strTemp;

	//	veryProduct.strRoomName=m_pRs->GetCollect("Room_name");
		strTemp=q.getValuebyName(L"Room_name");//
		 
		veryProduct.strRoomName=strTemp;
		m_VeryProdctLst.push_back(veryProduct);
		q.nextRow();
	}
	int nVerySerialNum;
	int nUserlevelSerial;
	CString strUserName;
	for(UINT i=0;i<m_VeryProdctLst.size();i++)
	{
		nVerySerialNum=m_VeryProdctLst.at(i).nSerialNumber;
		BOOL bFind=FALSE;
		for(UINT j=0;j<m_UserLevelLst.size();j++)
		{
			nUserlevelSerial=m_UserLevelLst.at(j).nSerialNumber;
			if(nVerySerialNum==nUserlevelSerial)
			{
	
				bFind=TRUE;
				break;
			}
			//else
			//{
			//	bFind=FALSE;
		
			//}
		}
			
		if(!bFind)//insert to userlevel table.
		{

			try
			{


			strSql.Format(_T("insert into user_level values('%s','%s',%i,'%i','%s','%s','%s','%i','%i','%i','%i','%i','%i','%i','%i',%i)"),
			m_VeryProdctLst.at(i).strMainBuildingName,
			m_VeryProdctLst.at(i).strBuildingName,
			m_VeryProdctLst.at(i).nSerialNumber,
			m_VeryProdctLst.at(i).ProductID,
			m_strUserName,
			m_VeryProdctLst.at(i).strFloorName,
			m_VeryProdctLst.at(i).strRoomName,
			0,
			0,
			0,
			0,
			0,
			0,
			0,
			0,
			0
			);				
			SqliteDBBuilding.execDML((UTF8MBSTR)strSql);
			}
			catch(_com_error *e)
			{
				AfxMessageBox(e->ErrorMessage());
			}
		}
		
	
		
	}
	
	SqliteDBBuilding.closedb();

}
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:101,代码来源:UserAcessSetDlg.cpp

示例9:

void T3000_Default_MainView::OnCbnSelchangeComboMstpModbus()
{
	int sel = m_mstpmodbus_combox.GetCurSel();
	int protocol = 0;

	if (product_register_value[7] == PM_TSTAT8
		|| (product_register_value[7] == PM_TSTAT8_WIFI) || (product_register_value[7] == PM_TSTAT8_OCC) || (product_register_value[7] == PM_TSTAT7_ARM) || (product_register_value[7] == PM_TSTAT8_220V)
		)
	{
 
		if (sel == 0)
		{
			protocol = 1;
		} 
		else
		{
			protocol = 0;
		}
	}
	else
	{
		if (sel == 1)
		{
			protocol = 3;
		}
	}
	
	 
    if (write_one(g_tstat_id, 21, protocol) > 0)
    {
        int temp_protocol = 0;
        if ((g_protocol == PROTOCOL_MSTP_TO_MODBUS) || (g_protocol == MODBUS_RS485))
        {
            if (protocol == 1) //设备选中MSTP 协议
            {
                temp_protocol = PROTOCOL_MSTP_TO_MODBUS;
            }
            else
            {
                temp_protocol = MODBUS_RS485;
            }
        }
        else //这里还要额外判断 挂在T3下面的MSTP 设备的处理方法;
        {
            return;
        }
        CString SqlText;
        SqlText.Format(_T("update ALL_NODE set Protocol = '%d' where Serial_ID='%d'"), temp_protocol, get_serialnumber());

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

}
开发者ID:temcocontrols,项目名称:T3000_Building_Automation_System,代码行数:63,代码来源:T3000_Default_MainView.cpp

示例10: BeginWaitCursor

void T3000_Default_MainView::OnBnClickedApplybutton()
{
    int m_nListenPort=0;
    BeginWaitCursor();
    //m_nListenPort	
    CString strText;
    m_ListenPort.GetWindowText(strText);
    if(!strText.IsEmpty())
        m_nListenPort=_wtoi(strText);
    if(m_nListenPort>=12767)
    {
        AfxMessageBox(_T("The listen port number is too big, please change it."));
        return;
    }
    if(m_nListenPort<=0)
    {
        AfxMessageBox(_T("The listen port number must be greater than 0!"));
        return;
    }
    write_one(g_tstat_id,75,m_nListenPort);
    product_register_value[75]=m_nListenPort;
    BYTE address1,address2,address3,address4;
    m_ipaddress.GetAddress(address1,address2,address3,address4);

    int sel = m_ip_model.GetCurSel ();
     write_one(g_tstat_id,61,sel);

    int CO2_NET_MODBUS_IP_ADDRESS_GHOST_START = 62 ;
    int n=write_one(g_tstat_id,CO2_NET_MODBUS_IP_ADDRESS_GHOST_START,address1);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_IP_ADDRESS_GHOST_START+1,address2);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_IP_ADDRESS_GHOST_START+2,address3);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_IP_ADDRESS_GHOST_START+3,address4);
    int CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START = 66;
    m_Subnet_Mask.GetAddress(address1,address2,address3,address4);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START+0,address1);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START+1,address2);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START+2,address3);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START+3,address4);
    m_GatewayAddress.GetAddress(address1,address2,address3,address4);
    int CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START =   70;
    n=write_one(g_tstat_id,CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START,address1);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START+1,address2);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START+2,address3);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START+3,address4);
    int CO2_NET_MODBUS_ENABLE_GHOST = 76;
    n=write_one(g_tstat_id,CO2_NET_MODBUS_ENABLE_GHOST,1);

    Sleep(5*1000);



    CMainFrame* pPraent=(CMainFrame*)GetParent();

    CString strBuilding,strSubBuilding;
    strBuilding=pPraent->m_strCurMainBuildingName;
    strSubBuilding=pPraent->m_strCurSubBuldingName;
    CString strIP,strPort;
    strPort.Format(_T("%d"),product_register_value[75]);
    // BYTE address1,address2,address3,address4;
    m_ipaddress.GetAddress(address1,address2,address3,address4);
    strIP.Format(_T("%d.%d.%d.%d"),address1,address2,address3,address4);
    if(g_CommunicationType==1)//TCP
    {
       /* int nPort;
        nPort=_wtoi(strPort);*/
        //m_strIP=build_info.strIp; 
        g_CommunicationType=1;
        SetCommunicationType(g_CommunicationType);
        BOOL bOk=FALSE;
        bOk=Open_Socket2(strIP,m_nListenPort);
        CString strInfo;

        strInfo.Format((_T("Open IP:%s successful")),strIP);//prompt info;
        SetPaneString(1,strInfo);
        if(bOk)
        {
            try
			{
			CppSQLite3DB SqliteDBBuilding;
			CppSQLite3Table table;
			CppSQLite3Query q;
			SqliteDBBuilding.open((UTF8MBSTR)g_strCurBuildingDatabasefilePath);


                CString strSql;
                //strSql.Format(_T("update Building set Ip_Address='%s' where Ip_Address='%s'"),strIP,pPraent->m_strIP);
                //t_pCon->Execute(strSql.GetString(),NULL,adCmdText);

                // ¸Änode
                CString strSID;

                strSID.Format(_T("%d"), get_serialnumber());
                strSql.Format(_T("update ALL_NODE set Bautrate='%s',Com_Port='%s' where Serial_ID='%s'"),strIP,strPort,strSID); //bautrate ·ÅIP
                SqliteDBBuilding.execDML((UTF8MBSTR)strSql);

                SqliteDBBuilding.closedb();

            }
            catch(_com_error *e)
            {
//.........这里部分代码省略.........
开发者ID:temcocontrols,项目名称:T3000_Building_Automation_System,代码行数:101,代码来源:T3000_Default_MainView.cpp


注:本文中的CppSQLite3DB::closedb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。