protected void Button1_Click(object sender, EventArgs e) { UserHandle.UserHandle.InitModules_Admin("GGGL"); if (UserHandle.UserHandle.ValidationHandle_Admin(RoleTag.Edit)) { Daxu.Entity.advertising adverinfo = new Daxu.Entity.advertising(); adverinfo.url = url.Text.Trim(); //上传图片 string fineme = FileUpload1.FileName; string fileth = ""; string name = DateTime.Now.ToString("yyMMddHHssfff"); if (FileUpload1.HasFile) { if (fleixing(fineme)) { fileth = "~/upload/GuGao/" + name + Path.GetExtension(FileUpload1.FileName); string lujing = Server.MapPath(string.Format("~/upload/GuGao/{0}", _name.Text)); FileInfo filee = new FileInfo(lujing);//删除以前的老文件 if (filee.Exists) { filee.Delete(); } FileUpload1.SaveAs(Server.MapPath(fileth)); } adverinfo.name = name + Path.GetExtension(FileUpload1.FileName); } else { adverinfo.name = "mr.jpg"; } if (padver.Value == "1") { adverinfo.id = Convert.ToInt32(Request.QueryString["id"]); Daxu.BLL.advertisingBll.UpdateIadvertising(adverinfo); Response.Write("<script>alert(\"已经成功修改!\");window.location.href='../advertising/advertising.aspx';</script>"); } if (padver.Value == "0") { Daxu.BLL.advertisingBll.InsertIadvertising(adverinfo); Response.Write("<script>alert(\"添加成功!\");window.location.href='../advertising/advertising.aspx';</script>"); } } else { Response.Write("<script>alert(\"用户已过期!\");top.location.href='../Pageinfo/login.aspx';</script>"); } }
protected void LoadAdver() { if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["id"]))) { Daxu.Entity.advertising adverinfo = new Daxu.Entity.advertising(); string sql = "select * from advertising where id='" + Convert.ToInt32(Request.QueryString["id"]) + "'"; adverinfo = Daxu.BLL.advertisingBll.getIadvertisingModel(sql); _name.Text = adverinfo.name; url.Text = adverinfo.url; _name.ReadOnly = true; if (!string.IsNullOrEmpty(adverinfo.name)) { adverimg.ImageUrl = string.Format("~/upload/GuGao/{0}", adverinfo.name); } else { adverimg.ImageUrl = string.Format("~/upload/GuGao/{0}", "mrlogo.jpg"); } padver.Value = "1"; } }
/// <summary> /// 重载上面的函数返回对应图片的url /// </summary> /// <param name="fenlei_id"></param> /// <param name="boo"></param> /// <returns></returns> public string advertising(string fenlei_id, bool boo) { Daxu.Entity.advertising ad = new advertising(); if (boo) { string sql = "select * from advertising where fenleiid='" + fenlei_id + "'"; ad = Daxu.BLL.advertisingBll.getIadvertisingModel(sql); } return ad.url; }
protected void submit_Click1(object sender, EventArgs e) { UserHandle.UserHandle.InitModules_Admin("GGGL"); if (UserHandle.UserHandle.ValidationHandle_Admin(RoleTag.Edit)) { if (HiddenField1.Value == "2") { string fileth = ""; string fid = MusicUrl.FileName; if (file(fid)) { fid = MusicUrl.FileName; fileth = "~/upload/GuGao/" + NameBx.Value; FileInfo filee = new FileInfo(Server.MapPath(fileth)); if (filee.Exists) { filee.Delete(); } fileth = ""; fid = fid.Substring(0, fid.LastIndexOf('.')) + "_GG_MC" + DateTime.Now.ToString("yyyyHHmmssfff") + Path.GetExtension(fid); fileth = "~/upload/GuGao/" + fid; MusicUrl.SaveAs(Server.MapPath(fileth)); Daxu.Entity.advertising advertising = new Daxu.Entity.advertising(); advertising.fenlei = profenlei.SelectedValue; advertising.DengJI = Convert.ToString(tools.methods.GetFulanmu(Convert.ToInt32(profenlei.SelectedValue))); advertising.url = _url.Text; advertising.name = fid; advertising.weizhi = _weizhi.Text; advertising.id = Convert.ToInt32(Request.QueryString["id"]); Daxu.BLL.advertisingBll.UpdateIadvertising(advertising); Response.Write("<script type=\"text/javascript\">alert(\"上传成功!\"); window.close();</script>"); } else { Response.Write("<script type=\"text/javascript\">alert(\"上传格式错误!\"); window.close();</script>"); } } else if (HiddenField1.Value == "1")//添加 { string fileth; string fid = MusicUrl.FileName; if (file(fid)) { fid = fid.Substring(0, fid.LastIndexOf('.')) + "_GG_MC" + DateTime.Now.ToString("yyyyHHmmssfff") + Path.GetExtension(fid); fileth = "~/upload/GuGao/" + fid; string text = Server.MapPath(fileth); MusicUrl.SaveAs(text); Daxu.Entity.advertising advertising = new Daxu.Entity.advertising(); advertising.DengJI = Convert.ToString(tools.methods.GetFulanmu(Convert.ToInt32(profenlei.SelectedValue))); advertising.fenlei = profenlei.SelectedValue; advertising.url = _url.Text; advertising.weizhi = _weizhi.Text; advertising.name = fid; Daxu.BLL.advertisingBll.InsertIadvertising(advertising); Response.Write("<script type=\"text/javascript\">alert(\"上传成功!\"); window.close();</script>"); } else { Response.Write("<script type=\"text/javascript\">alert(\"上传格式错误!\"); window.close();</script>"); } } } else { Response.Write("<script>alert(\"对不起权限不足!\");location.href='../baseinfo/info.aspx';</script>"); } }