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_gift_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_gift_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.GoodsName = Text_GoodsName.Text; model.GoodsPrices = Convert.ToDouble(Text_GoodsPrices.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.GoodsBody = ""; model.AddTime = DateTime.Now; model.utype = 10; 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(), "", ""); } catch { ClientScript.RegisterStartupScript(this.GetType(), "", ""); } } }; 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); if (model != null) { model.GoodsName = Text_GoodsName.Text; model.GoodsPrices = Convert.ToDouble(Text_GoodsPrices.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; 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(), "", ""); } } catch { 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("f2"); Hidd_ID.Value = model.Id.ToString(); strBody = model.GoodsBody; 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; } } } } } }