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

📄 themesoperation.aspx.cs

📁 易想商城系统
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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 YXShop.Common;
using YXShop.BLL;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Shop.Web.UI;

namespace YXShop.Web.Admin.ShopThemes
{
    public partial class ThemesOperation : System.Web.UI.Page
    {
        YXShop_ShopThemes shopthemes = new YXShop_ShopThemes();
        Model.YXShop_ShopThemes model = new YXShop.Model.YXShop_ShopThemes();
        BasePage bp = new BasePage();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string operationType = Request.QueryString["operationType"];
                if (operationType == "Edit")
                {
                    if (!PowerTree.PowerPass.isPass("015001004", PowerTree.PowerPanel.PowerType.update))
                    {
                        bp = new BasePage();
                        bp.PageError("对不起,你没有修改店铺风格的权限!", "../index.aspx");
                    }
                    txtTDec.Enabled = false;
                    BindData();
                }
                else 
                {
                    if (!PowerTree.PowerPass.isPass("015001002", PowerTree.PowerPanel.PowerType.add))
                    {
                        bp = new BasePage();
                        bp.PageError("对不起,你没有添加店铺风格的权限!", "../index.aspx");
                    }
                }
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string operationType = Request.QueryString["operationType"];

            if (operationType == "Edit")
            {
                update();               
            }

            else
            {
                Add();
            }
        }

        int CheckDec()
        {
            string tDec = this.txtTDec.Text;
            List<Model.YXShop_ShopThemes> listShopThemes = shopthemes.GetListByColumn("TDec",tDec);
            if (listShopThemes.Count > 0)
            {
                return listShopThemes[0].TID;
            }
            else { return 0; }
        }

        void Add()
        {
            //if (!(CheckDec()==0)) { alert.showOnly("文件夹名称已经存在"); return;}
            string folder = YXShop.Common.WebUtility.StringToHtml(txtTDec.Text);
            DirectoryInfo dInfo = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/Skins/ShopThemes"));
            foreach (DirectoryInfo dir in dInfo.GetDirectories())
            {
                if (folder == dir.ToString())
                {
                    ClientScript.RegisterStartupScript(GetType(), "error", "alert('文件夹名称已经存在!');", true);
                    return;
                }
            }
 


            string tName = this.txtTName.Text;
            string tInfo = this.txtTInfo.Text;
            string tDec = this.txtTDec.Text;
            int tState = Convert.ToInt32(this.rbtTState.Text);

            model.TName = tName;
            model.TInfo = tInfo;
            model.TDec = tDec;
            model.TState = tState;

            if (shopthemes.Create(model) > 0)
            {
                string dirName = HttpContext.Current.Server.MapPath("~/") + "Skins\\ShopThemes\\" + tDec + "\\";
                if (!Directory.Exists(dirName))
                {
                    Directory.CreateDirectory(dirName);
                    bp.PageRight("创建成功.", "Themes.aspx");
                }
                Cache.Remove("Themes");

            }
            else
            {
                bp.PageError("创建失败.", "Themes.aspx");
            }
        }

        protected string BindData()
        {
            int TID = Convert.ToInt32(Request.QueryString["TID"]);
            List<Model.YXShop_ShopThemes> listShopThemes = shopthemes.GetListByColumn("TID",TID);
            if (listShopThemes.Count > 0)
            {
                for (int i = 0; i < listShopThemes.Count; i++)
                {
                    this.txtTName.Text = listShopThemes[i].TName.ToString();
                    this.txtTInfo.Text = listShopThemes[i].TInfo.ToString();
                    this.txtTDec.Text = listShopThemes[i].TDec.ToString();
                    this.rbtTState.Text = listShopThemes[i].TState.ToString();
                }
            }
            return null;
        }

        void update()
        {
            int existName =CheckDec();
            int TID = Convert.ToInt32(Request.QueryString["TID"]);
            if (!(existName == 0)) { if (existName != TID) { alert.showOnly("文件夹名称已经存在"); return; } }
            
            string tName = this.txtTName.Text;
            string tInfo = this.txtTInfo.Text;
            string tDec = this.txtTDec.Text;
            int tState = Convert.ToInt32(this.rbtTState.Text);

            model.TID = TID;
            model.TName = tName;
            model.TInfo = tInfo;
            model.TDec = tDec;
            model.TState = tState;

            if(shopthemes.Amend(model)>0)
            {
                bp.PageRight("修改成功.", "Themes.aspx");
            }
            else bp.PageError("修改失败.", "Themes.aspx");
        }
    }
}

⌨️ 快捷键说明

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