コード例 #1
0
BOOL CAllNodesDiaolg::OnInitDialog()
{
	CDialog::OnInitDialog();
	m_InputTextEdt.ShowWindow(SW_HIDE);
	m_productCombox.ShowWindow(SW_HIDE);
	//GetDlgItem(IDC_ADDBUTTON)->ShowWindow(SW_HIDE);

	CMainFrame* pFrame=(CMainFrame*)(AfxGetApp()->m_pMainWnd);
	m_strMainBuildingName= pFrame->m_strCurMainBuildingName;
	m_strSubNetName= pFrame->m_strCurSubBuldingName;
	int k=0;
	for(UINT i=0;i<pFrame->m_subNetLst.size();i++)
	{
		if(m_strSubNetName.CompareNoCase(pFrame->m_subNetLst.at(i).strBuildingName)==0)
			k=i;
		m_SubLstCombox.AddString(pFrame->m_subNetLst.at(i).strBuildingName);
	}
	m_SubLstCombox.SetCurSel(k);

	m_SubLstCombox.ShowWindow(SW_HIDE);
	GetDlgItem(IDC_STATIC1)->ShowWindow(SW_HIDE);
	
	m_pCon.CreateInstance(_T("ADODB.Connection"));
	m_pRs.CreateInstance(_T("ADODB.Recordset"));
	m_pCon->Open(g_strDatabasefilepath.GetString(),_T(""),_T(""),adModeUnknown);

	ReloadAddBuildingDB();
	return TRUE;  // return TRUE unless you set the focus to a control
}
コード例 #2
0
void CAddBuilding::Update_Recorder()
{
	try
	{
		 
	}
	catch (...)
	{
	}
	ReloadAddBuildingDB();
}
コード例 #3
0
void CAllNodesDiaolg::OnCbnSelchangeCombo1()
{
	CString strSelect;
	int nIdext=m_SubLstCombox.GetCurSel();
	if(nIdext>=0)
	{
		m_SubLstCombox.GetLBText(nIdext,strSelect);
		m_strSubNetName=strSelect;
		ReloadAddBuildingDB();
	}
}
void ApplyGraphicLabelsDlg::OnCbnSelchangeCombo1()
{
	CString strText;
	int nIdext=m_subNetList.GetCurSel();
	if(nIdext>=0)
	{
		m_subNetList.GetLBText(nIdext,strText);
		m_strSubNetName=strText;

	}
	ReloadAddBuildingDB();
	
}
コード例 #5
0
BOOL CAddBuilding::OnInitDialog()
{
	CDialog::OnInitDialog();
	::InitializeCriticalSection(&g_Lock);

	GetSerialComPortNumber1(m_szComm);
	CString strIPTest;
//	GetIPbyHostName(_T("www.google.com"),strIPTest);
	m_AddBuiding_SetComBox.ShowWindow(SW_HIDE);
	m_AddBuiding_SetEditCtrl.ShowWindow(SW_HIDE);
	m_mainBuildEdt.ShowWindow(SW_HIDE);
	//GetDlgItem(IDC_SCANNCBTN)->ShowWindow(SW_HIDE);

	m_AddBuiding_FlexGrid.put_TextMatrix(0,AB_MAINNAME,_T("Main Building"));
	m_AddBuiding_FlexGrid.put_TextMatrix(0,AB_NAME,_T("Sub Net"));
	m_AddBuiding_FlexGrid.put_TextMatrix(0,AB_PROTOCOL,_T("Protocol"));
	m_AddBuiding_FlexGrid.put_TextMatrix(0,AB_IPADDRESS,_T("Ip Address"));
	m_AddBuiding_FlexGrid.put_TextMatrix(0,AB_IPPORT,_T("IP Port"));
	m_AddBuiding_FlexGrid.put_TextMatrix(0,AB_COMPORT,_T("COM Port"));
	m_AddBuiding_FlexGrid.put_TextMatrix(0,AB_BAUDRAT,_T("Baud Rate"));

	m_AddBuiding_FlexGrid.put_ColWidth(0,1100);
	m_AddBuiding_FlexGrid.put_ColWidth(AB_MAINNAME,1100);
	m_AddBuiding_FlexGrid.put_ColWidth(AB_NAME,1000);
	m_AddBuiding_FlexGrid.put_ColWidth(AB_PROTOCOL,1000);
	m_AddBuiding_FlexGrid.put_ColWidth(AB_IPADDRESS,1200);
	m_AddBuiding_FlexGrid.put_ColWidth(AB_IPPORT,1000);
	m_AddBuiding_FlexGrid.put_ColWidth(AB_COMPORT,1000);
	m_AddBuiding_FlexGrid.put_ColWidth(AB_BAUDRAT,1000);


 

	ReloadAddBuildingDB();

	m_NCFlexGrid.put_TextMatrix(0,0,_T("Serial Number"));
	m_NCFlexGrid.put_TextMatrix(0,1,_T("Modbus ID"));
	m_NCFlexGrid.put_TextMatrix(0,2,_T("Product type"));
	m_NCFlexGrid.put_TextMatrix(0,3,_T("IP address"));
	m_NCFlexGrid.put_TextMatrix(0,4,_T("Port"));	
	m_NCFlexGrid.put_ColWidth(0,1100);
	m_NCFlexGrid.put_ColWidth(1,1100);
	m_NCFlexGrid.put_ColWidth(2,1100);
	m_NCFlexGrid.put_ColWidth(3,1400);
	m_NCFlexGrid.put_ColWidth(4,1100);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #6
0
void CAddBuilding::OnBuildingDelete()
{
	if(m_nCurRow>=(m_AddBuiding_FlexGrid.get_Rows()-1) || m_nCurRow <1 )
	{
		return;
	}
	CString strSql;
	strSql.Format(_T("delete   from Building where Building_Name='%s' and Main_BuildingName='%s'"),m_strBuilding_Name2,m_strMainBuildingName);
	try
	{


		 
	}
	catch (...)
	{

	}
	ReloadAddBuildingDB();

}
コード例 #7
0
void CAllNodesDiaolg::OnBnClickedDelallbutton()
{
	CString strSql;
	strSql=_T("delete * from ALL_NODE ");
	CString strTemp;
	strTemp.Format(_T("Are you sure to delete all the sub node(s)"));
	if(AfxMessageBox(strTemp,MB_OKCANCEL)==IDOK)
	{
		try
		{


			m_pCon->Execute(strSql.GetString(),NULL,adCmdText);	
		}
		catch(_com_error *e)
		{
			AfxMessageBox(e->ErrorMessage());
		}
	}
	ReloadAddBuildingDB();
	m_bChanged=TRUE;
}
コード例 #8
0
void CAllNodesDiaolg::OnBnClickedDelbutton()
{
#if 1
	if(m_nCurRow==0||m_nCurRow==m_FlexGrid.get_Rows()-1)
	{
		AfxMessageBox(_T("Please select a item first!"));
		return;
	}
	CString strText;
	strText=m_FlexGrid.get_TextMatrix(m_nCurRow,AN_SerialID);
	if(strText.IsEmpty())
	{
		AfxMessageBox(_T("No item Selected!"));
	}
	CString strSql;
	strSql.Format(_T("delete * from ALL_NODE where Serial_ID ='%s'"),strText);
	CString strTemp;
	strTemp.Format(_T("Are you sure to delete thise item"));
	if(AfxMessageBox(strTemp,MB_OKCANCEL)==IDOK)
	{
		try
		{


			m_pCon->Execute(strSql.GetString(),NULL,adCmdText);	
		}
		catch(_com_error *e)
		{
			AfxMessageBox(e->ErrorMessage());
		}
	}
	ReloadAddBuildingDB();
	m_bChanged=TRUE;
#endif
	

}
BOOL ApplyGraphicLabelsDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
		
	m_pCon.CreateInstance(_T("ADODB.Connection"));
	m_pRs.CreateInstance(_T("ADODB.Recordset"));
	m_pCon->Open(g_strDatabasefilepath.GetString(),_T(""),_T(""),adModeUnknown);


	SetWindowText(_T("Set graphic labels to the others dialog"));
	CMainFrame* pFrame=(CMainFrame*)(AfxGetApp()->m_pMainWnd);
	m_strMainBuilding= pFrame->m_strCurMainBuildingName;
	m_strSubNetName= pFrame->m_strCurSubBuldingName;
	m_subNetList.ShowWindow(SW_HIDE);
	GetDlgItem(IDC_STATIC1)->ShowWindow(SW_HIDE);

//	m_strScanSubNetNameCobox.AddString(_T("All subNets..."));

/*	int k=0;
	for(int i=0;i<pFrame->m_subNetLst.size();i++)
	{
		if(m_strSubNetName.CompareNoCase(pFrame->m_subNetLst.at(i).strBuildingName)==0)
			k=i;
		m_subNetList.AddString(pFrame->m_subNetLst.at(i).strBuildingName);
	}
	if(m_subNetList.GetCount()>0)
		m_subNetList.SetCurSel(k);
		*/

	ReloadAddBuildingDB();

	// TODO:  Add extra initialization here

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #10
0
void CAllNodesDiaolg::OnBnClickedAddbutton()
{
	// TODO: Add your control notification handler code here
	//AfxMessageBox(_T("Not realized!"));

	CString strSql;
	int nMaxRowIndext=m_FlexGrid.get_Rows()-1;

	//CString strSBuildingNameTemp;
	//strSBuildingNameTemp.Format(_T("Subnet_%d"), nMaxRowIndext);	

	// main building name
	CString strMainBuildName=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_MAINNAME);
	if(strMainBuildName.IsEmpty())
	{
		strMainBuildName = m_strMainBuildingName;
		//AfxMessageBox(_T("Input the building info in the last row of grid, the Main Building can not be empty."));
		//return ;
	}
	// sub net name
	CString strSubBuildingName=m_FlexGrid.get_TextMatrix(nMaxRowIndext,AN_NAME);
	if(strSubBuildingName.IsEmpty())
	{
		strSubBuildingName = m_strSubNetName;
	}
	// serial ID
	CString strSID;
	strSID=m_FlexGrid.get_TextMatrix(nMaxRowIndext,AN_SerialID);
	if(strSID.IsEmpty())
	{
		AfxMessageBox(_T("The Serial ID can not be empty, please input."));
		return ;
	}
	// Floor name
	CString strFloorName;
	strFloorName=m_FlexGrid.get_TextMatrix(nMaxRowIndext,AN_FLOORNAME);
	if(strFloorName.IsEmpty())
	{
		strFloorName.Format(_T("Floor_%d"), nMaxRowIndext);
	}
	// room name
	CString strRoomName;
	strRoomName=m_FlexGrid.get_TextMatrix(nMaxRowIndext,AN_ROOMNAME);
	if(strRoomName.IsEmpty())
	{
		strRoomName.Format(_T("Room_%d"), nMaxRowIndext);
	}

	// PRODUCT NAME
	CString strProName;
	strProName=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_PRUDUCTNAME);
	if(strProName.IsEmpty())
	{
		strProName=_T("New device");
	}


	// product type 
	CString strProType;
	strProType=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_PRODUCTTYPE);
	if(strProType.IsEmpty())
	{
		AfxMessageBox(_T("The Product type can not be empty, please input."));
		return ;
	}
	
	// product ID
	CString strProID;
	strProID=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_PRODUCTID);
	if(strProID.IsEmpty())
	{
		AfxMessageBox(_T("The Product ID can not be empty, please input."));
		return ;
	}


	// SCREEN ID
	CString strScreenID;
	strScreenID=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_SCREENID);
	if(strScreenID.IsEmpty())
	{		
		strScreenID = _T("Screen(S:") + strSID +_T("--") + strProID + _T(")");
	}

	// baud rate 
	CString strBaudrate;
	strBaudrate=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_BAUDRATE);
	if(strBaudrate.IsEmpty())
	{		
		int nType = _wtoi(strProType);
		if ( nType == 100 )  // NC
		{
			strBaudrate = _T("192.168.0.3");
		}
		else
		{
			strBaudrate = _T("19200");
		}		
	}

	// GRAPHIC ID 
	CString strGraphicID;
	strGraphicID=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_GRAPHICID);
	if(strGraphicID.IsEmpty())
	{		
		strGraphicID = _T("Clicking here to add a image");
	}
	
	// Hard VERSION
	CString strHdVersion;
	strHdVersion=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_HDVERSION);
	if(strHdVersion.IsEmpty())
	{		
		strHdVersion = _T("0");
	}
	// soft VERSION
	CString strStVersion;
	strStVersion=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_SWVERSION);
	if(strStVersion.IsEmpty())
	{		
		strStVersion = _T("0");
	}

	// EP Size
	CString strEPSize;
	strEPSize=m_FlexGrid.get_TextMatrix(nMaxRowIndext, AN_EPSIZE);
	if(strEPSize.IsEmpty())
	{		
		strEPSize = _T("0");
	}

	CString strCom = _T("0");
	
	strSql.Format(_T("insert into ALL_NODE (MainBuilding_Name,Building_Name,Serial_ID,Floor_name,Room_name,Product_name,Product_class_ID,Product_ID,Screen_Name,Bautrate,Background_imgID,Hardware_Ver,Software_Ver,Com_Port,EPsize) values('"+strMainBuildName+"','"+strSubBuildingName +"','"+strSID+"','"+strFloorName+"','"+strRoomName+"','"+strProName+"','"+strProType+"','"+strProID+"','"+strScreenID+"','"+strBaudrate+"','"+strGraphicID+"','"+strHdVersion+"','"+strStVersion+"','"+strCom+"','"+strEPSize+"')"));
	//new nc//strSql.Format(_T("insert into ALL_NODE (MainBuilding_Name,Building_Name,Serial_ID,Floor_name,Room_name,Product_name,Product_class_ID,Product_ID,Screen_Name,Bautrate,Background_imgID,Hardware_Ver,Software_Ver,Com_Port,EPsize,Mainnet_info) values('"+strMainBuildName+"','"+strSubBuildingName +"','"+strSID+"','"+strFloorName+"','"+strRoomName+"','"+strProName+"','"+strProType+"','"+strProID+"','"+strScreenID+"','"+strBaudrate+"','"+strGraphicID+"','"+strHdVersion+"','"+strStVersion+"','"+strCom+"','"+strEPSize+"','"+strMainnetInfo+"')"));
	try
	{



	TRACE(strSql);
	
	m_pCon->Execute(strSql.GetString(),NULL,adCmdText);
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}
	ReloadAddBuildingDB();


}
コード例 #11
0
void CAllNodesDiaolg::OnEnKillfocusTextedit()
{
	// TODO: Add your control notification handler code here
	if(m_nCurRow==0)
		return;
	if(m_FlexGrid.get_RowSel()==0)
		return;
	m_InputTextEdt.ShowWindow(SW_HIDE);
	CString strName;
	m_InputTextEdt.GetWindowText(strName);
	
	if (m_nCurRow < m_FlexGrid.get_Rows()-1)
	{
		if(m_nCurCol==AN_PRUDUCTNAME)
		{
			CString strSerial=m_FlexGrid.get_TextMatrix(m_nCurRow,AN_SerialID);
			if(strSerial.IsEmpty())
				return;
			CString strSql;
			try
			{


			strSql.Format(_T("update ALL_NODE set Product_name ='%s' where Serial_ID = '%s' and Building_Name = '%s'"),strName,strSerial,m_strSubNetName);
			m_pCon->Execute(strSql.GetString(),NULL,adCmdText);		
			}
			catch(_com_error *e)
			{
				AfxMessageBox(e->ErrorMessage());
			}
			ReloadAddBuildingDB();
		}
		if(m_nCurCol==AN_ROOMNAME)
		{
			CString strSerial=m_FlexGrid.get_TextMatrix(m_nCurRow,AN_SerialID);
			if(strSerial.IsEmpty())
				return;
			CString strSql;
			try
			{


			strSql.Format(_T("update ALL_NODE set Room_name ='%s' where Serial_ID = '%s' and Building_Name = '%s'"),strName,strSerial,m_strSubNetName);
			m_pCon->Execute(strSql.GetString(),NULL,adCmdText);	
			}
			catch(_com_error *e)
			{
				AfxMessageBox(e->ErrorMessage());
			}
			ReloadAddBuildingDB();
		}
		if(m_nCurCol==AN_FLOORNAME)
		{
			CString strSerial=m_FlexGrid.get_TextMatrix(m_nCurRow,AN_SerialID);
			if(strSerial.IsEmpty())
				return;
			try
			{


			CString strSql;

			strSql.Format(_T("update ALL_NODE set Floor_name ='%s' where Serial_ID = '%s' and Building_Name = '%s'"),strName,strSerial,m_strSubNetName);
			m_pCon->Execute(strSql.GetString(),NULL,adCmdText);		
			}
			catch(_com_error *e)
			{
				AfxMessageBox(e->ErrorMessage());
			}

			ReloadAddBuildingDB();
		}
	}
	else // 最后一行,用来增加
	{
		//if(m_nCurCol==AN_PRODUCTTYPE)
		{
			m_FlexGrid.put_TextMatrix(m_nCurRow, m_nCurCol, strName);
		}

	}
}
コード例 #12
0
void CAddBuilding::OnMainBuildingUnSelect()
{
	 

	ReloadAddBuildingDB();
}