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_add : Mtxfw.Utility.MemberBase
{
public Mtxfw.DAL.user_Goods daoGoods = new Mtxfw.DAL.user_Goods();
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 != "")
{
Mtxfw.Model.user_Goods model = new Mtxfw.Model.user_Goods();
model.GoodsName = Text_GoodsName.Text;
model.GoodsPrices = 0;
model.GoodsPrices0 = 0;
model.GoodsPrices1 = 0;
model.starttime = Text_starttime.Text;
model.endtime = Text_endtime.Text;
Mtxfw.Utility.UploadFile upload = new Utility.UploadFile(File_AdsImg.PostedFile, config.webUpPath, config.webUpType, int.Parse(config.webUpSize));
if (File_AdsImg.FileName.Length > 0)
{
upload.StatrUpFile();
model.GoodsPic = upload.UploadPath;
}
else model.GoodsPic = Hidd_Img.Value;
model.GoodsUrl = "";
model.GoodsBody = "";
model.AddTime = DateTime.Now;
model.utype = 0;
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(), "", "");
}
};
Btn_Update.Click += delegate(object s, EventArgs ex)
{
if (Hidd_ID.Value != "" && Text_GoodsName.Text != "" && Text_GoodsPrices.Text != "")
{
Int32 ID = int.Parse(Hidd_ID.Value);
Mtxfw.Model.user_Goods model = daoGoods.GetModel(ID);
if (model != null)
{
model.GoodsName = Text_GoodsName.Text;
//model.GoodsPrices = Convert.ToDouble(Text_GoodsPrices.Text);
//model.GoodsPrices0 = Convert.ToDouble(Text_GoodsPrices0.Text);
Mtxfw.Utility.UploadFile upload = new Utility.UploadFile(File_AdsImg.PostedFile, config.webUpPath, config.webUpType, int.Parse(config.webUpSize));
if (File_AdsImg.FileName.Length > 0)
{
upload.StatrUpFile();
model.GoodsPic = upload.UploadPath;
}
else model.GoodsPic = Hidd_Img.Value;
model.starttime = Text_starttime.Text;
model.endtime = Text_endtime.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(), "", "");
}
}
};
}
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("f0");
Text_GoodsPrices0.Text = model.GoodsPrices0.ToString("f0");
Text_starttime.Text = model.starttime;
Text_endtime.Text = model.endtime;
Hidd_ID.Value = model.Id.ToString();
if (!String.IsNullOrEmpty(model.GoodsPic))
{
Img_Img.Visible = true;
Img_Img.Src = Mtxfw.Utility.Common.GetCoverPic(model.GoodsPic, "80x80", config.webImgMode);
Hidd_Img.Value = model.GoodsPic;
}
else
{
Img_Img.Visible = false;
Hidd_Img.Value = String.Empty;
}
}
}
}
}
}