📄 modify.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
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 MemberMgr
{
/// <summary>
/// modify 的摘要说明。
/// </summary>
public class modify : System.Web.UI.Page
{
protected System.Web.UI.WebControls.RegularExpressionValidator RegPin;
protected System.Web.UI.WebControls.RegularExpressionValidator RegName;
protected System.Web.UI.WebControls.RegularExpressionValidator RegPassword;
protected System.Web.UI.WebControls.RegularExpressionValidator RegBirth;
protected System.Web.UI.WebControls.RegularExpressionValidator Regzip;
protected System.Web.UI.WebControls.RegularExpressionValidator Regtel;
protected System.Web.UI.WebControls.RegularExpressionValidator RegEMail;
protected System.Web.UI.WebControls.CompareValidator CompPassword12;
protected System.Web.UI.WebControls.TextBox pin;
protected System.Web.UI.WebControls.RequiredFieldValidator RFpin;
protected System.Web.UI.WebControls.TextBox name;
protected System.Web.UI.WebControls.RequiredFieldValidator RFname;
protected System.Web.UI.WebControls.TextBox password1;
protected System.Web.UI.WebControls.RequiredFieldValidator RFpass;
protected System.Web.UI.WebControls.TextBox password2;
protected System.Web.UI.WebControls.TextBox birth;
protected System.Web.UI.WebControls.RadioButtonList sex;
protected System.Web.UI.WebControls.DropDownList city;
protected System.Web.UI.WebControls.TextBox zip;
protected System.Web.UI.WebControls.RequiredFieldValidator RFzip;
protected System.Web.UI.WebControls.TextBox email;
protected System.Web.UI.WebControls.RequiredFieldValidator RFemail;
protected System.Web.UI.WebControls.TextBox telephone;
protected System.Web.UI.WebControls.RequiredFieldValidator RFtel;
protected System.Web.UI.WebControls.TextBox address;
protected System.Web.UI.WebControls.RequiredFieldValidator RFAdrress;
protected System.Web.UI.WebControls.TextBox question;
protected System.Web.UI.WebControls.RequiredFieldValidator RFQ;
protected System.Web.UI.WebControls.TextBox answer;
protected System.Web.UI.WebControls.RequiredFieldValidator RFA;
protected System.Web.UI.WebControls.TextBox userid;
protected System.Web.UI.WebControls.Button Submit;
protected MemberMgr MemberMgr=new MemberMgr();
protected System.Web.UI.WebControls.Label ErrMsg;
protected MemberDetail theUser=new MemberDetail();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
citybind();
string m_PIN=Request.Params["PIN"];
string m_ID=Request.Params["ID"];
if((m_PIN==null)&&(m_ID==null))
{
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(m_ID, false);
}
else if(m_ID!=null)
{
theUser=this.MemberMgr.GetDetailByID(Convert.ToInt32(m_ID));
}
this.address.Text=this.theUser.Address;
this.answer.Text=this.theUser.Answer;
this.birth.Text=this.theUser.Birth.ToShortDateString();
if(this.city.Items.Count>0)
{
this.city.SelectedIndex=-1;
this.city.Items.FindByValue(this.theUser.City.ToString()).Selected=true;
}
this.email.Text=this.theUser.EMail;
this.name.Text=this.theUser.Name;
this.password1.Text=this.theUser.Password;
this.pin.Text=this.theUser.PIN;
this.question.Text=this.theUser.Question;
this.telephone.Text=this.theUser.Telephone;
if(this.theUser.Sex)
this.sex.Items.FindByValue("1").Selected=true;
else
this.sex.Items.FindByValue("0").Selected=true;
this.zip.Text=this.theUser.Zip;
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Submit.Click += new System.EventHandler(this.Submit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Submit_Click(object sender, System.EventArgs e)
{
if(Page.IsValid)
{
theUser.Address=this.address.Text.ToString();
theUser.Answer=this.answer.Text.ToString();
theUser.Birth=Convert.ToDateTime(this.birth.Text);
if(this.city.SelectedIndex!=-1)
theUser.City=Convert.ToInt32(this.city.SelectedItem.Value);
theUser.EMail=this.email.Text.ToString();
theUser.Name=this.name.Text.ToString();
theUser.Password=this.password1.Text.ToString();
theUser.PIN=this.pin.Text.ToString();
theUser.Question=this.question.Text.ToString();
bool bSex=true;
if(this.sex.SelectedItem.Value=="0")
{
bSex=false;
}
theUser.Sex=bSex;
theUser.Telephone=this.telephone.Text.ToString();
theUser.Zip=this.zip.Text.ToString();
this.theUser.ID=Convert.ToInt32(this.Page.Request.Params["ID"]);
}
try
{
this.MemberMgr.Modify(ref theUser);
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(theUser.ID.ToString(), false);
Page.Response.Redirect("Login.aspx");
}
catch
{
this.ErrMsg.Text="注册失败!";
}
}
private void citybind()
{
SQLDataReaderResult result;
City obj=new City();
result = obj.GetAll();
city.DataSource=result.dr;
city.DataBind();
result.ConnClose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -