Пример #1
0
        protected void EBtnSubmit_Click(object sender, EventArgs e)
        {
            string adZoneIdList = LstZoneName.SelectedValue;

            if (this.Page.IsValid)
            {
                int             adid = DataConverter.CLng(this.HdnID.Value.Trim());
                M_Advertisement adv  = new M_Advertisement();
                adv.UserID     = 0;
                adv.ADName     = Server.HtmlEncode(this.TxtADName.Text.Trim());
                adv.ADType     = DataConverter.CLng(this.RadlADType.SelectedValue);
                adv.Priority   = DataConverter.CLng(this.TxtPriority.Text.Trim());
                adv.Passed     = ChkPasses.Checked;
                adv.CountView  = this.ChkCountView.Checked;
                adv.Views      = DataConverter.CLng(this.TxtViews.Text.Trim());
                adv.CountClick = this.ChkCountClick.Checked;
                adv.Clicks     = DataConverter.CLng(this.TxtClicks.Text.Trim());
                //adv.ZoneID = adZoneIdList;
                adv.ADID        = adid;
                adv.OverdueDate = DataConverter.CDate(this.txtOverdueDate.Text);
                adv.Setting     = "";
                adv.Price       = DataConverter.CDecimal(this.Price.Text);
                adv.ADBuy       = this.ADBuy.Checked ? 1 : 0;
                switch (adv.ADType)
                {
                case 1:
                {
                    adv.ImgUrl = this.txtpic.Text.Trim();
                    if (string.IsNullOrEmpty(adv.ImgUrl))
                    {
                        function.WriteErrMsg("图片广告的图片地址不能为空!");
                    }
                    adv.ImgHeight = DataConverter.CLng(this.TxtImgHeight.Text.Trim());
                    adv.ImgWidth  = DataConverter.CLng(this.TxtImgWidth.Text.Trim());
                    string str2 = (this.TxtLinkUrl.Text.Trim() == "http://") ? "" : this.TxtLinkUrl.Text.Trim();
                    adv.LinkUrl    = str2;
                    adv.LinkTarget = DataConverter.CLng(this.RadlLinkTarget.SelectedValue);
                    adv.LinkAlt    = this.TxtLinkAlt.Text.Trim();
                    adv.ADIntro    = this.TxtADIntro.Text.Trim();
                    adv.ImgUrl1    = this.txtpic1.Text.Trim();
                    adv.ImgHeight1 = DataConverter.CLng(this.TxtImgHeight1.Text.Trim());
                    adv.ImgWidth1  = DataConverter.CLng(this.TxtImgWidth1.Text.Trim());
                    string str3 = (this.TxtLinkUrl1.Text.Trim() == "http://") ? "" : this.TxtLinkUrl1.Text.Trim();
                    adv.LinkUrl1    = str3;
                    adv.LinkTarget1 = DataConverter.CLng(this.RadlLinkTarget1.SelectedValue);
                    adv.LinkAlt1    = this.TxtLinkAlt1.Text.Trim();
                    adv.ADIntro1    = this.TxtADIntro1.Text.Trim();
                    break;
                }

                case 2:
                    adv.ImgUrl = this.txtFlashPath.Text.Trim();
                    if (string.IsNullOrEmpty(adv.ImgUrl))
                    {
                        function.WriteErrMsg("动画广告的Flash地址不能为空");
                    }
                    adv.ImgHeight   = DataConverter.CLng(this.TxtFlashHeight.Text.Trim());
                    adv.ImgWidth    = DataConverter.CLng(this.TxtFlashWidth.Text.Trim());
                    adv.FlashWmode  = DataConverter.CLng(this.RadlFlashMode.SelectedValue);
                    adv.ImgUrl1     = this.txtFlashPath1.Text.Trim();
                    adv.ImgHeight1  = DataConverter.CLng(this.TxtFlashHeight1.Text.Trim());
                    adv.ImgWidth1   = DataConverter.CLng(this.TxtFlashWidth1.Text.Trim());
                    adv.FlashWmode1 = DataConverter.CLng(this.RadlFlashMode1.SelectedValue);
                    break;

                case 3:
                    adv.ADIntro  = this.TxtADText.Text.Trim();
                    adv.ADIntro1 = this.TxtADText1.Text.Trim();
                    break;

                case 4:
                    adv.ADIntro  = this.TxtADCode.Text.Trim();
                    adv.ADIntro1 = this.TxtADCode1.Text.Trim();
                    break;

                case 5:
                    adv.ADIntro  = this.TxtWebFileUrl.Text.Trim();
                    adv.ADIntro1 = this.TxtWebFileUrl1.Text.Trim();
                    break;
                }
                bool flag = false;
                if (adv.ADID > 0)
                {
                    flag = B_Advertisement.Advertisement_Update(adv);
                }
                else
                {
                    adv.ADID = B_Advertisement.MaxID();
                    flag     = B_Advertisement.Advertisement_Add(adv);
                    adv.ADID = B_Advertisement.MaxID() - 1;
                }
                if (flag)
                {
                    int zid = 0;
                    B_ADZone.Delete_ADZone_Ad(adv.ADID.ToString());
                    if (!string.IsNullOrEmpty(adZoneIdList))
                    {
                        if (adZoneIdList.IndexOf(',') > -1)
                        {
                            string[] arr = adZoneIdList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            for (int s = 0; s < arr.Length; s++)
                            {
                                zid = DataConverter.CLng(arr[s]);
                                if (!B_Advertisement.IsExistZoneAdv(zid, adv.ADID))
                                {
                                    B_Advertisement.Add_Zone_Advertisement(zid, adv.ADID);
                                }
                            }
                            B_ADZone.CreateJS(adZoneIdList);
                        }
                        else
                        {
                            zid = DataConverter.CLng(adZoneIdList);
                            bool isadd = false;
                            if (!B_Advertisement.IsExistZoneAdv(zid, adv.ADID))
                            {
                                isadd = B_Advertisement.Add_Zone_Advertisement(zid, adv.ADID);
                            }
                            B_ADZone.CreateJS(adZoneIdList);
                        }
                    }
                    function.WriteSuccessMsg("广告信息保存成功!", "ADManage.aspx");
                }
                else
                {
                    function.WriteErrMsg("保存失败!");
                }
            }
        }
Пример #2
0
        protected void EBtnSubmit_Click(object sender, EventArgs e)
        {
            string adZoneIdList = this.GetAdZoneIdList();

            if (this.Page.IsValid)
            {
                M_Advertisement adv = new M_Advertisement();
                adv.UserId     = 0;
                adv.AdName     = DataSecurity.HtmlEncode(this.TxtADName.Text.Trim());
                adv.AdType     = DataConverter.CLng(this.RadlADType.SelectedValue);
                adv.Priority   = DataConverter.CLng(this.TxtPriority.Text.Trim());
                adv.Passed     = this.ChkPassed.Checked;
                adv.CountView  = this.ChkCountView.Checked;
                adv.Views      = DataConverter.CLng(this.TxtViews.Text.Trim());
                adv.CountClick = this.ChkCountClick.Checked;
                adv.Clicks     = DataConverter.CLng(this.TxtClicks.Text.Trim());
                //adv.ZoneID = adZoneIdList;
                adv.AdId        = DataConverter.CLng(this.HdnID.Value.Trim());
                adv.OverdueDate = DataConverter.CDate(this.txtOverdueDate.Text);
                adv.Setting     = "";
                switch (adv.AdType)
                {
                case 1:
                {
                    adv.ImgUrl = this.txtpic.Text.Trim();
                    if (string.IsNullOrEmpty(adv.ImgUrl))
                    {
                        function.WriteErrMsg("图片广告的图片地址不能为空!");
                    }
                    adv.ImgHeight = DataConverter.CLng(this.TxtImgHeight.Text.Trim());
                    adv.ImgWidth  = DataConverter.CLng(this.TxtImgWidth.Text.Trim());
                    string str2 = this.TxtLinkUrl.Text.Trim();
                    adv.LinkUrl    = str2;
                    adv.LinkTarget = DataConverter.CLng(this.RadlLinkTarget.SelectedValue);
                    adv.LinkAlt    = this.TxtLinkAlt.Text.Trim();
                    adv.ADIntro    = this.TxtADIntro.Text.Trim();
                    break;
                }

                case 2:
                    adv.ImgUrl = this.txtFlashPath.Text.Trim();
                    if (string.IsNullOrEmpty(adv.ImgUrl))
                    {
                        function.WriteErrMsg("动画广告的Flash地址不能为空");
                    }
                    adv.ImgHeight  = DataConverter.CLng(this.TxtFlashHeight.Text.Trim());
                    adv.ImgWidth   = DataConverter.CLng(this.TxtFlashWidth.Text.Trim());
                    adv.FlashWmode = DataConverter.CLng(this.RadlFlashMode.SelectedValue);
                    break;

                case 3:
                    adv.ADIntro = this.TxtADText.Text.Trim();
                    break;

                case 4:
                    adv.ADIntro = this.TxtADCode.Text.Trim();
                    break;

                case 5:
                    adv.ADIntro = this.TxtWebFileUrl.Text.Trim();
                    break;
                }
                bool flag = false;
                if (adv.AdId > 0)
                {
                    flag = B_Advertisement.Advertisement_Update(adv);
                }
                else
                {
                    adv.AdId = B_Advertisement.MaxID();
                    flag     = B_Advertisement.Advertisement_Add(adv);
                }
                if (flag)
                {
                    int zid = 0;
                    if (!string.IsNullOrEmpty(adZoneIdList))
                    {
                        string[] arr = adZoneIdList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        for (int s = 0; s < arr.Length; s++)
                        {
                            zid = DataConverter.CLng(arr[s]);
                            if (!B_Advertisement.IsExistZoneAdv(zid, adv.AdId))
                            {
                                B_Advertisement.Add_Zone_Advertisement(zid, adv.AdId);
                            }
                        }
                        B_ADZone.CreateJS(adZoneIdList);
                    }
                    Response.Write("<script>alert('广告信息保存成功!');window.document.location.href='ADManage.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('广告信息保存失败!');</script>");
                }
            }
        }