Exemplo n.º 1
0
        public static void Update(string strNewsId, string editionType)
        {
            if (strNewsId.Trim() != "")
            {
                int      sobainoibat = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["SoBaiNoiBatTrangChu"]);
                string[] arr         = strNewsId.Split(',');
                if (arr.Length == sobainoibat)
                {
                    using (MainDB db = new MainDB())
                    {
                        db.StoredProcedures.BonBaiNoiBat_Delete();
                        for (int i = 0; i < arr.Length; i++)
                        {
                            db.StoredProcedures.BonBaiNoiBat_Insert(Convert.ToInt64(arr[i]), false, i + 1);
                        }

                        // Update nhung bai tin noi bat khac ve tin thong tuong

                        db.SelectQuery(" Update News Set News_Mode = 0 Where News_Status = 3 And News_Mode = 2 And News_ID Not IN (" + strNewsId + ") ");
                        db.SelectQuery(" Update NewsPublished Set News_Mode = 0 From NewsPublished Join Category On NewsPublished.Cat_ID = Category.Cat_ID" +
                                       "Where  News_Mode = 2 And News_ID Not IN (" + strNewsId + ") And Category.EditionType_ID =" + editionType + "");
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void DeleteNewsRelation(string _news_id, string _news_id_relation_delete)
        {
            NewsRow objNewsRow             = NewsEditHelper.GetNewsInfo(Convert.ToInt64(_news_id.Trim()));
            string  strNew_NewsId_Relation = objNewsRow.News_Relation.Replace("," + _news_id_relation_delete, "");

            strNew_NewsId_Relation = strNew_NewsId_Relation.Replace(_news_id_relation_delete, "");


            // Xoa dau , o dau chuoi string
            if (strNew_NewsId_Relation.Trim() != "")
            {
                if (strNew_NewsId_Relation[0] == ',')
                {
                    strNew_NewsId_Relation = strNew_NewsId_Relation.Remove(0, 1);
                }
            }

            using (MainDB objDb = new MainDB()) {
                // Update vao bang news
                objDb.SelectQuery(" Update  News Set News_Relation = '" + strNew_NewsId_Relation + "'" +
                                  " Where News_Id = " + _news_id
                                  );
                //update vao bang news Published
                objDb.SelectQuery(" Update  NewsPublished Set News_Relation = '" + strNew_NewsId_Relation + "'" +
                                  " Where News_Id = " + _news_id
                                  );
            }
        }
Exemplo n.º 3
0
 public static DataTable BaiNoiBat_BaiNoiBat_Select(string EditionType)
 {
     using (MainDB db = new MainDB())
     {
         return(db.SelectQuery("Select * From v_BaiNoiBatTrangChu_Select vbn Join NewsPublished np On vbn.News_ID = np.News_ID Join Category c On np.Cat_ID = c.Cat_ID Where c.EditionType_ID = " + EditionType + " Order By Thutu"));
     }
 }
Exemplo n.º 4
0
        public void UpdateHtmlCache()
        {
            try
            {
                #region Load Category
                if (isFirstRun)
                {
                    GetAllCategory();
                    isFirstRun = false;
                }
                #endregion

                int toprow = 0;
                using (var db = new MainDB())
                {
                    //Type = 0 la web
                    //var data = db.SelectQuery("select [TableName] News_ID,[ChangeID] Cat_ID, [ChangeTime] from HtmlCached Where Type=0 where ChangeTime <= getdate()");
                    var data = db.SelectQuery("select [TableName] News_ID,[ChangeID] Cat_ID, [ChangeTime] from HtmlCached Where ChangeTime <= getdate()"); //  edit 20160623
                    toprow = data != null ? data.Rows.Count : 0;
                }

                if (toprow > 0)
                {
                    UpdateMonitor();
                }
            }
            catch (Exception ex)
            {
                ErrorLog(ex.Message + Environment.NewLine + ex.StackTrace + ":" + DateTime.Now + Environment.NewLine);
            }
        }
Exemplo n.º 5
0
        public DataTable GetMediaObjlist_Old(string strWhere, int PageSize, int StartRow)
        {
            //lay thong tin ve menh de where de loc thong tin
            if (strWhere == null)
            {
                strWhere = "";
            }
            DataTable objresult;
            int       intPageNum = StartRow / PageSize + 1;

            //lay duoc du lieu cua tat ca nhung thang co trang thai la status can lay
            using (MainDB objdb = new MainDB())
            {
                objresult = objdb.MediaObjectCollection.GetPageAsDataTable(intPageNum, PageSize, strWhere, "Object_ID DESC");;
            }

            objresult.Columns.Add(new DataColumn("News_ID", Type.GetType("System.String")));
            objresult.Columns.Add(new DataColumn("Film_ID", Type.GetType("System.String")));

            int pos = 0;

            DataTable dt;

            for (int i = 0; i < objresult.Rows.Count; i++)
            {
                pos = objresult.Rows[i]["Object_Url"].ToString().LastIndexOf("/");
                objresult.Rows[i]["Object_Url"] = objresult.Rows[i]["Object_Url"].ToString().Substring(pos + 1);
                // news_id =
                using (MainDB objMainDB = new MainDB())
                {
                    dt = objMainDB.SelectQuery(" Select News_ID,Film_Id from news_media Where Object_Id =  " + objresult.Rows[i]["Object_ID"] + " ");
                }

                if (dt.Rows.Count > 0)
                {
                    objresult.Rows[i]["News_ID"] = dt.Rows[0][0];
                    objresult.Rows[i]["Film_ID"] = dt.Rows[0][1];
                }
            }

            DataTable objTemp = objresult.Clone();

            if (objresult.Rows.Count == 0)
            {
                DataRow objrow = objTemp.NewRow();
                objrow["Object_ID"]    = 0;
                objrow["Object_Type"]  = 0;
                objrow["Object_Value"] = "";
                objrow["Object_Url"]   = "";
                objrow["Object_Note"]  = "";
                objrow["UserID"]       = HttpContext.Current.User.Identity.Name;
                objTemp.Rows.Add(objrow);
                objresult.Dispose();
                return(objTemp);
            }
            return(objresult);
        }
Exemplo n.º 6
0
        public static DataTable SelectFeedBack()
        {
            DataTable dt;

            using (MainDB db = new MainDB())
            {
                dt = db.SelectQuery("Select * from FeedBack order by ID DESC");
            }
            return(dt);
        }
Exemplo n.º 7
0
        public static DataTable GetActionHistory(long NewsID)
        {
            DataTable _result = null;

            using (MainDB db = new MainDB()) {
                _result = db.SelectQuery("SELECT * FROM Action WHERE News_ID = " + NewsID);
            }

            return(_result);
        }
Exemplo n.º 8
0
        public static DataTable SelectDangKyQuaTang()
        {
            DataTable dt;

            using (MainDB db = new MainDB())
            {
                dt = db.SelectQuery("Select * from DangKy order by ID DESC");
            }
            return(dt);
        }
Exemplo n.º 9
0
        public static DataTable SelectOneSupportOnline(string ID)
        {
            DataTable dt;

            using (MainDB db = new MainDB())
            {
                dt = db.SelectQuery("Select * from SupportOnline where ID ='" + ID + "'");
            }
            return(dt);
        }
Exemplo n.º 10
0
        public static DataTable SelectSupportOnline()
        {
            DataTable dt;

            using (MainDB db = new MainDB())
            {
                dt = db.SelectQuery("Select * from SupportOnline");
            }
            return(dt);
        }
Exemplo n.º 11
0
        internal static DataTable GetPublishedNews(long NewsID)
        {
            DataTable __result = null;

            using (MainDB __db = new MainDB()) {
                __result = __db.SelectQuery("SELECT * FROM NewsPublished WHERE News_ID = " + NewsID);
            }

            return(__result);
        }
Exemplo n.º 12
0
        public static DataTable SelectQuery(string sql)
        {
            DataTable dt;

            using (MainDB db = new MainDB())
            {
                dt = db.SelectQuery(sql);
            }
            return(dt);
        }
Exemplo n.º 13
0
        public DataTable GetOtherProductInCat(string CatID)
        {
            DataTable dt;

            using (MainDB db = new MainDB())
            {
                string sql = "select P_ID,P_Name from tblProduct where P_trangthai =1 and P_CatID=" + CatID;
                dt = db.SelectQuery(sql);
            }
            return(dt);
        }
Exemplo n.º 14
0
        public static DataTable GetNewsById(string _news_id)
        {
            DataTable dt = new DataTable();

            if (_news_id.Trim() != "")
            {
                using (MainDB objDb = new MainDB()) {
                    dt = objDb.SelectQuery("Select * From News Where News_id = " + _news_id);
                }
            }
            return(dt);
        }
Exemplo n.º 15
0
        public static bool IsHaveNewUpdateNewsPublished(string News_ID)
        {
            bool IsUpdate = false;

            using (MainDB __db = new MainDB())
            {
                DataTable __result = __db.SelectQuery("Select news_ID from news_extension where news_ID = " + News_ID);
                if (__result != null && __result.Rows.Count > 0)
                {
                    IsUpdate = true;
                }
            }

            return(IsUpdate);
        }
Exemplo n.º 16
0
        public static string GetNewsTitle(long NewsID)
        {
            string    _result = string.Empty;
            DataTable dt      = null;

            using (MainDB db = new MainDB()) {
                dt = db.SelectQuery("SELECT News_Title FROM News WHERE News_ID = " + NewsID);
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                _result = dt.Rows[0][0].ToString();
            }

            return(_result);
        }
Exemplo n.º 17
0
        private static void GetAllCategory()
        {
            var tbl = new DataTable();

            categoryDiction.Clear();
            using (var db = new MainDB())
            {
                tbl = db.SelectQuery("Select * from Category");
            }

            foreach (DataRow row in tbl.Rows)
            {
                if (!categoryDiction.ContainsKey(Convert.ToInt32(row["Cat_ID"].ToString())))
                {
                    categoryDiction.Add(Convert.ToInt32(row["Cat_ID"].ToString()), Convert.ToInt32(row["Cat_ParentID"]));
                }
            }
        }
Exemplo n.º 18
0
        public static string GetSenderIDByNewsID(string news_id)
        {
            string sReturn = "";

            using (MainDB objDb = new MainDB()) {
                DataTable dt = objDb.SelectQuery(" select top 1 sender_id from action where news_id = " + news_id + " order by createdate desc ");
                if (dt.Rows.Count > 0)
                {
                    sReturn = dt.Rows[0][0].ToString();
                }
                else
                {
                    sReturn = "";
                }
            }

            return(sReturn);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Thủ tục hiển thị danh sách Categories con
        /// </summary>
        /// <param name="_intParentCategoryID">Mã tham chiếu đến Category cha</param>
        /// <param name="dgrCatList"></param>
        private void LoadSubCategories(int _intParentCategoryID, DataGrid dgrCatList)
        {
            DataTable _objEditionCategories = null;

            using (MainDB _objDB = new MainDB())
            {
                //_objEditionCategories = _objDB.CategoryCollection.GetAsDataTable("Cat_ParentID = " + _intParentCategoryID, "");
                _objEditionCategories = _objDB.SelectQuery(
                    "SELECT     a.Cat_ID AS ParentCat_ID, a.Cat_Name AS Parent_CatName, a.Cat_DisplayURL as ParentCat_DisplayURL, " +
                    "a.Cat_DisplayURL + '.' + b.Cat_DisplayURL as SubCat_DisplayURL, b.Cat_ID AS SubCat_ID, b.Cat_Name AS SubCat_Name, b.EditionType_ID " +
                    "FROM         dbo.Category a INNER JOIN " +
                    "dbo.Category b ON a.Cat_ID = b.Cat_ParentID " +
                    "Where a.Cat_ID = " + _intParentCategoryID.ToString() + " Order By b.Cat_Order"
                    );
            }

            if (_objEditionCategories != null)
            {
                dgrCatList.DataSource   = _objEditionCategories;
                dgrCatList.DataKeyField = "SubCat_ID";
                dgrCatList.DataBind();
            }
        }
Exemplo n.º 20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["UpdateSapo"] != null)
     {
         var data = new DataTable();
         using (MainDB db = new MainDB())
         {
             data = db.SelectQuery("Select Top 100 ContentID, Description from Contents Where DistributionID is null");
         }
         foreach (DataRow row in data.Rows)
         {
             long   newsId           = Convert.ToInt64(row["ContentID"]);
             string News_InitContent = row["Description"].ToString();
             using (MainDB db = new MainDB())
             {
                 db.UpdateQuery(
                     "Update Contents set Description=@Description, DistributionID = 0 Where ContentID=@ContentID;",
                     new object[] { HttpUtility.HtmlDecode(Utils.RemoveHTMLTag(News_InitContent)).Trim(), newsId }, new[] { "Description", "ContentID" });
             }
         }
         Response.Write("<script>location.href = location.href;</script>");
     }
 }
Exemplo n.º 21
0
 public static DataTable BaiNoiBat_BaiNoiBat_Select()
 {
     using (MainDB db = new MainDB()) {
         return(db.SelectQuery("Select * From v_BaiNoiBatTrangChu_Select Order By ThuTu DESC,News_PublishDate DESC "));
     }
 }
Exemplo n.º 22
0
 public void DeleteThreadByNewsId(string news_id)
 {
     using (MainDB objdb = new MainDB()) {
         objdb.SelectQuery("Delete ThreadDetail Where News_ID = '" + news_id + "'");
     }
 }