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

📄 class_jchshch1.aspx.cs

📁 利用远程控制进行上课
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace free
{
	/// <summary>
	/// Summary description for class_jchshch1.
	/// </summary>
	public class class_jchshch1 : System.Web.UI.Page
	{
		protected System.Web.UI.HtmlControls.HtmlInputButton Button2;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button Button4;
		protected System.Web.UI.WebControls.Button Button5;
		protected System.Web.UI.WebControls.Button Button3;
		protected System.Data.SqlClient.SqlConnection myconn;
		protected System.Web.UI.WebControls.Label tishi;
		protected System.Web.UI.WebControls.DropDownList mingcheng;
		protected System.Web.UI.HtmlControls.HtmlInputText xuhao;
		protected System.Web.UI.HtmlControls.HtmlTextArea neirong;
		protected System.Data.SqlClient.SqlCommand mycomm;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			
			try
			{
				if(Session["free_quanxian"].ToString()!="0")
				{
					Response.Write("<script>alert('您无权使用!!')</script>");
					Response.Redirect("../admin/default.aspx");
				}
			}
			catch
			{
				Response.Write("<script>alert('您无权使用!!')</script>");
				Response.Redirect("../admin/default.aspx");
				
			}
			myconn=new SqlConnection(Session["str_connection"].ToString());
			string sqlstr="select shuming from class_jiaocheng ";
			SqlDataAdapter mydata1;
			myconn.Open();
			mydata1=new SqlDataAdapter(sqlstr,myconn);
			DataTable mytable;
			mytable=new DataTable();
			mydata1.Fill(mytable);
			mytable.TableName="shuming";
			if(mytable.Rows.Count>0)
			{
				for(int i=0;i<=mytable.Rows.Count-1;i++)
				{					
					mingcheng.Items.Add(mytable.Rows[i]["shuming"].ToString());
				}
				myconn.Close();
			}
			else
			{
				tishi.Text="";
				myconn.Close();
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Button4.Click += new System.EventHandler(this.Button4_Click);
			this.Button3.Click += new System.EventHandler(this.Button3_Click);
			this.Button2.ServerClick += new System.EventHandler(this.Button2_ServerClick);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button3_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("class_guanli.aspx");
		}

		
		private void Button1_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("class_jchshch.aspx");
		}

		private void Button4_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("class_jchshch2.aspx");
		}

		private void Button2_ServerClick(object sender, System.EventArgs e)
		{
			string sqlcmd="select id from class_jiaocheng where shuming='"+mingcheng.SelectedValue.Trim()+"'";
			myconn.Open();
			mycomm=new  SqlCommand(sqlcmd,myconn);
			int jiaochenghao=0;
			bool biaozhi=false;
			if(mycomm.ExecuteScalar()!=null)
			{
				jiaochenghao=Convert.ToInt32(mycomm.ExecuteScalar().ToString());
				myconn.Close();
				biaozhi=true;

			}
			else 
			{
				tishi.Text="";
				myconn.Close();
			}
			if(biaozhi)
			{
				sqlcmd="Insert into class_wenti(jiaocheng_id,id,neirong) values("+jiaochenghao+","+Convert.ToInt32(xuhao.Value.Trim())+",'"+neirong.Value.Trim()+"')";
				myconn.Open();
				mycomm=new SqlCommand(sqlcmd,myconn);
				if(mycomm.ExecuteNonQuery()>0)	
				{
					//tishi.Text="问题录入成功!";
					Response.Write("<script>alert('问题录入成功!')</script>");
					myconn.Close();
					
				}
				else
				{
					//tishi.Text="操作有误";
					Response.Write("<script>alert('操作有误')</script>");
					myconn.Close();
					
				}
				biaozhi=false;
			}

		
		}

		
	}
}

⌨️ 快捷键说明

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