📄 addstu.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 addStu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["adminId"] == null)
{
Response.Redirect("Default.aspx");
}
}
//提交按钮
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
int insert;
string stuId = tbx_stuId.Text;
string stuPwd = tbx_stuPwd.Text;
string stuName = tbx_stuName.Text;
int stuSex;
if (this.RadioButton1.Items[0].Selected)
stuSex = 0;
else stuSex = 1;
if (stuId == "" || stuName == "")
Response.Write("<script>alert(\"请输入完整资料!\");</script>");
else
{
int exist;
exist = (new projClass()).ifStuExist(stuId);
if (exist == 0)//exist等于0说明不存在,
{
insert = (new projClass()).insertStuinfo(stuId, stuName, stuPwd, stuSex, 0, "");
if (insert == 0)
{
Response.Write("<script>alert(\"添加失败!\");</script>");
}
if (!this.CheckBox2.Checked)
{
String script = "<script>window.opener.location.href='stuInfoView.aspx';window.close();</script> ";
Page.RegisterStartupScript("refresh", script);
}
else
{
tbx_stuId.Text = "";
tbx_stuName.Text = "";
}
}
else Response.Write("<script>alert(\"此学生已经存在!\");</script>");
}
}
//取消按钮
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 ImageButton3_Click(object sender, ImageClickEventArgs e)
{
this.tbx_stuId.Text = "";
this.tbx_stuName.Text = "";
this.tbx_stuPwd.Text = "";
this.RadioButton1.SelectedIndex = 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -