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

📄 managestudent.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;

namespace StudentScroeQuery.Admin
{
	/// <summary>
	/// managestudent 的摘要说明。
	/// </summary>
	public class managestudent : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(!this.IsPostBack)
			{
				bindgrid();
			}
		}
		void bindgrid()
		{
			this.DataGrid1.DataSource=new BLL.Student_bll().get_allStudent();
			this.DataGrid1.DataBind();
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
			this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
			this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
			this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
			this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
		{
			this.DataGrid1.CurrentPageIndex=e.NewPageIndex;
			bindgrid();
		}

		private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			this.DataGrid1.EditItemIndex=-1;
			bindgrid();
		}

		private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			
			int id=Convert.ToInt32(this.DataGrid1.DataKeys[e.Item.ItemIndex]);
			try
			{
				new BLL.Student_bll().delstudent(id);
				bindgrid();
				Response.Write("<script>alert('删除成功')</script>");
			}
			catch
			{
				Response.Write("<script>alert('删除成功')</script>");
			}
		}

		private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
				int id=Convert.ToInt32(this.DataGrid1.DataKeys[e.Item.ItemIndex]);
				string name=((TextBox)e.Item.Cells[1].Controls[0]).Text;
				string sex=((TextBox)e.Item.Cells[2].Controls[0]).Text;
				string nation=((TextBox)e.Item.Cells[3].Controls[0]).Text;
				string home=((TextBox)e.Item.Cells[4].Controls[0]).Text;
				string email=((TextBox)e.Item.Cells[5].Controls[0]).Text;
//			try
//			{
				new BLL.Student_bll().update_student(id,name,sex,nation,home,email);
				this.DataGrid1.EditItemIndex=-1;
				Response.Write("<script>alert('修改成功!')</script>");
				bindgrid();
//			}
//			catch
//			{
//				Response.Write("<script>alert('修改失败!')</script>");
//			}
		}

		private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			this.DataGrid1.EditItemIndex=e.Item.ItemIndex;
			
			bindgrid();
		}
	}
}

⌨️ 快捷键说明

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