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

📄 tcmg.aspx.cs

📁 选课系统
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace class_kinghome
{
	/// <summary>
	/// tcmg 的摘要说明。
	/// </summary>
	public class tcmg : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.HyperLink addc;
		protected System.Web.UI.WebControls.HyperLink seec;
		protected System.Web.UI.WebControls.TextBox tno;
		protected System.Web.UI.WebControls.TextBox tpas;
		protected System.Web.UI.WebControls.Label msg;
		protected System.Web.UI.WebControls.DataGrid cj;
	    public string getpas;
		private void Page_Load(object sender, System.EventArgs e)
		{
			 
		}
		public void binddata()
		{SqlConnection Con = new SqlConnection("Data Source=HSJ;Initial Catalog=class;User ID=sa;Pwd=hsj;");  
				DataSet ds;
			SqlDataAdapter Cmd;
				string sel="select * from sco where  cno in (select cno from csee where tno='"+tno.Text +"')";
			Cmd=new SqlDataAdapter(sel,Con);
			ds=new DataSet();
			Cmd.Fill(ds,"csee");
			cj.DataSource=ds.Tables["csee"].DefaultView;
			cj.DataBind();
		}
		protected void cj_Edit(Object sender, DataGridCommandEventArgs E) 
		{ 
			
			cj.EditItemIndex = (int)E.Item.ItemIndex; 
			binddata(); 
		}
		protected void cj_Cancel(Object sender, DataGridCommandEventArgs E) 
		{ 
			cj.EditItemIndex = -1; 
			binddata(); 
		}
		protected void cj_Update(Object sender, DataGridCommandEventArgs E)
		{
			int getid =(int)cj.DataKeys[(int)E.Item.ItemIndex]; 
			string getcj = ((TextBox)E.Item.Cells[2].Controls[0]).Text; 
		    decimal iscj=decimal.Parse(getcj);
			
			string SQL="update sco set score='"+iscj+"' WHERE id="+getid;
		SqlConnection Con = new SqlConnection("Data Source=HSJ;Initial Catalog=class;User ID=sa;Pwd=hsj;");  
			SqlCommand delCommand =new SqlCommand(SQL,Con);
			delCommand.Connection.Open();
			delCommand.ExecuteNonQuery();
			delCommand.Connection.Close();
			cj.EditItemIndex = -1;
			binddata();
			
		} 

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
         
		private void Button1_Click(object sender, System.EventArgs e)
		{
			
				if (tno.Text==""||tpas.Text=="")
		 {
			msg.Text="请输入完整资料!";
			 return;
		 }
			SqlConnection Con = new SqlConnection("Data Source=HSJ;Initial Catalog=class;User ID=sa;Pwd=hsj;");  
			string  sel="select * from tea where tno=" + tno.Text ; 
			SqlCommand addCommand =new SqlCommand(sel,Con);
			addCommand.Connection.Open();
			SqlDataReader selreader ;
			selreader=addCommand.ExecuteReader();
			if (selreader.Read() == false) 
			{
				msg.Text="该教师不存在!";
				return;
			}
			else 
			{
					getpas=selreader.GetString(4);
				addCommand.Connection.Close();
				if (getpas.CompareTo(tpas.Text.PadRight(30))==0)
				{
					Session["tea"]="hasin";
					msg.Text="登陆成功!";		
					seec.Visible=true;
					addc.Visible=true;
Button1.Visible=false;					seec.NavigateUrl="seec.aspx?tno="+tno.Text ;
					addc.NavigateUrl="addc.aspx?tno="+tno.Text;
					binddata();
				}
				else
					msg.Text="密码错误。";
			}
		
		}
	}
}

⌨️ 快捷键说明

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