毕业论文

打赏
当前位置: 毕业论文 > 计算机论文 >

C#网络计费与监控系统的设计与实现+流程图(14)

时间:2017-01-16 20:05来源:毕业论文
{ MessageBox.Show(this, ex.Message); } mySniffSocket.PacketArrival += new SniffSocket.PacketArrivedEventHandler(DataArrival);//绑定事件处理方法 LoadSettings(); if (IsAdmin == false) { btnStart


{
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#网络计费与监控系统的设计与实现+流程图(14):http://www.youerw.com/jisuanji/lunwen_2332.html
------分隔线----------------------------
推荐内容