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

📄 form_zcksj.cs

📁 一个很简单的考试系统。实用性很强啊!数据库在里面
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.numericUpDown3.TabIndex = 19;
			// 
			// numericUpDown4
			// 
			this.numericUpDown4.Location = new System.Drawing.Point(392, 16);
			this.numericUpDown4.Maximum = new System.Decimal(new int[] {
																		   255,
																		   0,
																		   0,
																		   0});
			this.numericUpDown4.Name = "numericUpDown4";
			this.numericUpDown4.Size = new System.Drawing.Size(48, 21);
			this.numericUpDown4.TabIndex = 19;
			// 
			// numericUpDown5
			// 
			this.numericUpDown5.Location = new System.Drawing.Point(200, 56);
			this.numericUpDown5.Maximum = new System.Decimal(new int[] {
																		   255,
																		   0,
																		   0,
																		   0});
			this.numericUpDown5.Name = "numericUpDown5";
			this.numericUpDown5.Size = new System.Drawing.Size(48, 21);
			this.numericUpDown5.TabIndex = 19;
			// 
			// button7
			// 
			this.button7.Enabled = false;
			this.button7.Location = new System.Drawing.Point(368, 72);
			this.button7.Name = "button7";
			this.button7.Size = new System.Drawing.Size(75, 32);
			this.button7.TabIndex = 10;
			this.button7.Text = "停 止";
			this.button7.Click += new System.EventHandler(this.button7_Click);
			// 
			// listBox2
			// 
			this.listBox2.ItemHeight = 12;
			this.listBox2.Location = new System.Drawing.Point(304, 136);
			this.listBox2.Name = "listBox2";
			this.listBox2.Size = new System.Drawing.Size(184, 304);
			this.listBox2.TabIndex = 20;
			this.listBox2.DoubleClick += new System.EventHandler(this.listBox2_DoubleClick);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(504, 453);
			this.Controls.Add(this.listBox2);
			this.Controls.Add(this.numericUpDown2);
			this.Controls.Add(this.numericUpDown1);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.textBox5);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.button6);
			this.Controls.Add(this.button5);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.listBox1);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.numericUpDown3);
			this.Controls.Add(this.numericUpDown4);
			this.Controls.Add(this.numericUpDown5);
			this.Controls.Add(this.button7);
			this.Name = "Form1";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "注册考试机";
			((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		private void button1_Click(object sender, System.EventArgs e)
		{
			button7.Enabled = true;
			button1.Enabled = false;
			listBox1.Items.Clear();
			
			//Thread 类: 创建并控制线程
			thScan = new Thread(new ThreadStart(ScanTarget));
			//Thread.Start 方法:启动线程
			thScan.Start();	
		}
		private void ScanTarget()
		{
			//构造IP地址的31-8BIT 位,也就是固定的IP地址的前段
			// numericUpDown1是定义的System.Windows.Forms.NumericUpDown控件
			string strIPAddress=numericUpDown1.Value.ToString()+"."+numericUpDown2.Value.ToString()+"."+numericUpDown3.Value.ToString()+".";
			//开始扫描地址
			int nStrat = Int32.Parse(numericUpDown4.Value.ToString());
			//终止扫描地址
			int aa = int.Parse(numericUpDown4.Value.ToString())+int.Parse(numericUpDown5.Value.ToString());
			int nEnd =Int32.Parse(aa.ToString());
			//扫描的操作
			for(int i=nStrat;i<=nEnd;i++)
			{
				string strScanIPAdd = strIPAddress +i.ToString();
				//转换成IP地址
				IPAddress myScanIP = IPAddress.Parse(strScanIPAdd);
				try
				{
					//你可以加入自已的,增强功能
					// Dns.GetHostByAddress 方法: 根据 IP 地址获取 DNS 主机信息。
					IPHostEntry myScanHost = Dns.GetHostByAddress(myScanIP);//获取主机的名
					string strHostName =myScanHost.HostName.ToString();//将主机名转换成字符串
					listBox1.Items.Add(strScanIPAdd+"\r");//在listbox里显示
				}
				catch
				{
					
				}
			}      
			MessageBox.Show("扫描完毕,请选择考试机,准备开始考试。","阜和考试系统提示");
			button1.Enabled = true;
			button7.Enabled = false;
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			try
			{
				int index = listBox1.SelectedIndex;
				this.listBox2.Items.Add(this.listBox1.Items[index].ToString());
				this.listBox1.Items.Remove(listBox1.Items[index]);
			}
			catch
			{
				MessageBox.Show("请选择所用于考试的机器IP地址!","阜和考试系统提示");
			}
		}

		private void button5_Click(object sender, System.EventArgs e)
		{
			try
			{
				int index = listBox2.SelectedIndex;
				listBox1.Items.Add(this.listBox2.Items[index].ToString());
				this.listBox2.Items.Remove(listBox2.Items[index]);
			}
			catch
			{
				MessageBox.Show("请选择所要移除的机器IP地址!","阜和考试系统提示");
			}
		}

		private void listBox1_DoubleClick(object sender, System.EventArgs e)
		{
			try
			{
				int index = listBox1.SelectedIndex;
				listBox2.Items.Add(this.listBox1.Items[index].ToString());
				this.listBox1.Items.Remove(listBox1.Items[index]);
			}
			catch
			{
				MessageBox.Show("请选择所用于考试的机器IP地址!","阜和考试系统提示");
			}
		}

		private void listBox2_DoubleClick(object sender, System.EventArgs e)
		{
			try
			{
				int index = this.listBox2.SelectedIndex;
				listBox1.Items.Add(this.listBox2.Items[index].ToString());
				this.listBox2.Items.Remove(listBox2.Items[index]);
			}
			catch
			{
				MessageBox.Show("请选择所要移除的机器IP地址!","阜和考试系统提示");
			}
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			int i,j;
			j=listBox1.Items.Count;
				
			for(i=0;i<j;i++)
			{
				this.listBox2.Items.Add(this.listBox1.Items[i].ToString());
			}
			listBox1.Items.Clear();
		}

		private void button6_Click(object sender, System.EventArgs e)
		{
			int i,j;
			j=this.listBox2.Items.Count;
				
			for(i=0;i<j;i++)
			{
				listBox1.Items.Add(this.listBox2.Items[i].ToString());
			}
			this.listBox2.Items.Clear();
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			//			try
			//			{
			string SQL = "select * from machineinfo";
			SqlConnection Conn = new SqlConnection();
			Conn.ConnectionString = "Server = 192.168.0.1; Database = examdb; User ID = sa; Password = jiuhao.com;";
			SqlDataAdapter da = new SqlDataAdapter();
			da.SelectCommand = new SqlCommand(SQL,Conn);
			DataSet ds = new DataSet();
			da.Fill(ds,"machineinfo");
			DataTable dt = ds.Tables["machineinfo"];
			DataRow newRow = dt.NewRow();
			int i,j,k=1;
			string time;
			time = DateTime.Now.ToString();
			j=listBox2.Items.Count;
			for(i=0;i<j;i++)
			{
				//					try
				//					{
				mac_IP = listBox2.Items[i].ToString();
				mac_code=k.ToString();
				SqlCommand insertcommand = new SqlCommand("INSERT INTO machineinfo(mac_code,mac_IP,mac_regTime)VALUES("+mac_code.ToString()+",'"+mac_IP.ToString()+"','"+time.ToString()+"')",Conn);
				Conn.Open();
				insertcommand.ExecuteReader();
						
				Conn.Close();
				k++;
				//					}
				//					catch(System.Exception m)
				//					{
				//						MessageBox.Show(m.Message);
				//					}
			}
			MessageBox.Show("数据输入成功!","阜和考试系统提示");
			//			}
			//			catch(System.Exception aa)
			//			{
			//				MessageBox.Show(aa.Message);
			//			}
			try
			{
				//				int port = Int32.Parse(textBox5.Text);
				//				int i,j;
				//				j=listBox2.Items.Count;
				//				
				//				for(i=0;i<j;i++)
				//				{
				//					client = new TcpClient();
				//					client.Connect(listBox2.Items[i].ToString(), port);
				//				}
				//				MessageBox.Show("连接成功,开始考试...","阜和考试系统提示");
				Form_fsksxh f2 = new Form_fsksxh(this);
				f2.Show();
			}
			catch
			{
				MessageBox.Show("无法连接!");
			}
			
		}

		private void button7_Click(object sender, System.EventArgs e)
		{
			button1.Enabled = true;
			thScan.Abort();
		}

		
	}
}

⌨️ 快捷键说明

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