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

📄 topnews.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.TopNews
{
	/// <summary>
	/// TopNews 的摘要说明。
	/// </summary>
	public partial class TopNews : System.Web.UI.Page
	{

		protected TopNewsVO topNewsVO = new TopNewsVO();
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面

			if( Session["LoginName"] == null )
			{
				panel3.Visible = true;
			}
			else
			{
				panel3.Visible = false;
			}
			if( Request.Params["TopId"] == null )
			{
				IndexPageDAO indexPageDAO = new IndexPageDAO();
				topNewsVO = indexPageDAO.getPrimaryNews();
				Title.InnerText = topNewsVO.Title;
				Content.InnerHtml = topNewsVO.Content;
				ArticleDetail.InnerText = "发表日期:" + topNewsVO.AddDate;
				CommentDAO commentDAO = new CommentDAO();
				Comment.InnerHtml = commentDAO.getComment( topNewsVO.TopId, -1, -1 );
			}
			else
			{
				int id = Convert.ToInt32(Request.Params["TopId"].ToString() );
				TopNewsDAO topNewsDAO = new TopNewsDAO();
				topNewsVO = topNewsDAO.getTopNewsArticle( id );
				Title.InnerText = topNewsVO.Title;
				Content.InnerHtml = topNewsVO.Content;
				ArticleDetail.InnerText = "发表日期:" + topNewsVO.AddDate + "  所属栏目:" + topNewsVO.CategoryName;
				CommentDAO commentDAO = new CommentDAO();
				Comment.InnerHtml = commentDAO.getComment( topNewsVO.TopId, -1, -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.AddTime = DateTime.Now.ToString();
			commentVO.TopNewsId = topNewsVO.TopId;
			commentVO.Content = TextBox3.Text.Replace( "\n", "<br>").Replace(" ", "&nbsp;");
			commentVO.GoodsId = -1;
			commentVO.InformationId = -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 + -