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

📄 userinfo.aspx.cs

📁 在线考试系统...asp.net
💻 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;

namespace TestOnline
{
	/// <summary>
	/// userInfo 的摘要说明。
	/// </summary>
	public class userInfo : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lbl_stuId;
		protected System.Web.UI.WebControls.Label lbl_stuName;
		protected System.Web.UI.WebControls.DropDownList ddl_course;
		protected System.Web.UI.WebControls.ImageButton ImageButton1;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		protected System.Web.UI.WebControls.ImageButton ImageButton3;
		protected System.Web.UI.WebControls.Label lbl_noResult;
		protected System.Web.UI.WebControls.TextBox tbx_oldPwd;
		protected System.Web.UI.WebControls.TextBox tbx_newPwd1;
		protected System.Web.UI.WebControls.TextBox tbx_newPwd2;
		protected System.Web.UI.WebControls.ImageButton Ibtn_ok;
		protected System.Web.UI.WebControls.Label lbl_name;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(Session["stuId"]==null)
				Response.Redirect("login.aspx");
			else
			{
				if(!Page.IsPostBack)
				{BindGrid();
					
					string stuId=Convert.ToString(Session["stuId"]);
					lbl_stuId.Text=stuId;
					string stuName=(new projClass()).getUserName(stuId);
					lbl_stuName.Text=stuName;
					DataSet ds=new DataSet();
					ds=(new projClass()).getCourses();
					foreach(DataRow row in ds.Tables[0].Rows)
					{
						ddl_course.Items.Add(row["courseName"].ToString());
					}
				
				}	
			}	
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.ImageButton3.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton3_Click);
			this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
			this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
			this.Ibtn_ok.Click += new System.Web.UI.ImageClickEventHandler(this.Ibtn_ok_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
		void BindGrid() 
		{   string stuId=Convert.ToString(Session["stuId"]);
			DataSet ds=new DataSet();
			ds=(new projClass()).getStuScore(stuId);
			DataTable dt=ds.Tables["stuInfo"];
			DataView dv=new DataView(dt);
			DataGrid1.DataSource=dv;
			int count=dv.Count;
			if(count==0)
			{
				lbl_noResult.Visible=true;
				DataGrid1.Visible=false;
			}
			DataGrid1.DataBind();
		}

	

		

		private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			string stuId=Convert.ToString(Session["stuId"]);
			string courseName=ddl_course.SelectedItem.Text.Trim();
			string courseId=(new projClass()).getCourseIdAsCourseName(courseName);
             bool ifTest=(new projClass()).getIfTest(courseId);
			if(ifTest)
			{
				int count=(new projClass()).ifCourseHasTest(stuId,courseId);
				if(count==0)
				{
					Session["courseId"]=courseId;
					Response.Redirect("createTest.aspx?"+courseId+"&"+stuId);
				}
				else
					Response.Write("<script>alert(\"该科目您已经考试过了,不能再次考试!\");</script>");
			}else Response.Write("<script>alert(\"该科目目前不能考试!请联系管理员开通考试!\");</script>");
		}

		private void ImageButton3_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Session["stuId"]=null;
			//	Session.RemoveAll();
			Response.Redirect("login.aspx");
		}

		private void Ibtn_ok_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			string stuId=Convert.ToString(Session["stuId"]);
			string stuPwd=tbx_oldPwd.Text;
			string newPwd1=tbx_newPwd1.Text;
			string newPwd2=tbx_newPwd2.Text;
			if(newPwd1==""||newPwd2=="")
				Response.Write("<script>alert(\"密码不能为空\");</script>");
			else
			{
				int count=(new projClass()).getUser(stuId,stuPwd);
			if(count==0)
			{
				Response.Write("<script>alert(\"密码错误!请重新输入\");</script>");
			}
			else
			{
				if(!newPwd1.Equals(newPwd2))
					Response.Write("<script>alert(\"两次密码不一致!请重新输入!\");</script>");
				else
				{
					int count1=(new projClass()).updateStuPwd(stuId,newPwd1);
					if(count1==1)
						Response.Write("<script>alert(\"密码修改成功!\");</script>");
					else  Response.Write("<script>alert(\"更新失败!\");</script>");
				}
			}
		}
			
			
		}

		private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		
	}
}

⌨️ 快捷键说明

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