示例#1
0
        private XmlNode GetNode(int CategoryID, XmlDocument xdoc)
        {
            XmlNode TempNode = xdoc.CreateElement("categorynode");

            NewsModelBll      bll           = new NewsModelBll();
            NewsCategoryModel CategoryModel = new NewsCategoryModelBll().GetModel(CategoryID);
            DataTable         dt            = bll.GetTopCategoryNews(6, CategoryID);

            XmlNode NewsCategoryNode = XmlUtility.AddNewNode(TempNode, "category", null);

            if (CategoryModel != null)
            {
                XmlUtility.AddNewNode(NewsCategoryNode, "categoryid", CategoryModel.CateID.ToString());
                XmlUtility.AddNewNode(NewsCategoryNode, "categoryname", CategoryModel.CateName);


                XmlNode NewsListNode = XmlUtility.AddNewNode(TempNode, "newslist", null);
                foreach (DataRow row in dt.Rows)
                {
                    XmlNode NewsNode = XmlUtility.AddNewNode(NewsListNode, "news", null);

                    XmlUtility.AddNewNode(NewsNode, "newsid", row["newsid"].ToString());
                    XmlUtility.AddNewNode(NewsNode, "title", row["title"].ToString());
                    XmlUtility.AddNewNode(NewsNode, "image", NewsImageRule.GetImageUrl(row["imageurl"].ToString()));
                    XmlUtility.AddNewNode(NewsNode, "video", NewsVideoRule.GetVideoUrl(row["videourl"].ToString()));
                }
            }

            return(TempNode);
        }
示例#2
0
        public XmlNode GetNewsDetail()
        {
            XmlNode NewsDetailNode = xdoc.CreateElement("newsdetail");

            DataTable dt = dal.GetNewDetail(Parameter.NewsID);

            //c.cateid,c.catename,
            //n.newsid,n.title,n.subtitle,n.brief,n.newscontent,
            //n.smallimageurl,n.author,n.newsfrom,n.videourl,n.imageurl,n.productid,n.inserttime,n.tags
            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                XmlUtility.AddNewNode(NewsDetailNode, "newsid", Convert.ToString(row["newsid"]));
                XmlUtility.AddNewNode(NewsDetailNode, "title", Convert.ToString(row["title"]));
                XmlUtility.AddNewNode(NewsDetailNode, "subtitle", Convert.ToString(row["subtitle"]));
                XmlUtility.AddNewNode(NewsDetailNode, "cateid", Convert.ToString(row["cateid"]));
                XmlUtility.AddNewNode(NewsDetailNode, "catename", Convert.ToString(row["catename"]));
                XmlUtility.AddCDataNode(NewsDetailNode, "brief", Convert.ToString(row["brief"]));
                XmlUtility.AddCDataNode(NewsDetailNode, "newscontent", Convert.ToString(row["newscontent"]));
                XmlUtility.AddNewNode(NewsDetailNode, "smallimageurl", NewsImageRule.GetImageUrl(Convert.ToString(row["smallimageurl"])));
                XmlUtility.AddNewNode(NewsDetailNode, "author", Convert.ToString(row["author"]));
                XmlUtility.AddNewNode(NewsDetailNode, "newsfrom", Convert.ToString(row["newsfrom"]));
                XmlUtility.AddNewNode(NewsDetailNode, "videourl", NewsVideoRule.GetVideoUrl(Convert.ToString(row["videourl"])));
                XmlUtility.AddNewNode(NewsDetailNode, "imageurl", NewsImageRule.GetImageUrl(Convert.ToString(row["imageurl"])));
                XmlUtility.AddNewNode(NewsDetailNode, "productid", Convert.ToString(row["productid"]));
                XmlUtility.AddNewNode(NewsDetailNode, "inserttime", Convert.ToDateTime(row["inserttime"]).ToString("yyyy-MM-dd hh:mm:ss"));
                XmlUtility.AddNewNode(NewsDetailNode, "tags", Convert.ToString(row["tags"]));
            }

            return(NewsDetailNode);
        }
示例#3
0
        public XmlNode GetSplendidNewsList()
        {
            XmlNode   SplendidNewsListNode = xdoc.CreateElement("splendidnewslist");
            DataTable dt = dal.GetSplendidNewsList(0);

            foreach (DataRow row in dt.Rows)
            {
                XmlNode NewsNode = XmlUtility.AddNewNode(SplendidNewsListNode, "news", null);

                XmlUtility.AddNewNode(NewsNode, "newsid", Convert.ToString(row["newsid"]));
                XmlUtility.AddNewNode(NewsNode, "title", Convert.ToString(row["title"]));
                XmlUtility.AddNewNode(NewsNode, "brief", Convert.ToString(row["brief"]));
                XmlUtility.AddNewNode(NewsNode, "imageurl", NewsImageRule.GetImageUrl(Convert.ToString(row["imageurl"])));
            }

            return(SplendidNewsListNode);
        }
示例#4
0
        public XmlDocument GetData(NameValueCollection TagParameter)
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?><tag />");
            XmlNode rootNode = xdoc.SelectSingleNode("/tag");


            int CategoryID = 43;

            NewsModelBll      bll           = new NewsModelBll();
            NewsCategoryModel CategoryModel = new NewsCategoryModelBll().GetModel(CategoryID);
            DataTable         dt            = bll.GetTopCategoryNews(6, CategoryID);

            XmlNode NewsCategoryNode = XmlUtility.AddNewNode(rootNode, "category", null);

            if (CategoryModel != null)
            {
                XmlUtility.AddNewNode(NewsCategoryNode, "categoryid", CategoryModel.CateID.ToString());
                XmlUtility.AddNewNode(NewsCategoryNode, "categoryname", CategoryModel.CateName);


                XmlNode NewsListNode = XmlUtility.AddNewNode(rootNode, "newslist", null);
                foreach (DataRow row in dt.Rows)
                {
                    XmlNode NewsNode = XmlUtility.AddNewNode(NewsListNode, "news", null);

                    XmlUtility.AddNewNode(NewsNode, "newsid", row["newsid"].ToString());
                    XmlUtility.AddNewNode(NewsNode, "title", row["title"].ToString());
                    XmlUtility.AddNewNode(NewsNode, "image", NewsImageRule.GetImageUrl(row["imageurl"].ToString()));
                    XmlUtility.AddNewNode(NewsNode, "video", NewsVideoRule.GetVideoUrl(row["videourl"].ToString()));
                }
            }



            return(xdoc);
        }
示例#5
0
        private void BindData()
        {
            NewsModel model = bll.GetModel(NewsID);

            if (model != null)
            {
                TextBox_Title.Text     = model.Title;
                TextBox_SubTitle.Text  = model.SubTitle;
                TextBox_Author.Text    = model.Author;
                TextBox_NewsFrom.Text  = model.From;
                TextBox_ProductID.Text = model.ProductId == "0"?"":model.ProductId;

                NewsCategorySelect1.PresetRegionInfo(new NewsCategoryModelBll().GetPath(model.CategoryID));

                TextBox_Tags.Text        = model.Tags;
                TextBox_Brief.Text       = model.Brief;
                TextBox_Content.Text     = model.Content;
                Image_NewsImage.ImageUrl = NewsImageRule.GetImageUrl(model.ImageUrl);
            }
            else
            {
                MessageBox.Show(this, "指定新闻不存在");
            }
        }
