📄 studentupdate.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class studentUpdate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["adminId"] == null)
{
Response.Redirect("Default.aspx");
}
else
{
if (!Page.IsPostBack)
{
tbx_stuId.Text = Convert.ToString(Session["stuId"]);
getStudentInfo();
}
}
}
public void getStudentInfo()
{
string stuId = tbx_stuId.Text.Trim();
DataSet ds = (new projClass()).getStuInfoAsId(stuId);
DataTable dt = ds.Tables["stuInfo"];
DataRow dataRow = dt.Rows[0];
tbx_stuName.Text = Convert.ToString(dataRow["stuName"]);
string stuSex = Convert.ToString(dataRow["stuSex"]);
if (stuSex == "男")
this.RadioButton1.Items[0].Selected=true;
else
this.RadioButton1.Items[1].Selected = true;
tbx_stuPwd.Text = Convert.ToString(dataRow["stuPwd"]);
}
//取消事件
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
string script = "<script>window.opener.location.href='stuInfoView.aspx';window.close();</script> ";
Page.RegisterStartupScript("refresh", script);
}
//更新事件
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string stuId, stuName, stuPwd;
stuId = tbx_stuId.Text.Trim();
stuName = tbx_stuName.Text.Trim();
stuPwd = tbx_stuPwd.Text.Trim();
int stuSex = 0;
if (this.RadioButton1.SelectedIndex == 1)
stuSex = 1;
int update = 0;
update = (new projClass()).updateStuInfo(stuId, stuPwd, stuName, stuSex);
if (update == 1)
{
Response.Write("<script>alert(\"更新成功!\");</script>");
string script = "<script>window.opener.location.href='stuInfoView.aspx';window.close();</script> ";
Page.RegisterStartupScript("refresh", script);
}
else
Response.Write("<script>alert(\"更新失败!\");</script>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -