📄 buyerinformation.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;
using System.Configuration;
using System.Data.SqlClient;
namespace Supermart
{
/// <summary>
/// buyerinformation 的摘要说明。
/// </summary>
public class buyerinformation : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Image Image4;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Image Image2;
protected System.Web.UI.WebControls.Label lb_name;
protected System.Web.UI.WebControls.Label lb_buytime;
protected System.Web.UI.WebControls.Label lb_totalMoney;
protected System.Web.UI.WebControls.Label lb_phone;
protected System.Web.UI.WebControls.Label lb_address;
protected System.Web.UI.WebControls.Label lb_Date;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.WebControls.TextBox txt_phone;
protected System.Web.UI.WebControls.TextBox txt_address;
protected System.Web.UI.WebControls.LinkButton putinphone;
protected System.Web.UI.WebControls.LinkButton putinaddress;
private string strConn=System.Configuration.ConfigurationSettings.AppSettings["SQLCONNECTION"];
private void Page_Load(object sender, System.EventArgs e)
{
Bindinformation();
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.putinphone.Click += new System.EventHandler(this.putinphone_Click);
this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
this.putinaddress.Click += new System.EventHandler(this.putinaddress_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LinkButton1_Click(object sender, System.EventArgs e)
{
this.lb_phone.Visible=false;
this.txt_phone.Visible=true;
this.putinphone.Visible=true;
}
private void LinkButton2_Click(object sender, System.EventArgs e)
{
this.lb_address.Visible=false;
this.txt_address.Visible=true;
this.putinaddress.Visible=true;
}
private void putinphone_Click(object sender, System.EventArgs e)
{
if(this.txt_phone.Text!="")
{
string buyerID=Request.QueryString["buyerID"].ToString();
SqlConnection con=new SqlConnection(strConn);
con.Open();
SqlCommand cmd=new SqlCommand("update buyer set phone='"+this.txt_phone.Text+"' where buyerID='"+buyerID+"'",con);
cmd.ExecuteNonQuery();
}
else
{
Response.Write("<script>alert(\"不能提交空内容!!\");</script>");
}
this.lb_phone.Visible=true;
this.txt_phone.Visible=false;
this.putinphone.Visible=false;
Bindinformation();
}
private void putinaddress_Click(object sender, System.EventArgs e)
{
if(this.txt_address.Text!="")
{
string buyerID=Request.QueryString["buyerID"].ToString();
SqlConnection con=new SqlConnection(strConn);
con.Open();
SqlCommand cmd=new SqlCommand("update buyer set address='"+this.txt_address.Text+"' where buyerID='"+buyerID+"'",con);
cmd.ExecuteNonQuery();
}
else
{
Response.Write("<script>alert(\"不能提交空内容!!\");</script>");
}
this.lb_address.Visible=true;
this.txt_address.Visible=false;
this.putinaddress.Visible=false;
Bindinformation();
}
public void Bindinformation()
{
string buyerID=Request.QueryString["buyerID"].ToString();
SqlConnection con=new SqlConnection(strConn);
con.Open();
SqlCommand cmd=new SqlCommand("select * from buyer where buyerID='"+buyerID+"'",con);
SqlDataReader sdr=cmd.ExecuteReader();
sdr.Read();
this.lb_name.Text=sdr["buyerName"].ToString();
this.lb_buytime.Text=sdr["buyTime"].ToString();
this.lb_totalMoney.Text=sdr["totalMoney"].ToString();
this.lb_phone.Text=sdr["phone"].ToString();
this.lb_address.Text=sdr["address"].ToString();
this.lb_Date.Text=sdr["latestBuy"].ToString();
sdr.Close();
con.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -