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

📄 netstrategydlg.cpp

📁 本程序使用Visual C++6.0编写
💻 CPP
📖 第 1 页 / 共 5 页
字号:
					SQLStr="select * from Ftpfilter";
					hTRes = m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
						             	((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
										adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
					for(int i=0;i<N;i++)
					{
						if(filestate[i]==1)
						{
							m_pRecordset->AddNew();//添加新的记录
							m_pRecordset->PutCollect("Deviceid",_variant_t(m_strdeviceid));
							CString s;
							s.Format("%d",filetype[i]);
							m_pRecordset->PutCollect("Filetypeid",_variant_t(s));
  							m_pRecordset->PutCollect("Action",_variant_t("1"));
			       			m_pRecordset->Update(); //更新数据库
						}
					}
				}
		  }
			catch(_com_error e)///捕捉异常
				{
					CString errormessage;
					MessageBox("创建记录集失败!","错误");
				}
				m_pRecordset->Close();  
		  }
    	if(m_flagstate[5]==2)
		{
			SQLStr.Format("delete from Ftpfilter where Deviceid='%d' and Action='0'",m_deviceid);
            (((CSjsysApp*)AfxGetApp())->pConnection)->Execute((_bstr_t)SQLStr,&RecordsAffected,adCmdText);
		  try
			  {
				HRESULT hTRes;
				hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
		    	if (SUCCEEDED(hTRes))
				{  
					SQLStr="select * from Ftpfilter";
					hTRes = m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
						             	((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
										adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
					for(int i=0;i<N;i++)
					{
						if(filestate[i]==1)
						{
							m_pRecordset->AddNew();//添加新的记录
							m_pRecordset->PutCollect("Deviceid",_variant_t(m_strdeviceid));
							CString s;
							s.Format("%d",filetype[i]);
							m_pRecordset->PutCollect("Filetypeid",_variant_t(s));
  							m_pRecordset->PutCollect("Action",_variant_t("0"));
			       			m_pRecordset->Update(); //更新数据库
						}
					}
				}
		  }
		catch(_com_error e)///捕捉异常
			{
				CString errormessage;
				MessageBox("创建记录集失败!","错误");
			}
			m_pRecordset->Close();  
		  }

	if(m_flagstate[7]==1 && m_port[0].GetSize())
		{
			SQLStr.Format("delete from Portfilter where Deviceid='%d' and Action='1'",m_deviceid);
            (((CSjsysApp*)AfxGetApp())->pConnection)->Execute((_bstr_t)SQLStr,&RecordsAffected,adCmdText);
	     	try
			 {
				SQLStr="select * from Portfilter"; 
				HRESULT hTRes;
				hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
			    if (SUCCEEDED(hTRes))
					{   
						hTRes = m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
						             	((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
				        				adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
					    int k=m_port[1].GetSize();
						for(int i=0;i<m_port[0].GetSize();i++)
						{
							m_pRecordset->AddNew();//添加新的记录
							m_pRecordset->PutCollect("Deviceid",_variant_t(m_strdeviceid));
							m_pRecordset->PutCollect("Startport",_variant_t(m_port[0].GetAt(i)));
							if(i<k)
				    		  m_pRecordset->PutCollect("Endport",_variant_t(m_port[1].GetAt(i)));
  							m_pRecordset->PutCollect("Action",_variant_t("1"));
				       		m_pRecordset->Update(); //更新数据库
						}
					}
			}
			  catch(_com_error e)///捕捉异常
				{
					CString errormessage;
					MessageBox("创建记录集失败!","错误");
				}
				m_pRecordset->Close();
			}

		if(m_flagstate[7]==2 && m_port[2].GetSize())
		{
			SQLStr.Format("delete from Portfilter where Deviceid='%d' and Action='0'",m_deviceid);
            (((CSjsysApp*)AfxGetApp())->pConnection)->Execute((_bstr_t)SQLStr,&RecordsAffected,adCmdText);
	     	try
			 {
				SQLStr="select * from Portfilter"; 
				HRESULT hTRes;
				hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
			    if (SUCCEEDED(hTRes))
					{   
						hTRes = m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
						             	((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
				        				adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
						int k=m_port[3].GetSize();
						for(int i=0;i<m_port[2].GetSize();i++)
						{
						m_pRecordset->AddNew();//添加新的记录
						m_pRecordset->PutCollect("Deviceid",_variant_t(m_strdeviceid));
						m_pRecordset->PutCollect("Startport",_variant_t(m_port[2].GetAt(i)));
						if(i<k)
				    	   m_pRecordset->PutCollect("Endport",_variant_t(m_port[3].GetAt(i)));
  			            m_pRecordset->PutCollect("Action",_variant_t("0"));
				       	m_pRecordset->Update(); //更新数据库
						}
				}
			}
		  catch(_com_error e)///捕捉异常
			{
				CString errormessage;
				MessageBox("创建记录集失败!","错误");
			}
				m_pRecordset->Close();
		}

		if(m_flagstate[9]==1)
		{
			SQLStr.Format("delete from Servfilter where Deviceid='%d' and Action='1'",m_deviceid);
            (((CSjsysApp*)AfxGetApp())->pConnection)->Execute((_bstr_t)SQLStr,&RecordsAffected,adCmdText);
		  try
			  {
				HRESULT hTRes;
				hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
		    	if (SUCCEEDED(hTRes))
				{  
					SQLStr="select * from Servfilter";
					hTRes = m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
						             	((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
										adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
					for(int i=0;i<N;i++)
					{
						if(servicestate[i]==1)
						{
							m_pRecordset->AddNew();//添加新的记录
							m_pRecordset->PutCollect("Deviceid",_variant_t(m_strdeviceid));
							CString s;
							s.Format("%d",servicetype[i]);
							m_pRecordset->PutCollect("Servtypeid",_variant_t(s));
  							m_pRecordset->PutCollect("Action",_variant_t("1"));
			       			m_pRecordset->Update(); //更新数据库
						}
					}
				}
		  }
			catch(_com_error e)///捕捉异常
				{
					CString errormessage;
					MessageBox("创建记录集失败!","错误");
				}
				m_pRecordset->Close();  
		  }
    	if(m_flagstate[9]==2)
		{
			SQLStr.Format("delete from Servfilter where Deviceid='%d' and Action='0'",m_deviceid);
            (((CSjsysApp*)AfxGetApp())->pConnection)->Execute((_bstr_t)SQLStr,&RecordsAffected,adCmdText);
		  try
			  {
				HRESULT hTRes;
				hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
		    	if (SUCCEEDED(hTRes))
				{  
					SQLStr="select * from Servfilter";
					hTRes = m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
						             	((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
										adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
					for(int i=0;i<N;i++)
					{
						if(servicestate[i]==1)
						{
							m_pRecordset->AddNew();//添加新的记录
							m_pRecordset->PutCollect("Deviceid",_variant_t(m_strdeviceid));
							CString s;
							s.Format("%d",servicetype[i]);
							m_pRecordset->PutCollect("Servtypeid",_variant_t(s));
  							m_pRecordset->PutCollect("Action",_variant_t("0"));
			       			m_pRecordset->Update(); //更新数据库
						}
					}
				}
		  }
		catch(_com_error e)///捕捉异常
			{
				CString errormessage;
				MessageBox("创建记录集失败!","错误");
			}
			m_pRecordset->Close();  
		  }

/*	for(int i=0;i<m_url[0].GetSize();i++)
		MessageBox(m_url[0].GetAt(i));
	for(i=0;i<m_url[1].GetSize();i++)
		MessageBox(m_url[1].GetAt(i));

	for( i=0;i<m_email[0].GetSize();i++)
		MessageBox(m_email[0].GetAt(i));
	for(i=0;i<m_email[1].GetSize();i++)
		MessageBox(m_email[1].GetAt(i));
	for( i=0;i<m_port[0].GetSize();i++)
		MessageBox(m_port[0].GetAt(i));
	for(i=0;i<m_port[1].GetSize();i++)
		MessageBox(m_port[1].GetAt(i));
	for( i=0;i<m_port[2].GetSize();i++)
		MessageBox(m_port[2].GetAt(i));
	for(i=0;i<m_port[3].GetSize();i++)
		MessageBox(m_port[3].GetAt(i));

*/
	SQLStr.Format("select * from Filterconf where Deviceid='%d'",m_deviceid);
     try
		{
			HRESULT hTRes;
			hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
			if (SUCCEEDED(hTRes))
			{   
				hTRes = m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
					((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
				if(SUCCEEDED(hTRes))
				{
					TRACE(_T("连接成功!\n"));
					if(m_pRecordset->adoEOF)
					{
						MessageBox("您还没有选择设备或不存在这个设备","确认");
						return;
					}
				//	m_pRecordset->AddNew();//添加新的记录
				//	m_pRecordset->PutCollect("ID",_variant_t(m_ID));
					CString s;
					if(m_flagstate[0]>=0)
					{
						s.Format("%d",m_flagstate[0]);
						m_pRecordset->PutCollect("bUrlMonitor",_variant_t(s));
					}
					if(m_flagstate[2]>=0)
					{
						s.Format("%d",m_flagstate[2]);
						m_pRecordset->PutCollect("bEmailMonitor",_variant_t(s));
					}
					if(m_flagstate[4]>=0)
					{
						s.Format("%d",m_flagstate[4]);
						m_pRecordset->PutCollect("bftpMonitor",_variant_t(s)); 
					}
					if(m_flagstate[6]>=0)
					{
						s.Format("%d",m_flagstate[6]);
						m_pRecordset->PutCollect("bPortMonitor",_variant_t(s));
					}
					if(m_flagstate[8]>=0)
					{
						s.Format("%d",m_flagstate[8]);
						m_pRecordset->PutCollect("bServMonitor",_variant_t(s)); 
					}
					if(m_flagstate[1]>=0)
					{
						s.Format("%d",m_flagstate[1]);
			    		m_pRecordset->PutCollect("bUsingUrlFilter",_variant_t(s));
					}
					if(m_flagstate[3]>=0)
					{
						s.Format("%d",m_flagstate[3]);
						m_pRecordset->PutCollect("bUsingEmailFilter",_variant_t(s));
					}
                    if(m_flagstate[5]>=0)
					{
						s.Format("%d",m_flagstate[5]);
						m_pRecordset->PutCollect("bUsingftpFilter",_variant_t(s)); 
					}
					if(m_flagstate[7]>=0)
					{
						s.Format("%d",m_flagstate[7]);
						m_pRecordset->PutCollect("bUsingPortFilter",_variant_t(s));
					}
					if(m_flagstate[9]>=0)
					{
						s.Format("%d",m_flagstate[9]);
						m_pRecordset->PutCollect("bUsingServFilter",_variant_t(s)); 
					}
					
					m_pRecordset->Update(); //更新数据库
				//	AfxMessageBox("设置保存成功!");  //提示信息
				}
				m_pRecordset->Close();
			}
		}
		catch(_com_error e)///捕捉异常
		{
			CString errormessage;
			MessageBox("创建记录集失败!","错误");
		}

	SQLStr="SELECT * FROM SysFlag" ;//构造sql语句
	try
		{
			HRESULT hTRes;
			hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
			if (SUCCEEDED(hTRes))
			{   
				hTRes = m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
					((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
					adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
				if(SUCCEEDED(hTRes))
				{
					TRACE(_T("连接成功!\n"));
			     //	m_pRecordset->AddNew();//添加新的记录
					m_pRecordset->PutCollect("IsUpdate",_variant_t("1"));
					m_pRecordset->Update(); //更新数据库
				   AfxMessageBox("保存成功!");  //提示信息
				}
				m_pRecordset->Close();
			}
		}
		catch(_com_error e)///捕捉异常
		{
			CString errormessage;
			MessageBox("创建记录集失败!","错误");
		}
	}
CDialog::OnOK();
}

void CNetStrategyDlg::EanbleControls()
{
   CString s;
   GetDlgItemText(IDC_RADIO3,s);
   if(s=="禁止端口")
   {
       GetDlgItem(IDC_RADIO6)->EnableWindow(TRUE);
	   GetDlgItem(IDC_RADIO4)->EnableWindow(TRUE);
	   GetDlgItem(IDC_RADIO5)->EnableWindow(TRUE);
	   GetDlgItem(IDC_LIST3)->EnableWindow(FALSE);
	   GetDlgItem(IDC_LIST4)->EnableWindow(FALSE);
	   return;
   }

   GetDlgItem(IDC_RADIO6)->EnableWindow(TRUE);
   GetDlgItem(IDC_RADIO4)->EnableWindow(TRUE);
   GetDlgItem(IDC_RADIO5)->EnableWindow(TRUE);
   GetDlgItem(IDC_LIST1)->EnableWindow(FALSE);
   GetDlgItem(IDC_LIST2)->EnableWindow(FALSE);
}

void CNetStrategyDlg::DisableControls()
{
   CString s;
   GetDlgItemText(IDC_RADIO3,s);
   if(s=="禁止端口")
   {
       GetDlgItem(IDC_RADIO6)->EnableWindow(FALSE);
	   GetDlgItem(IDC_RADIO4)->EnableWindow(FALSE);
	   GetDlgItem(IDC_RADIO5)->EnableWindow(FALSE);
	   GetDlgItem(IDC_LIST3)->EnableWindow(FALSE);
	   GetDlgItem(IDC_LIST4)->EnableWindow(FALSE);
	   return;
   }
   GetDlgItem(IDC_RADIO6)->EnableWindow(FALSE);
   GetDlgItem(IDC_RADIO4)->EnableWindow(FALSE);
   GetDlgItem(IDC_RADIO5)->EnableWindow(FALSE);
   GetDlgItem(IDC_LIST1)->EnableWindow(FALSE);
   GetDlgItem(IDC_LIST2)->EnableWindow(FALSE);
   GetDlgItem(IDC_LIST3)->EnableWindow(FALSE);
   GetDlgItem(IDC_LIST4)->EnableWindow(FALSE);
}

void CNetStrategyDlg::GetControlInfo()
{
   int i=0;
   int n=0;
   //int typeindex;
   CString str="";
   switch(m_btnflag)
   {
   case 1:
       m_flagstate[1]=m_radioflag2;
	   if(m_radioflag2==1)
	   { 
		   m_url[0].RemoveAll();
		   n=m_list11.GetItemCount();
		   if(n==0)
			   break;
		   for(i=0;i<n;i++)
		   {
              str=m_list11.GetItemText(i,0);
			  if(str=="")
				  continue;
			  m_url[0].Add(str);
            /*  SQLStr="select * from Urlfilter";
		    	try
				 {
					HRESULT hTRes;
					hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
			    	if (SUCCEEDED(hTRes))
					{   
						hTRes = m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
						             	((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
				        				adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
						m_pRecordset->AddNew();//添加新的记录
					//	CString s;
					//	s.Format("%d",m_deviceid);
						m_pRecordset->PutCollect("Deviceid",_variant_t(m_strdeviceid));
						m_pRecordset->PutCollect("Urlname",_variant_t(str));
  				        m_pRecordset->PutCollect("Action",_variant_t("1"));
				       	m_pRecordset->Update(); //更新数据库
						}
					}
					catch(_com_error e)///捕捉异常

⌨️ 快捷键说明

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