📄 studentinfo.aspx.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.Student
{
/// <summary>
/// StudentInfo 的摘要说明。
/// </summary>
public class StudentInfo : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtnum;
protected System.Web.UI.WebControls.TextBox txtname;
protected System.Web.UI.WebControls.TextBox txtnation;
protected System.Web.UI.WebControls.TextBox txtaddress;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.Label labmsg;
protected System.Web.UI.WebControls.TextBox txtquestion;
protected System.Web.UI.WebControls.TextBox txtanswer;
protected System.Web.UI.WebControls.TextBox txtsex;
protected System.Web.UI.WebControls.TextBox txtemail;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(Session["username"]==null)
{
Response.Redirect("user_login.aspx",true);
}
if(!this.IsPostBack)
{
int num=Convert.ToInt32(Session["username"]);
showInfo(num);
}
}
void showInfo(int num)
{
string[] info=new BLL.Student_bll().getStudentInfo(num);
txtnum.Text=info[0];
txtname.Text=info[1];
txtsex.Text=info[2];
txtnation.Text=info[3];
txtaddress.Text=info[4];
txtquestion.Text=info[5];
txtanswer.Text=info[6];
txtemail.Text=info[7];
}
#region Web 窗体设计器生成的代码
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)
{
int id=Convert.ToInt32(txtnum.Text);
string name=txtname.Text;
string sex=txtsex.Text;
string nation=txtnation.Text;
string home=txtaddress.Text;
string question=txtquestion.Text;
string answer=txtanswer.Text;
string email=txtemail.Text;
try
{
new BLL.Student_bll().update_student(id,name,sex,nation,question,answer,home,email);
labmsg.Text="修改成功!";
}
catch
{
labmsg.Text="修改失败!";
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -