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

📄 theme.aspx.cs

📁 前台:asp.net;后台: sql server 一个功能完善的BBS系统源码。
💻 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 Stella.Web.ProcessFlow;
using Stella.Model;
using System.Security.Permissions;

namespace Stella.Web.admin
{
	/// <summary>
	/// theme 的摘要说明。
	/// </summary>
	[PrincipalPermission(SecurityAction.Demand,Role="adminer")]
	public class theme : PageBase
	{
		protected System.Web.UI.WebControls.DataGrid oldData;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.TextBox comment;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
		protected System.Web.UI.WebControls.TextBox lv;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.DataGrid newData;
		protected System.Web.UI.WebControls.TextBox tname;
		protected System.Web.UI.WebControls.Button Button2;
	
		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.oldData.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.oldData_ItemCommand);
			this.oldData.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.oldData_CancelCommand_1);
			this.oldData.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.oldData_EditCommand_1);
			this.oldData.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.oldData_UpdateCommand_1);
			this.oldData.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.oldData_DeleteCommand_1);
			this.oldData.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.oldData_ItemDataBound_1);
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void setUp()
		{
			CacheController cc=new CacheController();
			Forum forum=cc.GetCachedForum();
			District distNow=new District();
			foreach(District dist in forum.Districts)
			{
				if(dist.Did.ToString()==Request["did"])
					distNow=dist;
			}

			ViewState.Add("did",distNow.Did);
			ViewState.Add("dname",distNow.Dname);

			this.oldData.DataSource=distNow.Themes;
			this.oldData.DataBind();
			if(Session["newThemes"]!=null)
			{
				District newThemes=(District)Session["newThemes"];
				this.newData.DataSource=newThemes.Themes;
				this.newData.DataBind();
				this.Button2.Visible=true;
			}
		}


		
		private void Button1_Click(object sender, System.EventArgs e)
		{
			if(!this.IsRefresh)
			{
				Theme theme=new Theme();
				theme.Tname=this.tname.Text;
				theme.Comment=this.comment.Text;
				theme.Lv=short.Parse(this.lv.Text);
				theme.District=(int)ViewState["did"];
				if(Session["newThemes"]==null)
				{
					District dist=new District();
					Session["newThemes"]=dist;
				}
				District newThemes=(District)Session["newThemes"];
				newThemes.AddTheme(theme);
			}
			setUp();
		}

		private void Button2_Click(object sender, System.EventArgs e)
		{
			if(Session["newThemes"]!=null)
			{
				this.themeLogic.Create((District)Session["newThemes"]);
			    Session["newThemes"]=null;
				Session.Remove("newThemes");
				this.Button2.Visible=false;
			}

			setUp();
		}

		private void oldData_ItemDataBound_1(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if(e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
			{
				LinkButton del=(LinkButton)e.Item.FindControl("del");
				del.Attributes.Add("onclick","javascript:return confirm('确认要删除吗?')");

				Label dist=(Label)e.Item.FindControl("dist");
				dist.Text=(string)ViewState["dname"];
				Label did=(Label)e.Item.FindControl("did");
				did.Text=ViewState["did"].ToString();
			}
		
		}

		private void oldData_UpdateCommand_1(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			Theme theme=new Theme();
			theme.Tid=int.Parse(e.Item.Cells[2].Text);
			theme.Tname=((TextBox)e.Item.Cells[3].Controls[0]).Text;
			theme.Comment=((TextBox)e.Item.Cells[4].Controls[0]).Text;
			theme.Lv=short.Parse(((TextBox)e.Item.Cells[5].Controls[0]).Text);
			theme.District=(int)ViewState["did"];

			this.themeLogic.Update(theme);
			this.oldData.EditItemIndex=-1;
			setUp();
		}

		private void oldData_CancelCommand_1(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			this.oldData.EditItemIndex=-1;
			setUp();
		}

		private void oldData_EditCommand_1(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			this.oldData.EditItemIndex=e.Item.ItemIndex;
			setUp();
			Label dist=(Label)this.oldData.Items[e.Item.ItemIndex].FindControl("dist");
			dist.Text=(string)ViewState["dname"];
			Label did=(Label)this.oldData.Items[e.Item.ItemIndex].FindControl("did");
			did.Text=ViewState["did"].ToString();
		}

		private void oldData_DeleteCommand_1(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			this.themeLogic.Remove(int.Parse(e.Item.Cells[2].Text));
			setUp();	
		}

		private void oldData_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			if(e.CommandName=="manage")
			{
				if(!this.IsRefresh)
				{
					Member mm=new Member();
					mm.Name=((TextBox)e.Item.FindControl("mname")).Text;
					mm.Role=UserRole.Manager;
					mm.Manage=int.Parse(e.Item.Cells[2].Text);
					mm.Mzone=e.Item.Cells[3].Text;
					this.userLogic.UpdateRole(mm);
				}
				
				setUp();	
			}
		}
	}
}

⌨️ 快捷键说明

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