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

📄 class_jchshch2.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;
using System.IO;

namespace free
{
	/// <summary>
	/// Summary description for class_jchshch2.
	/// </summary>
	public class class_jchshch2 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button heihei;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Label tishi;
		protected System.Web.UI.WebControls.Button Button3;
		protected System.Web.UI.HtmlControls.HtmlInputButton Button4;
		protected System.Data.SqlClient.SqlConnection myconn;
		protected System.Web.UI.WebControls.DropDownList mingcheng;
		protected System.Web.UI.HtmlControls.HtmlInputFile tupian;
		protected System.Web.UI.WebControls.TextBox xuhao;
		protected System.Web.UI.WebControls.TextBox neirong;
		protected System.Data.SqlClient.SqlCommand mycomm;
		string filename,path;
	
		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.heihei.Click += new System.EventHandler(this.heihei_Click);
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			this.Button4.ServerClick += new System.EventHandler(this.Button4_ServerClick);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		

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

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

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

		private void Button4_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();
			}
//			sqlcmd="select max(xuhao_id) as id from class_zhijie where shuming_id="+jiaochenghao+" and wenti_id="+Convert.ToInt32(xuhao.Text.Trim())+"";
//			SqlDataAdapter mydata1;
//			myconn.Open();
//			mydata1=new SqlDataAdapter(sqlcmd,myconn);
//			DataTable mytable1;
//			mytable1=new DataTable();
//			mydata1.Fill(mytable1);
//			mytable1.TableName="zhijiehao";
//			string id;
//			int hao=0;
//			if(mytable1.Rows.Count>0)
//			{
//				id=mytable1.Rows[0]["id"].ToString();
//				myconn.Close();
//				
//			}
//			else
//			{
//				id="0";
//				myconn.Close();
//			}
//			hao=Convert.ToInt32(id);
//			hao=hao+1;
            
			
			bool flag=true;
			//string filename;
			
			if(tupian.Value=="")
			{ 
				flag=false;
			}
			if(flag==true)
			{
				filename=Path.GetFileName(tupian.PostedFile.FileName);
				path=Server.MapPath("网上课堂/"+mingcheng.SelectedValue.Trim()+"//");
				if( Directory.Exists(path)==false)
					Directory.CreateDirectory (path) ;
				path="网上课堂/"+mingcheng.SelectedValue.Trim()+"/"+filename;
			}
			else 
			{
				path="1";
			}
				
//				filename=Path.GetFileName(tupian.PostedFile.FileName);
//				//				string lujing="
//				path=Server.MapPath("网上课堂/"+mingcheng.SelectedValue.Trim()//");
//				if( Directory.Exists(path)==false)
//					Directory.CreateDirectory (path) ;
//				path+=filename;
//				
//			}
////            tishi.Text=tupian.Value;
			if(biaozhi)
			{
				sqlcmd="Insert into class_zhijie(shuming_id,wenti_id,neirong,tupian) values("+jiaochenghao+","+Convert.ToInt32(xuhao.Text.Trim())+",'"+neirong.Text.Trim()+"','"+path+"')";
				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 + -