您目前尚未登陆,请选择【登陆】或【注册
首页->新闻文章->破竹CMS4.0免安装版源码>>admin/PropertyDefinition/EditPropertyDefinition.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
普通视图
		            
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.Categories; 12using Pozhu.Sites; 13using Pozhu.CMS.PropertyDefinitions; 14using Pozhu.CMS.Documents; 15using Pozhu.Common.Utilities; 16using Pozhu.CMS.Web; 17 18public partial class admin_PropertyDefinition_EditPropertyDefinition : 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 // 27 string identify = Request.QueryString["Identify"]; 28 PropertyDefinitionControllerBase pdController = null; 29 if (identify.ToLower() == "category") 30 { 31 pdController = new CategoryPropertyDefinitionController(); 32 } 33 else if (identify.ToLower() == "document") 34 { 35 pdController = new DocumentPropertyDefinitionController(); 36 } 37 38 // 39 ddlSerializeAs.DataSource = Enum.GetNames(typeof(SerializeAs)); 40 ddlSerializeAs.DataBind(); 41 42 // 43 ddlPropertyCategory.DataSource = pdController.GetPropertyCategories(categoryID); 44 ddlPropertyCategory.DataBind(); 45 ddlPropertyCategory.Items.Insert(0, new ListItem("不指定分类", "-1")); 46 ddlPropertyType.Attributes.Add("onchange", "selectPropertyType_onchange('" + this.tbPropertyType.ClientID + "')"); 47 48 // 49 string action = Request.QueryString["action"]; 50 if (action == "add") 51 { 52 this.lbtnUpdate.Visible = false; 53 } 54 else if (action == "edit") 55 { 56 // 57 int propertyID = int.Parse(Request.QueryString["PropertyDefinitionID"]); 58 PropertyDefinition pd = pdController.GetProperty(propertyID); 59 60 // 61 this.tbDescription.Text = pd.Description; 62 this.tbName.Text = pd.Name; 63 this.ddlPropertyCategory.SelectedValue = pd.PropertyCategoryID.ToString(); 64 this.tbPropertyType.Text = pd.PropertyType.AssemblyQualifiedName.Substring(0, pd.PropertyType.AssemblyQualifiedName.IndexOf(",", pd.PropertyType.AssemblyQualifiedName.IndexOf(",") + 1)); 65 this.ddlPropertyType.SelectedValue = pd.PropertyType.FullName; 66 this.ddlSerializeAs.SelectedValue = pd.SerializeAs.ToString(); 67 this.cbRequired.Checked = pd.Required; 68 69 lbtnAdd.Visible = false; 70 } 71 } 72 73 } 74 protected void lbtnCancel_Click(object sender, EventArgs e) 75 { 76 string identify = Request.QueryString["Identify"]; 77 78 Response.Redirect("PropertyDefinitions.aspx?tabindex=" + Request.QueryString["tabindex"] + "&path=" + Request.QueryString["path"] + "&identify=" + identify); 79 } 80 protected void lbtnAdd_Click(object sender, EventArgs e) 81 { 82 int siteID = SiteController.GetCurrentSite().SiteID; 83 int categoryID = CategoryController.GetCategory(siteID, Request.QueryString["path"]).CategoryID; 84 85 // 86 string redirectUrl = Null.NullString; 87 string identify = Request.QueryString["Identify"]; 88 PropertyDefinitionControllerBase pdController = null; 89 if (identify.ToLower() == "category") 90 { 91 pdController = new CategoryPropertyDefinitionController(); 92 } 93 else if (identify.ToLower() == "document") 94 { 95 pdController = new DocumentPropertyDefinitionController(); 96 } 97 98 // 99 PropertyDefinition pd = new PropertyDefinition(); 100 pd.Name = tbName.Text; 101 pd.Description = tbDescription.Text; 102 pd.CategoryID = categoryID; 103 pd.PropertyCategoryID = int.Parse(ddlPropertyCategory.SelectedValue); 104 try 105 { 106 pd.PropertyType = Type.GetType(tbPropertyType.Text, true, true); 107 } 108 catch (Exception exc) 109 { 110 plState.CssClass = "warning"; 111 plState.Controls.Add(new LiteralControl(exc.Message)); 112 return; 113 } 114 pd.Required = cbRequired.Checked; 115 pd.SerializeAs = (SerializeAs)Enum.Parse(typeof(SerializeAs), ddlSerializeAs.SelectedValue); 116 117 //添加 118 try 119 { 120 pdController.AddProperty(pd); 121 // 122 Response.Redirect("PropertyDefinitions.aspx?tabindex=" + Request.QueryString["tabindex"] + "&path=" + Request.QueryString["path"] + "&identify=" + identify); 123 } 124 catch (Exception exc) 125 { 126 plState.CssClass = "warning"; 127 plState.Controls.Add(new LiteralControl(exc.Message)); 128 } 129 130 } 131 protected void lbtnUpdate_Click(object sender, EventArgs e) 132 { 133 int siteID = SiteController.GetCurrentSite().SiteID; 134 int categoryID = CategoryController.GetCategory(siteID, Request.QueryString["path"]).CategoryID; 135 136 // 137 string redirectUrl = Null.NullString; 138 string identify = Request.QueryString["Identify"]; 139 PropertyDefinitionControllerBase pdController = null; 140 if (identify.ToLower() == "category") 141 { 142 pdController = new CategoryPropertyDefinitionController(); 143 } 144 else if (identify.ToLower() == "document") 145 { 146 pdController = new DocumentPropertyDefinitionController(); 147 } 148 149 // 150 int propertyID = int.Parse(Request.QueryString["PropertyDefinitionID"]); 151 PropertyDefinition pd = pdController.GetProperty(propertyID); 152 pd.Name = tbName.Text; 153 pd.Description = tbDescription.Text; 154 pd.CategoryID = categoryID; 155 pd.PropertyCategoryID = int.Parse(ddlPropertyCategory.SelectedValue); 156 try 157 { 158 pd.PropertyType = Type.GetType(tbPropertyType.Text, true, true); 159 } 160 catch (Exception exc) 161 { 162 plState.CssClass = "warning"; 163 plState.Controls.Add(new LiteralControl(exc.Message)); 164 return; 165 } 166 pd.Required = cbRequired.Checked; 167 pd.SerializeAs = (SerializeAs)Enum.Parse(typeof(SerializeAs), ddlSerializeAs.SelectedValue); 168 169 //更新 170 try 171 { 172 pdController.UpdateProperty(pd); 173 // 174 Response.Redirect("PropertyDefinitions.aspx?tabindex=" + Request.QueryString["tabindex"] + "&path=" + Request.QueryString["path"] + "&identify=" + identify); 175 } 176 catch (Exception exc) 177 { 178 plState.CssClass = "warning"; 179 plState.Controls.Add(new LiteralControl(exc.Message)); 180 } 181 182 } 183} 184
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:破竹CMS4.0免安装版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号