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

📄 contentmanage.aspx.cs

📁 asp开发的项目管理系统,能够跟进工程进度
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Content_Admin_ContentManage : System.Web.UI.Page
{
	int nCatalogID = -1;
	protected void Page_Load(object sender,EventArgs e)
	{
		if(Session[SystemConst.USERIDKEY] == null)
		{
			Response.Write(SysOperation.OpenDialog(
				"你还没有登录,请先登录..."));
			Response.Write("<script>history.back()<script>");
			return;
		}
		if(Request.Params["CatalogID"] != null)
		{
			if(Int32.TryParse(Request.Params["CatalogID"].ToString(),out nCatalogID) == false)
			{
				return;
			}
		}
		if(!Page.IsPostBack)
		{
			if(nCatalogID > -1)
			{
				SetAddBtnEnabled(nCatalogID);				
			}
			if(NewContentBtn.Enabled == true)
			{
				BindContentData(nCatalogID);
			}
		}
	}
	private void BindContentData(int nCatalogID)
	{
		IContent content = new Content();
		DataSet ds = new DataSet("Content");
		content.GetContentDSByCatalog(nCatalogID,ref ds);

		ContentView.DataSource = ds;
		ContentView.DataBind();
	}

	private void SetAddBtnEnabled(int nCatalogID)
	{   ///如果是首页,则不能添加内容
		if(nCatalogID == 2)
		{
			NewContentBtn.Enabled = false;
			return;
		}
		///如果存在子目录,则不能添加内容
		ICatalog catalog = new Catalog();
		SqlDataReader dr = catalog.GetSubCatalog(nCatalogID);
		bool bEnabled = true;
		if(dr.Read())
		{
			bEnabled = false;
		}
		dr.Close();
		NewContentBtn.Enabled = bEnabled;
	}

	protected string FormatContentType(bool bType)
	{
		return bType ? "~/Images/content.gif" : "~/Images/url.gif";
	}
	protected string FormatContentState(short sState)
	{
		switch(sState)
		{
			case 0:
				return "未审核";
			case 1:
				return "审核未通过";
			case 2:
				return "审核已通过";
			case 3:
				return "已发布";
			case 4:
				return "已存档";
			default:
				return "未知状态";
		}
	}
	protected string FormatContentdpFlag(short sdpFlag)
	{
		switch(sdpFlag)
		{
			case 0:
				///"无附件";
				return "";
			case 1:
				///"附件";
				return "~/Images/Attch.gif";
			case 2:
				///"图片";
				return "~/Images/pic.gif";
			case 3:
				///"图片和附件";
				return "~/Images/paa.gif";
			default:
				///"未知状态";
				return "~/Images/unknown.gif";
		}
	}

	protected bool FormatImageVisible(short visible)
	{
		return visible == 0 ? false : true;
	}

	protected void NewContentBtn_Click(object sender,EventArgs e)
	{
		Response.Redirect("~/Content/Admin/AddContent.aspx?CatalogID="
			+ nCatalogID.ToString());
	}
	protected void ContentView_PageIndexChanging(object sender,GridViewPageEventArgs e)
	{
		ContentView.PageIndex = e.NewPageIndex;
		BindContentData(nCatalogID);
	}

	protected void ContentView_RowDataBound(object sender,GridViewRowEventArgs e)
	{
		ImageButton deleteBtn = (ImageButton)e.Row.FindControl("DeleteBtn");
		if(deleteBtn != null)
		{
			deleteBtn.Attributes.Add("onclick","return confirm('你确定要删除所选择的数据吗?');");
		}
	}
	protected void ContentView_RowCommand(object sender,GridViewCommandEventArgs e)
	{
		if(e.CommandName == "delete")
		{
			IContent content = new Content();
			try
			{
				content.DeleteContent(Int32.Parse(e.CommandArgument.ToString()));
				Response.Write(SysOperation.OpenDialog(
						SysInfomation.DELETE_DATA_SUCESS));
			}
			catch(Exception ex)
			{
				Server.Transfer(SysOperation.FormatErrorPageUrl(
					SysOperation.FormatErrorUrl(Request.RawUrl),ex.Message),
					false);
			}
		}
	}
	protected void ContentView_RowDeleting(object sender,GridViewDeleteEventArgs e)
	{
		///
	}
}

⌨️ 快捷键说明

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