代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Describe : System.Web.UI.Page
{
SqlHelper sqloperate = new SqlHelper();
SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["connStr"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["users"] != null)
{
sqlconn.Open();
string sqlstr = "Select * from tb_GoodsInfo where GoodsID='" + Session["users"].ToString() + "'";
SqlDataAdapter myApter = new SqlDataAdapter(sqlstr, sqlconn);
DataSet myDS = new DataSet();
myApter.Fill(myDS, "tb_GoodsInfo");
if (myDS.Tables["tb_GoodsInfo"].Rows.Count > 0)
{
DataRowView rowView = myDS.Tables["tb_GoodsInfo"].DefaultView[0];
txtGoodsName.Text = Convert.ToString(rowView["GoodsName"]);
txtKind.Text = Convert.ToString(rowView["GoodsKind"]);
imgGoodsPhoto.ImageUrl = Convert.ToString(rowView["GoodsPhoto"]);
txtGoodsDesc.Text = Convert.ToString(rowView["GoodsIntroduce"]);
}
}
else
Response.Write("<script>alert('您还没有登录,请登录后再使用,谢谢!');</script>");
}
}
//关闭窗口
protected void btnClose_Click(object sender, EventArgs e)
{
Response.Write("<script>window.close();</script>");
}
}