📄 modifyuserinfo.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
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 e_librarys
{
/// <summary>
/// ModifyUserInfo 的摘要说明。
/// </summary>
public partial class ModifyUserInfo : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void Button_Modify_Click(object sender, System.EventArgs e)
{
if(Page.IsValid)
{
string StrConn="server=(local);database=e_library;uid=sa;pwd=";
SqlConnection Conn=new SqlConnection(StrConn);
Conn.Open();
string StrSql="update User_Info set U_Name='"+TextBox_Name.Text.ToString()+"',U_Pswd='"+TextBox_Pswd.Text.ToString()+"',U_Email='"+TextBox_Email.Text.ToString()+"',"+
"U_Telephone='"+TextBox_Telephone.Text.ToString()+"',U_Dirthday='"+TextBox_Birthday.Text.ToString()+"',U_QQ='"+TextBox_QQ.Text.ToString()+"',"+
"U_Sex='" + TextBox_Sex.Text.ToString() + "' where U_ID='" + Session["U_ID"] + "'";
SqlCommand Comm=new SqlCommand(StrSql,Conn);
Comm.ExecuteNonQuery();
Conn.Close();
Response.Write("<script language='javascript'>alert('修改信息成功')</script>");
}
}
protected void Button_Blank_Click(object sender, EventArgs e)
{
//从数据库中取出用户基本信息
SqlConnection Conn = new SqlConnection("server=(local);database=e_library;uid=sa;pwd=");
Conn.Open();
string StrSql = "select * from User_Info where U_Name='" + Session["U_Name"] + "'";
SqlDataAdapter Da = new SqlDataAdapter(StrSql, Conn);
DataSet Ds = new DataSet();
Da.Fill(Ds);
TextBox_Name.Text = Ds.Tables[0].Rows[0].ItemArray[0].ToString();
TextBox_Pswd.Text = Ds.Tables[0].Rows[0].ItemArray[2].ToString();
TextBox_Email.Text = Ds.Tables[0].Rows[0].ItemArray[4].ToString();
TextBox_QQ.Text = Ds.Tables[0].Rows[0].ItemArray[3].ToString();
TextBox_Telephone.Text = Ds.Tables[0].Rows[0].ItemArray[6].ToString();
TextBox_Sex.Text = Ds.Tables[0].Rows[0].ItemArray[5].ToString();
TextBox_Birthday.Text = Ds.Tables[0].Rows[0].ItemArray[7].ToString();
}
protected void Button_Close_Click(object sender, EventArgs e)
{
//this.Dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -