{
MessageBox.Show(this, ex.Message);
}
mySniffSocket.PacketArrival +=
new SniffSocket.PacketArrivedEventHandler(DataArrival);//绑定事件处理方法
LoadSettings();
if (IsAdmin == false)
{
btnStart.Visible = false;
btnClear.Visible = false;
btnClose.Visible = false;
cmbIpList.Enabled = false;
}
StartScocket();
}
private void LoadSettings()
{
SqlDataReader dr;
dr = MyData.MySQL.GetData("select * from [Settings]");
if (dr.HasRows)
{
if (dr.Read())
{
warnCheckInterval = Convert.ToUInt32(dr["warnCheckInterval"]);
warnByteSize = Convert.ToUInt32(dr["warnByteSize"]);
saveDataInterval = Convert.ToUInt32(dr["saveDataInterval"]);
paidMoney = Convert.ToDouble(dr["paidMoney"]);
}
}
else
{
string sql = "INSERT INTO [Settings]([WarnCheckInterval],[WarnByteSize],[SaveDataInterval],[PaidMoney])Values('"
+ warnCheckInterval + "','" + warnByteSize + "','" + saveDataInterval + "','" + paidMoney + "')";
MyData.MySQL.updata(sql);
}
MyData.MySQL.CloseSQL();
}
private void btnStart_Click(object sender, EventArgs e)
{
StartScocket();
}
private void StartScocket()
{
if (mySniffSocket.KeepRunning == false)
{
mySniffSocket.KeepRunning = true;
try
{
mySniffSocket.Run();//开始监听
}
catch (SocketException)//如果监听出现异常,将重新创建和绑定连接
{
mySniffSocket.CreateAndBindSocket(cmbIpList.Text);
mySniffSocket.Run();
}
btnStart.Text = "暂停";
}
else
{
mySniffSocket.KeepRunning = false;
btnStart.Text = "恢复";
}
}
private void btnClose_Click(object sender, EventArgs e)
{
mySniffSocket.KeepRunning = false;
btnStart.Text = "开始";
Thread.Sleep(10);//需要引用System.Threading
mySniffSocket.ShutDown(); //禁止Socket上的发送和接收
}
private void btnClear_Click(object sender, EventArgs e)
{
lvSniffInfo.Items.Clear();
txtPacketInfo.Text = "";
}
private void lvSniffInfo_SelectedIndexChanged(object sender, EventArgs e)
{
if (lvSniffInfo.SelectedItems.Count != 0)
{
foreach (ListViewItem item in lvSniffInfo.SelectedItems) {                    
txtPacketInfo.Text = item.SubItems[6].Text;
}
}
}
private void menuItemSettings_Click(object sender, EventArgs e)
{
if (IsAdmin == false)
{
MessageBox.Show("您不是管理员,不能进入系统设置!", "提  示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
SettingForm F1 = new SettingForm(this);
F1.Show();
}
}
private void menuItemExit_Click(object sender, EventArgs e)
{
mySniffSocket.KeepRunning = false;
Thread.Sleep(5);//需要引用System.Threading
mySniffSocket.ShutDown(); //禁止Socket上的发送和接收
Application.Exit();
}
private void menuItemAbout_Click(object sender, EventArgs e)
{
About_Sniffer F1 = new About_Sniffer();
F1.Show();
}
private void menuItem3_Click(object sender, EventArgs e)
{
FlowManage F1 = new FlowManage(this);
F1.Show();
}
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (isbegin == true)
{
SaveData(false);
}
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
上一篇:C#汽车销售系统财务管理和销售管理设计
下一篇:基于AS3的休闲英雄联盟游戏设计+文献综述

考证平台静态网页设计与制作

java+mysql通用试题库系统后台设计与实现

数据挖掘的主题标绘数据获取技术与实现

基于PageRank算法的网络数据分析

基于神经网络的验证码识别算法

基于网络的通用试题库系...

论高职计算机應用专业課...

公寓空调设计任务书

C#学校科研管理系统的设计

AT89C52单片机的超声波测距...

志愿者活动的调查问卷表

中国学术生态细节考察《...

10万元能开儿童乐园吗,我...

承德市事业单位档案管理...

神经外科重症监护病房患...

医院财务风险因素分析及管理措施【2367字】

国内外图像分割技术研究现状