Example #1
0
 public ActionResult Index(CostUnit_Filter filter)
 {
     if (!sessionData.trading.Dept.HasValue)
     {
         return(View("~/Views/Manage/PermissionDeny.aspx"));
     }
     else
     {
         WanFang.BLL.CostUnit_Manager man = new WanFang.BLL.CostUnit_Manager();
         if (filter.UnitName == "請輸入單元名稱搜尋")
         {
             filter.UnitName = null;
         }
         if (!sessionData.trading.IsVerifier)
         {
             filter.DeptName = EnumHelper.GetEnumDescription <WS_Dept_type>(sessionData.trading.Dept.Value);
             filter.CostName = sessionData.trading.CostName;
         }
         Rest.Core.Paging page = new Rest.Core.Paging()
         {
             ItemsPerPage = 9999
         };
         string sortingby = "SortNum";
         if (sessionData.trading.IsVerifier)
         {
             sortingby = "DeptName, CostName, SortNum";
         }
         var data = man.GetByParameter(filter, page, null, sortingby);
         ViewData["Model"] = data;
         return(View());
     }
 }
Example #2
0
        public List <CostUnit_Info> GetByParam(CostUnit_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 <CostUnit_Info>(Page.CurrentPage, Page.ItemsPerPage, SQLStr);
                Page.Convert <CostUnit_Info>(result);

                return(result.Items);
            }
        }
Example #3
0
 public List <CostUnit_Info> GetByParameter(CostUnit_Filter Filter, string[] fieldNames, string _orderby, Rest.Core.Paging Page)
 {
     return(new CostUnit_Repo().GetByParam(Filter, fieldNames, _orderby, Page));
 }
Example #4
0
 public List <CostUnit_Info> GetByParameter(CostUnit_Filter Filter, string _orderby)
 {
     return(new CostUnit_Repo().GetByParam(Filter, _orderby));
 }
Example #5
0
 public List <CostUnit_Info> GetByParameter(CostUnit_Filter Filter, Rest.Core.Paging Page)
 {
     return(new CostUnit_Repo().GetByParam(Filter, Page));
 }
Example #6
0
 public List <CostUnit_Info> GetByParameter(CostUnit_Filter Filter)
 {
     return(new CostUnit_Repo().GetByParam(Filter));
 }
Example #7
0
 public List <CostUnit_Info> GetByParam(CostUnit_Filter Filter, string[] fieldNames, string _orderby, Paging Page)
 {
     return(GetByParam(Filter, Page, fieldNames, _orderby));
 }
Example #8
0
 public List <CostUnit_Info> GetByParam(CostUnit_Filter Filter, string _orderby, Paging Page)
 {
     return(GetByParam(Filter, Page, null, _orderby));
 }
Example #9
0
 public List <CostUnit_Info> GetByParam(CostUnit_Filter Filter, Paging Page)
 {
     return(GetByParam(Filter, Page, null, ""));
 }
Example #10
0
 public List <CostUnit_Info> GetByParam(CostUnit_Filter Filter)
 {
     return(GetByParam(Filter, null, null, ""));
 }
Example #11
0
        private Rest.Core.PetaPoco.Sql ConstructSQL(CostUnit_Filter filter, string[] fieldNames, string _orderby)
        {
            var SQLStr = Rest.Core.PetaPoco.Sql.Builder
                         .Append("SELECT " + FieldNameArrayToFieldNameString(fieldNames) + " FROM db_CostUnit")
                         .Append("WHERE 1=1 ");

            if (filter != null)
            {
                if (filter.CostUnitId.HasValue)
                {
                    SQLStr.Append(" AND CostUnitId=@0", filter.CostUnitId.Value);
                }
                if (filter.SortNum.HasValue)
                {
                    SQLStr.Append(" AND SortNum=@0", filter.SortNum.Value);
                }
                if (!string.IsNullOrEmpty(filter.CostName))
                {
                    SQLStr.Append(" AND CostName=@0", filter.CostName);
                }
                if (!string.IsNullOrEmpty(filter.CostId))
                {
                    SQLStr.Append(" AND CostId=@0", filter.CostId);
                }
                if (!string.IsNullOrEmpty(filter.DeptName))
                {
                    SQLStr.Append(" AND DeptName=@0", filter.DeptName);
                }
                if (!string.IsNullOrEmpty(filter.UnitName))
                {
                    SQLStr.Append(" AND UnitName like @0", "%" + filter.UnitName + "%");
                }
                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 (filter.IsHomePage.HasValue)
                {
                    SQLStr.Append(" AND IsHomePage=@0", filter.IsHomePage.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.LastUpdator))
                {
                    SQLStr.Append(" AND LastUpdator=@0", filter.LastUpdator);
                }
                if (filter.VerifiedDate.HasValue)
                {
                    SQLStr.Append(" AND VerifiedDate=@0", filter.VerifiedDate.Value);
                }
                if (_orderby != "")
                {
                    SQLStr.OrderBy(_orderby);
                }
            }
            return(SQLStr);
        }
Example #12
0
 private Rest.Core.PetaPoco.Sql ConstructSQL(CostUnit_Filter filter)
 {
     return(ConstructSQL(filter, new string[] { "*" }, ""));
 }