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

📄 addids.cpp

📁 入侵检测系统
💻 CPP
字号:
// AddIds.cpp : implementation file
//

#include "stdafx.h"
#include "ipcontrol.h"
#include "AddIds.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAddIds dialog


CAddIds::CAddIds(CWnd* pParent /*=NULL*/)
	: CDialog(CAddIds::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAddIds)
	m_nCurrentSel = -1;
	m_bAutoSave = TRUE;
	m_code = _T("");
	m_name = _T("");
	m_protocol = _T("");
	m_definition = _T("");
	m_description = _T("");
	m_alert = _T("");
	m_level = _T("");
	//}}AFX_DATA_INIT
}


void CAddIds::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAddIds)
	DDX_Text(pDX, IDC_EDIT1, m_code);
	DDX_Text(pDX, IDC_EDIT2, m_name);
	DDX_Text(pDX, IDC_EDIT3, m_protocol);
	DDX_Text(pDX, IDC_EDIT4, m_definition);
	DDX_Text(pDX, IDC_EDIT5, m_description);
	DDX_Text(pDX, IDC_EDIT6, m_alert);
	DDX_Text(pDX, IDC_EDIT7, m_level);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAddIds, CDialog)
	//{{AFX_MSG_MAP(CAddIds)
	ON_BN_CLICKED(IDC_ADD_BTN, OnAddBtn)
	ON_BN_CLICKED(IDC_RST_BTN, OnRstBtn)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAddIds message handlers

void CAddIds::OnAddBtn() 
{   if(UpdateData())
	
	if ( (strcmp(m_name,"") == 0) || (strcmp(m_protocol,"") == 0)||(strcmp(m_level,"") == 0)||(strcmp(m_alert,"") == 0)||(strcmp(m_definition,"") == 0)||(strcmp(m_description,"") == 0)||(strcmp(m_code,"") == 0) )
	{
		AfxMessageBox("信息不全");
		return;
	}
	
	//CString Temp;	
	
	/*m_ids.name = m_strname;
	m_ids.definition = m_strdefinition;
	m_ids.description = m_strdescription;
	m_ids.alert=m_stralert;
	m_ids.level=m_strlevel;
	m_ids.protocol=m_strprotocol;
	//Temp = INSERT INTO telelist (name, tele, remarks) VALUES ('张展明', '13519193372', '深蓝培训');
	Temp = "INSERT INTO ids (EventName, EventProtocol, EventDefinition,EventDescription,AlertType,EventLevel) VALUES ('" + m_strname + " ', '" + m_strprotocol + " ', '" +m_strdefinition + " ', '" +m_strdescription + " ', '" +m_stralert + " ', '" +m_strlevel + " ') " ;
   	AfxMessageBox("写入成功");
    */
	
		// 写入各字段值
	else{	m_pRecordset->AddNew();
		//m_pRecordset->PutCollect("EventName", _variant_t(m_strname));
		//m_pRecordset->PutCollect("EventProtocol", _variant_t(m_strprotocol));
		//m_pRecordset->PutCollect("EventDefinition", _variant_t(m_strdefinition));
		//m_pRecordset->PutCollect("EventDescription", _variant_t(m_strdescription));
		//m_pRecordset->PutCollect("AlertType", _variant_t(m_stralert));
		//m_pRecordset->PutCollect("EventLevel", _variant_t(m_strlevel));
	//	m_pRecordset->Update();

	//	AfxMessageBox("插入成功!");

		// 更新显示其库内容
		m_nCurrentSel = m_ListCtrl.InsertItem(0xffff,"");
		SaveData();///保存数据
		m_ListCtrl.SetItemState(m_nCurrentSel,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
		m_ListCtrl.SetHotItem(m_nCurrentSel);
		m_ListCtrl.SetFocus();}
	//	m_ListCtrl.setcur.SetCurSel(nCurSel);
		// 移动记录指针到新的位置
	//	OnSelchangeListaccess();
	
	// TODO: Add your control notification handler code here
	
}

void CAddIds::OnRstBtn() 
{   UpdateData(FALSE);
	// TODO: Add your control notification handler code here
	
}

BOOL CAddIds::OnInitDialog() 
{
	CDialog::OnInitDialog();
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAddIds::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	
	// Do not call CDialog::OnPaint() for painting messages
}

void CAddIds::SaveData()
{if(!m_pRecordset->rsEOF && m_nCurrentSel >= 0 && m_bAutoSave)
	{
		vEventCode = m_code;
		vEventName = m_name;
		vEventProtocol=m_protocol;
		vEventDefinition=m_definition;
		vEventDescription=m_description;
		vAlertType=m_alert;
        vEventLevel = m_level;
		m_pRecordset->PutCollect("事件代码",vEventCode);
		m_pRecordset->PutCollect("事件名称",vEventName);
		m_pRecordset->PutCollect("事件协议",vEventProtocol);
		m_pRecordset->PutCollect("事件定义",vEventDefinition);
		m_pRecordset->PutCollect("事件说明",vEventDescription);
		m_pRecordset->PutCollect("响应方式",vAlertType);
		m_pRecordset->PutCollect("事件级别",vEventLevel);
		m_ListCtrl.SetItem(m_nCurrentSel,0,LVIF_TEXT,(_bstr_t)vEventCode,NULL,0,0,0);
		m_ListCtrl.SetItem(m_nCurrentSel,1,LVIF_TEXT,(_bstr_t)vEventName,NULL,0,0,0);
		m_ListCtrl.SetItem(m_nCurrentSel,2,LVIF_TEXT,(_bstr_t)vEventProtocol,NULL,0,0,0);
		m_ListCtrl.SetItem(m_nCurrentSel,3,LVIF_TEXT,(_bstr_t)vEventDefinition,NULL,0,0,0);
		m_ListCtrl.SetItem(m_nCurrentSel,4,LVIF_TEXT,(_bstr_t)vEventDescription,NULL,0,0,0);
		m_ListCtrl.SetItem(m_nCurrentSel,5,LVIF_TEXT,(_bstr_t)vAlertType,NULL,0,0,0);
		m_ListCtrl.SetItem(m_nCurrentSel,6,LVIF_TEXT,(_bstr_t)vEventLevel,NULL,0,0,0);
        
 
	}

}

⌨️ 快捷键说明

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