📄 bookinfo.aspx.cs
字号:
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary>
/// bookinfo 的摘要说明。
/// </summary>
public class bookinfo : System.Web.UI.Page
{protected CCUtility Utility;
protected System.Web.UI.HtmlControls.HtmlInputHidden p_theID;
protected System.Web.UI.WebControls.TextBox BookName;
protected System.Web.UI.WebControls.TextBox Type;
private Access acc=new Access();
protected System.Web.UI.WebControls.TextBox TPI;
protected System.Web.UI.WebControls.TextBox Writer;
protected System.Web.UI.WebControls.TextBox Price;
protected System.Web.UI.WebControls.TextBox pDate;
protected System.Web.UI.WebControls.TextBox memo;
protected System.Web.UI.WebControls.TextBox Introduce;
protected System.Web.UI.WebControls.TextBox state;
protected System.Web.UI.WebControls.Image cover;
protected System.Web.UI.WebControls.Button btSave;
protected System.Web.UI.WebControls.TextBox BookIDtxt;
protected System.Web.UI.WebControls.Label BookID;
private DataSet ds=new DataSet();
private void Page_Load(object sender, System.EventArgs e)
{
this.Utility=new CCUtility(this);
Utility.CheckSecurity();
if (!(this.IsPostBack))
{
CCUtility cc=new CCUtility(this);
BookID.Text=cc.GetParam("ID");
this.Page_Show(sender,e);
if(BookID.Text==""){return;}
}
}
protected void Page_Show(object sender, EventArgs e)
{
CCUtility cc=new CCUtility(this);
string str_sql="select * from DB_bookinfo where BookID='"+cc.GetParam("ID")+"'";
Access acc=new Access();
acc.GetDataSet(str_sql,ds);
//书名绑定
this.BookName.Text=ds.Tables[0].Rows[0]["BookName"].ToString();
//封面绑定
string path="cover/"+ds.Tables[0].Rows[0]["cover"].ToString();
this.cover.ImageUrl=path.ToString();
this.Type.Text=ds.Tables[0].Rows[0]["Type"].ToString();
this.TPI.Text=ds.Tables[0].Rows[0]["TPI"].ToString();
this.Writer.Text=ds.Tables[0].Rows[0]["Writer"].ToString();
this.pDate.Text=ds.Tables[0].Rows[0]["pDate"].ToString();
this.memo.Text=ds.Tables[0].Rows[0]["memo"].ToString();
this.Introduce.Text=ds.Tables[0].Rows[0]["Introduce"].ToString();
this.state.Text=ds.Tables[0].Rows[0]["state"].ToString();
this.Price.Text=ds.Tables[0].Rows[0]["Price"].ToString();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.btSave.Click += new System.EventHandler(this.btSave_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void MsgBox( string msg )
{
string strScript = "<script language='Javascript'>alert('" + msg + "');</script>";
Page.RegisterStartupScript("alert", strScript);
}
private void btSave_Click(object sender, System.EventArgs e)
{
string strUpdt = " UPDATE DB_bookinfo SET BookName = '"
+ this.BookName.Text+"'"+ " WHERE BookID = '" + this.BookID.Text+"'" ;
bool success=acc.ExecuteSQL(strUpdt);
if(success==true)
{this.MsgBox("更新成功!");}
else {this.MsgBox("更新失败!");}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -