⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 managecategorycustomproperty.aspx.cs

📁 ASP.NET多线程编程(二),ASP.NET多线程编程(二) .
💻 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 Zeroone.Custom;
using Zeroone.FileSystem;

public partial class Admin_ManageCategoryCustomProperty : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string customName = Request.QueryString["name"];
            string dataProviderAction = string.IsNullOrEmpty(Request.QueryString["action"]) ? "insert" : Request.QueryString["action"];
            string path = Request.QueryString["path"];
            ViewState["ReferralLink"] = Request.UrlReferrer.ToString();

            ddlSerializeAs.DataSource = Enum.GetNames(typeof(CustomSerializeAs));
            ddlSerializeAs.DataBind();
            if (dataProviderAction.ToLower() == "update")
            {
                CustomProperty property = CategoryCustomPropertyController.Instance().GetCustomProperty(path, customName);
                tbName.Text = property.Name;
                tbDefaultValue.Text = property.DefaultValue.ToString();
                tbPropertyType.Text = property.PropertyType.AssemblyQualifiedName;
                ddlSerializeAs.SelectedValue = property.SerializeAs.ToString();
                btnEdit.Text = "更新";

                btnDelete.Visible = true;
            }
        }

    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        string customName = Request.QueryString["name"];
        string dataProviderAction = string.IsNullOrEmpty(Request.QueryString["action"]) ? "insert" : Request.QueryString["action"];
        string path = Request.QueryString["path"];

        if (dataProviderAction.ToLower() == "update")
        {
            CustomProperty property = CategoryCustomPropertyController.Instance().GetCustomProperty(path, customName);
            property.Name = tbName.Text;
            property.DefaultValue = tbDefaultValue.Text;
            property.PropertyType = Type.GetType(tbPropertyType.Text);
            property.SerializeAs = (CustomSerializeAs)Enum.Parse(typeof(CustomSerializeAs), ddlSerializeAs.SelectedValue);
            CategoryCustomPropertyController.Instance().UpdateCustomProperty(property);
        }
        else if (dataProviderAction.ToLower() == "insert")
        {
            CustomProperty property = new CustomProperty();
            property.Name = tbName.Text;
            property.DefaultValue = tbDefaultValue.Text;
            property.PropertyType = Type.GetType(tbPropertyType.Text);
            property.SerializeAs = (CustomSerializeAs)Enum.Parse(typeof(CustomSerializeAs), ddlSerializeAs.SelectedValue);
            property.Path = path;
            CategoryCustomPropertyController.Instance().AddCustomProperty(property);
        }

        //转向链接
        if (ViewState["ReferralLink"] == null)
            Response.Redirect(path.Substring(1) + "CategoryCustomProperties.aspx");
        else
            Response.Redirect(ViewState["ReferralLink"].ToString());
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string customName = Request.QueryString["name"];
        string path = Request.QueryString["path"];
        CategoryCustomPropertyController.Instance().DeleteCustomProperty(path, customName);

        //转向链接
        if (ViewState["ReferralLink"] == null)
            Response.Redirect(path.Substring(1) + "CategoryCustomProperties.aspx");
        else
            Response.Redirect(ViewState["ReferralLink"].ToString());
    }
    protected void lbtnCancel_Click(object sender, EventArgs e)
    {
        //转向链接
        if (ViewState["ReferralLink"] == null)
            Response.Redirect(Request.QueryString["path"].Substring(1) + "CategoryCustomProperties.aspx");
        else
            Response.Redirect(ViewState["ReferralLink"].ToString());
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -