Пример #1
0
        public void GetSearchCondition()
        {
            SearchCondition = "";

            if (CheckBox_NewsID.Checked)
            {
                if (PageValidate.IsNumber(TextBox_NewsID.Text))
                {
                    SearchCondition += " and newsid=" + Convert.ToInt32(TextBox_NewsID.Text);
                }
                else
                {
                    MessageBox.Show(this, "请输入正确的新闻ID");
                    return;
                }
            }

            if (CheckBox_NewsName.Checked)
            {
                if (!String.IsNullOrEmpty(TextBox_NewsName.Text))
                {
                    SearchCondition += " and title like '%" + TextBox_NewsName.Text.Trim().Replace("'", "") + "%'";
                }
                else
                {
                    MessageBox.Show(this, "请输入新闻标题");
                    return;
                }
            }

            if (CheckBox_Category.Checked)
            {
                bool test;
                NewsCategoryModel model = NewsCategorySelect1.GetSelectedRegionInfo(out test);
                if (model != null)
                {
                    SearchCondition += " and dbo.GetNewsCategoryPath(cateid)+'/' like dbo.GetNewsCategoryPath(" + model.CateID + ")+'/%'";

                    if (!CheckBox_Category.Checked)
                    {
                        CheckBox_Category.Checked = true;
                    }
                    string CategoryPath = new NewsCategoryModelBll().GetPath(model.CateID);
                    //CategoryPath = CategoryPath.Contains("/") ? CategoryPath.Substring(0, CategoryPath.LastIndexOf("/")) : CategoryPath;
                    NewsCategorySelect1.PresetRegionInfo(CategoryPath);
                }
                else
                {
                    MessageBox.Show(this, "请选择分类");
                    return;
                }
            }
        }
Пример #2
0
        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");
        }
Пример #3
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);
        }