📄 customeredit.aspx.cs
字号:
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace NewGlassBook
{
/// <summary>
/// Summary description for lensPrice.
/// </summary>
public class customerEdit : MyPage
{
protected NewGlassBook.MyTextBox aid;
protected NewGlassBook.MyTextBox aPassword;
protected NewGlassBook.MyTextBox aName;
protected NewGlassBook.MyDropDownList aSex;
protected NewGlassBook.MyTextBox aAddress;
protected NewGlassBook.MyTextBox aTel;
protected NewGlassBook.MyTextBox aMobile;
protected NewGlassBook.MyTextBox aEmail;
protected NewGlassBook.MyButton dbtn_ok;
protected NewGlassBook.MyButton dbtn_cancel;
protected System.Web.UI.WebControls.Label lblWarning;
protected System.Web.UI.WebControls.TextBox did;
protected string strID;//客户编号
string strSql;//Sql字符串
protected Record r=new Record();//增加Record类访问数据库用
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
initData();//取得客户信息
}
}
private void initData()
{
DataSet ds;
strID=Request.QueryString["id"].ToString();//客户编号
did.Text=strID;//取得客户编号
strSql="select * from customer where id='"+strID+"'";
ds=r.GetData("customer",strSql);//从数据库中取得客户信息
aid.Text=ds.Tables["customer"].Rows[0]["id"].ToString();//客户编号
aPassword.Text=ds.Tables["customer"].Rows[0]["Password"].ToString();//客户口令
aName.Text=ds.Tables["customer"].Rows[0]["Name"].ToString();//客户姓名
aAddress.Text=ds.Tables["customer"].Rows[0]["Address"].ToString();//客户地址
if (ds.Tables["customer"].Rows[0]["Sex"].ToString()=="女")//性别
{
aSex.SelectedIndex=1;
}
else
{
aSex.SelectedIndex=0;
}
aTel.Text=ds.Tables["customer"].Rows[0]["Tel"].ToString();//电话
aMobile.Text=ds.Tables["customer"].Rows[0]["Mobile"].ToString();//手机
aEmail.Text=ds.Tables["customer"].Rows[0]["Email"].ToString();//email
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.dbtn_ok.Click += new System.EventHandler(this.dbtn_ok_Click);
this.dbtn_cancel.Click += new System.EventHandler(this.dbtn_cancel_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void dbtn_cancel_Click(object sender, System.EventArgs e)
{
Response.Write("<script lannguage='javascript'>window.close();</script>");
}
private void dbtn_ok_Click(object sender, System.EventArgs e)
{
did.Visible=true;
if(r.RequestUpdate("customer",Request)==1)//更新customer表
{
//返回上一页
Response.Write("<script lannguage='javascript'>window.close();</script>");
Response.Write("<script lannguage='javascript'>window.opener.location.href='customeradmin.aspx';</script>");
}
else
{
lblWarning.Text=r.ErrMsg;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -