Ejemplo n.º 1
0
        //private void ViewNewsResult(string keyword)
        //{
        //    NewsGroupBSO newsBSO = new NewsGroupBSO();
        //    DataTable table = newsBSO.GetNewsGroupAll(Language.language);
        //    DataView dataView = new DataView(table);
        //    string sqlSearch = "";

        //    sqlSearch = "(Title like '%" + keyword + "%' or ShortDescribe like '%" + keyword + "%') And Status =1 And IsApproval=1";

        //    dataView.RowFilter = sqlSearch;

        //    DataListCateNews.DataSource = dataView;
        //    DataListCateNews.DataBind();

        //}

        private void ViewNewsResult(string keyword)
        {
            NewsGroupBSO newsBSO = new NewsGroupBSO();
            DataTable table = newsBSO.GetNewsGroupAll(Language.language);
            DataView dataView = new DataView(table);

            if (keyword.Trim() != "")
            {

                keyword = keyword.Replace("'", "");
                string[] _keyws = keyword.Split('_');
                if (_keyws != null)
                {
                    if (_keyws.Length > 0)
                    {
                        string _finter = "";
                        foreach (string _key in _keyws)
                        {
                            _finter += " AND (Title like N'%" + _key + "%'";
                            _finter += " or ShortDescribe like N'%" + _key + "%'" + ")";
                        }
                        _finter += " And Status =1 And IsApproval=1 " + " AND Language = '" + Language.language + "'";

                        DataTable _tb = newsBSO.NewsGroupSearch(_finter);
                        if (_tb != null)
                        {
                            if (_tb.Rows.Count > 0)
                            {
                                foreach (string _key1 in _keyws)
                                {

                                    foreach (DataRow _dr in _tb.Rows)
                                    {
                                        if (_dr["Title"].ToString().Contains(_key1))
                                        {
                                            _dr["Title"] = _dr["Title"].ToString().Replace(_key1, "<font color ='Red'>" + _key1 + "</font>");

                                        }
                                        if (_dr["ShortDescribe"] != null && _dr["ShortDescribe"] != DBNull.Value)
                                        {
                                            if (_dr["ShortDescribe"].ToString().Contains(_key1))
                                            {
                                                _dr["ShortDescribe"] = HtmlRemoval.StripTagsCharArray(HttpUtility.HtmlDecode(_dr["ShortDescribe"].ToString()));
                                                _dr["ShortDescribe"] = _dr["ShortDescribe"].ToString().Replace(_key1, "<font color ='Red'>" + _key1 + "</font>");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        DataListCateNews.DataSource = _tb;
                        DataListCateNews.DataBind();
                    }
                }
            }


        }
        private void ViewNewsGroup(int group)
        {
            var newsGroupBSO = new NewsGroupBSO();
            var table = new DataTable();

            if (!Session["Admin_UserName"].Equals("administrator"))
            {
                var strCate = GetCateParentIdArrayById(group);
                if (strCate != "")
                    table = newsGroupBSO.GetNewsGroupAll(Language.language, group, strCate);
            }
            else
            {
                if (ddlCateNewsSearch.SelectedValue == "0")
                    table = newsGroupBSO.GetNewsGroupAll(Language.language, group);
                else
                {
                    var cId = Convert.ToInt32(ddlCateNewsSearch.SelectedValue);
                    table = newsGroupBSO.NewsGroupSearch(txtKeyword.Text, cId, Language.language);
                }
            }
            var commonBSO = new commonBSO();
            commonBSO.FillToGridView(grvNewsGroup, table);
        }