private void BindOrderGifts() { OrderGiftQuery query = new OrderGiftQuery(); query.PageSize = 10; query.PageIndex = pagerOrderGifts.PageIndex; query.OrderId = orderId; DbQueryResult orderGifts = SubsiteSalesHelper.GetOrderGifts(query); dlstOrderGifts.DataSource = orderGifts.Data; dlstOrderGifts.DataBind(); pagerOrderGifts.TotalRecords = orderGifts.TotalRecords; }
public override DbQueryResult GetOrderGifts(OrderGiftQuery query) { DbQueryResult result = new DbQueryResult(); StringBuilder builder = new StringBuilder(); builder.AppendFormat("select top {0} * from Hishop_OrderGifts where OrderId=@OrderId", query.PageSize); if (query.PageIndex == 1) { builder.Append(" ORDER BY GiftId ASC"); } else { builder.AppendFormat(" and GiftId > (select max(GiftId) from (select top {0} GiftId from Hishop_OrderGifts where 0=0 and OrderId=@OrderId ORDER BY GiftId ASC ) as tbltemp) ORDER BY GiftId ASC", (query.PageIndex - 1) * query.PageSize); } if (query.IsCount) { builder.AppendFormat(";select count(GiftId) as Total from Hishop_OrderGifts where OrderId=@OrderId", new object[0]); } DbCommand sqlStringCommand = database.GetSqlStringCommand(builder.ToString()); database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, query.OrderId); using (IDataReader reader = database.ExecuteReader(sqlStringCommand)) { result.Data = DataHelper.ConverDataReaderToDataTable(reader); if (query.IsCount && reader.NextResult()) { reader.Read(); result.TotalRecords = reader.GetInt32(0); } } return result; }
public static DbQueryResult GetOrderGifts(OrderGiftQuery query) { return SalesProvider.Instance().GetOrderGifts(query); }
public abstract DbQueryResult GetOrderGifts(OrderGiftQuery query);