示例#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
        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, "指定新闻不存在");
            }
        }