コード例 #1
0
        public static DataTable GetProductDetailList(string Title, int ProductType, string startDate, string endDate, int pageNumber, int pageSize, out int pageCount, out int rowCount, DBOperationManagment dbm)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@" select pcd.*,pcm.ProductModel,stuff((select ','+detail.Title from 
ProductRelation pr
inner join ProductCenterDetail detail on pr.RelatinProductDetailID=detail.ProductDetailID
where pr.ProductDetailID=pcd.ProductDetailID for xml path('')),1,1,'') 
ProductRelation 
from ProductCenterDetail pcd
inner join ProductCenterModel pcm on pcd.ProductModelID=pcm.ProductModelID
inner join ProductCenter pc on pcm.ProductID=pc.ProductID 
where 1=1 ");

            if (ProductType != 0)
            {
                strSql.AppendFormat(" AND pc.ProductType = '{0}' ", ProductType);
            }
            if (!string.IsNullOrEmpty(Title))
            {
                strSql.AppendFormat(" AND pcd.Title like '%{0}%' ", Title);
            }
            if (!string.IsNullOrEmpty(startDate) && !string.IsNullOrEmpty(endDate))
            {
                strSql.AppendFormat(" AND pcd.UpdateTime between '{0} 00:00:00' and '{1} 23:59:59' ", startDate, endDate);
            }
            strSql.Append(" ORDER BY pcd.UpdateTime DESC ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@sql",         SqlDbType.VarChar, 3000),
                new SqlParameter("@page",        SqlDbType.Int,        4),
                new SqlParameter("@pageSize",    SqlDbType.Int,        4),
                new SqlParameter("@pageCount",   SqlDbType.Int,        4),
                new SqlParameter("@recordCount", SqlDbType.Int,        4),
            };

            ExecProcedure ep = new ExecProcedure();

            ep.SqlCommand           = "Common_FastPageList";
            parameters[0].Value     = strSql.ToString();
            parameters[1].Value     = pageNumber;
            parameters[2].Value     = pageSize;
            parameters[3].Direction = ParameterDirection.Output;
            parameters[4].Direction = ParameterDirection.Output;
            ep.Parameters           = parameters;
            dbm.Execute(ep);
            pageCount = (int)parameters[3].Value;
            rowCount  = (int)parameters[4].Value;
            if (ep.ResultData != null && ep.ResultData.Tables != null && ep.ResultData.Tables.Count > 1)
            {
                return(ep.ResultData.Tables[1]);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        public static DataTable GetList <T>(string Title, string startDate, string endDate, int pageNumber, int pageSize, out int pageCount, out int rowCount, DBOperationManagment dbm)
        {
            Type          type      = typeof(T);
            object        obj       = Activator.CreateInstance(type);
            string        tableName = obj.GetType().Name;
            StringBuilder strSql    = new StringBuilder();

            strSql.Append(@"select * from " + tableName + " t1 where 1=1 ");

            if (!string.IsNullOrEmpty(Title))
            {
                strSql.AppendFormat(" AND t1.Title like '%{0}%' ", Title);
            }
            if (!string.IsNullOrEmpty(startDate) && !string.IsNullOrEmpty(endDate))
            {
                strSql.AppendFormat(" AND t1.UpdateTime between '{0} 00:00:00' and '{1} 23:59:59' ", startDate, endDate);
            }
            strSql.Append(" ORDER BY t1.ID ASC ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@sql",         SqlDbType.VarChar, 3000),
                new SqlParameter("@page",        SqlDbType.Int,        4),
                new SqlParameter("@pageSize",    SqlDbType.Int,        4),
                new SqlParameter("@pageCount",   SqlDbType.Int,        4),
                new SqlParameter("@recordCount", SqlDbType.Int,        4),
            };

            ExecProcedure ep = new ExecProcedure();

            ep.SqlCommand           = "Common_FastPageList";
            parameters[0].Value     = strSql.ToString();
            parameters[1].Value     = pageNumber;
            parameters[2].Value     = pageSize;
            parameters[3].Direction = ParameterDirection.Output;
            parameters[4].Direction = ParameterDirection.Output;
            ep.Parameters           = parameters;
            dbm.Execute(ep);
            pageCount = (int)parameters[3].Value;
            rowCount  = (int)parameters[4].Value;
            if (ep.ResultData != null && ep.ResultData.Tables != null && ep.ResultData.Tables.Count > 1)
            {
                return(ep.ResultData.Tables[1]);
            }
            else
            {
                return(null);
            }
        }