managedocumentcustomproperty.aspx.cs

来自「ASP.NET多线程编程(二),ASP.NET多线程编程(二) .」· CS 代码 · 共 79 行

CS
79
字号
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_ManageDocumentCustomProperty : 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"];

            ddlSerializeAs.DataSource = Enum.GetNames(typeof(CustomSerializeAs));
            ddlSerializeAs.DataBind();
            if (dataProviderAction.ToLower() == "update")
            {
                CustomProperty property = DocumentCustomPropertyController.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 = DocumentCustomPropertyController.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);
            DocumentCustomPropertyController.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;
            DocumentCustomPropertyController.Instance().AddCustomProperty(property);
        }
        Response.Redirect(path.Substring(1) + "DocumentCustomProperties.aspx");
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string customName = Request.QueryString["name"];
        string path = Request.QueryString["path"];
        DocumentCustomPropertyController.Instance().DeleteCustomProperty(path, customName);
        Response.Redirect(path.Substring(1) + "DocumentCustomProperties.aspx");
    }
    protected void lbtnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect(Request.QueryString["path"].Substring(1) + "DocumentCustomProperties.aspx");
    }
}

⌨️ 快捷键说明

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