Files
g.hnyhua.cn/Mtxfw.shop/_Admin/admin_ads_eadd.aspx.cs

93 lines
3.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Mtxfw.shop._Admin
{
public partial class admin_ads_eadd : Mtxfw.Utility.AdminPage
{
public Mtxfw.DAL.Ads daoAds = new Mtxfw.DAL.Ads();
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config();
public String TitName, strimg = "";
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!IsPostBack)
{
if (Request.QueryString["action"] == "add")
{
Btn_Update.Visible = false;
TitName = "添加广告";
}
else
{
TitName = "更新广告";
Btn_Insert.Visible = false;
Mtxfw.Model.Ads model = daoAds.GetModel(Int32.Parse((Request.QueryString["ID"])));
Text_AdsName.Text = model.AdsName;
Text_AdsUrl.Text = model.AdsUrl;
Text_AdsSort.Text = model.AdsSort.ToString();
hiddenphoto.Value = model.AdsPic;
}
if (hiddenphoto.Value != "")
{
strimg = "<li id='picli0'><img src='/GetFiles.ashx?image=" + hiddenphoto.Value + "&itsize=100x100&itmode=cut' width='100' class='pic'/><a href=javascript:DeletePic('" + hiddenphoto.Value + "',0)>删除</a></li>";
}
}
//添加
Btn_Insert.Click += delegate(object s, EventArgs ex)
{
if (!String.IsNullOrEmpty(Text_AdsName.Text) && !String.IsNullOrEmpty(Text_AdsUrl.Text))
{
Mtxfw.Model.Ads model = new Mtxfw.Model.Ads();
model.utype = "英文版广告";
model.AdsName = Text_AdsName.Text;
model.AdsUrl = Text_AdsUrl.Text;
model.AdsSort = int.Parse(Text_AdsSort.Text);
model.AdsPic = hiddenphoto.Value;
daoAds.Add(model);
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
Cache.Remove(CacheEnum.Key.ToString());
}
new admin_Product_list().Createtopproduct();
Response.Redirect("admin_ads_elist.aspx?utype=" + model.utype);
}
else Mtxfw.Utility.Tools.Message("请不要提交空值!");
};
//更改
Btn_Update.Click += delegate(object s, EventArgs ex)
{
if (!String.IsNullOrEmpty(Text_AdsName.Text) && !String.IsNullOrEmpty(Text_AdsUrl.Text))
{
Mtxfw.Model.Ads model = daoAds.GetModel(Int32.Parse((Request.QueryString["ID"])));
model.utype = "英文版广告";
model.AdsName = Text_AdsName.Text;
model.AdsUrl = Text_AdsUrl.Text;
model.AdsSort = int.Parse(Text_AdsSort.Text);
model.AdsPic = hiddenphoto.Value;
daoAds.Update(model);
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
Cache.Remove(CacheEnum.Key.ToString());
}
new admin_Product_list().Createtopproduct();
Response.Redirect("admin_ads_elist.aspx?utype=" + model.utype);
}
else Mtxfw.Utility.Tools.Message("请不要提交空值!");
};
}
}
}