Exemple #1
0
        public override List <ProductInfoVO> GetModels(ref ProductInfoPara 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 <ProductInfoVO> list = new List <ProductInfoVO>();

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

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

            return(list);
        }
Exemple #2
0
        public override string GetOrderByPara(ProductInfoPara mp)
        {
            if (!string.IsNullOrEmpty(mp.OrderBy))
            {
                return(string.Format(" order by {0}", mp.OrderBy));
            }

            return("");
        }
Exemple #3
0
        public override ProductInfoVO GetSingle(ProductInfoPara mp)
        {
            var list = GetModels(mp);

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

            return(null);
        }
Exemple #4
0
        public override string GetConditionByPara(ProductInfoPara 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 (mp.AdId.HasValue)
            {
                sb.AppendFormat(" AND [AdId]='{0}' ", mp.AdId);
            }
            if (mp.Price.HasValue)
            {
                sb.AppendFormat(" AND [Price]='{0}' ", mp.Price);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.AttrText)))
            {
                sb.AppendFormat(" AND [AttrText]='{0}' ", mp.AttrText);
            }
            if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.AttrStyle)))
            {
                sb.AppendFormat(" AND [AttrStyle]='{0}' ", mp.AttrStyle);
            }
            if (mp.IsState.HasValue)
            {
                sb.AppendFormat(" AND [IsState]='{0}' ", mp.IsState);
            }
            if (mp.IsDelete.HasValue)
            {
                sb.AppendFormat(" AND [IsDelete]='{0}' ", mp.IsDelete);
            }
            if (mp.CreateUserId.HasValue)
            {
                sb.AppendFormat(" AND [CreateUserId]='{0}' ", mp.CreateUserId);
            }
            if (mp.CreateDate.HasValue)
            {
                sb.AppendFormat(" AND [CreateDate]='{0}' ", mp.CreateDate);
            }


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

            return(sb.ToString());
        }
Exemple #5
0
        public override int GetRecords(ProductInfoPara 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()));
        }
Exemple #6
0
        private void Bind(int pageIndex = 1)
        {
            ProductInfoPara aip = new ProductInfoPara();

            aip.PageIndex = pageIndex - 1;
            aip.PageSize  = 10;
            aip.OrderBy   = " id desc ";

            var list = ProductInfoBLL.Instance.GetModels(ref aip);

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

            apPager.RecordCount = aip.Recount.Value;
        }
Exemple #7
0
        public override bool Delete(ProductInfoPara 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);
        }
Exemple #8
0
        public override List <ProductInfoVO> GetModels(ProductInfoPara 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 <ProductInfoVO> list = new List <ProductInfoVO>();

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

            return(list);
        }
Exemple #9
0
 public override string GetOtherConditionByPara(ProductInfoPara mp)
 {
     return("");
 }