示例#6
0
        public XmlNode GetNewsList()
        {
            XmlNode NewsListNode = xdoc.CreateElement("newslist");

            XmlNode   ListNode = XmlUtility.AddNewNode(NewsListNode, "list", null);
            int       RecordCount = 0, PageCount = 0;
            DataTable dt = dal.GetNewsList(Parameter.PageIndex, Config.ListPageSize, Parameter.CategoryID, out RecordCount, out PageCount);

            foreach (DataRow row in dt.Rows)
            {
                XmlNode NewsNode = XmlUtility.AddNewNode(ListNode, "news", null);

                XmlUtility.AddNewNode(NewsNode, "newsid", Convert.ToString(row["newsid"]));
                XmlUtility.AddNewNode(NewsNode, "title", Convert.ToString(row["title"]));
                XmlUtility.AddNewNode(NewsNode, "brief", Convert.ToString(row["brief"]));
                XmlUtility.AddNewNode(NewsNode, "imageurl", NewsImageRule.GetImageUrl(Convert.ToString(row["imageurl"])));
            }

            //分页信息节点
            XmlNode PageInfoNode = XmlUtility.AddNewNode(NewsListNode, "pageinfo", null);

            XmlUtility.SetAtrributeValue(PageInfoNode, "recordcount", RecordCount.ToString());
            XmlUtility.SetAtrributeValue(PageInfoNode, "pagecount", PageCount.ToString());
            XmlUtility.SetAtrributeValue(PageInfoNode, "currentpage", Parameter.PageIndex.ToString());

            if (PageCount <= 11) //小于最大显示数目,全部显示即可
            {
                for (int i = 1; i <= PageCount; i++)
                {
                    XmlNode PageNode = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                    XmlUtility.SetAtrributeValue(PageNode, "pageindex", i.ToString());
                    if (i == Parameter.PageIndex)
                    {
                        XmlUtility.SetAtrributeValue(PageNode, "isselected", "true");
                    }
                }
            }
            else                //大于最大显示数据,需要根据pageindex决定显示页码
            {
                XmlNode PageNodeS = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                XmlUtility.SetAtrributeValue(PageNodeS, "pageindex", 1.ToString());
                if (Parameter.PageIndex == 1)
                {
                    XmlUtility.SetAtrributeValue(PageNodeS, "isselected", "true");
                }

                if (Parameter.PageIndex < 10)
                {
                    for (int i = 2; i <= 10; i++)
                    {
                        XmlNode PageNode = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                        XmlUtility.SetAtrributeValue(PageNode, "pageindex", i.ToString());
                        if (i == Parameter.PageIndex)
                        {
                            XmlUtility.SetAtrributeValue(PageNode, "isselected", "true");
                        }
                    }
                    XmlNode PageNodeME = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                    XmlUtility.SetAtrributeValue(PageNodeME, "pageindex", "...");
                }
                else
                {
                    if (Parameter.PageIndex >= 10 && Parameter.PageIndex <= PageCount - 10)
                    {
                        XmlNode PageNodeMS = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                        XmlUtility.SetAtrributeValue(PageNodeMS, "pageindex", "...");

                        for (int i = Parameter.PageIndex - 5; i < Parameter.PageIndex + 5; i++)
                        {
                            XmlNode PageNode = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                            XmlUtility.SetAtrributeValue(PageNode, "pageindex", i.ToString());
                            if (i == Parameter.PageIndex)
                            {
                                XmlUtility.SetAtrributeValue(PageNode, "isselected", "true");
                            }
                        }

                        XmlNode PageNodeME = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                        XmlUtility.SetAtrributeValue(PageNodeME, "pageindex", "...");
                    }
                    else
                    {
                        if (Parameter.PageIndex > PageCount - 10)
                        {
                            XmlNode PageNodeMS = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                            XmlUtility.SetAtrributeValue(PageNodeMS, "pageindex", "...");

                            for (int i = PageCount - 10; i <= PageCount - 1; i++)
                            {
                                XmlNode PageNode = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                                XmlUtility.SetAtrributeValue(PageNode, "pageindex", i.ToString());
                                if (i == Parameter.PageIndex)
                                {
                                    XmlUtility.SetAtrributeValue(PageNode, "isselected", "true");
                                }
                            }
                        }
                    }
                }

                XmlNode PageNodeE = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                XmlUtility.SetAtrributeValue(PageNodeE, "pageindex", PageCount.ToString());
                if (Parameter.PageIndex == PageCount)
                {
                    XmlUtility.SetAtrributeValue(PageNodeE, "isselected", "true");
                }
            }

            return(NewsListNode);
        }
        protected void Button_Submit_Click(object sender, EventArgs e)
        {
            bool isEndCate = false;
            int  SelectedParentCategoryID = NewsCategorySelect1.GetSelectedRegionInfo(out isEndCate).CateID;

            string strErr = String.Empty;

            if (TextBox_Title.Text == String.Empty)
            {
                strErr += "新闻标题不能为空!\\n";
            }
            if (TextBox_Author.Text == String.Empty)
            {
                strErr += "新闻作者不能为空!\\n";
            }
            if (TextBox_NewsFrom.Text == String.Empty)
            {
                strErr += "新闻来源不能为空!\\n";
            }
            if (TextBox_Tags.Text == String.Empty)
            {
                strErr += "新闻标签不能为空!\\n";
            }
            if (!isEndCate)
            {
                strErr += "新闻不能添加在非末级分类下!\\n";
            }

            if (strErr != String.Empty)
            {
                MessageBox.Show(this, strErr);
                return;
            }

            int       NewsID = CommDataHelper.GetNewSerialNum("ne");
            NewsModel model  = new NewsModel();

            model.NewsId     = NewsID;
            model.Title      = TextBox_Title.Text;
            model.SubTitle   = TextBox_SubTitle.Text;
            model.Author     = TextBox_Author.Text;
            model.From       = TextBox_NewsFrom.Text;
            model.CategoryID = SelectedParentCategoryID;
            model.Tags       = TextBox_Tags.Text;
            model.Brief      = TextBox_Brief.Text;
            model.Content    = TextBox_Content.Text;
            model.InsertTime = DateTime.Now;
            model.ModifyTime = DateTime.Now;
            model.ProductId  = String.IsNullOrEmpty(TextBox_ProductID.Text) ? "0" : TextBox_ProductID.Text;


            model.NewsType      = 1;
            model.Status        = 1;
            model.ImageUrl      = "";
            model.SmallImageUrl = "";
            model.VideoUrl      = "";

            if (!String.IsNullOrEmpty(FileUpload_Image.FileName))
            {
                string ImageUrl = String.Empty;

                if (NewsImageRule.SaveNewsImage(NewsID, FileUpload_Image.PostedFile, out ImageUrl))
                {
                    model.ImageUrl = ImageUrl;
                }
                else
                {
                    MessageBox.Show(this, "图片上传失败,请检查格式及大小是否正确。");
                    return;
                }
            }
            if (!String.IsNullOrEmpty(FileUpload_Video.FileName))
            {
                string VideoUrl = String.Empty;

                if (NewsVideoRule.SaveNewsVideo(NewsID, FileUpload_Video.PostedFile, out VideoUrl))
                {
                    model.VideoUrl = VideoUrl;
                }
                else
                {
                    MessageBox.Show(this, "视频上传失败,请检查格式及大小是否正确。");
                    return;
                }
            }

            bll.Add(model);
            PageControler.Publish(6, true);
            Response.Redirect("List.aspx");
        }
        public XmlDocument GetData(NameValueCollection TagParameter)
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?><tag />");
            XmlNode rootNode = xdoc.SelectSingleNode("/tag");

            NewsModelBll bll = new NewsModelBll();

            XmlNode CategoryNodel1 = XmlUtility.AddNewNode(rootNode, "category1", null);

            NewsCategoryModel Category1Model = new NewsCategoryModelBll().GetModel(3);
            DataTable         dt1            = bll.GetTopCategoryNews(6, 3);

            XmlNode NewsCategoryNode1 = XmlUtility.AddNewNode(CategoryNodel1, "category", null);
            XmlNode NewsListNode1     = XmlUtility.AddNewNode(CategoryNodel1, "newslist", null);

            if (Category1Model != null)
            {
                XmlUtility.AddNewNode(NewsCategoryNode1, "categoryid", Category1Model.CateID.ToString());
                XmlUtility.AddNewNode(NewsCategoryNode1, "categoryname", Category1Model.CateName);


                foreach (DataRow row in dt1.Rows)
                {
                    XmlNode NewsNode = XmlUtility.AddNewNode(NewsListNode1, "news", null);

                    XmlUtility.AddNewNode(NewsNode, "newsid", row["newsid"].ToString());
                    XmlUtility.AddNewNode(NewsNode, "title", row["title"].ToString().Length > 15 ? row["title"].ToString().Substring(0, 14) + "..." : row["title"].ToString());
                    XmlUtility.AddNewNode(NewsNode, "image", NewsImageRule.GetImageUrl(row["imageurl"].ToString()));
                    XmlUtility.AddNewNode(NewsNode, "video", NewsVideoRule.GetVideoUrl(row["videourl"].ToString()));
                }
            }



            XmlNode CategoryNode2 = XmlUtility.AddNewNode(rootNode, "category2", null);


            NewsCategoryModel CategoryModel2 = new NewsCategoryModelBll().GetModel(6);
            DataTable         dt2            = bll.GetTopCategoryNews(6, 6);

            XmlNode NewsCategoryNode2 = XmlUtility.AddNewNode(CategoryNode2, "category", null);
            XmlNode NewsListNode2     = XmlUtility.AddNewNode(CategoryNode2, "newslist", null);

            if (CategoryModel2 != null)
            {
                XmlUtility.AddNewNode(NewsCategoryNode2, "categoryid", CategoryModel2.CateID.ToString());
                XmlUtility.AddNewNode(NewsCategoryNode2, "categoryname", CategoryModel2.CateName);

                foreach (DataRow row in dt2.Rows)
                {
                    XmlNode NewsNode = XmlUtility.AddNewNode(NewsListNode2, "news", null);

                    XmlUtility.AddNewNode(NewsNode, "newsid", row["newsid"].ToString());
                    XmlUtility.AddNewNode(NewsNode, "title", row["title"].ToString().Length > 17 ? row["title"].ToString().Substring(0, 16) + "..." : row["title"].ToString());
                    XmlUtility.AddNewNode(NewsNode, "image", NewsImageRule.GetImageUrl(row["imageurl"].ToString()));
                    XmlUtility.AddNewNode(NewsNode, "video", NewsVideoRule.GetVideoUrl(row["videourl"].ToString()));
                }
            }

            return(xdoc);
        }
示例#9
0
        protected void Button_Submit_Click(object sender, EventArgs e)
        {
            NewsModel model = bll.GetModel(NewsID);
            bool      IsEndClass;

            int SelectedParentCategoryID = NewsCategorySelect1.GetSelectedRegionInfo(out IsEndClass).CateID;

            string strErr = String.Empty;

            if (TextBox_Title.Text == String.Empty)
            {
                strErr += "新闻标题不能为空!\\n";
            }
            if (TextBox_Author.Text == String.Empty)
            {
                strErr += "新闻作者不能为空!\\n";
            }
            if (TextBox_NewsFrom.Text == String.Empty)
            {
                strErr += "新闻来源不能为空!\\n";
            }
            if (TextBox_Tags.Text == String.Empty)
            {
                strErr += "新闻标签不能为空!\\n";
            }
            if (!IsEndClass)
            {
                strErr += "新闻不能添加在非末级分类下!\\n";
            }

            if (strErr != String.Empty)
            {
                MessageBox.Show(this, strErr);
                return;
            }

            model.Title      = TextBox_Title.Text;
            model.SubTitle   = TextBox_SubTitle.Text;
            model.Author     = TextBox_Author.Text;
            model.From       = TextBox_NewsFrom.Text;
            model.CategoryID = SelectedParentCategoryID;
            model.Tags       = TextBox_Tags.Text;
            model.Brief      = TextBox_Brief.Text;
            model.Content    = TextBox_Content.Text;
            model.ModifyTime = DateTime.Now;
            model.ProductId  = String.IsNullOrEmpty(TextBox_ProductID.Text) ? "0" : TextBox_ProductID.Text;

            if (!String.IsNullOrEmpty(FileUpload_Image.FileName))
            {
                string ImageUrl = String.Empty;

                if (NewsImageRule.SaveNewsImage(NewsID, FileUpload_Image.PostedFile, out ImageUrl))
                {
                    model.ImageUrl = ImageUrl;
                }
                else
                {
                    MessageBox.Show(this, "图片上传失败,请检查格式及大小是否正确。");
                    return;
                }
            }
            if (!String.IsNullOrEmpty(FileUpload_Video.FileName))
            {
                string VideoUrl = String.Empty;

                if (NewsVideoRule.SaveNewsVideo(NewsID, FileUpload_Video.PostedFile, out VideoUrl))
                {
                    model.VideoUrl = VideoUrl;
                }
                else
                {
                    MessageBox.Show(this, "视频上传失败,请检查格式及大小是否正确。");
                    return;
                }
            }

            bll.Update(model);
            PageControler.Publish(6, true);
            Response.Redirect("List.aspx?page=" + CurrentPageIndex);
        }