Exemple #1
0
    /// <summary>
    /// 定义页面加载事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpContext.Current.Response.Buffer = true;
        HttpContext.Current.Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
        HttpContext.Current.Response.Expires = 0;

        CheckRole("news");
        if (!IsPostBack)
        {
            addlistBind();

            this.imagetype.Value = webInfo.UploadFileType;

            newsId = XYECOM.Core.XYRequest.GetQueryInt64("id");

            if (newsId > 0)
            {

                UploadFile1.InfoID = newsId;
                UploadFile2.InfoID = newsId;

                NewsDataBind(newsId);
                //this.AddOrUpdate的值为0,则表示修改新闻
                this.AddOrUpdate.Value = "0";
            }
            else
            {
                newsInfo = new XYECOM.Model.NewsInfo();
                InitOption("");
                //this.AddOrUpdate的值为1,则表示添加新闻
                this.AddOrUpdate.Value = "1";
                this.rbcommonnews.Checked = true;
                this.hipictype.Value = "0";
                this.reswords.Text = "";
                this.IsContributor.Visible = false;
                this.tbnewsauthor.Text = webInfo.WebName;
                this.tbnewsorigin.Text = webInfo.WebName;
                this.infoIds.Value = "";
                //ClientScript.RegisterStartupScript(GetType(), Guid.NewGuid().ToString(), "myclick('" + this.rbpicupload.ClientID + "','click');", true);
                //ClientScript.RegisterStartupScript(GetType(), Guid.NewGuid().ToString(), "myclick('" + this.rbcommonnews.ClientID + "','click');", true);
            }

            #region 加载JS事件
            this.rbcommonnews.Attributes.Add("onclick", "javascript:return TypeChange();");
            this.rbpicnews.Attributes.Add("onclick", "javascript:return TypeChange();");
            this.rbcaptionnews.Attributes.Add("onclick", "javascript:return TypeChange();");

            this.btadadd.Attributes.Add("onclick", "javascript:return Input();");
            this.ddlnewsauthor.Attributes.Add("onchange", "javascript:return getauthor();");
            this.ddlnewsorigin.Attributes.Add("onchange", "javascript:return getorigin();");
            this.rbpicurl.Attributes.Add("onclick", "javascript:return ChangePicType();");
            this.rbpicupload.Attributes.Add("onclick", "javascript:return ChangePicType();");
            #endregion
        }
    }
Exemple #2
0
    /// <summary>
    /// 绑定要修改的新闻信息
    /// </summary>
    /// <param name="id">要修改的新闻ID</param>
    private void NewsDataBind(Int64 id)
    {
        newsInfo = new XYECOM.Business.News().GetItem(newsId);

        if (newsInfo != null)
        {
            string newstypeckId = "";
            //新闻类型
            if (newsInfo.Type == XYECOM.Model.NewsType.TextNews)
            {
                this.rbcommonnews.Checked = true;
                this.rbpicnews.Checked = false;
                this.rbcaptionnews.Checked = false;
                newstypeckId = this.rbcommonnews.ClientID;
            }
            else if (newsInfo.Type == XYECOM.Model.NewsType.ImageNews)
            {
                this.rbpicnews.Checked = true;
                this.rbcommonnews.Checked = false;
                this.rbcaptionnews.Checked = false;
                newstypeckId = this.rbpicnews.ClientID;
            }
            else if (newsInfo.Type == XYECOM.Model.NewsType.HeadlineNews)
            {
                this.rbcaptionnews.Checked = true;
                this.rbcommonnews.Checked = false;
                this.rbpicnews.Checked = false;
                newstypeckId = this.rbcaptionnews.ClientID;
            }

            this.tbnewsname.Text = newsInfo.Title;

            //if (newsInfo.FileUrl != "")
            //{
            //    rbfileUrl.Checked = true;
            //    txtfileUrl.Text = newsInfo.FileUrl;
            //}

            if (!newsInfo.TitleStyle.Equals(""))
            {
                string[] strs = newsInfo.TitleStyle.Split(';');

                foreach (string s in strs)
                {
                    if (s.Equals("")) continue;

                    string[] ss = s.Split(':');

                    if (ss.Length != 2) continue;

                    if (ss[0].Equals("color"))
                    {
                        this.txtTitleColor.Value = ss[1];
                        this.selTitleColor.Value = ss[1];
                    }

                    if (ss[0].Equals("font-weight")) this.chkFontBold.Checked = true;

                    if (ss[0].Equals("font-style")) this.chkFontItalic.Checked = true;

                    if (ss[0].Equals("text-decoration")) this.chkFontUnderline.Checked = true;
                }
            }

            if (newsInfo.TypeIds != "")
            {
                this.hdgetid.Value = XYECOM.Core.Utils.RemoveComma(newsInfo.TypeIds.ToString());
            }

            hidTopicID.Value = newsInfo.TopicType;

            this.tbtwoname.Text = newsInfo.SubTitle;
            this.reswords.Text = newsInfo.Keyword;
            this.tbnewsness.Text = newsInfo.Leadin;
            this.tblinkaddress.Text = newsInfo.HeadlineNewsUrl;

            //附件信息
            DataTable tableAttInfo = new XYECOM.Business.Attachment().GetDataTable(newsInfo.NewsId, XYECOM.Model.AttachmentItem.News, XYECOM.Model.UploadFileType.Image);
            string uploadTypeckId = "";
            if (tableAttInfo.Rows.Count > 0 && newsInfo.PicUrl.Equals("Image"))
            {
                this.rbpicupload.Checked = true;
                this.rbpicurl.Checked = false;

                uploadTypeckId = this.rbpicupload.ClientID;
            }
            else
            {
                this.hipictype.Value = "-1";
                this.hdpicurl.Value = newsInfo.PicUrl;
                this.rbpicurl.Checked = true;
                this.rbpicupload.Checked = false;
                this.tbpinurl.Value = newsInfo.PicUrl;
                uploadTypeckId = this.rbpicurl.ClientID;
            }

            this.tbnewsauthor.Text = newsInfo.Author;
            this.ddlnewsauthor.SelectedValue = this.tbnewsauthor.Text.Trim();
            this.tbnewsorigin.Text = newsInfo.Origin;
            this.ddlnewsorigin.SelectedValue = this.tbnewsorigin.Text.Trim();
            this.newsBody.Value = newsInfo.Content;

            if (newsInfo.AddTime != "")
            {
                try
                {
                    this.tbaddtime.Value = Convert.ToDateTime(newsInfo.AddTime).ToShortDateString();
                }
                catch
                {
                    this.tbaddtime.Value = DateTime.Now.ToShortDateString();
                }
            }

            this.tbcount.Text = newsInfo.ClickNumber.ToString();

            this.cbIsFlag.Checked = newsInfo.IsCommend;

            this.cbIsDiscuss.Checked = newsInfo.IsAllowComment;

            this.cbIsTop.Checked = newsInfo.IsTop;

            this.cbIsHot.Checked = newsInfo.IsHot;

            this.cbIsSlide.Checked = newsInfo.IsSlide;

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

            if (newsInfo.ChargeState != "1")
            {
                if (newsInfo.HTMLPage != "")
                {
                    this.cbcreate.Checked = true;
                }
            }
            else
            {
                this.cbcreate.Enabled = false;
            }

            if (newsInfo.Contributor.Equals(0))
            {
                this.IsContributor.Visible = false;
            }
            else
            {
                if (newsInfo.Contributor.ToString() == "-1")
                {
                    this.Contributor.InnerHtml = "<a href=\"#\">游客</a>";
                }
                else
                {
                    XYECOM.Business.UserReg urBLL = new UserReg();
                    XYECOM.Model.UserRegInfo urinfo = new XYECOM.Model.UserRegInfo();
                    urinfo = urBLL.GetItem(newsInfo.Contributor);
                    if (!urinfo.Type)
                        this.Contributor.InnerHtml = "<a href=\"../UserManage/IndividualInfo.aspx?U_ID=" + newsInfo.Contributor + "&backURL=../news/AddNews.aspx?id=" + newsId + "&" + XYECOM.Core.XYRequest.GetQueryString("backURL") + "\">" + newsInfo.Author + "(个人会员)</a>";
                    else
                        this.Contributor.InnerHtml = "<a href=\"../UserManage/UserInfo.aspx?U_ID=" + newsInfo.Contributor + "&backURL=../news/AddNews.aspx?id=" + newsId + "&" + XYECOM.Core.XYRequest.GetQueryString("backURL") + "\">" + newsInfo.Author + "(企业会员)</a>";
                }

            }

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

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

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

            InitOption(newsInfo.FileUrl);

            ClientScript.RegisterStartupScript(GetType(), Guid.NewGuid().ToString(), "myclick('" + newstypeckId + "','click');", true);
            ClientScript.RegisterStartupScript(GetType(), Guid.NewGuid().ToString(), "myclick('" + uploadTypeckId + "','click');", true);

            if (newsInfo.IsScheme == 1)
                this.cbIsScheme.Checked = true;

            if (newsInfo.IsScheme != 0 && newsInfo.ProIds != null)
            {
                string StrHtml = "";
                string[] IdsArry = newsInfo.ProIds.Split(',');
                string ItemStr = "";

                for (int i = 0; i < IdsArry.Length; i++)
                {
                    if (IdsArry[i] != null)
                    {
                        XYECOM.Model.SupplyInfo SupplyInfo = SupplyBLL.GetSupplyById(XYECOM.Core.MyConvert.GetInt32(IdsArry[i]));

                        StrHtml += "<input checked='checked' onclick=\"Selectchange('" + IdsArry[i] + "')\" type='checkbox' id='cbsel_" + IdsArry[i] + "' value='" + IdsArry[i] + "'/><label>" + SupplyInfo.Title + "</label>";
                        ItemStr += IdsArry[i] + ":" + SupplyInfo.Title + ",";
                    }
                }
                this.Infostxt.Text = StrHtml;
                this.HidItemStr.Value = ItemStr.Substring(0, ItemStr.Length - 1);
            }
        }
    }
Exemple #3
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;
    }