📄 brow.cpp
字号:
// Brow.cpp : implementation file
//
#include "stdafx.h"
#include "ipcontrol.h"
#include "Brow.h"
#include "AddIds.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBrow dialog
extern CIPControlApp theApp;
CBrow::CBrow(CWnd* pParent /*=NULL*/)
: CDialog(CBrow::IDD, pParent)
{
//{{AFX_DATA_INIT(CBrow)
m_name = _T("");
m_protocol = _T("");
m_definition = _T("");
m_description = _T("");
m_alert = _T("");
m_level = _T("");
m_code = _T("");
//}}AFX_DATA_INIT
}
void CBrow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBrow)
DDX_Control(pDX, IDC_LIST, m_AccessList);
DDX_Text(pDX, IDC_EDIT3, m_name);
DDV_MaxChars(pDX, m_name, 100);
DDX_Text(pDX, IDC_EDIT4, m_protocol);
DDV_MaxChars(pDX, m_protocol, 100);
DDX_Text(pDX, IDC_EDIT5, m_definition);
DDV_MaxChars(pDX, m_definition, 1000);
DDX_Text(pDX, IDC_EDIT6, m_description);
DDV_MaxChars(pDX, m_description, 1000);
DDX_CBString(pDX, IDC_COMBO2, m_alert);
DDX_CBString(pDX, IDC_COMBO3, m_level);
DDX_Text(pDX, IDC_EDIT2, m_code);
DDV_MaxChars(pDX, m_code, 100);
DDX_Control(pDX, IDC_BUTTON_READ, m_btnread);
DDX_Control(pDX, IDC_BUTTON_MODIFY, m_btnmodify);
DDX_Control(pDX, IDC_BUTTON_DEL, m_btndel);
DDX_Control(pDX, IDC_BUTTON_ADD, m_btnadd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBrow, CDialog)
//{{AFX_MSG_MAP(CBrow)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
ON_BN_CLICKED(IDC_BUTTON_MODIFY, OnButtonModify)
ON_COMMAND(IDM_IDSRULE, OnIdsrule)
ON_BN_CLICKED(IDC_BUTTON_READ, OnButtonRead)
ON_LBN_SELCHANGE(IDC_LIST, OnSelchangeList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBrow message handlers
void CBrow::OnButtonAdd()
{ /* if(UpdateData())
if((m_code.GetLength()>0)&&(m_name.GetLength()>0)&&(m_protocol.GetLength()>0)&&(m_definition.GetLength()>0)&&(m_description.GetLength()>0)&&(m_alert.GetLength()>0)&&(m_level.GetLength()>0))
{
m_pRecordset->AddNew();
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();
}
else
AfxMessageBox("请输入所有策略信息!");
// TODO: Add your control notification handler code here
*/
UpdateData();
if(m_code == "" || m_name == ""||m_protocol==""||m_definition==""||m_description==""||m_alert==""||m_level=="")
{
AfxMessageBox("策略信息不完整!");
return;
}
try
{
// 写入各字段值
m_pRecordset->AddNew();
m_pRecordset->PutCollect("EventCode", _variant_t(m_code));
m_pRecordset->PutCollect("EventName", _variant_t(m_name));
m_pRecordset->PutCollect("EventProtocol", _variant_t(m_protocol));
m_pRecordset->PutCollect("EventDefinition", _variant_t(m_definition));
m_pRecordset->PutCollect("EventDescription", _variant_t(m_description));
m_pRecordset->PutCollect("AlertType", _variant_t(m_alert));
m_pRecordset->PutCollect("EventLevel", _variant_t(m_level));
m_pRecordset->Update();
AfxMessageBox("插入成功!");
// 更新显示其库内容
int nCurSel = m_AccessList.GetCurSel();
OnButtonRead();
m_AccessList.SetCurSel(nCurSel);
// 移动记录指针到新的位置
OnSelchangeList();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
}
void CBrow::OnButtonDel()
{ /*m_bAutoSave = FALSE;
if(m_nCurrentSel >= 0)
{
m_ListCtrl.DeleteItem(m_nCurrentSel);
int count = m_ListCtrl.GetItemCount();
if(count <= m_nCurrentSel)
m_nCurrentSel = count-1;
m_pRecordset->Delete(adAffectCurrent);
m_pRecordset->MoveNext();
LoadData();
m_ListCtrl.SetItemState(m_nCurrentSel,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
m_ListCtrl.SetFocus();
}
m_bAutoSave = TRUE;*/
// TODO: Add your control notification handler code here
if(m_AccessList.GetCount() == 0)
return;
else if(m_AccessList.GetCurSel() < 0 || m_AccessList.GetCurSel() > m_AccessList.GetCount())
m_AccessList.SetCurSel(0);
try
{
// 删除当前行记录
m_pRecordset->Delete(adAffectCurrent);
m_pRecordset->Update();
// 删除列表中当前值
int nCurSel = m_AccessList.GetCurSel();
m_AccessList.DeleteString(nCurSel);
if(nCurSel == 0 && (m_AccessList.GetCount() != 0))
m_AccessList.SetCurSel(nCurSel);
else if(m_AccessList.GetCount() != 0)
m_AccessList.SetCurSel(nCurSel-1);
// 移动记录指针到新的位置
OnSelchangeList();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
}
//DEL void CBrow::OnButtonLog()
//DEL {
//DEL /*int nItem;
//DEL _variant_t vEventCode,vEventName,vEventProtocol,vEventDefinition,vEventDescription,vAlertType,vEventLevel;
//DEL try
//DEL { m_pRecordset.CreateInstance("ADODB.Recordset");
//DEL m_pRecordset->Open("SELECT * FROM ids",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
//DEL m_bSuccess = TRUE;
//DEL while(!m_pRecordset->rsEOF)
//DEL {
//DEL vEventCode = m_pRecordset->GetCollect("EventCode");
//DEL vEventName = m_pRecordset->GetCollect("EventName");
//DEL vEventProtocol = m_pRecordset->GetCollect("EventProtocol");
//DEL vEventDefinition = m_pRecordset->GetCollect("EventDefinition");
//DEL vEventDescription = m_pRecordset->GetCollect("EventDescription");
//DEL vAlertType = m_pRecordset->GetCollect("AlertType");
//DEL vEventLevel = m_pRecordset->GetCollect("EventLevel");
//DEL nItem=m_ListCtrl.InsertItem(0xffff,(_bstr_t)vEventCode);
//DEL m_ListCtrl.SetItem(nItem,0,1,(_bstr_t)vEventCode,NULL,0,0,0);
//DEL m_ListCtrl.SetItem(nItem,1,1,(_bstr_t)vEventName,NULL,0,0,0);
//DEL m_ListCtrl.SetItem(nItem,2,1,(_bstr_t)vEventProtocol,NULL,0,0,0);
//DEL m_ListCtrl.SetItem(nItem,3,1,(_bstr_t)vEventDefinition,NULL,0,0,0);
//DEL m_ListCtrl.SetItem(nItem,4,1,(_bstr_t)vEventDescription,NULL,0,0,0);
//DEL m_ListCtrl.SetItem(nItem,5,1,(_bstr_t)vAlertType,NULL,0,0,0);
//DEL m_ListCtrl.SetItem(nItem,6,1,(_bstr_t)vEventLevel,NULL,0,0,0);
//DEL
//DEL m_pRecordset->MoveNext();
//DEL }
//DEL }
//DEL catch(_com_error e)///捕捉异常
//DEL {
//DEL AfxMessageBox("读取数据库失败!");///显示错误信息
//DEL }
//DEL
//DEL // TODO: Add your control notification handler code here
//DEL */
//DEL }
void CBrow::OnButtonModify()
{
// TODO: Add your control notification handler code here
UpdateData(); // 更新对话框数据
if(m_AccessList.GetCount() == 0 || m_code == "" || m_name == ""||m_protocol==""||m_definition==""||m_description==""||m_alert==""||m_level=="")
{
AfxMessageBox("没有选择策略!");
return;
}
else if(m_AccessList.GetCurSel() < 0 || m_AccessList.GetCurSel() > m_AccessList.GetCount())
m_AccessList.SetCurSel(0);
// 修改当前记录的字段值
try
{
m_pRecordset->PutCollect("EventCode", _variant_t(m_code));
m_pRecordset->PutCollect("EventName", _variant_t(m_name));
m_pRecordset->PutCollect("EventProtocol", _variant_t(m_protocol));
m_pRecordset->PutCollect("EventDefinition", _variant_t(m_definition));
m_pRecordset->PutCollect("EventDescription", _variant_t(m_description));
m_pRecordset->PutCollect("AlertType", _variant_t(m_alert));
m_pRecordset->PutCollect("EventLevel", _variant_t(m_level));
m_pRecordset->Update();
// 重新读入库记录更新显示
int nCurSel = m_AccessList.GetCurSel();
OnButtonRead();
m_AccessList.SetCurSel(nCurSel);
// 移动记录指针到新的位置
OnSelchangeList();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
}
BOOL CBrow::OnInitDialog()
{
CDialog::OnInitDialog();
/*m_btndel.EnableWindow(FALSE);
::SendMessage(m_ListCtrl.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
// TODO: Add extra initialization here
m_ListCtrl.InsertColumn(0,"事件代码",LVCFMT_LEFT,80);
m_ListCtrl.InsertColumn(1,"事件名称",LVCFMT_LEFT,80);
m_ListCtrl.InsertColumn(2,"事件协议",LVCFMT_LEFT,80);
m_ListCtrl.InsertColumn(3,"事件定义",LVCFMT_LEFT,80);
m_ListCtrl.InsertColumn(4,"事件说明",LVCFMT_LEFT,80);
m_ListCtrl.InsertColumn(5,"响应方式",LVCFMT_LEFT,80);
m_ListCtrl.InsertColumn(6,"入侵级别",LVCFMT_LEFT,80);
int nItem;
_variant_t vEventCode,vEventName,vEventProtocol,vEventDefinition,vEventDescription,vAlertType,vEventLevel;
try
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -