Пример #1
0
        public List <Question_Info> GetByParam(Question_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 <Question_Info>(Page.CurrentPage, Page.ItemsPerPage, SQLStr);
                Page.Convert <Question_Info>(result);

                return(result.Items);
            }
        }
Пример #2
0
        public ActionResult Question(Question_Filter filter, Rest.Core.Paging Page)
        {
            var PermissionCheck = CheckPermission("詢問台管理");

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

            if (!string.IsNullOrEmpty(filter.Q_question) && filter.Q_question.StartsWith("請輸入"))
            {
                filter.Q_question = null;
            }
            if (filter != null && !string.IsNullOrEmpty(filter.Q_type) && filter.Q_type.StartsWith("請選擇"))
            {
                filter.Q_type = null;
            }
            if (filter != null && !string.IsNullOrEmpty(filter.CostName) && filter.CostName.StartsWith("請選擇"))
            {
                filter.CostName = null;
            }
            if (filter != null && !string.IsNullOrEmpty(filter.Dept) && filter.Dept.StartsWith("請選擇"))
            {
                filter.Dept = null;
            }
            ViewData["Filter"] = filter;
            Rest.Core.Paging page = new Rest.Core.Paging()
            {
            };
            if (Page.CurrentPage > 0)
            {
                page.CurrentPage = Page.CurrentPage;
            }
            List <Question_Info> data = QMan.GetByParameter(filter, page, null, "QuestionId desc");

            ViewData["Model"] = data;
            ViewData["Page"]  = page;
            return(View());
        }
Пример #3
0
 public List <Question_Info> GetByParameter(Question_Filter Filter, string[] fieldNames, string _orderby, Rest.Core.Paging Page)
 {
     return(new Question_Repo().GetByParam(Filter, fieldNames, _orderby, Page));
 }
Пример #4
0
 public List <Question_Info> GetByParameter(Question_Filter Filter, string _orderby)
 {
     return(new Question_Repo().GetByParam(Filter, _orderby));
 }
Пример #5
0
 public List <Question_Info> GetByParameter(Question_Filter Filter, Rest.Core.Paging Page)
 {
     return(new Question_Repo().GetByParam(Filter, Page));
 }
Пример #6
0
 public List <Question_Info> GetByParameter(Question_Filter Filter)
 {
     return(new Question_Repo().GetByParam(Filter));
 }
Пример #7
0
 public List <Question_Info> GetByParam(Question_Filter Filter, string[] fieldNames, string _orderby, Paging Page)
 {
     return(GetByParam(Filter, Page, fieldNames, _orderby));
 }
Пример #8
0
 public List <Question_Info> GetByParam(Question_Filter Filter, string _orderby, Paging Page)
 {
     return(GetByParam(Filter, Page, null, _orderby));
 }
Пример #9
0
 public List <Question_Info> GetByParam(Question_Filter Filter, Paging Page)
 {
     return(GetByParam(Filter, Page, null, ""));
 }
Пример #10
0
 public List <Question_Info> GetByParam(Question_Filter Filter)
 {
     return(GetByParam(Filter, null, null, ""));
 }
Пример #11
0
        private Rest.Core.PetaPoco.Sql ConstructSQL(Question_Filter filter, string[] fieldNames, string _orderby)
        {
            var SQLStr = Rest.Core.PetaPoco.Sql.Builder
                         .Append("SELECT " + FieldNameArrayToFieldNameString(fieldNames) + " FROM db_Question")
                         .Append("WHERE 1=1 ");

            if (filter != null)
            {
                if (filter.QuestionId.HasValue)
                {
                    SQLStr.Append(" AND QuestionId=@0", filter.QuestionId.Value);
                }
                if (filter.Q_time.HasValue)
                {
                    SQLStr.Append(" AND Q_time=@0", filter.Q_time.Value);
                }
                if (!string.IsNullOrEmpty(filter.Q_type))
                {
                    SQLStr.Append(" AND Q_type=@0", filter.Q_type);
                }
                if (!string.IsNullOrEmpty(filter.DeptName))
                {
                    SQLStr.Append(" AND DeptName=@0", filter.DeptName);
                }
                if (!string.IsNullOrEmpty(filter.Dept))
                {
                    SQLStr.Append(" AND Dept=@0", filter.Dept);
                }
                if (!string.IsNullOrEmpty(filter.CostName))
                {
                    SQLStr.Append(" AND CostName=@0", filter.CostName);
                }
                if (!string.IsNullOrEmpty(filter.Q_title))
                {
                    SQLStr.Append(" AND Q_title=@0", filter.Q_title);
                }
                if (!string.IsNullOrEmpty(filter.Q_question))
                {
                    SQLStr.Append(" AND Q_question like @0", "%" + filter.Q_question + "%");
                }
                if (!string.IsNullOrEmpty(filter.Q_ans))
                {
                    SQLStr.Append(" AND Q_ans=@0", filter.Q_ans);
                }
                if (!string.IsNullOrEmpty(filter.Q_edit))
                {
                    SQLStr.Append(" AND Q_edit=@0", filter.Q_edit);
                }
                if (filter.hit.HasValue)
                {
                    SQLStr.Append(" AND hit=@0", filter.hit.Value);
                }
                if (filter.LastUpdate.HasValue)
                {
                    SQLStr.Append(" AND LastUpdate=@0", filter.LastUpdate.Value);
                }
                if (!string.IsNullOrEmpty(filter.LastUpdator))
                {
                    SQLStr.Append(" AND LastUpdator=@0", filter.LastUpdator);
                }
                if (_orderby != "")
                {
                    SQLStr.OrderBy(_orderby);
                }
            }
            return(SQLStr);
        }
Пример #12
0
 private Rest.Core.PetaPoco.Sql ConstructSQL(Question_Filter filter)
 {
     return(ConstructSQL(filter, new string[] { "*" }, ""));
 }