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

📄 form_fsksxh.cs

📁 一个很简单的考试系统。实用性很强啊!数据库在里面
💻 CS
📖 第 1 页 / 共 2 页
字号:
																						  this.statusBarPanel3});
			this.statusBar1.ShowPanels = true;
			this.statusBar1.Size = new System.Drawing.Size(592, 24);
			this.statusBar1.TabIndex = 14;
			this.statusBar1.Text = "statusBar1";
			// 
			// statusBarPanel1
			// 
			this.statusBarPanel1.Text = "name:";
			this.statusBarPanel1.Width = 200;
			// 
			// statusBarPanel2
			// 
			this.statusBarPanel2.Text = "time:";
			this.statusBarPanel2.Width = 200;
			// 
			// statusBarPanel3
			// 
			this.statusBarPanel3.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.statusBarPanel3.Text = "time:";
			this.statusBarPanel3.ToolTipText = "current time";
			this.statusBarPanel3.Width = 176;
			// 
			// timer1
			// 
			this.timer1.Enabled = true;
			this.timer1.Interval = 1000;
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(424, 368);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(72, 32);
			this.button2.TabIndex = 13;
			this.button2.Text = "退 出";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// textBox3
			// 
			this.textBox3.Location = new System.Drawing.Point(272, 152);
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(312, 21);
			this.textBox3.TabIndex = 10;
			this.textBox3.Text = "";
			// 
			// Form2
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(592, 485);
			this.Controls.Add(this.textBox3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.statusBar1);
			this.Controls.Add(this.listView1);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.checkBox3);
			this.Controls.Add(this.checkBox2);
			this.Controls.Add(this.checkBox1);
			this.Controls.Add(this.radioButton3);
			this.Controls.Add(this.radioButton2);
			this.Controls.Add(this.radioButton1);
			this.Controls.Add(this.label1);
			this.Name = "Form2";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "考试管理";
			this.Load += new System.EventHandler(this.Form2_Load);
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void Form2_Load(object sender, System.EventArgs e)
		{	
			
			int i,j,k=1;
			j=f1.listBox2.Items.Count;
			for(i=0;i<j;i++)
			{
				listView1.Items.Add(f1.listBox2.Items[i].ToString());
				listView1.Items[i].SubItems.Add(k.ToString());
				k++;
			}
			Form1.ActiveForm.Hide();

			
		}

		private void timer1_Tick(object sender, System.EventArgs e)
		{
			statusBar1.Panels[2].Text = "time: "+DateTime.Now.TimeOfDay.ToString().Substring(0,8);
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		private void listView1_DoubleClick(object sender, System.EventArgs e)
		{
			string index = listView1.Items[0].Index.ToString();
			textBox1.Text=listView1.Items[int.Parse(index)].Text.ToString(); 
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			
			if(radioButton1.Checked == true)//判断是否发送开考信号
			{
				try
				{
					int port = Int32.Parse("8000");
					int i,j;
					j=listView1.Items.Count;
					
					for(i=0;i<j;i++)
					{
						client = new TcpClient();
						client.Connect(listView1.Items[i].Text.ToString(), port);
					}
					MessageBox.Show("连接成功,开始考试...","阜和考试系统提示");
				}
				catch
				{
					MessageBox.Show("无法连接,请重新连接...","阜和考试系统提示");
				}
			}

			if(radioButton3.Checked == true)//判断是否发送信息
			{
				if(checkBox3.Checked == false)
				{
					netStream = client.GetStream();
					string send = System.DateTime.Now + " 系统发送到 " + 
						textBox1.Text + ":" +textBox3.Text + "\r\n";
					textBox2.AppendText(send);
					byte[] messageByte = System.Text.Encoding.BigEndianUnicode
						.GetBytes(send.ToCharArray());
					netStream.Write(messageByte,0,messageByte.Length);
					netStream.Flush();
				}
				else
				{
					int i,j;
					j=listView1.Items.Count;
					for(i=0;i<j;i++)
					{
						textBox1.Text = listView1.Items[i].Text.ToString();
						netStream = client.GetStream();
						string send = System.DateTime.Now + " 系统发送到 " + 
							textBox1.Text + ":" +textBox3.Text + "\r\n";
						textBox2.AppendText(send);
						byte[] messageByte = System.Text.Encoding.BigEndianUnicode
							.GetBytes(send.ToCharArray());
						netStream.Write(messageByte,0,messageByte.Length);
						netStream.Flush();
					}
				}

				if(checkBox2.Checked = true)//判断是否重启
				{
					if(checkBox3.Checked = true)//判断是否重启一台
					{
						//定义连接远程计算机的一些选项
						ConnectionOptions options = new ConnectionOptions ( );
						options.Username = "administrator" ;
						options.Password = "" ;
						ManagementScope scope = new ManagementScope( "\\\\" + textBox1.Text + "\\root\\cimv2", options ) ;
						try 
						{
							//用给定管理者用户名和口令连接远程的计算机
							scope.Connect ( ) ;
							System.Management.ObjectQuery oq = new System.Management.ObjectQuery ( "SELECT * FROM Win32_OperatingSystem" ) ;
							ManagementObjectSearcher query1 = new ManagementObjectSearcher ( scope , oq ) ;
							//得到WMI控制
							ManagementObjectCollection queryCollection1 = query1.Get ( ) ;
							foreach ( ManagementObject mo in queryCollection1 ) 
							{
								string [ ] ss= { "" } ;
								//重启远程计算机
								mo.InvokeMethod ( "Reboot" , ss ) ;
								//mo.InvokeMethod ( "Shutdown" , ss );
								//mo.InvokeMethod ( "Create" , ss );
							}
						}
							//报错
						catch ( Exception ee ) 
						{
							MessageBox.Show ( "连接" + textBox1.Text + "出错,出错信息为:" + ee.Message ) ;
						}
					}

					if(checkBox2.Checked = false)
					{
						int i,j;
						j=listView1.Items.Count;
						for(i=0;i<j;i++)
						{
							//定义连接远程计算机的一些选项
							ConnectionOptions options = new ConnectionOptions ( );
							options.Username = "administrator" ;
							options.Password = "" ;
							textBox1.Text = listView1.Items[i].Text.ToString();
							ManagementScope scope = new ManagementScope( "\\\\" + textBox1.Text + "\\root\\cimv2", options ) ;
							try 
							{
								//用给定管理者用户名和口令连接远程的计算机
								scope.Connect ( ) ;
								System.Management.ObjectQuery oq = new System.Management.ObjectQuery ( "SELECT * FROM Win32_OperatingSystem" ) ;
								ManagementObjectSearcher query1 = new ManagementObjectSearcher ( scope , oq ) ;
								//得到WMI控制
								ManagementObjectCollection queryCollection1 = query1.Get ( ) ;
								foreach ( ManagementObject mo in queryCollection1 ) 
								{
									string [ ] ss= { "" } ;
									//重启远程计算机
									mo.InvokeMethod ( "Reboot" , ss ) ;
									//mo.InvokeMethod ( "Shutdown" , ss );
									//mo.InvokeMethod ( "Create" , ss );
								}
							}
								//报错
							catch ( Exception ee )
							{
								MessageBox.Show ( "连接" + textBox1.Text + "出错,出错信息为:" + ee.Message ) ;
							}
						}
					}	
				}
			}

		}
	}
}

⌨️ 快捷键说明

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