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

📄 personinfomanage.aspx.cs

📁 网络学生家教招聘系统.使用ASP.NET环境+C#开发。功能完备。代码扩展方便。
💻 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 DataPage;

namespace PeopleInfo
{
	/// <summary>
	/// PersonInfoManage 的摘要说明。
	/// </summary>
	public class PersonInfoManage : DataPage.DataPage
	{
		protected SqlConnection sqlconn;
		protected SqlDataAdapter sqladapter;
		protected DataSet ds;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(Session["User"]==null)
			{
				Response.Redirect("Result.aspx?Succeed=false&Message=未登录&URL=Enter.aspx");
			}
			
			string CmdText;
			
			DataPage.DataPage.DataPageDeclare(this.Session,"PersonInfoManage.aspx");
			CmdText=this.BuildCmdText("SELECT NewID,Name,sex,Class,PhoneNumber FROM EnterPerson");			
			sqlconn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnString"]);
			sqladapter=new SqlDataAdapter(CmdText,sqlconn);
			ds=new DataSet();
			sqladapter.Fill(ds,"EnterPerson");
			DataGrid1.DataSource=ds.Tables["EnterPerson"].DefaultView;

			if(!IsPostBack)
			{
				DataGrid1.DataBind();
				PageIndex.Text=(DataGrid1.CurrentPageIndex+1).ToString();
				PageCount.Text=(DataGrid1.PageCount).ToString();
				ChangeState();
				int i;
				for(i=1;i<=DataGrid1.PageCount;i++)
				{
					ChangeIndex.Items.Add(i.ToString());
				}
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
			this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.Item_Bound);
			this.First.Click += new System.EventHandler(this.First_Click);
			this.Pre.Click += new System.EventHandler(this.Pre_Click);
			this.Next.Click += new System.EventHandler(this.Next_Click);
			this.Last.Click += new System.EventHandler(this.Last_Click);
			this.ChangeIndex.SelectedIndexChanged += new System.EventHandler(this.ChangeIndex_SelectedIndexChanged);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		

		private void Item_Bound(Object sender, DataGridItemEventArgs e)
		{
			if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
			{
				e.Item.Cells[2].Text=(e.Item.Cells[2].Text.Trim().Equals("M"))?"男":"女";
				e.Item .Cells[5].Text="<a href=ShowDetailInformation.aspx?NewID="+e.Item.Cells[5].Text.Trim()+"&Type=1>详细信息</a>";
			}
		}

		private void DataGrid1_DeleteCommand(object source, DataGridCommandEventArgs e)
		{
			SqlCommand cmd;
			cmd=new SqlCommand("DELETE  FROM EnterPerson WHERE NewID='"+e.Item.Cells[0].Text+"'".Trim(),sqlconn);
			
			sqlconn.Open();
			cmd.ExecuteNonQuery();
			sqlconn.Close();

			ds.Tables["EnterPerson"].DefaultView.Sort="NewID";
			ds.Tables["EnterPerson"].DefaultView.Delete(ds.Tables["EnterPerson"].DefaultView.Find(e.Item.Cells[0].Text));
			DataGrid1.DataBind();
		}

	}
}

⌨️ 快捷键说明

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