您目前尚未登陆,请选择【登陆】或【注册
首页->新闻文章->破竹CMS4.0免安装版源码>>admin/Categories/EditDocument.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:文件类型 PozhuCMS/admin/Categories/EditDocument.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.Documents; 12using Pozhu.CMS; 13using Pozhu.CMS.Categories; 14using Pozhu.Common.Utilities; 15using Pozhu.Security.Users; 16using Pozhu.Common; 17using Pozhu.Sites; 18using Pozhu.CMS.DocumentTypes; 19using Pozhu.UI.WebControls; 20using Pozhu.CMS.PropertyDefinitions.PropertyControls; 21using Pozhu.CMS.PropertyDefinitions; 22using Pozhu.CMS.Web; 23 24public partial class admin_Categories_EditDocument : AdminPageBase 25{ 26 27 protected override bool IsAuthenticated() 28 { 29 if (base.IsAuthenticated()) 30 return true; 31 32 if (base.IsEditor()) 33 return true; 34 35 return false; 36 } 37 38 protected void Page_Load(object sender, EventArgs e) 39 { 40 if (!Page.IsPostBack) 41 { 42 string action = Request.QueryString["action"]; 43 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 44 int siteID = SiteController.GetCurrentSite().SiteID; 45 Category category = CategoryController.GetCategory(siteID,path); 46 47 //文档所在的栏目 48 ddlPath.Items.Add(new ListItem(category.Title, category.CategoryID.ToString())); 49 BindChildCategories(siteID, path,1); 50 if (action == "add") 51 { 52 this.lbtnUpdate.Visible = false; 53 54 //文档类型 55 dtDocumentTypes.CategoryID = category.CategoryID; 56 } 57 else if (action == "edit") 58 { 59 int documentID = int.Parse(Request.QueryString["documentID"]); 60 Document document = DocumentController.GetDocument( documentID); 61 tbSubject.Text = document.Subject; 62 tbName.Text = document.Name; 63 ddlPath.SelectedValue = document.CategoryID.ToString(); 64 65 lbtnAdd.Visible = false; 66 67 //文档类型 68 dtDocumentTypes.CategoryID = category.CategoryID; 69 dtDocumentTypes.DocumentID = document.DocumentID; 70 71 //上一个文档、下一个文档 72 Document nextDoc = DocumentController.GetNextDocument(documentID); 73 Document prevDoc = DocumentController.GetPreviousDocument(documentID); 74 if (nextDoc != null) 75 { 76 hlkNext.Visible = true; 77 hlkNext.NavigateUrl = Globals.ApplicationPath + "/admin/path" + document.Path + "editDocument/documentID/" + nextDoc.DocumentID + ".aspx?action=edit"; 78 } 79 if (prevDoc != null) 80 { 81 hlkPrevious.Visible = true; 82 hlkPrevious.NavigateUrl = Globals.ApplicationPath + "/admin/path" + document.Path + "editDocument/documentID/" + prevDoc.DocumentID + ".aspx?action=edit"; 83 } 84 } 85 86 //验证权限 87 if (!category.IsAuthorization(CategoryController.PermissionCreateDocument)) 88 { 89 lbtnAdd.Visible = false; 90 } 91 if (!category.IsAuthorization(CategoryController.PermissionUpdateDocument)) 92 { 93 lbtnUpdate.Visible = false; 94 } 95 } 96 } 97 98 void BindChildCategories(int siteID, string parentPath, int level) 99 { 100 CategoryCollection categories = CategoryController.GetChildCategories(siteID, parentPath); 101 foreach (Category c in categories) 102 { 103 ddlPath.Items.Add(new ListItem(new string('-', level * 2) + c.Title, c.CategoryID.ToString())); 104 BindChildCategories(siteID, c.Path, ++level); 105 --level; 106 } 107 } 108 109 protected void lbtnCancel_Click(object sender, EventArgs e) 110 { 111 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 112 Goto(); 113 } 114 protected void lbtnAdd_Click(object sender, EventArgs e) 115 { 116 UserInfo user = UserController.GetCurrentUserInfo(); 117 Document document = new Document(); 118 //构造文档 119 document.CategoryID = Convert.ToInt32(ddlPath.SelectedValue); 120 document.Subject = tbSubject.Text; 121 document.Name = tbName.Text.Length > 0 ? tbName.Text : null; 122 document.UserID = user.UserID; 123 //add 124 DocumentController.AddDocument(document); 125 126 //更新文档类型 127 AddTypesToDocument(document); 128 129 //更新文档的自定义属性值 130 UpdatePropertyValues(document); 131 132 //关联文档 133 AddDocumentToRelation(document); 134 135 //返回到文档 136 Goto(); 137 } 138 protected void lbtnUpdate_Click(object sender, EventArgs e) 139 { 140 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 141 int siteID = SiteController.GetCurrentSite().SiteID; 142 int documentID = int.Parse(Request.QueryString["documentID"]); 143 Category category = CategoryController.GetCategory(siteID,path); 144 UserInfo user = UserController.GetCurrentUserInfo(); 145 146 Document document = DocumentController.GetDocument(category.CategoryID, documentID); 147 document.Subject = tbSubject.Text; 148 document.Name = tbName.Text.Length > 0 ? tbName.Text : null; 149 document.CategoryID = Convert.ToInt32(ddlPath.SelectedValue); 150 151 DocumentController.UpdateDocument(document); 152 153 //更新文档类型 154 AddTypesToDocument(document); 155 156 // 157 UpdatePropertyValues(document); 158 159 //返回到文档 160 Goto(); 161 } 162 163 void AddTypesToDocument(Document document) 164 { 165 DocumentTypeController objTypeControl = new DocumentTypeController(); 166 //先清除原有的文档类型 167 objTypeControl.ClearDocumentTypes(document.DocumentID); 168 169 //依次添加 170 int[] arrSelectTypes = this.dtDocumentTypes.GetSelectTypes(); 171 for (int i = 0; i < arrSelectTypes.Length; i++) 172 { 173 objTypeControl.AddDocumentToType(document.DocumentID, arrSelectTypes[i]); 174 } 175 } 176 177 void UpdatePropertyValues(Document document) 178 { 179 WrappedRepeater rptPropertyCategories = (WrappedRepeater)PropertyDefinitions2.FindControl("rptPropertyCategories"); 180 foreach (RepeaterItem ri in rptPropertyCategories.Items) 181 { 182 if ((ri.ItemType == ListItemType.Item) || (ri.ItemType == ListItemType.AlternatingItem)) 183 { 184 WrappedRepeater rptProperties = (WrappedRepeater)ri.FindControl("rptProperties"); 185 foreach (RepeaterItem riProperty in rptProperties.Items) 186 { 187 if ((riProperty.ItemType == ListItemType.Item) || (riProperty.ItemType == ListItemType.AlternatingItem)) 188 { 189 PlaceHolder phControl = (PlaceHolder)riProperty.FindControl("phControl"); 190 if (phControl.HasControls()) 191 { 192 if (!(phControl.Controls[0] is LiteralControl)) 193 { 194 PropertyControlBase tb = (PropertyControlBase)phControl.Controls[0]; 195 document.Profile.SetProperty(((PropertyDefinition)riProperty.DataItem).Name, tb.GetValue()); 196 } 197 } 198 } 199 } 200 } 201 } 202 DocumentPropertyController.UpdatePropertyValues(document); 203 } 204 205 void AddDocumentToRelation(Document document) 206 { 207 if (Request.QueryString["relationID"] != null) 208 { 209 int relationID = Convert.ToInt32(Request.QueryString["relationID"]); 210 if (!string.IsNullOrEmpty(Request.QueryString["PrimaryDocumentID"])) 211 { 212 int primaryDocumentID = Convert.ToInt32(Request.QueryString["PrimaryDocumentID"]); 213 int primaryCategoryID = Convert.ToInt32(Request.QueryString["PrimaryCategoryID"]); 214 Document primaryDocument = DocumentController.GetDocument(primaryCategoryID,primaryDocumentID); 215 primaryDocument.AddRelationDocument(document.DocumentID, relationID); 216 } 217 else if (Request.QueryString["PrimaryCategoryID"] != null) 218 { 219 int primaryCategoryID = Convert.ToInt32(Request.QueryString["PrimaryCategoryID"]); 220 Category primaryCategory = CategoryController.GetCategory(primaryCategoryID); 221 primaryCategory.AddRelationDocument(document.DocumentID, relationID); 222 } 223 } 224 } 225 226 void Goto() 227 { 228 if (Request.QueryString["relationID"] != null) 229 { 230 int relationID = Convert.ToInt32(Request.QueryString["relationID"]); 231 Category primaryCategory = null; 232 if (Request.QueryString["PrimaryDocumentID"] != null) 233 { 234 int primaryDocumentID = Convert.ToInt32(Request.QueryString["PrimaryDocumentID"]); 235 int primaryCategoryID = Convert.ToInt32(Request.QueryString["PrimaryCategoryID"]); 236 primaryCategory = CategoryController.GetCategory(primaryCategoryID); 237 Response.Redirect(Globals.ApplicationPath + "/admin/path" + primaryCategory.Path + "categoryList.aspx?PrimaryCategoryID=" + primaryCategory.CategoryID + "&PrimaryDocumentID=" + primaryDocumentID + "&relationID=" + relationID); 238 } 239 else if (Request.QueryString["PrimaryCategoryID"] != null) 240 { 241 int primaryCategoryID = Convert.ToInt32(Request.QueryString["PrimaryCategoryID"]); 242 primaryCategory = CategoryController.GetCategory(primaryCategoryID); 243 Response.Redirect(Globals.ApplicationPath + "/admin/path" + primaryCategory.Path + "categoryList.aspx?PrimaryCategoryID=" + primaryCategory.CategoryID + "&relationID=" + relationID); 244 } 245 } 246 else 247 { 248 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 249 Response.Redirect(Globals.ApplicationPath + "/admin/path" + path + "categoryList.aspx"); 250 } 251 } 252} 253
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:破竹CMS4.0免安装版源码