136 lines
5.8 KiB
C#
136 lines
5.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace Mtxfw.VipSite
|
|
{
|
|
public partial class Admin_Member_goods_add1 : Mtxfw.Utility.MemberBase
|
|
{
|
|
public Mtxfw.DAL.user_Goods daoGoods = new Mtxfw.DAL.user_Goods();
|
|
public Mtxfw.DAL.user_Goods_lb daolb = new Mtxfw.DAL.user_Goods_lb();
|
|
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config("");
|
|
public String strTitle = "",strBody = "";
|
|
public int gtype = 0;
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
string hostname = Request.Url.Host;
|
|
|
|
if (!IsPostBack)
|
|
{
|
|
if (Session["IFPassword"] == null)
|
|
{
|
|
Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_goods_add.aspx");
|
|
}
|
|
if (IFStores != 1)
|
|
{
|
|
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
|
|
}
|
|
if (MemberJS.IndexOf("优惠券列表") == -1)
|
|
{
|
|
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
|
|
}
|
|
Data_Bind();
|
|
}
|
|
Btn_Insert.Click += delegate(object s, EventArgs ex)
|
|
{
|
|
if (Text_GoodsName.Text != "" && Text_GoodsPrices.Text != "")
|
|
{
|
|
try
|
|
{
|
|
Mtxfw.Model.user_Goods model = new Mtxfw.Model.user_Goods();
|
|
model.GoodsLB = 0;
|
|
model.GoodsName = Text_GoodsName.Text;
|
|
model.GoodsPrices = Convert.ToDouble(Text_GoodsPrices.Text);
|
|
model.GoodsPrices0 = 0;
|
|
model.GoodsPrices1 = 0;
|
|
model.GoodsPrices2 = 0;
|
|
model.starttime = "";
|
|
model.endtime = "";
|
|
model.GoodsPic = "";
|
|
model.GoodsUrl = "";
|
|
model.GoodsBody = "";
|
|
model.AddTime = DateTime.Now;
|
|
model.utype = 1;
|
|
model.gtype = gtype;
|
|
daoGoods.Add(model);
|
|
Model.User_CZ_log logmodel = new Model.User_CZ_log();
|
|
logmodel.MemberId = Card;
|
|
logmodel.AddTime = DateTime.Now;
|
|
logmodel.IP = Mtxfw.Utility.Common.GetIP;
|
|
logmodel.Body = "添加优惠券,名称:" + model.GoodsName + "";
|
|
logmodel.UType = 0;
|
|
logmodel.gtype = gtype;
|
|
new DAL.User_CZ_log().Add(logmodel);
|
|
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('添加成功!');location.replace('" + Hidd_Url.Value + "')</script>");
|
|
}
|
|
catch
|
|
{
|
|
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('添加失败,可能是您的输入有误!');</script>");
|
|
}
|
|
}
|
|
};
|
|
|
|
Btn_Update.Click += delegate(object s, EventArgs ex)
|
|
{
|
|
if (Hidd_ID.Value != "" && Text_GoodsName.Text != "" && Text_GoodsPrices.Text != "")
|
|
{
|
|
try
|
|
{
|
|
Int32 ID = int.Parse(Hidd_ID.Value);
|
|
Mtxfw.Model.user_Goods model = daoGoods.GetModel(ID);
|
|
model.GoodsName = Text_GoodsName.Text;
|
|
model.GoodsPrices = Convert.ToDouble(Text_GoodsPrices.Text);
|
|
|
|
daoGoods.Update(model);
|
|
Model.User_CZ_log logmodel = new Model.User_CZ_log();
|
|
logmodel.MemberId = Card;
|
|
logmodel.AddTime = DateTime.Now;
|
|
logmodel.IP = Mtxfw.Utility.Common.GetIP;
|
|
logmodel.Body = "修改优惠券,名称:" + model.GoodsName + "";
|
|
logmodel.UType = 0;
|
|
logmodel.gtype = gtype;
|
|
new DAL.User_CZ_log().Add(logmodel);
|
|
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('更新成功!');location.replace('" + Hidd_Url.Value + "')</script>");
|
|
}
|
|
catch
|
|
{
|
|
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('更新失败,可能是您的输入有误!');</script>");
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
protected void Data_Bind()
|
|
{
|
|
Hidd_Url.Value = Request.UrlReferrer.ToString();
|
|
|
|
if (Request.QueryString["ID"] == null)
|
|
{
|
|
strTitle = "添加新优惠券";
|
|
Page.Title = strTitle + " - " + GetWebName;
|
|
Btn_Update.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
strTitle = "更新优惠券";
|
|
Page.Title = strTitle + " - " + GetWebName;
|
|
Btn_Insert.Visible = false;
|
|
|
|
Mtxfw.Model.user_Goods model = daoGoods.GetModel(int.Parse(Request.QueryString["ID"]));
|
|
if (model != null)
|
|
{
|
|
Text_GoodsName.Text = model.GoodsName;
|
|
Text_GoodsPrices.Text = model.GoodsPrices.ToString();
|
|
|
|
Hidd_ID.Value = model.Id.ToString();
|
|
strBody = model.GoodsBody;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
} |