コード例 #1
0
        public override List <ChannelInfoVO> GetModels(ref ChannelInfoPara mp)
        {
            string where = GetConditionByPara(mp);

            int    pStart = mp.PageIndex.Value * mp.PageSize.Value;
            int    pEnd   = mp.PageSize.Value;
            string cmd    = QUERYPAGE
                            .Replace("@PAGESIZE", pEnd.ToString())
                            .Replace("@PTOP", pStart.ToString())
                            .Replace("@WHERE", where)
                            .Replace("@ORDER", GetOrderByPara(mp));

            CodeCommand command = new CodeCommand();

            command.CommandText = cmd;

            var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command);

            List <ChannelInfoVO> list = new List <ChannelInfoVO>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                list.Add(new ChannelInfoVO(table.Rows[i]));
            }

            if (!mp.Recount.HasValue)
            {
                mp.Recount = GetRecords(mp);
            }

            return(list);
        }
コード例 #2
0
        public override string GetConditionByPara(ChannelInfoPara mp)
        {
            StringBuilder sb = new StringBuilder();

            if (mp.Id.HasValue)
            {
                sb.AppendFormat(" AND [Id]='{0}' ", mp.Id);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Name)))
            {
                sb.AppendFormat(" AND [Name]='{0}' ", mp.Name);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Desc)))
            {
                sb.AppendFormat(" AND [Desc]='{0}' ", mp.Desc);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.LinkUrl)))
            {
                sb.AppendFormat(" AND [LinkUrl]='{0}' ", mp.LinkUrl);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ImgUrl)))
            {
                sb.AppendFormat(" AND [ImgUrl]='{0}' ", mp.ImgUrl);
            }
            if (mp.IsShow.HasValue)
            {
                sb.AppendFormat(" AND [IsShow]='{0}' ", mp.IsShow);
            }
            if (mp.IsHot.HasValue)
            {
                sb.AppendFormat(" AND [IsHot]='{0}' ", mp.IsHot);
            }
            if (mp.IsTop.HasValue)
            {
                sb.AppendFormat(" AND [IsTop]='{0}' ", mp.IsTop);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ColorValue)))
            {
                sb.AppendFormat(" AND [ColorValue]='{0}' ", mp.ColorValue);
            }
            if (mp.CreateDate.HasValue)
            {
                sb.AppendFormat(" AND [CreateDate]='{0}' ", mp.CreateDate);
            }
            if (mp.LastDate.HasValue)
            {
                sb.AppendFormat(" AND [LastDate]='{0}' ", mp.LastDate);
            }
            if (mp.CreateUserId.HasValue)
            {
                sb.AppendFormat(" AND [CreateUserId]='{0}' ", mp.CreateUserId);
            }


            sb.Insert(0, " WHERE 1=1 ");

            return(sb.ToString());
        }
コード例 #3
0
        public override string GetOrderByPara(ChannelInfoPara mp)
        {
            if (!string.IsNullOrEmpty(mp.OrderBy))
            {
                return(string.Format(" order by {0}", mp.OrderBy));
            }

            return("");
        }
コード例 #4
0
        public override ChannelInfoVO GetSingle(ChannelInfoPara mp)
        {
            var list = GetModels(mp);

            if (list.Count == 1)
            {
                return(list[0]);
            }

            return(null);
        }
コード例 #5
0
        public override int GetRecords(ChannelInfoPara mp)
        {
            string where = GetConditionByPara(mp);

            CodeCommand command = new CodeCommand();

            command.CommandText = QUERYCOUNT + where;

            var result = DbProxyFactory.Instance.Proxy.ExecuteScalar(command);

            return(int.Parse(result.ToString()));
        }
コード例 #6
0
        private void Bind(int pageIndex = 1)
        {
            ChannelInfoPara cip = new ChannelInfoPara();

            cip.PageIndex = pageIndex - 1;
            cip.PageSize  = 10;

            var list = ChannelInfoBLL.Instance.GetModels(ref cip);

            rptTables.DataSource = list;
            rptTables.DataBind();

            apPager.RecordCount = cip.Recount.Value;
        }
コード例 #7
0
        public override bool Delete(ChannelInfoPara mp)
        {
            string where = GetConditionByPara(mp);

            CodeCommand command = new CodeCommand();

            command.CommandText = DELETE + where;

            int result = DbProxyFactory.Instance.Proxy.ExecuteNonQuery(command);

            if (result >= 1)
            {
                return(true);
            }

            return(false);
        }
コード例 #8
0
        public override List <ChannelInfoVO> GetModels(ChannelInfoPara mp)
        {
            string where = GetConditionByPara(mp);

            CodeCommand command = new CodeCommand();

            string cmd = LOAD
                         .Replace("@WHERE", where)
                         .Replace("@ORDER", GetOrderByPara(mp));

            command.CommandText = cmd;

            var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command);

            List <ChannelInfoVO> list = new List <ChannelInfoVO>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                list.Add(new ChannelInfoVO(table.Rows[i]));
            }

            return(list);
        }
コード例 #9
0
 public override string GetOtherConditionByPara(ChannelInfoPara mp)
 {
     return("");
 }