Пример #1
0
        public ActionResult NewsDataPrivate(NewsData_Filter filter, Rest.Core.Paging Page)
        {
            ViewData["MenuItem"] = 9;
            if (!sessionData.trading.Dept.HasValue)
            {
                return(View("~/Views/Manage/PermissionDeny.aspx"));
            }
            else
            {
                if (filter.Title == "請輸入標題搜尋")
                {
                    filter.Title = null;
                }
                if (filter.DeptName == "請選擇")
                {
                    filter.DeptName = null;
                }
                if (filter.Cost == "請選擇")
                {
                    filter.Cost = null;
                }
                if (!sessionData.trading.IsVerifier)
                {
                    filter.DeptName = EnumHelper.GetEnumDescription <WS_Dept_type>(sessionData.trading.Dept.Value);
                    filter.Cost     = sessionData.trading.CostName;
                }
                else
                {
                    ViewData["DeptName"] = filter.DeptName;//不預設搜尋條件
                }
                if (filter.DeptName != null && filter.DeptName.Length == 1)
                {
                    filter.DeptName = EnumHelper.GetEnumDescription <WS_Dept_type>(EnumHelper.GetEnumByName <WS_Dept_type>(filter.DeptName));
                }

                //私領域
                filter.IsPrivate   = 1;
                ViewData["Filter"] = filter;

                Rest.Core.Paging page = new Rest.Core.Paging()
                {
                };
                if (Page.CurrentPage > 0)
                {
                    page.CurrentPage = Page.CurrentPage;
                }
                List <NewsData_Info> data = NewsDataMan.GetByParameter(filter, page, null, "PublishDate desc");
                ViewData["Model"] = data;
                ViewData["Page"]  = page;
                return(View("~/Views/Page6/NewsData.aspx"));
            }
        }
Пример #2
0
        public ActionResult NewsData(NewsData_Filter filter, Rest.Core.Paging Page)
        {
            var PermissionCheck = CheckPermission("衛教園區管理");

            if (PermissionCheck != null)
            {
                return(PermissionCheck);
            }

            if (filter.Title == "請輸入標題搜尋")
            {
                filter.Title = null;
            }
            if (filter.DeptName == "請選擇")
            {
                filter.DeptName = null;
            }
            if (filter.Cost == "請選擇")
            {
                filter.Cost = null;
            }
            if (!sessionData.trading.IsVerifier && sessionData.trading.Dept != null)
            {
                filter.DeptName = EnumHelper.GetEnumDescription <WS_Dept_type>(sessionData.trading.Dept.Value);
                filter.Cost     = sessionData.trading.CostName;
            }
            if (filter.DeptName != null && filter.DeptName.Length == 1)
            {
                filter.DeptName = EnumHelper.GetEnumDescription <WS_Dept_type>(EnumHelper.GetEnumByName <WS_Dept_type>(filter.DeptName));
            }
            //公領域
            filter.IsPrivate   = 0;
            ViewData["Filter"] = filter;

            Rest.Core.Paging page = new Rest.Core.Paging()
            {
            };
            if (Page.CurrentPage > 0)
            {
                page.CurrentPage = Page.CurrentPage;
            }
            List <NewsData_Info> data = NewsDataMan.GetByParameter(filter, page, null, "PublishDate desc");

            ViewData["Model"]    = data;
            ViewData["Page"]     = page;
            ViewData["DeptName"] = filter.DeptName;//不預設搜尋條件
            return(View());
        }
Пример #3
0
        public List <NewsData_Info> GetByParam(NewsData_Filter Filter, Paging Page, string[] fieldNames, string _orderby)
        {
            if (fieldNames == null)
            {
                fieldNames = new string[] { "*" };
            }
            if (Page == null)
            {
                Page = new Paging();
            }
            using (var db = new DBExecutor().GetDatabase())
            {
                var SQLStr = ConstructSQL(Filter, fieldNames, _orderby);

                var result = db.Page <NewsData_Info>(Page.CurrentPage, Page.ItemsPerPage, SQLStr);
                Page.Convert <NewsData_Info>(result);

                return(result.Items);
            }
        }
Пример #4
0
 public List <NewsData_Info> GetByParameter(NewsData_Filter Filter, string[] fieldNames, string _orderby, Rest.Core.Paging Page)
 {
     return(new NewsData_Repo().GetByParam(Filter, fieldNames, _orderby, Page));
 }
Пример #5
0
 public List <NewsData_Info> GetByParameter(NewsData_Filter Filter, string _orderby)
 {
     return(new NewsData_Repo().GetByParam(Filter, _orderby));
 }
Пример #6
0
 public List <NewsData_Info> GetByParameter(NewsData_Filter Filter, Rest.Core.Paging Page)
 {
     return(new NewsData_Repo().GetByParam(Filter, Page));
 }
Пример #7
0
 public List <NewsData_Info> GetByParameter(NewsData_Filter Filter)
 {
     return(new NewsData_Repo().GetByParam(Filter));
 }
Пример #8
0
 public List <NewsData_Info> GetByParam(NewsData_Filter Filter, string[] fieldNames, string _orderby, Paging Page)
 {
     return(GetByParam(Filter, Page, fieldNames, _orderby));
 }
Пример #9
0
 public List <NewsData_Info> GetByParam(NewsData_Filter Filter, string _orderby, Paging Page)
 {
     return(GetByParam(Filter, Page, null, _orderby));
 }
Пример #10
0
 public List <NewsData_Info> GetByParam(NewsData_Filter Filter, Paging Page)
 {
     return(GetByParam(Filter, Page, null, ""));
 }
Пример #11
0
 public List <NewsData_Info> GetByParam(NewsData_Filter Filter)
 {
     return(GetByParam(Filter, null, null, ""));
 }
Пример #12
0
        private Rest.Core.PetaPoco.Sql ConstructSQL(NewsData_Filter filter, string[] fieldNames, string _orderby)
        {
            var SQLStr = Rest.Core.PetaPoco.Sql.Builder
                         .Append("SELECT " + FieldNameArrayToFieldNameString(fieldNames) + " FROM db_NewsData")
                         .Append("WHERE 1=1 ");

            if (filter != null)
            {
                if (filter.NewsId.HasValue)
                {
                    SQLStr.Append(" AND NewsId=@0", filter.NewsId.Value);
                }
                if (filter.PublishDate.HasValue)
                {
                    SQLStr.Append(" AND PublishDate=@0", filter.PublishDate.Value);
                }
                if (!string.IsNullOrEmpty(filter.DeptName))
                {
                    SQLStr.Append(" AND DeptName=@0", filter.DeptName);
                }
                if (!string.IsNullOrEmpty(filter.DeptCode))
                {
                    SQLStr.Append(" AND DeptCode=@0", filter.DeptCode);
                }
                if (!string.IsNullOrEmpty(filter.CostId))
                {
                    SQLStr.Append(" AND CostId like @0", filter.CostId);
                }
                if (!string.IsNullOrEmpty(filter.Cost))
                {
                    SQLStr.Append(" AND Cost=@0", filter.Cost);
                }
                if (!string.IsNullOrEmpty(filter.Title))
                {
                    SQLStr.Append(" AND Title like @0", "%" + filter.Title + "%");
                }
                if (!string.IsNullOrEmpty(filter.Author))
                {
                    SQLStr.Append(" AND Author=@0", filter.Author);
                }
                if (!string.IsNullOrEmpty(filter.Keyword))
                {
                    SQLStr.Append(" AND Keyword=@0", filter.Keyword);
                }
                if (!string.IsNullOrEmpty(filter.ContentBody))
                {
                    SQLStr.Append(" AND ContentBody=@0", filter.ContentBody);
                }
                if (!string.IsNullOrEmpty(filter.Image1))
                {
                    SQLStr.Append(" AND Image1=@0", filter.Image1);
                }
                if (!string.IsNullOrEmpty(filter.Image2))
                {
                    SQLStr.Append(" AND Image2=@0", filter.Image2);
                }
                if (!string.IsNullOrEmpty(filter.Image3))
                {
                    SQLStr.Append(" AND Image3=@0", filter.Image3);
                }
                if (!string.IsNullOrEmpty(filter.Image4))
                {
                    SQLStr.Append(" AND Image4=@0", filter.Image4);
                }
                if (filter.IsShowOnTeam.HasValue)
                {
                    SQLStr.Append(" AND IsShowOnTeam=@0", filter.IsShowOnTeam.Value);
                }
                if (filter.IsPrivate.HasValue)
                {
                    SQLStr.Append(" AND IsPrivate=@0", filter.IsPrivate.Value);
                }
                if (filter.Hit.HasValue)
                {
                    SQLStr.Append(" AND Hit=@0", filter.Hit.Value);
                }
                if (filter.IsActive.HasValue)
                {
                    SQLStr.Append(" AND IsActive=@0", filter.IsActive.Value);
                }
                if (filter.LastUpdate.HasValue)
                {
                    SQLStr.Append(" AND LastUpdate=@0", filter.LastUpdate.Value);
                }
                if (!string.IsNullOrEmpty(filter.LastUpadtor))
                {
                    SQLStr.Append(" AND LastUpadtor=@0", filter.LastUpadtor);
                }
                if (filter.VerifiedDate.HasValue)
                {
                    SQLStr.Append(" AND VerifiedDate=@0", filter.VerifiedDate.Value);
                }
                if (_orderby != "")
                {
                    SQLStr.OrderBy(_orderby);
                }
            }
            return(SQLStr);
        }
Пример #13
0
 private Rest.Core.PetaPoco.Sql ConstructSQL(NewsData_Filter filter)
 {
     return(ConstructSQL(filter, new string[] { "*" }, ""));
 }