public int GetIDbyPageCode(string PageCode)
 {
     int nResult = 0;
     cStaticPages objDAL = new cStaticPages();
     nResult = objDAL.GetIDbyPageCode(PageCode);
     return nResult;
 }
 public DataTable GetItemByPageCode(string PageCode)
 {
     DataTable tbResult = new DataTable();
     cStaticPages objDAL = new cStaticPages();
     tbResult = objDAL.GetItemByPageCode(PageCode);
     return tbResult;
 }
 public bool CheckExistPage(string PageCode)
 {
     bool isExist = false;
     cStaticPages objDAL = new cStaticPages();
     isExist = objDAL.CheckExistPage(PageCode);
     return isExist;
 }
 public int DeleteById(int ID)
 {
     int nResult = 0;
     cStaticPages objDAL = new cStaticPages();
     try
     {
         objDAL.LoadByPrimaryKey(ID);
         objDAL.MarkAsDeleted();
         objDAL.Save();
         nResult = ID;
     }
     catch
     {
         nResult = 0;
     }
     return nResult;
 }
 public int Insert()
 {
     int nResult = 0;
     cStaticPages objInfor = new cStaticPages();
     try
     {
         objInfor.AddNew();
         this.MappingData(objInfor);
         objInfor.Save();
         nResult = objInfor.StaticPageID ;
     }
     catch
     {
         nResult = 0;
     }
     return nResult;
 }
 public void DeleteChildItem(int ParentPage)
 {
     cStaticPages objDAL = new cStaticPages();
     objDAL.DeleteChildItem(ParentPage);
 }
        private void MappingData(cStaticPages objInfor)
        {
            objInfor.PageCode = Data.PageCode;
            try { objInfor.PageName = Data.PageName; }
            catch { objInfor.PageName = ""; }
            try { objInfor.MenuName = Data.MenuName; }
            catch { objInfor.MenuName = ""; }
            objInfor.Parent = Data.Parent;
            try { objInfor.PageContent = Data.PageContent; }
            catch { objInfor.PageContent = ""; }
            objInfor.DateCreated = Data.DateCreated;
            objInfor.Images = Data.Images;
            objInfor.Priority = Data.Priority;
            objInfor.Status = Data.Status;

            try { objInfor.GroupID = Data.GroupID; }
            catch { objInfor.GroupID = 0; }

            try { objInfor.InitContent = Data.InitContent; }
            catch { objInfor.InitContent = ""; }
        }
 public int UpdateStatus(int ID, int Status)
 {
     int nResult = 0;
     cStaticPages objDAL = new cStaticPages();
     try
     {
         objDAL.LoadByPrimaryKey(ID);
         objDAL.Status = Status;
       //  objDAL.DateCreated  = DateTime.Today;
         objDAL.Save();
         nResult = objDAL.StaticPageID ;
     }
     catch
     {
         nResult = 0;
     }
     return nResult;
 }
 private void ConvertData(cStaticPages objInfor)
 {
     Data.PageCode = objInfor.PageCode;
     Data.PageName = objInfor.PageName;
     Data.MenuName = objInfor.MenuName;
     Data.Parent = objInfor.Parent;
     Data.PageContent = objInfor.PageContent;
     Data.DateCreated = objInfor.DateCreated;
     Data.Images = objInfor.Images;
     Data.Priority = objInfor.Priority;
     Data.Status = objInfor.Status;
     Data.GroupID = objInfor.GroupID;
     Data.InitContent = objInfor.InitContent;
 }
        public int UpdatePriority(int StaticPageID, int Priority)
        {
            int nResult = 0;
            cStaticPages objDAL = new cStaticPages();
            try
            {
                objDAL.LoadByPrimaryKey(StaticPageID);
                objDAL.Priority = Priority;

                objDAL.Save();
                nResult = objDAL.StaticPageID;
            }
            catch
            {
                nResult = 0;
            }
            return nResult;
        }
 public int Update(int ID)
 {
     int nResult = 0;
     cStaticPages objInfor = new cStaticPages();
     try
     {
         objInfor.LoadByPrimaryKey(ID);
         this.MappingData(objInfor);
         objInfor.Save();
         nResult = ID;
     }
     catch
     {
         nResult = 0;
     }
     return nResult;
 }
 public DataTable SearchAll()
 {
     DataTable tbResult = new DataTable();
     cStaticPages objDAL = new cStaticPages();
     tbResult = objDAL.SearchAll();
     return tbResult;
 }
 public DataTable Search(string Title, int Parent, int GroupID,  int Status, int PageIndex, int PageSize, ref int PageCount)
 {
     DataTable tbResult = new DataTable();
     cStaticPages objDAL = new cStaticPages();
     tbResult = objDAL.Search(Title, Parent, GroupID, Status, PageIndex, PageSize, ref  PageCount);
     return tbResult;
 }
 public void LoadById(int ID)
 {
     cStaticPages objDAL = new cStaticPages();
     objDAL.LoadByPrimaryKey(ID);
     ConvertData(objDAL);
 }