📄 templatesoperation.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 TemplatesOperation : System.Web.UI.Page
{
BasePage bp = null;
YXShop_ShopTemplates shoptemplates = new YXShop_ShopTemplates();
Model.YXShop_ShopTemplates model = new YXShop.Model.YXShop_ShopTemplates();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindThemesData();
string operationType = Request.QueryString["operationType"];
if (operationType == "Edit")
{
if (!PowerTree.PowerPass.isPass("015002004", PowerTree.PowerPanel.PowerType.update))
{
bp = new BasePage();
bp.PageError("对不起,你没有修改店铺模板的权限!", "../index.aspx");
}
BindData();
ddlThemes.Enabled = false;
}
else
{
if (!PowerTree.PowerPass.isPass("015002002", 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()
{
int tID = Convert.ToInt32(ddlThemes.Text);
//int tID = Convert.ToInt32(Request.QueryString["TID"]);
int pageID = Convert.ToInt32(Request.Form["sltTID"]);
string stName = this.txtSTName.Text;
string stContent = this.txtSTContent.Text.ToString();
int stState = Convert.ToInt32(this.rbtSTState.Text);
model.TID = tID;
model.StPageID = pageID;
model.STName = stName;
model.STContent = stContent;
model.STState = stState;
//shoptemplates.Create(model);
if (shoptemplates.Create(model) > 0)
{
alert.showAndGo("添加成功", "Templates.aspx?TID="+ddlThemes.Text);
}
else
{
alert.showOnly("添加失败");
}
}
protected string BindData()
{
int STID = Convert.ToInt32(Request.QueryString["STID"]);
List<Model.YXShop_ShopTemplates> listShopTemplates = shoptemplates.GetListByColumn("STID", STID);
if (listShopTemplates.Count > 0)
{
for (int i = 0; i < listShopTemplates.Count; i++)
{
this.txtTID.Value = listShopTemplates[i].TID.ToString();
txtSTPageID.Value = listShopTemplates[i].StPageID.ToString();
this.txtSTName.Text = listShopTemplates[i].STName.ToString();
this.txtSTContent.Text = listShopTemplates[i].STContent;
this.rbtSTState.Text = listShopTemplates[i].STState.ToString();
}
}
return null;
}
void update()
{
int STID = Convert.ToInt32(Request.QueryString["STID"]);
int tID = Convert.ToInt32(ddlThemes.Text); //Convert.ToInt32(txtTID.Value);
int stPageID = Convert.ToInt32(Request.Form["sltTID"]);
string stName = this.txtSTName.Text;
string stContent = this.txtSTContent.Text.ToString();
int stState = Convert.ToInt32(this.rbtSTState.Text);
model.STID = STID;
model.TID = tID;
model.StPageID = stPageID;
model.STName = stName;
model.STContent = stContent;
model.STState = stState;
//shoptemplates.Amend(model);
if (shoptemplates.Amend(model) > 0)
{
alert.showAndGo("修改成功", "Templates.aspx?TID="+ddlThemes.Text);
}
else
{
alert.showOnly("修改失败");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -