protected void btnApplication_Click(object sender, EventArgs e)
        {
            Guid pID = new Guid();//模块ID
            if (ddlModuleP.SelectedValue == "0")
            {
                lbErr.InnerText = "请选择模块";
                return;
            }
            else if (ddlModuleP.SelectedValue != "0")
            {
                pID = new Guid(ddlModuleP.SelectedValue);
                List<CY.CSTS.Core.Business.NewsModule> ListM = CY.CSTS.Core.Business.NewsModule.GetNewsModuleList(" WBS like '%" + pID + ".%' ")
                       as List<CY.CSTS.Core.Business.NewsModule>;

                if (ListM.Count > 0 && Request.Form["ddlModuleSub"] != "0" && Request.Form["ddlModuleSub"] != null)
                {
                    string pid = Request.Form["ddlModuleSub"].ToString();
                    pID = new Guid(pid);
                }
                else
                {
                    pID = new Guid(ddlModuleP.SelectedValue.ToString());
                }
            }
            if (string.IsNullOrEmpty(tbTitle.Text.Trim()))
            {
                lbErr.InnerText = "请输入标题";
                tbTitle.Focus();
                return;
            }
            if (radioIsPhotoY.Checked)//是图片新闻
            {
                if (!IsPhoto())
                {
                    lbErr.InnerText = "内容不包含图片不能设置成图片新闻";
                    radioIsPhotoN.Focus();
                    return;
                }
            }

            NewsContent newsC = NewsContent.Load(newsID);
            newsC.Title = tbTitle.Text.Trim();
            newsC.ModuleID = pID;
            int tag = 0;
            if (string.IsNullOrEmpty(tbTagName.Text.Trim()))
            {
                newsC.Tag = 2;//没有
                tag = 2;
            }
            else
            {
                newsC.Tag = 1;//有
                tag = 1;
            }
            if (!string.IsNullOrEmpty(tbPubTime.Text.Trim()))
            {
                newsC.PublishTime = DateTime.Parse(tbPubTime.Text.Trim());
            }
            newsC.Source = tbSource.Text.Trim();
            newsC.Content = fck.Value;

            newsC.Status = 3;//申请
            CY.CSTS.Core.Business.NewsModule m = CY.CSTS.Core.Business.NewsModule.Load(newsC.ModuleID);
            if (m != null)
            {
                if (m.CheckStatus == 1)
                {
                    newsC.Status = 2;//发表状态
                }
            }

            int isAnnex = IsAnnex();
            newsC.Annex = isAnnex;
            newsC.Author = userSession.UserID;
            newsC.Index = int.Parse(ddlIndex.SelectedValue.ToString());
            newsC.SortTime = DateTime.Parse(tbSortTime.Text.Trim());
            newsC.Save();
            if (tag == 1)
            {
                if (!string.IsNullOrEmpty(tbTagName.Text.Trim()))
                {
                    string tagTemp = tbTagName.Text.Trim();
                    if (tagTemp.Contains(","))
                    {
                        tagTemp = tagTemp.Replace(",", ",");
                    }
                    else if (tagTemp.Contains(" "))
                    {
                        tagTemp = tagTemp.Replace(" ", ",");
                    }
                    CY.CSTS.Core.Business.Tag tagCore = new CY.CSTS.Core.Business.Tag();
                    tagCore.ContentID = newsC.Id;
                    tagCore.TagName = tagTemp;
                    tagCore.ContentType = 2;//信息
                    tagCore.Save();
                }
            }
            if (isAnnex == 1)
            {
                SaveAttach(newsC.Id);
            }
            if (radioIsPhotoY.Checked)
            {
                List<NewsPhoto> listPhoto = NewsPhoto.SelectNewsPhotosDynamic(" ContentID ='" + newsC.Id.ToString() + "'")
                                                            as List<NewsPhoto>;
                if (listPhoto.Count > 0)
                {
                   NewsPhoto np = listPhoto[0];
                   string url = GetPhotoSrc(fck.Value);
                   np.Status = 2;//内容新闻
                   np.ContentID = newsC.Id;
                   np.Title = newsC.Title;
                   np.Author = newsC.Author;
                   np.PhotoSrc = url;
                   np.AddDate = newsC.PublishTime;
                   np.Save();
                }
                else
                {
                    /*图片新闻*/
                    string url = GetPhotoSrc(fck.Value);
                    NewsPhoto newsPhoto = new NewsPhoto();
                    newsPhoto.Status = 2;//内容新闻
                    newsPhoto.ContentID = newsC.Id;
                    newsPhoto.Title = newsC.Title;
                    newsPhoto.Author = newsC.Author;
                    newsPhoto.PhotoSrc = url;
                    newsPhoto.AddDate = newsC.PublishTime;
                    newsPhoto.Save();
                }

            }
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('申请成功');window.location.href='UserNewsPreview.aspx?id=" + newsID + "&tabIndex=" + hdTabIndex.Value + "'</script>");
        }
Example #2
0
        //private void BindHeader()
        //{
        //    if (ddlModuleP.SelectedValue != "0")
        //    {
        //        string moduleName = ddlModuleP.SelectedItem.Text;
        //        NewsModule m = NewsModule.SelectByName(moduleName);
        //        int isChedk = m.CheckStatus;
        //        if (isChedk == 1)//不需要审核
        //        {
        //            status = 2;//发表
        //            btnApplication.Visible = false;
        //        }
        //        else if (isChedk == 2)//需要审核
        //        {
        //            status = 3;//申请
        //            btnApplication.Visible = true;
        //        }
        //    }
        //}
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddNews_Click(object sender, EventArgs e)
        {
            string strMidList = hdSelectModuleList.Value;

            if (strMidList != "")
            {
                string[] listMID = strMidList.Split(',');
                for (int i = 0; i < listMID.Length; i++)
                {
                    if (CY.Utility.Common.StringHelper.IsGuid(listMID[i]))
                    {
                        #region 添加新闻
                        try
                        {

                            //Guid pID = new Guid();//模块ID
                            ////if (ddlModuleP.SelectedValue == "0")
                            //{

                            //}
                            ////else if (ddlModuleP.SelectedValue != "0")
                            //{
                            //    pID = new Guid(ddlModuleP.SelectedValue);
                            //    List<CY.CSTS.Core.Business.NewsModule> ListM = CY.CSTS.Core.Business.NewsModule.GetNewsModuleList(" WBS like '%" + pID + ".%' ")
                            //          as List<CY.CSTS.Core.Business.NewsModule>;

                            //    if (ListM.Count > 0 && Request.Form["ddlModuleSub"] != "0" && Request.Form["ddlModuleSub"] != null)
                            //    {
                            //        pID = new Guid(Request.Form["ddlModuleSub"].ToString());
                            //    }
                            //    else
                            //    {
                            //        pID = new Guid(ddlModuleP.SelectedValue.ToString());
                            //    }
                            //}
                            if (string.IsNullOrEmpty(tbTitle.Text.Trim()))
                            {
                                lbErr.Text = "请输入标题";
                                tbTitle.Focus();
                                return;
                            }
                            if (radioIsPhotoY.Checked)//是图片新闻
                            {
                                if (!IsPhoto())
                                {
                                    lbErr.Text = "内容不包含图片不能设置成图片新闻";
                                    radioIsPhotoN.Focus();
                                    return;
                                }
                            }
                            NewsContent newsC = new NewsContent();
                            newsC.ModuleID = new Guid(listMID[i]);
                            newsC.Title = tbTitle.Text.Trim();
                            int tag = 0;
                            if (string.IsNullOrEmpty(tbTag.Text.Trim()))
                            {
                                newsC.Tag = 2;//没有
                                tag = 2;
                            }
                            else
                            {
                                newsC.Tag = 1;//有
                                tag = 1;
                            }
                            newsC.Source = tbSource.Text.Trim();
                            newsC.Content = fck.Value;
                            string status = hdStatus.Value;
                            if (status == "1")
                            {
                                newsC.Status = 2;//发表
                            }
                            else if (status == "2")
                            {
                                newsC.Status = 1;//保存
                            }
                            newsC.Author = userSession.UserID;
                            if (!string.IsNullOrEmpty(tbPubTime.Text.Trim()))
                            {
                                newsC.PublishTime = DateTime.Parse(tbPubTime.Text.Trim());
                            }
                            else
                            {
                                newsC.PublishTime = DateTime.Now;
                            }
                            HttpFileCollection files = HttpContext.Current.Request.Files;
                            bool hasAnnex = false;
                            if (files[0].FileName == "" || files[0].ContentLength == 0)
                            {
                                newsC.Annex = 2;//没有附件
                                hasAnnex = false;
                            }
                            else
                            {
                                newsC.Annex = 1;//有附件
                                hasAnnex = true;
                            }
                            newsC.Index = int.Parse(ddlIndex.SelectedValue.ToString());
                            newsC.Traffic = 0;
                            if (!string.IsNullOrEmpty(tbSortTime.Text.Trim()))
                            {
                                newsC.SortTime = DateTime.Parse(tbSortTime.Text.Trim());
                            }
                            else
                            {
                                newsC.SortTime = DateTime.Now;
                            }
                            newsC.Save();
                            if (tag == 1)
                            {
                                /*Tag*/
                                if (!string.IsNullOrEmpty(tbTag.Text.Trim()))
                                {
                                    string tagTemp = tbTag.Text.Trim();
                                    if (tagTemp.Contains(","))
                                    {
                                        tagTemp = tagTemp.Replace(",", ",");
                                    }
                                    else if (tagTemp.Contains(" "))
                                    {
                                        tagTemp = tagTemp.Replace(" ", ",");
                                    }
                                    CY.CSTS.Core.Business.Tag tagT = new CY.CSTS.Core.Business.Tag();
                                    tagT.ContentID = newsC.Id;
                                    tagT.TagName = tagTemp;
                                    tagT.ContentType = 2;//信息
                                    tagT.Save();
                                }
                            }
                            if (radioIsPhotoY.Checked)
                            {
                                /*图片新闻*/
                                string url = GetPhotoSrc(fck.Value);
                                NewsPhoto newsPhoto = new NewsPhoto();
                                newsPhoto.Status = 2;//内容新闻
                                newsPhoto.ContentID = newsC.Id;
                                newsPhoto.Title = newsC.Title;
                                newsPhoto.Author = newsC.Author;
                                newsPhoto.PhotoSrc = url;
                                newsPhoto.AddDate = newsC.PublishTime;
                                newsPhoto.Save();
                            }
                            if (hasAnnex == true)
                            {
                                SaveAttach(newsC.Id);
                            }
                            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('新增成功');window.location.href='UserNewsList.aspx'</script>");
                        }
                        catch (Exception ex)
                        {
                            lbErr.Text = ex.Message;
                        }
                        #endregion
                    }
                }
            }
            else
            {
                lbErr.Text = "请选择模块";
                return;
            }
        }