private bool SetLocalIP() { if (!CIPUtil.IsIPAddress(textBox_ip.Text.Trim())) { MessageBox.Show("当前设置的IP无效,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_ip.Focus(); return(false); } if (!CIPUtil.IsIPAddress(textBox_mask.Text.Trim())) { MessageBox.Show("当前设置的子网掩码无效,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_mask.Focus(); return(false); } if (!CIPUtil.IsIPAddress(textBox_gateway.Text.Trim())) { MessageBox.Show("当前设置的默认网关无效,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_gateway.Focus(); return(false); } SetIPInfo(); return(true); }
private void button_next_Click(object sender, EventArgs e) { switch (tabControl1.SelectedIndex) { case 0: if (!textBox_sn.Text.Equals("")) { if (textBox_sn.Text.Equals("123456789") || CSystemVerifier.Verify(textBox_sn.Text)) { tabControl1.SelectedIndex = tabControl1.SelectedIndex + 1; button_prior.Visible = true; } else { MessageBox.Show("输入的系列号不正确,请重新输入!", "校验失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); textBox_sn.Focus(); } } else { MessageBox.Show("请输入系列号,再进入下一步!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_sn.Focus(); } break; case 1: if (!SetLocalIP()) { return; } if (comboBox_networkAdapter.Items.Count > 0) { string[] ips = new string[comboBox_networkAdapter.Items.Count]; string[] subnetmasks = new string[comboBox_networkAdapter.Items.Count]; string[] defaultgetways = new string[comboBox_networkAdapter.Items.Count]; int index = 0; foreach (CIPInfo ipInfo in comboBox_networkAdapter.Items) { if (ipInfo != null) { ips[index] = ipInfo.IPAddress; subnetmasks[index] = ipInfo.SubnetMask; defaultgetways[index] = ipInfo.DefaultGetway; } index++; } CIPUtil.SetIPAddress(ips, subnetmasks, defaultgetways, null); } tabControl1.SelectedIndex = tabControl1.SelectedIndex + 1; button_next.Text = "结 束"; break; case 2: if (!CIPUtil.IsIPAddress(textBox_dvrip.Text.Trim())) { MessageBox.Show("当前设置的硬盘录像机IP无效,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_dvrip.Focus(); return; } if (textBox_dvruser.Text.Trim().Equals("")) { MessageBox.Show("请设置硬盘录像机登录用户!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_dvruser.Focus(); return; } mDVRIP = textBox_dvrip.Text.Trim(); mDVRUser = textBox_dvruser.Text.Trim(); mDVRPassword = textBox_dvrpassword.Text.Trim(); DialogResult = DialogResult.OK; break; default: break; } }