?? catalog.aspx.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 SQLHelper;
public partial class Content_Admin_Catalog : System.Web.UI.Page
{
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(!Page.IsPostBack)
{
InitCatalogView();
}
DeleteBtn.Attributes.Add("onclick","return confirm('你確定要刪除所選擇的數據嗎?');");
}
private void InitCatalogView()
{
ICatalog cata = new Catalog();
cata.BindCatalogTreeView(CatalogView,true,"-1");
}
protected void OperationBtn_Command(object sender,CommandEventArgs e)
{
string sCmdName = e.CommandName.ToLower();
if(SysOperation.StringNullChecked(sCmdName) == false)
{
Response.Write(SysOperation.OpenDialog(
SysInfomation.DATA_ISNULL));
return;
}
if(CatalogView.SelectedNode == null)
{
Response.Write(SysOperation.OpenDialog(
SysInfomation.SELECT_DATA_NO_ITEM));
return;
}
switch(sCmdName)
{
case "add":
{
Response.Redirect("~/Content/Admin/AddCatalog.aspx?CatalogID="
+ CatalogView.SelectedNode.Value);
break;
}
case "update":
{
Response.Redirect("~/Content/Admin/UpdateCatalog.aspx?CatalogID="
+ CatalogView.SelectedNode.Value);
break;
}
case "delete":
{
DeleteCatalog(Int32.Parse(CatalogView.SelectedNode.Value));
break;
}
case "up":
case "down":
{
MoveCatalog(Int32.Parse(CatalogView.SelectedNode.Value),sCmdName);
break;
}
default: break;
}
}
private void DeleteCatalog(int nCatalogID)
{
if(CatalogView.SelectedNode.ChildNodes.Count > 0)
{
Response.Write(
SysOperation.OpenDialog(
"要刪除的結點包含孩子結點,不能刪除,請重新選擇結點。")
);
return;
}
ICatalog cata = new Catalog();
try
{
cata.DeleteCatalog(nCatalogID);
InitCatalogView();
Response.Write(SysOperation.OpenDialog(
SysInfomation.DELETE_DATA_SUCESS));
}
catch(Exception ex)
{
Server.Transfer(SysOperation.FormatErrorPageUrl(
SysOperation.FormatErrorUrl(Request.RawUrl),ex.Message),
false);
}
}
private void MoveCatalog(int nCatalogID,string sMoveFlag)
{
if(SysOperation.StringNullChecked(sMoveFlag) == false)
{
Response.Write(SysOperation.OpenDialog(
SysInfomation.DATA_ISNULL));
return;
}
TreeNode parentNode = CatalogView.SelectedNode.Parent;
if(parentNode == null)
{
return;
}
///第一個結點不上移
if(sMoveFlag == "up"
&& parentNode.ChildNodes.IndexOf(CatalogView.SelectedNode) == 0)
{
Response.Write(
SysOperation.OpenDialog(
"第一個結點不上移,請重新選擇結點。")
);
return;
}
///最后一個結點不下移
if(sMoveFlag == "down"
&& parentNode.ChildNodes.IndexOf(CatalogView.SelectedNode)
== parentNode.ChildNodes.Count - 1)
{
Response.Write(
SysOperation.OpenDialog(
"最后一個結點不下移,請重新選擇結點。")
);
return;
}
ICatalog cata = new Catalog();
try
{
cata.UpdateCatalogOrder(nCatalogID,sMoveFlag);
InitCatalogView();
Response.Write(SysOperation.OpenDialog(
SysInfomation.MOVE_DATA_SUCESS));
}
catch(Exception ex)
{
Server.Transfer(SysOperation.FormatErrorPageUrl(
SysOperation.FormatErrorUrl(Request.RawUrl),ex.Message),
false);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -