protected void Page_Load(object sender, EventArgs e) { VerifyPage("", false); ePath = Server.MapPath("/UpLoad/"); try { var batta = Request.QueryString["batta"]; var name = HttpUtility.UrlDecode(HttpUtility.UrlDecode(Request.QueryString["name"])); var iid = Request.QueryString["aid"]; if (!string.IsNullOrEmpty(iid)) { var infomodel = _infosDal.GetModel(Convert.ToInt32(iid)); infomodel.AName = name; if (batta != infomodel.AImg) { var fi = new FileInfo(ePath + batta); if (fi.Exists) { fi.MoveTo(Server.MapPath("/UploadFiles/" + batta)); var ofi = new FileInfo(Server.MapPath("/UploadFiles/" + infomodel.AImg)); if (ofi.Exists) { ofi.Delete(); } infomodel.AImg = batta; } } if (_infosDal.Exists(Convert.ToInt32(iid), name)) { Response.Write("1|~|广告名称已经存在!"); Response.End(); } var upres = _infosDal.Update(infomodel); if (upres) { Response.Write("0|~|" + iid); Response.End(); } else { Response.Write("1|~|操作失败"); Response.End(); } } else { var inmodel = new Admin.Model.Advertisement(); inmodel.AName = name; inmodel.Status = 1; inmodel.CreateDate = DateTime.Now; var fi = new FileInfo(ePath + batta); if (fi.Exists) { fi.MoveTo(Server.MapPath("/UploadFiles/" + batta)); inmodel.AImg = batta; } if (_infosDal.Exists(0, name)) { Response.Write("1|~|广告名称已经存在!"); Response.End(); } var aiid = _infosDal.Add(inmodel); Response.Write("0|~|" + aiid); Response.End(); } } catch (System.Threading.ThreadAbortException ex) { } catch (Exception ee) { Response.Write("1|~|" + ee.Message); Response.End(); } }
protected void EBtnSubmit_Click(object sender, EventArgs e) { string adZoneIdList = this.GetAdZoneIdList(); if (this.Page.IsValid) { DataActionState state; AdvertisementInfo advertisementInfo = new AdvertisementInfo(); advertisementInfo.UserId = 0; advertisementInfo.ADName = this.TxtADName.Text.Trim(); advertisementInfo.ADType = DataConverter.CLng(this.RadlADType.SelectedValue); advertisementInfo.Priority = DataConverter.CLng(this.TxtPriority.Text.Trim()); advertisementInfo.Passed = this.ChkPassed.Checked; advertisementInfo.CountView = this.ChkCountView.Checked; advertisementInfo.Views = DataConverter.CLng(this.TxtViews.Text.Trim()); advertisementInfo.CountClick = this.ChkCountClick.Checked; advertisementInfo.Clicks = DataConverter.CLng(this.TxtClicks.Text.Trim()); advertisementInfo.ZoneId = adZoneIdList; advertisementInfo.ADId = DataConverter.CLng(this.HdnAdId.Value.Trim()); advertisementInfo.OverdueDate = this.DpkOverdueDate.Date; switch (advertisementInfo.ADType) { case 1: { advertisementInfo.ImgUrl = this.FileUploadControl1.FilePath; if (string.IsNullOrEmpty(advertisementInfo.ImgUrl)) { AdminPage.WriteErrMsg("图片广告请上传图片!"); } advertisementInfo.ImgHeight = DataConverter.CLng(this.TxtImgHeight.Text.Trim()); advertisementInfo.ImgWidth = DataConverter.CLng(this.TxtImgWidth.Text.Trim()); string str2 = this.TxtLinkUrl.Text.Trim(); advertisementInfo.LinkUrl = str2; advertisementInfo.LinkTarget = DataConverter.CLng(this.RadlLinkTarget.SelectedValue); advertisementInfo.LinkAlt = this.TxtLinkAlt.Text.Trim(); advertisementInfo.ADIntro = this.TxtADIntro.Text.Trim(); break; } case 2: advertisementInfo.ImgUrl = this.ExtenFileUpload.FilePath; if (string.IsNullOrEmpty(advertisementInfo.ImgUrl)) { AdminPage.WriteErrMsg("Flash广告请上传Flash!"); } advertisementInfo.ImgHeight = DataConverter.CLng(this.TxtFlashHeight.Text.Trim()); advertisementInfo.ImgWidth = DataConverter.CLng(this.TxtFlashWidth.Text.Trim()); advertisementInfo.FlashWmode = DataConverter.CLng(this.RadlFlashMode.SelectedValue); break; case 3: advertisementInfo.ADIntro = this.TxtADText.Text.Trim(); break; case 4: advertisementInfo.ADIntro = this.TxtADCode.Text.Trim(); break; case 5: advertisementInfo.ADIntro = this.TxtWebFileUrl.Text.Trim(); break; } if (this.HdnAction.Value.Trim() == "Modify") { state = Advertisement.Update(advertisementInfo); } else { state = Advertisement.Add(advertisementInfo); } switch (state) { case DataActionState.Successed: if (!string.IsNullOrEmpty(adZoneIdList)) { ADZone.CreateJS(adZoneIdList); } AdminPage.WriteSuccessMsg("保存操作广告成功!", "AdManage.aspx"); return; case DataActionState.Unknown: AdminPage.WriteErrMsg("操作失败!", "Advertisement.aspx?AdId=" + advertisementInfo.ADId + "&Action=Modify"); return; } BasePage.ResponseRedirect("AdManage.aspx"); } }