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

📄 includefileui.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.Template
{
    using AjaxControlToolkit;
    using PowerEasy.Components;
    using PowerEasy.Controls;
    using PowerEasy.Enumerations;
    using PowerEasy.Model.TemplateProc;
    using PowerEasy.Model.Templates;
    using PowerEasy.Templates;
    using PowerEasy.Web.UI;
    using System;
    using System.IO;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class IncludeFileUI : AdminPage
    {
        protected AlternateLiteral AltrTitle;
        protected Button BtnSaveIncludeFile;
        protected DropDownList DropLabelList;
        protected DropDownList DropPagerList;
        protected Label LblLabelList;
        protected Label LblPageList;
        protected RadioButtonList RadlAssociateType;
        protected RadioButtonList RadlIncludeType;
        protected RegularExpressionValidator RegTxtFileName;
        protected PowerEasy.Controls.RequiredFieldValidator ReqTxtFileName;
        protected PowerEasy.Controls.RequiredFieldValidator ReqTxtName;
        protected ScriptManager ScriptManager1;
        protected ExtendedSiteMapPath SmpNavigator;
        protected TabContainer TabContainer1;
        protected TabPanel TabPanel1;
        protected TabPanel TabPanel2;
        protected TabPanel TabPanel3;
        protected TabPanel TabPanel4;
        protected TextBox TxtDescription;
        protected TextBox TxtFileName;
        protected TextBox TxtName;
        protected TextBox TxtTemplate;
        protected System.Web.UI.UpdatePanel UpdatePanel1;
        protected System.Web.UI.UpdatePanel UpdatePanel2;

        private void BindDataToControls()
        {
            IncludeFileInfo includeFileInfoById = IncludeFile.GetIncludeFileInfoById(BasePage.RequestInt32("id"));
            if (!includeFileInfoById.IsNull)
            {
                this.TxtName.Text = includeFileInfoById.Name;
                this.ViewState["Name"] = includeFileInfoById.Name;
                this.TxtDescription.Text = includeFileInfoById.Description;
                this.TxtFileName.Text = includeFileInfoById.FileName;
                this.ViewState["FileName"] = includeFileInfoById.FileName;
                this.RadlIncludeType.SelectedValue = Enum.GetName(typeof(IncludeType), includeFileInfoById.IncludeType);
                this.RadlAssociateType.SelectedValue = Enum.GetName(typeof(AssociateType), includeFileInfoById.AssociateType);
                this.TxtTemplate.Text = includeFileInfoById.Template;
            }
            else
            {
                AdminPage.WriteErrMsg("您修改的内嵌代码不存在!", "IncludeFileManage.aspx");
            }
        }

        protected void BtnSaveIncludeFile_Click(object sender, EventArgs e)
        {
            IncludeFileInfo includeFileInfo = new IncludeFileInfo();
            includeFileInfo.Id = BasePage.RequestInt32("id");
            includeFileInfo.Name = this.TxtName.Text;
            includeFileInfo.FileName = this.TxtFileName.Text;
            includeFileInfo.Description = this.TxtDescription.Text;
            includeFileInfo.Template = this.TxtTemplate.Text;
            includeFileInfo.IncludeType = (IncludeType) Enum.Parse(typeof(IncludeType), this.RadlIncludeType.SelectedValue);
            includeFileInfo.AssociateType = (AssociateType) Enum.Parse(typeof(AssociateType), this.RadlAssociateType.SelectedValue);
            if (BasePage.RequestStringToLower("action") == "modify")
            {
                if ((includeFileInfo.Name != this.ViewState["Name"].ToString()) && IncludeFile.ExistsName(includeFileInfo.Name))
                {
                    AdminPage.WriteErrMsg("内嵌代码名称已经存在");
                }
                bool flag = string.Compare(includeFileInfo.FileName, this.ViewState["FileName"].ToString(), true) != 0;
                if (flag && IncludeFile.ExistsFileName(includeFileInfo.FileName))
                {
                    AdminPage.WriteErrMsg("内嵌代码文件名已经存在");
                }
                if (IncludeFile.Update(includeFileInfo))
                {
                    if (flag)
                    {
                        string includeFilePath = SiteConfig.SiteOption.IncludeFilePath;
                        includeFilePath = "~/" + includeFilePath + "/" + this.ViewState["FileName"].ToString();
                        FileInfo info2 = new FileInfo(HttpContext.Current.Request.MapPath(includeFilePath));
                        if (info2.Exists)
                        {
                            info2.Delete();
                        }
                    }
                    AdminPage.WriteSuccessMsg("修改成功", "IncludeFileManage.aspx");
                }
                else
                {
                    AdminPage.WriteErrMsg("修改失败", "IncludeFileManage.aspx");
                }
            }
            else
            {
                if (IncludeFile.ExistsName(includeFileInfo.Name))
                {
                    AdminPage.WriteErrMsg("内嵌代码名称已经存在");
                }
                if (IncludeFile.ExistsFileName(includeFileInfo.FileName))
                {
                    AdminPage.WriteErrMsg("内嵌代码文件名已经存在");
                }
                if (IncludeFile.Add(includeFileInfo))
                {
                    AdminPage.WriteSuccessMsg("添加成功", "IncludeFileManage.aspx");
                }
                else
                {
                    AdminPage.WriteErrMsg("添加失败", "IncludeFileManage.aspx");
                }
            }
        }

        protected void BuildLabelList(string typename)
        {
            this.LblLabelList.Text = string.Empty;
            foreach (LabelManageInfo info in LabelManage.GetLabelList(typename))
            {
                string text = this.LblLabelList.Text;
                this.LblLabelList.Text = text + "<div onclick=\"cit()\" outype=\"1\" class=\"spanfixdiv\" alt=\"" + info.Intro + "\">" + info.Name + "</div>";
            }
        }

        protected void BuildPagerList(string typename)
        {
            this.LblPageList.Text = string.Empty;
            foreach (PagerManageInfo info in PagerManage.GetPagerList(typename))
            {
                string text = this.LblPageList.Text;
                this.LblPageList.Text = text + "<div onclick=\"cit()\" outype=\"2\" class=\"spanfixdiv\" alt=\"" + info.Intro + "\">" + info.Name + "</div>";
            }
        }

        protected void DropLabelList_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.BuildLabelList(this.DropLabelList.SelectedValue);
        }

        protected void DropPagerList_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.BuildPagerList(this.DropPagerList.SelectedValue);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            string str = BasePage.RequestStringToLower("action");
            this.TxtTemplate.Attributes.Add("onmouseup", "dragend(this)");
            this.TxtTemplate.Attributes.Add("onClick", "savePos(this)");
            this.TxtTemplate.Attributes.Add("onmousemove", "DragPos(this)");
            this.RegTxtFileName.ValidationExpression = "^[^\\\\\\./:\\*\\?\\\"<>\\|]{1}[^\\\\/:\\*\\.\\?\\\"<>\\|]{0,254}\\.[^\\\\/:\\*\\.\\?\\\"<>\\|]{1,8}$";
            this.RegTxtFileName.ErrorMessage = "文件名格式不正确";
            if (!base.IsPostBack)
            {
                ListItem item = new ListItem();
                item.Text = "全部分类";
                this.DropLabelList.DataSource = LabelManage.GetLabelTypeList();
                this.DropLabelList.DataTextField = "Name";
                this.DropLabelList.DataValueField = "Name";
                this.DropLabelList.DataBind();
                this.DropLabelList.Items.Insert(0, item);
                this.DropPagerList.DataSource = PagerManage.GetPagerTypeList();
                this.DropPagerList.DataTextField = "Name";
                this.DropPagerList.DataValueField = "Name";
                this.DropPagerList.DataBind();
                this.DropPagerList.Items.Insert(0, item);
                this.BuildLabelList(string.Empty);
                this.BuildPagerList(string.Empty);
            }
            if ((str == "modify") && !base.IsPostBack)
            {
                this.BindDataToControls();
            }
        }
    }
}

⌨️ 快捷键说明

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