edit.aspx.cs
来自「前台:asp.net;后台: sql server 一个功能完善的BBS系统源」· CS 代码 · 共 109 行
CS
109 行
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 System.Security.Permissions;
namespace Stella.Web.Pages
{
/// <summary>
/// edit 的摘要说明。
/// </summary>
[PrincipalPermission(SecurityAction.Demand,Authenticated=true)]
public class edit : Container
{
protected System.Web.UI.WebControls.Button go;
protected System.Web.UI.WebControls.Button delete;
protected Stella.Web.Controls.NewTopic ed;
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
setUp();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.go.Click += new System.EventHandler(this.go_Click);
this.delete.Click += new System.EventHandler(this.delete_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
//这页的代码写的真是难受,关键是自己对多态的掌握比较混乱
//可以说是完全没有领会多态的意义所在
//还有就是newtopic.ascx这个控件从一开始就存在设计上的失误
//这个大家从名字上也可以看出来
//以后有机会的话一定要改进!
private void setUp()
{
Stella.Utility.DebugHelper.CheckCondition(Request["aid"]!=null,"没有主题编号top传入reply.aspx页");
Stella.Utility.DebugHelper.CheckCondition(Request["num"]!=null,"没有版块编号tid传入reply.aspx页");
bool isTop=( int.Parse(Request["num"])==1 );
if(isTop)
{
delete.Enabled=false;
delete.Visible=false;
}
else
ed.EditMode=true;
if(isTop)
{
Stella.Model.TopArt art=new Stella.Model.TopArt();
art.Aid=int.Parse(Request["aid"]);
this.artLogic.SelectInfo(art);
ed.TopValue=art;
}
else
{
Stella.Model.CommonArt art=new Stella.Model.CommonArt();
art.Aid=int.Parse(Request["aid"]);
this.artLogic.SelectInfo(art);
ed.ComValue=art;
}
}
private void delete_Click(object sender, System.EventArgs e)
{
this.artLogic.Remove(ed.ComValue);
Response.Redirect(string.Format("theme.aspx?tid={0}",int.Parse(Request["tid"])));
}
private void go_Click(object sender, System.EventArgs e)
{
bool isTop=( int.Parse(Request["num"])==1 );
if(isTop)
this.artLogic.Update(ed.TopValue);
else
this.artLogic.Update(ed.ComValue);
Response.Redirect(string.Format("theme.aspx?tid={0}",int.Parse(Request["tid"])));
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?