📄 student.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;
using UseDataBase;
using System.Data.SqlClient;
using System.Collections.Generic;
public partial class Student : System.Web.UI.Page
{
string connectionString = ConfigurationManager.ConnectionStrings["DataBaseConnectionString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
txtUserID.Text = (string)Session["UserID"];
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
int index = Int32.Parse(e.Item.Value);
MultiView1.ActiveViewIndex = index;
if (index == 2)
GridView1.DataBind();
}
protected void btnOk_Click(object sender, EventArgs e)
{
if (IsValid)
{
string updatePasswordCmd = "update [users] set [User_Password]=@Password where [User_id]=@ID";
SqlParameter parPassword = new SqlParameter("@Password", SqlDbType.VarChar);
parPassword.Value = txtPassword.Text.Trim();
SqlParameter parID = new SqlParameter("@ID", SqlDbType.VarChar);
parID.Value = txtUserID.Text;
DataBaseIO db = new DataBaseIO(connectionString);
db.ExecuteSQL(updatePasswordCmd, parPassword, parID);
Response.Write("<script>alert('密码修改成功!')</script>");
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
txtPassword.Text = null;
txtSurePassword.Text = null;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
bool success = false;
int n = 0;
List<int> tmp = new List<int>();
for (int i = 0; i < checkBoxSelectCourse.Items.Count; i++)
{
if (checkBoxSelectCourse.Items[i].Selected)
{
n++;
if (n >= 4)
{
Response.Write("<script>alert('对不起,您选择的课程大于三门,请重新选择')</script>");
checkBoxSelectCourse.ClearSelection();
tmp = null;
break;
}
else
tmp.Add(i);
}
}
if (tmp != null)
{
for (int m = 0; m < tmp.Count; m++)
{
string insertCmd = "insert tabstu_cour (Sid,Crid) values (@Sid,@Crid)";
SqlParameter parSid = new SqlParameter("@Sid", SqlDbType.VarChar);
parSid.Value = (string)Session["UserID"];
SqlParameter parCrid = new SqlParameter("@Crid", SqlDbType.VarChar);
parCrid.Value = checkBoxSelectCourse.Items[m].Value;
DataBaseIO db = new DataBaseIO(connectionString);
db.ExecuteSQL(insertCmd, parSid, parCrid);
success = true;
}
}
checkBoxSelectCourse.ClearSelection();
if (success == true)
{
checkBoxSelectCourse.DataBind();
Response.Write("<script>alert('选课成功!')</script>");
}
}
protected void btnCalcelSubmit_Click(object sender, EventArgs e)
{
checkBoxSelectCourse.ClearSelection();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -