⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 information.aspx.cs

📁 一个电子商务网源码
💻 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.Index
{
	/// <summary>
	/// Information 的摘要说明。
	/// </summary>
	public partial class Information : System.Web.UI.Page
	{

		protected InformationVO informationVO = new InformationVO();
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if( Session["LoginName"] == null )
			{
				panel3.Visible = true;
			}
			else
			{
				panel3.Visible = false;
			}
			if( Request.Params["InformationId"] == null )
			{
				Title.InnerHtml = "<font color=\"red\">没有指定的文章</font> ";
				submit1.Enabled = false;
			}
			else
			{
				int id = Convert.ToInt32(Request.Params["InformationId"].ToString() );
				InformationDAO informationDAO = new InformationDAO();
				informationVO = informationDAO.getInformation( id );
				Title.InnerText = informationVO.Title;
				Content.InnerHtml = informationVO.Content;
				ArticleDetail.InnerText = "发表日期:" + informationVO.AddDate + "   点击数:" + informationVO.Hit.ToString();
				CommentDAO commentDAO = new CommentDAO();
				Comment.InnerHtml = commentDAO.getComment( -1, -1, informationVO.InformationId );
			}
		}

		#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.AddTime = DateTime.Now.ToString();
			commentVO.InformationId = informationVO.InformationId;
			commentVO.Content = TextBox3.Text.Replace( "\n", "<br>").Replace(" ", "&nbsp;");
			commentVO.GoodsId = -1;
			commentVO.TopNewsId = -1;
			commentVO.UserName = getCommenter();

			CommentDAO commentDAO = new CommentDAO();
			commentDAO.AddComment( commentVO );

			TextBox3.Text = "";
			Response.Redirect( this.Request.Url.ToString() );
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -