📄 modify_students.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 es_business = com.egt.business;
public partial class StuMessage_modify_students : System.Web.UI.Page
{
private es_business.StudentAttribute StuAtt = new com.egt.business.StudentAttribute();
private es_business.User m_user;
private es_business.student stu = new com.egt.business.student();
private DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
#region 绑定学员信息列表
ds = stu.select_student();
if (ds != null)
{
this.Grvstudent.DataSource = ds;
this.Grvstudent.DataBind();
}
else
{
this.Grvstudent.DataSource = null;
this.Grvstudent.DataBind();
}
#endregion
ds = stu.select_class();
if (ds != null)
{
this.drop_classid.DataTextField = ds.Tables[0].Columns["name"].ColumnName;
this.drop_classid.DataValueField = ds.Tables[0].Columns["id"].ColumnName;
this.drop_classid.DataSource = ds;
this.drop_classid.DataBind();
}
else
{
this.drop_classid.Items.Clear();
}
}
this.update();
}
protected void btn_modify_Click(object sender, EventArgs e)
{
#region 初试化属性
this.m_user = (es_business.User)this.Session["user"];
StuAtt.id = m_user.id;
StuAtt.names = this.txt_names.Text;
StuAtt.password = this.txt_password.Text;
StuAtt.phone = this.txt_phone.Text;
StuAtt.schoolname = this.drop_schoolname.SelectedValue;
StuAtt.classid = Convert.ToInt32(this.drop_classid.SelectedValue);
StuAtt.address = this.txt_address.Text;
StuAtt.sex = this.rab_sex.SelectedValue;
StuAtt.state = this.rab_state.SelectedValue;
#endregion
int i=stu.update_student(StuAtt);
if (i == 1)
{
Response.Write("<script language=javascript>window.alert('修改成功');</script>");
}
else
{
Response.Write("<script language=javascript>window.alert('修改失败');</script>");
}
}
protected void Grvstudent_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='GhostWhite'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");
e.Row.Attributes.Add("onDblClick", "window.open('modify_students.aspx?bh=" + e.Row.Cells[0].Text + "','mainFrame')");
}
}
public void update()
{
if (Request.QueryString["bh"] != null)
{
if (Request.QueryString["bh"].ToString() != "")
{
ds = stu.select_student();
ds.Tables[0].DefaultView.RowFilter = "id='" + Convert.ToInt32(Request.QueryString["bh"].ToString()) + "'";
if (ds.Tables[0].DefaultView.Count > 0)
{
this.lab_landnames.Text = ds.Tables[0].DefaultView[0].Row["landnames"].ToString();
this.txt_password.Text = ds.Tables[0].DefaultView[0].Row["password"].ToString();
this.txt_names.Text = ds.Tables[0].DefaultView[0].Row["names"].ToString();
this.txt_address.Text = ds.Tables[0].DefaultView[0].Row["address"].ToString();
this.txt_phone.Text = ds.Tables[0].DefaultView[0].Row["phone"].ToString();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -