您目前尚未登陆,请选择【登陆】或【注册
首页->新闻文章->破竹CMS4.0免安装版源码>>admin/DocumentTypes/EditDocumentType.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:文件类型 PozhuCMS/admin/DocumentTypes/EditDocumentType.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using Pozhu.CMS.DocumentTypes; 12using Pozhu.CMS.Categories; 13using Pozhu.CMS; 14using Pozhu.Common.Utilities; 15using Pozhu.Sites; 16using Pozhu.CMS.Web; 17 18public partial class admin_DocumentTypes_EditDocumentType : AdminPageBase 19{ 20 protected void Page_Load(object sender, EventArgs e) 21 { 22 if (!Page.IsPostBack) 23 { 24 int siteID = SiteController.GetCurrentSite().SiteID; 25 int categoryID = CategoryController.GetCategory(siteID,Request.QueryString["path"]).CategoryID; 26 DocumentTypeController objTypes = new DocumentTypeController(); 27 ArrayList typeGroups = objTypes.GetDocumentTypeGroups(categoryID); 28 29 //文档类型组 30 ddlTypeGroups.DataSource = typeGroups; 31 ddlTypeGroups.DataBind(); 32 ddlTypeGroups.Items.Insert(0,(new ListItem("不分组", Null.NullInteger.ToString()))); 33 34 35 // 36 string action = Request.QueryString["action"]; 37 if (action == "add") 38 { 39 //未分组的文档类型 40 BindTypes(objTypes.GetNoGroupTypes(categoryID, true)); 41 42 this.lbtnUpdate.Visible = false; 43 } 44 else if (action == "edit") 45 { 46 int typeID = int.Parse(Request.QueryString["typeID"]); 47 DocumentType type = objTypes.GetDocumentType(typeID); 48 if (type.GroupID == Null.NullInteger) 49 { 50 BindTypes(objTypes.GetNoGroupTypes(categoryID, true)); 51 } 52 else 53 { 54 BindTypes(objTypes.GetDocumentTypesByGroupID(categoryID,type.GroupID, true)); 55 } 56 57 // 58 tbName.Text = type.TypeName; 59 tbDescription.Text = type.Description; 60 ddlTypeGroups.SelectedValue = type.GroupID.ToString(); 61 ddlTypes.SelectedValue = type.ParentID.ToString(); 62 63 lbtnAdd.Visible = false; 64 } 65 else if (action == "delete") 66 { 67 int typeID = int.Parse(Request.QueryString["typeID"]); 68 objTypes.DeleteDocumentType(typeID); 69 Response.Redirect("DocumentTypes.aspx?tabindex=" + Request.QueryString["tabindex"] + "&path=" + Request.QueryString["path"]); 70 } 71 } 72 } 73 74 //邦定到文档类型下拉框  75 void BindTypes(ArrayList types) 76 { 77 ddlTypes.Items.Clear(); 78 foreach (DocumentType type in types) 79 { 80 ddlTypes.Items.Add(new ListItem(new string('-', type.Level * 2) + type.TypeName, type.TypeID.ToString())); 81 } 82 ddlTypes.Items.Insert(0, new ListItem("无父类型","-1")); 83 } 84 85 86 protected void ddlTypeGroups_SelectedIndexChanged(object sender, EventArgs e) 87 { 88 DocumentTypeController objTypes = new DocumentTypeController(); 89 int siteID = SiteController.GetCurrentSite().SiteID; 90 int categoryID = CategoryController.GetCategory(siteID,Request.QueryString["path"]).CategoryID; 91 //重新邦定项目 92 if (ddlTypeGroups.SelectedValue == Null.NullInteger.ToString()) 93 { 94 BindTypes(objTypes.GetNoGroupTypes(categoryID, true)); 95 } 96 else 97 { 98 BindTypes(objTypes.GetDocumentTypesByGroupID(categoryID,int.Parse(ddlTypeGroups.SelectedValue), true)); 99 } 100 } 101 protected void lbtnCancel_Click(object sender, EventArgs e) 102 { 103 Response.Redirect("DocumentTypes.aspx?tabindex=" + Request.QueryString["tabindex"] + "&path=" + Request.QueryString["path"]); 104 } 105 protected void lbtnAdd_Click(object sender, EventArgs e) 106 { 107 int siteID = SiteController.GetCurrentSite().SiteID; 108 int categoryID = CategoryController.GetCategory(siteID,Request.QueryString["path"]).CategoryID; 109 DocumentTypeController objTypes = new DocumentTypeController(); 110 ArrayList types = objTypes.GetDocumentTypes(categoryID); 111 //检测是否已存同名的文档类型 112 foreach (DocumentType type in types) 113 { 114 if (type.TypeName.ToLower() == tbName.Text) 115 { 116 plState.CssClass = "warning"; 117 plState.Controls.Add(new LiteralControl(string.Format("已存在 {0} 文档类型", tbName.Text))); 118 119 return; 120 } 121 } 122 123 //添加 124 objTypes.AddDocumentType(categoryID, tbName.Text, int.Parse(ddlTypeGroups.SelectedValue), int.Parse(ddlTypes.SelectedValue), tbDescription.Text); 125 Response.Redirect("DocumentTypes.aspx?tabindex=" + Request.QueryString["tabindex"] + "&path=" + Request.QueryString["path"]); 126 } 127 protected void lbtnUpdate_Click(object sender, EventArgs e) 128 { 129 int siteID = SiteController.GetCurrentSite().SiteID; 130 int categoryID = CategoryController.GetCategory(siteID,Request.QueryString["path"]).CategoryID; 131 int typeID = int.Parse(Request.QueryString["typeID"]); 132 DocumentTypeController objTypes = new DocumentTypeController(); 133 ArrayList types = objTypes.GetDocumentTypes(categoryID); 134 //检测是否已存同名的文档类型 135 foreach (DocumentType type in types) 136 { 137 if ((type.TypeName.ToLower() == tbName.Text) && (type.TypeID != typeID)) 138 { 139 plState.CssClass = "warning"; 140 plState.Controls.Add(new LiteralControl(string.Format("已存在 {0} 文档类型", tbName.Text))); 141 142 return; 143 } 144 } 145 146 //更新 147 DocumentType updateType = objTypes.GetDocumentType(typeID); 148 try 149 { 150 objTypes.UpdateDocumentType(updateType.TypeID, updateType.CategoryID, tbName.Text, int.Parse(ddlTypeGroups.SelectedValue), int.Parse(ddlTypes.SelectedValue), tbDescription.Text); 151 } 152 catch(Exception error) 153 { 154 plState.CssClass = "warning"; 155 plState.Controls.Add(new LiteralControl(error.Message)); 156 return; 157 } 158 Response.Redirect("DocumentTypes.aspx?tabindex=" + Request.QueryString["tabindex"] + "&path=" + Request.QueryString["path"]); 159 } 160} 161
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:破竹CMS4.0免安装版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号