public static bool UpdateCategoryRow(Portal.Core.DAL.CategoryRow row)
        {
            CleanCacheCategory();

            using (Portal.Core.DAL.MainDB objDb = new Portal.Core.DAL.MainDB())
            {
                objDb.CategoryCollection.Update(row);
            }

            #region Cập nhập vào bảng Category ở database User
            Portal.User.Db.CategoryRow objCateUserRow = new Portal.User.Db.CategoryRow();
            using (Portal.User.Db.MainDB objDb = new Portal.User.Db.MainDB())
            {
                objCateUserRow              = objDb.CategoryCollection.GetByPrimaryKey(row.Cat_ID);
                objCateUserRow.Cat_Name     = row.Cat_Name;
                objCateUserRow.Cat_ParentID = row.Cat_ParentID;
                objCateUserRow.Cat_Order    = row.Cat_Order;
                objCateUserRow.Channel_ID   = Portal.API.Config.CurrentChannel;
                objDb.CategoryCollection.Update(objCateUserRow);
            }
            #endregion


            return(true);
        }
        public static Portal.Core.DAL.CategoryRow getCatInfoAsCategoryRow(int _catid)
        {
            Portal.Core.DAL.CategoryRow objrow;
            ArrayList objresult = new ArrayList();

            using (Portal.Core.DAL.MainDB objDb = new Portal.Core.DAL.MainDB())
            {
                objrow = objDb.CategoryCollection.GetByPrimaryKey(_catid);
            }
            if (objrow != null)
            {
                return(objrow);
            }

            objrow = new Portal.Core.DAL.CategoryRow();
            return(objrow);
        }
        public static Portal.Core.DAL.CategoryRow CreateCat2(string name, int order, string description, string displayURL, int parentCatId, int editionId, string icon, bool isColumn, bool isHidden, string tabCloneRef)
        {
            CleanCacheCategory();
            #region Cập nhật vào bảng Category ở database dữ liệu chính [Portal.Core.DAL.CategoryRow]
            Portal.Core.DAL.CategoryRow objrow = new Portal.Core.DAL.CategoryRow();
            objrow.Cat_Name        = name;
            objrow.Cat_Description = description;
            objrow.Cat_DisplayURL  = displayURL;
            objrow.Cat_ParentID    = parentCatId;
            objrow.EditionType_ID  = editionId;
            objrow.Cat_Icon        = icon;
            objrow.Cat_Order       = order;
            objrow.Cat_isColumn    = isColumn;
            objrow.Cat_isHidden    = isHidden;
            Portal.Core.DAL.MainDB db = new Portal.Core.DAL.MainDB();
            db.CategoryCollection.Insert(objrow);

            #endregion

            #region Cập nhập vào bảng Category ở database User [Portal.User.Db.CategoryRow]
            Portal.User.Db.CategoryRow objCateUserRow = new Portal.User.Db.CategoryRow();
            objCateUserRow.Cat_ID       = objrow.Cat_ID;
            objCateUserRow.Cat_Name     = objrow.Cat_Name;
            objCateUserRow.Cat_ParentID = objrow.Cat_ParentID;
            objCateUserRow.Cat_Order    = objrow.Cat_Order;
            objCateUserRow.Channel_ID   = Portal.API.Config.CurrentChannel;
            using (Portal.User.Db.MainDB userDB = new Portal.User.Db.MainDB())
            {
                userDB.CategoryCollection.Insert(objCateUserRow);
            }
            #endregion

            //#region Cập nhật file Portal.config
            //string parentTabRef = string.Empty;
            //if (parentCatId == 0)
            //    parentTabRef = db.EditionTypeCollection.GetByPrimaryKey(editionId).EditionDisplayURL;
            //else
            //    CategoryHelper.GetTabReferenceByCatId(parentCatId);

            //string newTabRef = parentTabRef + "." + name;
            //Gentabhelper.AddNewTab(newTabRef, parentTabRef, name, tabCloneRef);
            //#endregion

            return(objrow);
        }
        public static string GetTabReferenceByCatId(int catId)
        {
            string tab = string.Empty;

            Portal.Core.DAL.MainDB      db       = new Portal.Core.DAL.MainDB();
            Portal.Core.DAL.CategoryRow category = db.CategoryCollection.GetByPrimaryKey(catId);
            if (category != null)
            {
                tab = category.Cat_DisplayURL;
                while (category.Cat_ParentID != 0)
                {
                    category = db.CategoryCollection.GetByPrimaryKey(category.Cat_ParentID);
                    if (category != null)
                    {
                        tab = category.Cat_DisplayURL + "." + tab;
                    }
                }
                tab = db.EditionTypeCollection.GetByPrimaryKey(category.EditionType_ID).EditionDisplayURL + "." + tab;
            }

            return(tab);
        }
        public static void UpdateCate(int _catid, string _catname, string _catdes, string _caturl, int _catparent, int _catedition, string _caticon, bool _catiscolumn, bool _catishide)
        {
            CleanCacheCategory();

            Portal.Core.DAL.CategoryRow    objrow;
            Portal.Core.DAL.EditionTypeRow objEditRow         = null;
            Portal.Core.DAL.CategoryRow    objParentRow       = null;
            Portal.Core.DAL.CategoryRow    objrow_find_parent = null;

            string strOldUrl = "";

            using (Portal.Core.DAL.MainDB objDb = new Portal.Core.DAL.MainDB())
            {
                objrow       = objDb.CategoryCollection.GetByPrimaryKey(_catid);
                objParentRow = objDb.CategoryCollection.GetByPrimaryKey(objrow.Cat_ParentID);
                objEditRow   = objDb.EditionTypeCollection.GetByPrimaryKey(objrow.EditionType_ID);

                if (_catparent != 0)
                {
                    int cat_id_find_parent = GetCatParent(Convert.ToInt32(_catparent));
                    objrow_find_parent = objDb.CategoryCollection.GetByPrimaryKey(cat_id_find_parent);
                    _catedition        = objrow_find_parent.EditionType_ID;
                }
            }
            if (objrow != null)
            {
                strOldUrl              = objrow.Cat_DisplayURL;
                objrow.Cat_Name        = _catname;
                objrow.Cat_Description = _catdes;
                objrow.Cat_DisplayURL  = _caturl;
                objrow.Cat_ParentID    = _catparent;
                objrow.EditionType_ID  = _catedition;
                //objrow.EditionType_ID = objrow_find_parent.EditionType_ID;
                if (_caticon != null && _caticon != "")
                {
                    objrow.Cat_Icon = _caticon;
                }
                objrow.Cat_isColumn = _catiscolumn;
                objrow.Cat_isHidden = _catishide;
                using (Portal.Core.DAL.MainDB objDb = new Portal.Core.DAL.MainDB())
                {
                    objDb.CategoryCollection.Update(objrow);
                    //UpdateEditionType(objrow.Cat_ID, objrow.EditionType_ID, objDb);
                }
                //cap nhat lai tabref neu co su thay doi ten o displayUrl
                string strEditionRef   = "";
                string strParentTabRef = "";
                string strNewRef       = "";
                string strOldRef       = "";
                if (objEditRow != null)
                {
                    //strEditionRef = objEditRow.EditionDisplayURL;
                    //SonPC
                    String UseEditionType = System.Configuration.ConfigurationSettings.AppSettings["UseEditionType"];
                    if (UseEditionType.ToLower().IndexOf("false") >= 0)
                    {
                        strEditionRef = System.Configuration.ConfigurationSettings.AppSettings["PrefixEditionType"];
                    }
                    else
                    {
                        strEditionRef = objEditRow.EditionDisplayURL;
                    }
                    //SonPC


                    strOldRef = strEditionRef + ".";
                    strNewRef = strEditionRef + ".";
                }
                if (objParentRow != null)
                {
                    strParentTabRef = objParentRow.Cat_DisplayURL;
                    strOldRef       = strOldRef + "." + strParentTabRef + ".";
                    strNewRef       = strNewRef + "." + strParentTabRef + ".";
                }
                strOldRef = strOldRef + strOldUrl;
                strNewRef = strNewRef + _caturl;
                Gentabhelper objHelp = new Gentabhelper();
                objHelp.SyncCategoryTab(strOldRef, strNewRef, _catname, strEditionRef, strParentTabRef, _caturl, _catname);

                #region Cập nhập vào bảng Category ở database User
                Portal.User.Db.CategoryRow objCateUserRow = new Portal.User.Db.CategoryRow();
                using (Portal.User.Db.MainDB objDb = new Portal.User.Db.MainDB())
                {
                    objCateUserRow = objDb.CategoryCollection.GetByPrimaryKey(objrow.Cat_ID);
                }
                objCateUserRow.Cat_Name     = objrow.Cat_Name;
                objCateUserRow.Cat_ParentID = objrow.Cat_ParentID;
                objCateUserRow.Cat_Order    = objrow.Cat_Order;
                objCateUserRow.Channel_ID   = Portal.API.Config.CurrentChannel;
                using (Portal.User.Db.MainDB objDb = new Portal.User.Db.MainDB())
                {
                    objDb.CategoryCollection.Update(objCateUserRow);
                }

                #endregion
            }
        }
        public static void CreateCat(string _catname, string _catdes, string _caturl, int _catparent, int _catedition, string _caticon, bool _catiscolumn, bool _catishide)
        {
            CleanCacheCategory();

            Portal.Core.DAL.CategoryRow objrow = new Portal.Core.DAL.CategoryRow();
            objrow.Cat_Name        = _catname;
            objrow.Cat_Description = _catdes;
            objrow.Cat_DisplayURL  = _caturl;
            objrow.Cat_ParentID    = _catparent;
            objrow.EditionType_ID  = _catedition;
            objrow.Cat_Icon        = _caticon;
            objrow.Cat_isColumn    = _catiscolumn;
            objrow.Cat_isHidden    = _catishide;
            EditionTypeRow objEditRow = null;

            Portal.Core.DAL.CategoryRow objParentRow       = null;
            Portal.Core.DAL.CategoryRow objrow_find_parent = null;

            Portal.Core.DAL.CategoryRow[] objTopRows;
            int intMaxOrder = 0;

            using (Portal.Core.DAL.MainDB objDb = new Portal.Core.DAL.MainDB())
            {
                if (_catparent != 0)
                {
                    int cat_id_find_parent = GetCatParent(Convert.ToInt32(_catparent));
                    objrow_find_parent = objDb.CategoryCollection.GetByPrimaryKey(cat_id_find_parent);
                    _catedition        = objrow_find_parent.EditionType_ID;
                }

                //if (_catparent == 0)
                //    objEditRow = objDb.EditionTypeCollection.GetByPrimaryKey(_catedition);
                //else
                //{
                objParentRow = objDb.CategoryCollection.GetByPrimaryKey(_catparent);
                //    objEditRow = objDb.EditionTypeCollection.GetByPrimaryKey(objParentRow.EditionType_ID);
                //}

                objEditRow = objDb.EditionTypeCollection.GetByPrimaryKey(_catedition);

                objTopRows = objDb.CategoryCollection.GetTopAsArray(1, "Cat_ParentID=" + _catparent, "Cat_Order DESC");
                if (objTopRows.Length == 1)
                {
                    if (objTopRows[0].IsCat_OrderNull)
                    {
                        intMaxOrder = 1;
                    }
                    else
                    {
                        intMaxOrder = objTopRows[0].Cat_Order + 1;
                    }
                }
                objrow.Cat_Order      = intMaxOrder;
                objrow.EditionType_ID = _catedition;
                objDb.CategoryCollection.Insert(objrow);
            }

            //#region Cập nhập vào bảng Category ở database User
            //Portal.User.Db.CategoryRow objCateUserRow = new Portal.User.Db.CategoryRow();
            //objCateUserRow.Cat_ID = objrow.Cat_ID;
            //objCateUserRow.Cat_Name = objrow.Cat_Name;
            //objCateUserRow.Cat_ParentID = objrow.Cat_ParentID;
            //objCateUserRow.Cat_Order = objrow.Cat_Order;
            //objCateUserRow.Channel_ID = Portal.API.Config.CurrentChannel;
            //using (Portal.User.Db.MainDB objDb = new Portal.User.Db.MainDB())
            //{
            //    objDb.CategoryCollection.Insert(objCateUserRow);
            //}
            //#endregion



            //cap nhat thong tin ve tab moi khi them cat
            string strEditionRef   = "";
            string strParentTabRef = "";

            if (objEditRow != null)
            {
                //strEditionRef = objEditRow.EditionDisplayURL;
                //SonPC
                String UseEditionType = ConfigurationSettings.AppSettings["UseEditionType"];
                if (UseEditionType.ToLower().IndexOf("false") >= 0)
                {
                    strEditionRef = ConfigurationSettings.AppSettings["PrefixEditionType"];
                }
                else
                {
                    strEditionRef = objEditRow.EditionDisplayURL;
                }

                //SonPC
            }
            if (objParentRow != null)
            {
                strParentTabRef = objParentRow.Cat_DisplayURL;
            }
            //thuc hien lay doi tuong GenTabHelper
            Gentabhelper objHelp = new Gentabhelper();

            objHelp.AddCategoryTab(strEditionRef, strParentTabRef, _caturl, _catname);
        }