📄 cssoperation.aspx.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.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using YXShop.Common;
using YXShop.BLL;
using System.Collections.Generic;
using System.Text;
using Shop.Web.UI;
namespace YXShop.Web.Admin.ShopThemes
{
public partial class CssOperation : System.Web.UI.Page
{
YXShop_ShopCss shopcss = new YXShop_ShopCss();
Model.YXShop_ShopCss model = new YXShop.Model.YXShop_ShopCss();
BasePage bp = new BasePage();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//int TID =Convert.ToInt32(Request.QueryString["TID"]);
//txtTName.Text = GetTName(TID);
BindThemesData();
string operationType = Request.QueryString["operationType"];
if (operationType == "Edit")
{
if (!PowerTree.PowerPass.isPass("015003004", PowerTree.PowerPanel.PowerType.update))
{
bp = new BasePage();
bp.PageError("对不起,你没有修改店铺样式的权限!", "../index.aspx");
}
BindData();
ddlThemes.Enabled = false;
}
else
{
if (!PowerTree.PowerPass.isPass("015003002", PowerTree.PowerPanel.PowerType.add))
{
bp = new BasePage();
bp.PageError("对不起,你没有删除店铺样式的权限!", "../index.aspx");
}
}
}
}
void BindThemesData()
{
int TID = Convert.ToInt32(Request.QueryString["TID"]);
if (Cache["Themes"] == null)
{
List<Model.YXShop_ShopThemes> cacheThemes = new BLL.YXShop_ShopThemes().GetListByColumn();
Cache["Themes"] = cacheThemes;
}
List<Model.YXShop_ShopThemes> listThemes = (List<Model.YXShop_ShopThemes>)Cache["Themes"];
if (listThemes.Count > 0)
{
//foreach (Model.YXShop_ShopThemes M_Themes in listThemes)
//{
// ListItem listItemThemes = new ListItem();
// listItemThemes.Text = M_Themes.TName;
// listItemThemes.Value = M_Themes.TID;
// ddlThemes.Items.Add(listItemThemes);
//}
ddlThemes.DataSource = listThemes;
ddlThemes.DataTextField = "TName";
ddlThemes.DataValueField = "TID";
ddlThemes.DataBind();
ddlThemes.SelectedValue = TID.ToString();
}
else
{
alert.showAndGo("请先添加店铺风格", "ThemesOperation.aspx");
Response.End();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string operationType = Request.QueryString["operationType"];
if (operationType == "Edit")
{
update();
}
else
{
Add();
}
}
void Add()
{
try
{
int tID = Convert.ToInt32(ddlThemes.Text); //Convert.ToInt32(Request.QueryString["TID"]);
string scName = this.txtSCName.Text;
string scPath = this.txtSCPath.Text;
string scContent = this.txtSCContent.Text;
int scState = Convert.ToInt32(this.rbtSCState.Text);
string scPic = txtPIc.Text;
model.SCName = scName;
model.SCPath = scPath;
model.SCContent = "";//scContent;
model.TID = tID;
model.SCState = scState;
model.SCPic = scPic;
// shopcss.Create(model);
if (shopcss.Create(model) > 0)
{
YXShop.Common.FileAccessHelper.WriteTextFile(HttpContext.Current.Server.MapPath("~/") + string.Format("Skins\\ShopThemes\\{0}\\{1}.css",GetTDec(tID), scPath), scContent, false, true, System.Text.Encoding.GetEncoding("GB2312"));
bp.PageRight("添加成功","Css.aspx");
}
else
{
bp.PageError("添加失败", "Css.aspx");
}
}catch(Exception eex)
{
Response.Write(eex);
}
}
protected string BindData()
{
int SCID = Convert.ToInt32(Request.QueryString["SCID"]);
List<Model.YXShop_ShopCss> listShopCss = shopcss.GetListByColumn("SCID",SCID);
if (listShopCss.Count > 0)
{
for (int i = 0; i < listShopCss.Count; i++)
{
this.txtSCName.Text = listShopCss[i].SCName;
this.txtSCPath.Text = listShopCss[i].SCPath;
this.txtSCContent.Text = listShopCss[i].SCContent;
YXShop.Common.FileAccessHelper.ReadTextFile(HttpContext.Current.Server.MapPath("~/") + string.Format("Skins\\ShopThemes\\{0}\\{1}.css",GetTDec(Convert.ToInt32(ddlThemes.Text)), listShopCss[i].SCPath), System.Text.Encoding.GetEncoding("GB2312"));
this.rbtSCState.Text = listShopCss[i].SCState.ToString();
txtPIc.Text = listShopCss[i].SCPic;
}
}
return null;
}
protected string GetTName(int TID)
{
if (Cache["Themes"] == null)
{
List<Model.YXShop_ShopThemes> cacheThemes = new BLL.YXShop_ShopThemes().GetListByColumn();
Cache["Themes"] = cacheThemes;
}
List<Model.YXShop_ShopThemes> listThemes = (List<Model.YXShop_ShopThemes>)Cache["Themes"];
if (listThemes.Count > 0)
{
for (int i = 0; i < listThemes.Count; i++)
{
if (TID == listThemes[i].TID)
{
return listThemes[i].TName;
}
}
}
return "";
}
protected string GetTDec(int TID)
{
if (Cache["Themes"] == null)
{
List<Model.YXShop_ShopThemes> cacheThemes = new BLL.YXShop_ShopThemes().GetListByColumn();
Cache["Themes"] = cacheThemes;
}
List<Model.YXShop_ShopThemes> listThemes = (List<Model.YXShop_ShopThemes>)Cache["Themes"];
if (listThemes.Count > 0)
{
for (int i = 0; i < listThemes.Count; i++)
{
if (TID == listThemes[i].TID)
{
return listThemes[i].TDec;
}
}
}
return "";
}
void update()
{
int SCID = Convert.ToInt32(Request.QueryString["SCID"]);
string scName = this.txtSCName.Text;
string scPath = this.txtSCPath.Text;
string scContent = this.txtSCContent.Text;
int scState = Convert.ToInt32(this.rbtSCState.Text);
string scPic = txtPIc.Text;
model.SCID = SCID;
model.SCName = scName;
model.SCPath = scPath;
model.SCContent = scContent;// scContent;
model.SCState = scState;
model.SCPic = scPic;
//shopcss.Amend(model);
if (shopcss.Amend(model) > 0)
{
alert.showAndGo("修改成功", "Css.aspx");
YXShop.Common.FileAccessHelper.WriteTextFile(HttpContext.Current.Server.MapPath("~/") + string.Format("Skins\\ShopThemes\\{0}\\{1}.css", GetTDec(Convert.ToInt32(ddlThemes.Text)),scPath), scContent, false, true, System.Text.Encoding.GetEncoding("GB2312"));
}
else
{
alert.showOnly("修改失败");
}
}
protected void btnUpPic_Click(object sender, EventArgs e)
{
string path = WaterImage.waterImage(fudPic, "/Images/ShopThemesImage/", "/Images/ShopThemesImage/", "/Images/ShopThemesImage/", "/Images/ShopThemesImage/", "/Images/ShopThemesImage/", 100, 100, .8, 0.8, 0.8, 0.8, false, false, false);
txtPIc.Text = path.Split('|')[0];
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -