Beispiel #1
0
    private void addlistBind()
    {
        XYECOM.Business.NewsAuthor na = new XYECOM.Business.NewsAuthor();
        XYECOM.Business.NewsOrigin no = new XYECOM.Business.NewsOrigin();
        this.ddlnewsauthor.DataSource = na.GetDataTable("", "");
        this.ddlnewsauthor.DataTextField = "NA_Name";
        this.ddlnewsauthor.DataValueField = "NA_Name";
        this.ddlnewsauthor.DataBind();
        this.ddlnewsauthor.Items.Insert(0, new ListItem("--请选择--", ""));

        this.ddlnewsorigin.DataSource = no.GetDataTable("", "");
        this.ddlnewsorigin.DataTextField = "NO_Name";
        this.ddlnewsorigin.DataValueField = "NO_Name";
        this.ddlnewsorigin.DataBind();
        this.ddlnewsorigin.Items.Insert(0, new ListItem("--请选择--", ""));
    }
Beispiel #2
0
    /// <summary>
    /// 定义确定添加事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btadadd_Click(object sender, EventArgs e)
    {
        XYECOM.Business.NewsAuthor newsAuthorBLL = new XYECOM.Business.NewsAuthor();
        XYECOM.Business.News newsBLL = new XYECOM.Business.News();
        XYECOM.Business.NewsTitles newsTitlesBLL = new XYECOM.Business.NewsTitles();

        XYECOM.Model.NewsAuthorInfo newsAuthorInfo = new XYECOM.Model.NewsAuthorInfo();

        if (this.cbnewsauthor.Checked == true && this.tbnewsauthor.Text.ToString() != "")
        {
            int authorId = 0;
            newsAuthorInfo.NA_Name = this.tbnewsauthor.Text.ToString().Trim();
            int rowauthor = newsAuthorBLL.Insert(newsAuthorInfo, out authorId);
        }

        XYECOM.Business.NewsOrigin newsOriginBLL = new XYECOM.Business.NewsOrigin();
        XYECOM.Model.NewsOriginInfo newsOriginInfo = new XYECOM.Model.NewsOriginInfo();

        if (this.cbnewsorigin.Checked == true && this.tbnewsorigin.Text.ToString() != "")
        {
            int originId = 0;
            newsOriginInfo.NO_Name = this.tbnewsorigin.Text.ToString().Trim();
            int rowOrigin = newsOriginBLL.Insert(newsOriginInfo, out originId);
        }

        newsInfo.Title = this.tbnewsname.Text.Trim();

        newsInfo.SubTitle = this.tbtwoname.Text.Trim();

        string titleStyle = "";

        if (!this.txtTitleColor.Value.Trim().Equals("")) titleStyle += "color:" + this.txtTitleColor.Value.Trim() + ";";

        if (this.chkFontBold.Checked) titleStyle += "font-weight:bold;";

        if (this.chkFontItalic.Checked) titleStyle += "font-style:italic;";

        if (this.chkFontUnderline.Checked) titleStyle += "text-decoration:underline";

        newsInfo.TitleStyle = titleStyle;

        newsInfo.TopicType = hidTopicID.Value.Trim();

        newsInfo.Keyword = this.reswords.Text.ToString().Replace(",", ",").Replace(" ", "");
        newsInfo.Leadin = this.tbnewsness.Text.Trim();

        if (this.tbaddtime.Value.ToString() != "" && this.tbaddtime.Value.StartsWith("NaN") != true)
            newsInfo.AddTime = this.tbaddtime.Value;
        else
            newsInfo.AddTime = DateTime.Now.ToString();

        newsInfo.ClickNumber = XYECOM.Core.MyConvert.GetInt32(this.tbcount.Text.Trim());

        if (this.cbIsFlag.Checked)
            newsInfo.IsCommend = true;
        else
            newsInfo.IsCommend = false;

        if (this.cbIsDiscuss.Checked)
            newsInfo.IsAllowComment = true;
        else
            newsInfo.IsAllowComment = false;

        if (this.cbIsTop.Checked)
            newsInfo.IsTop = true;
        else
            newsInfo.IsTop = false;

        if (this.cbIsHot.Checked)
            newsInfo.IsHot = true;
        else
            newsInfo.IsHot = false;

        if (this.cbIsSlide.Checked)
            newsInfo.IsSlide = true;
        else
            newsInfo.IsSlide = false;

        if (this.cbAuditing.Checked)
        {
            newsInfo.State = XYECOM.Model.AuditingState.Passed;
        }
        else
        {
            newsInfo.State = XYECOM.Model.AuditingState.NoPass;
        }

        newsInfo.AreaIds = XYECOM.Core.Utils.AppendComma(city.Value);

        newsInfo.TradeIds = XYECOM.Core.Utils.AppendComma(tradeid.Value);

        newsInfo.ProtypeIds = XYECOM.Core.Utils.AppendComma(offerid.Value);

        if (this.cbIsScheme.Checked)
        {
            newsInfo.IsScheme = 1;
        }
        else
        {
            newsInfo.IsScheme = 0;
        }

        if (this.HidItemStr.Value != "")
        {
            string[] HSA = this.HidItemStr.Value.Split(',');
            string StrIds = "";

            for (int i = 0; i < HSA.Length; i++)
            {
                StrIds += HSA[i].Split(':')[0] + ",";
            }

            newsInfo.ProIds = StrIds.Substring(0, StrIds.Length - 1);
        }
        else
        {
            newsInfo.ProIds = "";
        }

        //如果是普通新闻,获取各参数
        if (rbcommonnews.Checked == true)
        {
            newsInfo.Type = XYECOM.Model.NewsType.TextNews;
            newsInfo.HeadlineNewsUrl = "";
            newsInfo.PicUrl = "";
            newsInfo.Author = "";

            if (!this.tbnewsauthor.Text.Trim().Equals(""))
                newsInfo.Author = this.tbnewsauthor.Text.Trim();
            else if (this.ddlnewsauthor.SelectedValue != "")
                newsInfo.Author = this.ddlnewsauthor.SelectedValue;

            newsInfo.Origin = "";

            if (!this.tbnewsorigin.Text.Trim().Equals(""))
                newsInfo.Origin = this.tbnewsorigin.Text.Trim();
            else if (this.ddlnewsorigin.SelectedValue != "")
                newsInfo.Origin = this.tbnewsorigin.Text.Trim();

            newsInfo.Content = this.newsBody.Value;
        }
        //如果是图片新闻,获取各参数
        else if (rbpicnews.Checked == true)
        {
            this.cbIsSlide.Visible = true;
            newsInfo.Type = XYECOM.Model.NewsType.ImageNews;
            newsInfo.HeadlineNewsUrl = "";

            if (this.rbpicurl.Checked == true && this.tbpinurl.Value != "")
                newsInfo.PicUrl = this.tbpinurl.Value.Trim();
            else if (this.rbpicupload.Checked == true)
                newsInfo.PicUrl = "Image";

            if (this.tbnewsauthor.Text == "")
            {
                this.hipictype.Value = "-1";
                newsInfo.Author = this.ddlnewsauthor.SelectedValue;
            }
            else
                newsInfo.Author = this.tbnewsauthor.Text;

            if (this.tbnewsorigin.Text == "")
                this.tbnewsorigin.Text = this.ddlnewsorigin.SelectedValue;
            else
                newsInfo.Origin = this.tbnewsorigin.Text;

            newsInfo.Content = this.newsBody.Value;
        }
        //如果是标题新闻,获取各参数
        else if (rbcaptionnews.Checked == true)
        {
            this.cbIsSlide.Visible = true;
            newsInfo.Type = XYECOM.Model.NewsType.HeadlineNews;
            newsInfo.HeadlineNewsUrl = this.tblinkaddress.Text;
            newsInfo.Author = "";
            newsInfo.Origin = "";
            newsInfo.PicUrl = "";

            if (this.rbpicurl.Checked == true && this.tbpinurl.Value != "")
            {
                this.hipictype.Value = "-1";
                newsInfo.PicUrl = this.tbpinurl.Value.Trim();
            }
            else if (this.rbpicupload.Checked == true)
            {
                newsInfo.PicUrl = "Image";
            }

            newsInfo.Content = "";

        }
        //记录发布人ID
        newsInfo.UM_ID = AdminId;

        Int64 ID = 0;
        int rowAff = 0;
        if (this.AddOrUpdate.Value.ToString() == "1")
        {
            newsInfo.HTMLPage = "";
            if (this.hdgetid.Value != null)   //新闻栏目编号集
            {
                newsInfo.TypeIds = XYECOM.Core.Utils.AppendComma(this.hdgetid.Value.ToString().Trim());

                int total = XYECOM.Core.MyConvert.GetInt32(this.OptionTotal.Value.ToString());

                string option = "";
                string filename = "";

                newsInfo.FileUrl = "";

                for (int i = 1; i <= total; i++)
                {
                    option = XYECOM.Core.XYRequest.GetFormString("option" + i).Trim();
                    filename = XYECOM.Core.XYRequest.GetFormString("filename" + i).Trim();

                    if (string.IsNullOrEmpty(option)) continue;

                    if (filename == "") filename = "附件" + i;

                    if (newsInfo.FileUrl.Equals(""))
                        newsInfo.FileUrl = filename + "$" + option.ToString();
                    else
                        newsInfo.FileUrl = newsInfo.FileUrl + "|" + filename + "$" + option.ToString();
                }

                rowAff = newsBLL.Insert(newsInfo, out ID);

                if (this.cbcreate.Checked)
                {
                    CreateHTML(ID.ToString(), "news", "news");
                }

                if (rowAff == -2)
                {
                    Alert("添加失败,可重新操作.", "NewsList.aspx");
                }
                else if (rowAff == -1)
                {
                    Alert("添加失败,所选栏目下已有雷同新闻.", "NewsList.aspx");
                }
                else
                {
                    UploadFile2.InfoID = ID;
                    UploadFile2.Update();

                    if (rbcommonnews.Checked == false)
                    {
                        if (this.rbpicurl.Checked == true)
                        {
                            AllowPicType();
                        }
                        else if (this.rbpicupload.Checked == true)
                        {
                            AllowPicType();
                            UploadFile1.InfoID = ID;
                            UploadFile1.Update();
                        }
                    }

                    Response.Redirect("NewsList.aspx");
                }
            }
        }
        else //修改新闻(此时,栏目是单选,即上传图片也为一张)
        {
            newsInfo.TypeIds = XYECOM.Core.Utils.AppendComma(this.hdgetid.Value.Trim());
            //newsInfo.NewsId = Convert.ToInt64(Request.QueryString["id"].ToString());

            if (rbcaptionnews.Checked == true || rbpicnews.Checked == true)
            {
                if (this.rbpicurl.Checked == true)
                {
                    AllowPicType();
                }
                else if (this.rbpicupload.Checked == true)
                {
                    AllowPicType();
                    UploadFile1.InfoID = newsInfo.NewsId;
                    UploadFile1.Update();
                }
            }

            UploadFile2.InfoID = newsInfo.NewsId;
            UploadFile2.Update();

            int total = XYECOM.Core.MyConvert.GetInt32(this.OptionTotal.Value.ToString());

            string option = "";
            string filename = "";

            newsInfo.FileUrl = "";

            for (int i = 1; i <= total; i++)
            {
                option = XYECOM.Core.XYRequest.GetFormString("option" + i).Trim();
                filename = XYECOM.Core.XYRequest.GetFormString("filename" + i).Trim();

                if (string.IsNullOrEmpty(option)) continue;

                if (filename == "") filename = "附件" + i;

                if (newsInfo.FileUrl.Equals(""))
                    newsInfo.FileUrl = filename + "$" + option.ToString();
                else
                    newsInfo.FileUrl = newsInfo.FileUrl + "|" + filename + "$" + option.ToString();
            }

            rowAff = newsBLL.Update(newsInfo);

            if (this.cbcreate.Checked)
            {
                CreateHTML(newsInfo.NewsId.ToString(), "news", "news");
            }

            if (rowAff >= 0)
            {
                Response.Redirect(XYECOM.Core.XYRequest.GetQueryString("backURL"));
            }
            else
            {
                Alert("修改新闻失败,可重新操作.", XYECOM.Core.XYRequest.GetQueryString("backURL"));
            }
        }

        newsInfo = null;
    }