您目前尚未登陆,请选择【登陆】或【注册
首页->新闻文章->破竹CMS4.0免安装版源码>>admin/Categories/DocumentTypesControl.ascx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:文件类型 PozhuCMS/admin/Categories/DocumentTypesControl.ascx.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; 13using Pozhu.Sites; 14using Pozhu.CMS.Categories; 15using Pozhu.Common.Utilities; 16 17public partial class admin_Categories_DocumentTypesControl : System.Web.UI.UserControl 18{ 19 int _CategoryID = Null.NullInteger; 20 21 public int CategoryID 22 { 23 get 24 { 25 if (_CategoryID == Null.NullInteger) 26 throw new Exception("请设置CategoryID属性的值"); 27 28 return _CategoryID; 29 } 30 set { _CategoryID = value; } 31 } 32 int _DocumentID = Null.NullInteger; 33 34 public int DocumentID 35 { 36 get { return _DocumentID; } 37 set { _DocumentID = value; } 38 } 39 protected void Page_Load(object sender, EventArgs e) 40 { 41 if (!Page.IsPostBack) 42 { 43 44 DocumentTypeController objTypes = new DocumentTypeController(); 45 //邦定 46 this.rptDocumentTypes.DataSource = objTypes.GetDocumentTypeGroups(CategoryID); 47 this.rptDocumentTypes.DataBind(); 48 49 ArrayList noGroupTypes = objTypes.GetNoGroupTypes(CategoryID, true); 50 51 if (noGroupTypes.Count > 0) 52 { 53 //bind 54 foreach (DocumentType type in noGroupTypes) 55 { 56 lbNoGroupTypes.Items.Add(new ListItem(new string('-', type.Level * 2) + type.TypeName, type.TypeID.ToString())); 57 } 58 59 // 60 lbNoGroupTypes.Items.Insert(0, new ListItem("<-未分组的文档类型->", Null.NullInteger.ToString())); 61 62 //设置选中的项目 63 ItemSelected(lbNoGroupTypes); 64 } 65 else 66 { 67 lbNoGroupTypes.Visible = false; 68 } 69 } 70 } 71 protected void rptDocumentTypes_ItemDataBound(object sender, RepeaterItemEventArgs e) 72 { 73 DocumentTypeController objTypes = new DocumentTypeController(); 74 int categoryID; 75 string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 76 int siteID = SiteController.GetCurrentSite().SiteID; 77 categoryID = CategoryController.GetCategory(siteID, path).CategoryID; 78 79 if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) 80 { 81 ListBox lbTypes = (ListBox)e.Item.FindControl("lbTypes"); 82 83 DocumentTypeGroup group = (DocumentTypeGroup)(e.Item.DataItem); 84 ArrayList types = objTypes.GetDocumentTypesByGroupID(categoryID, group.TypeGroupID, true); 85 foreach (DocumentType type in types) 86 { 87 lbTypes.Items.Add(new ListItem(new string('-', type.Level * 2) + type.TypeName, type.TypeID.ToString())); 88 } 89 90 // 91 lbTypes.Items.Insert(0, new ListItem("<-" + group.TypeGroupName + "->", Null.NullInteger.ToString())); 92 93 //设置选中的项目 94 ItemSelected(lbTypes); 95 } 96 97 } 98 99 public int[] GetSelectTypes() 100 { 101 //用于存储文档类型的ID数组 102 ArrayList alSelectItems = new ArrayList(); 103 foreach (RepeaterItem ri in rptDocumentTypes.Items) 104 { 105 ListBox lbTypes = (ListBox)ri.FindControl("lbTypes"); 106 foreach (ListItem li in lbTypes.Items) 107 { 108 if ((li.Selected) && (li.Value != Null.NullInteger.ToString())) 109 { 110 alSelectItems.Add(li); 111 } 112 } 113 } 114 115 //未分组的文档类型 116 foreach (ListItem li in lbNoGroupTypes.Items) 117 { 118 if ((li.Selected) && (li.Value != Null.NullInteger.ToString())) 119 { 120 alSelectItems.Add(li); 121 } 122 } 123 124 // 125 int[] arrDocumentTypes = new int[alSelectItems.Count]; 126 for (int i = 0; i < alSelectItems.Count; i++) 127 { 128 arrDocumentTypes[i] = int.Parse(((ListItem)alSelectItems[i]).Value); 129 } 130 131 return arrDocumentTypes; 132 } 133 134 void ItemSelected(ListBox lbTypes) 135 { 136 if (DocumentID != Null.NullInteger) 137 { 138 DocumentTypeController objTypeController = new DocumentTypeController(); 139 ArrayList documentTypes = objTypeController.GetDocumentTypesByDocumentID(DocumentID); 140 foreach (ListItem item in lbTypes.Items) 141 { 142 foreach (DocumentType type in documentTypes) 143 { 144 if (type.TypeID == int.Parse(item.Value)) 145 item.Selected = true; 146 } 147 } 148 } 149 } 150} 151
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:破竹CMS4.0免安装版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号