📄 productdetail.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 web.Code;
namespace web.Products
{
/// <summary>
/// ProductsDetail 的摘要说明。
/// </summary>
public partial class ProductsDetail : System.Web.UI.Page
{
protected int goodsid = -1;
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if( Session["LoginName"] == null )
{
panel3.Visible = true;
}
else
{
panel3.Visible = false;
}
if( Request.Params["GoodsId"] == null )
{
ProductInfo.InnerHtml = "<font color=\"red\">没有指定的商品</font> ";
submit1.Enabled = false;
}
else
{
GoodsDAO goodsDAO = new GoodsDAO();
goodsid = Convert.ToInt32(Request.Params["GoodsId"].ToString());
GoodsVO goodsVO = new GoodsVO();
goodsVO = goodsDAO.getProductInfo( goodsid );
ProductImg.InnerHtml = "<BR><BR><IMG height=\"90\" src=\"" + goodsVO.ImgUrl +"\" width=\"120\" border=\"1\">";
ProductInfo.InnerHtml = "<BR><BR>商品名称:" + goodsVO.GoodsName + "<BR><BR>商品所属类别:" + goodsVO.SubCategoryId + "<BR><BR>商品价格:"
+ goodsVO.Price + "元<BR><BR>商品添加日期:" + goodsVO.AddDate +"<BR><BR>点击数:" + goodsVO.Hit + "<BR><BR>";
Info.InnerHtml = goodsVO.Description;
CommentDAO commentDAO = new CommentDAO();
Conmments.InnerHtml = commentDAO.getComment( -1, goodsVO.GoodsId, -1 );
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
private string getCommenter()
{
string Name = null;
if( CheckBox1.Checked == true )
{
Name = "游客";
}
else if( Session["LoginName"] != null )
{
Name = Session["LoginName"].ToString();
}
else
{
string loginName = TextBox1.Text.Trim();
string loginPwd = TextBox2.Text.Trim();
CustomerDAO customerDAO = new CustomerDAO();
if( customerDAO.checkIsExist( loginName,loginPwd ) != 0 )
{
Name = loginName;
}
}
return Name;
}
protected void submit1_Click(object sender, System.EventArgs e)
{
CommentVO commentVO = new CommentVO();
commentVO.TopNewsId = -1;
commentVO.GoodsId = goodsid;
commentVO.InformationId = -1;
commentVO.Content = TextBox3.Text.Replace(" ", " ").Replace("\n","<br>");
commentVO.UserName = getCommenter();
commentVO.AddTime = DateTime.Now.ToString();
CommentDAO commentDAO = new CommentDAO();
commentDAO.AddComment( commentVO );
TextBox3.Text = "";
Response.Redirect( this.Request.Url.ToString() );
}
protected void LinkButton1_Click(object sender, System.EventArgs e)
{
if( Session["LoginName"] == null)
{
Response.Redirect("../Login.aspx?Return=" + Request.Url.ToString());
}
else
{
CustomerDAO customerDAO = new CustomerDAO();
int userId = customerDAO.getUserId( Session["LoginName"].ToString() );
int goodsId = Convert.ToInt32( Request.Params["GoodsId"].ToString() );
GoodsDAO goodsDAO = new GoodsDAO();
goodsDAO.inputCar(goodsId,userId);
Response.Redirect("../Customer/Car.aspx?Return="+Request.Url.ToString());
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -