Tuesday, May 3, 2016

NOP Commerce (purge products)

This is for purging all products and all associations.  Normally when you delete Products from NOP you flip the 'Deleted' bit.  However this will purge all Products from the system.

version 3.7
Deletes from tables, reseeds the identity, and rebuilds the indexes.

DELETE FROM ShoppingCartItem
DELETE FROM OrderNote
DELETE FROM RecurringPayment
DELETE FROM RewardPointsHistory
DELETE FROM [Order]
DELETE FROM ProductAttributeCombination
DELETE FROM RelatedProduct
DELETE FROM ProductAttributeValue
DELETE FROM ProductAttribute
DELETE FROM Picture
DELETE FROM Product_Category_Mapping
DELETE FROM Product
DELETE FROM Product_Picture_Mapping
DELETE FROM Product_ProductAttribute_Mapping
DELETE FROM Product_ProductTag_Mapping
DELETE FROM Product_SpecificationAttribute_Mapping
DELETE FROM ProductReview
DELETE FROM ProductReviewHelpfulness
DELETE UrlRecord Where EntityName = 'Product'

DBCC CHECKIDENT (ShoppingCartItem, RESEED, 0)
DBCC CHECKIDENT (OrderNote, RESEED, 0)
DBCC CHECKIDENT (RecurringPayment, RESEED, 0)
DBCC CHECKIDENT (RewardPointsHistory, RESEED, 0)
DBCC CHECKIDENT ([Order], RESEED, 0)
DBCC CHECKIDENT(ProductAttributeCombination, RESEED, 0)
DBCC CHECKIDENT (RelatedProduct, RESEED, 0)
DBCC CHECKIDENT ([ProductAttributeValue], RESEED, 0)
DBCC CHECKIDENT (ProductAttribute, RESEED, 0)
DBCC CHECKIDENT (Picture, RESEED, 0)
DBCC CHECKIDENT (Product_Category_Mapping, RESEED, 0)
DBCC CHECKIDENT (Product, RESEED, 0)
DBCC CHECKIDENT (Product_Picture_Mapping, RESEED, 0)
DBCC CHECKIDENT (Product_ProductAttribute_Mapping, RESEED, 0)
DBCC CHECKIDENT (Product_SpecificationAttribute_Mapping, RESEED, 0)
DBCC CHECKIDENT (ProductReview, RESEED, 0)
DBCC CHECKIDENT (ProductReviewHelpfulness, RESEED, 0)

DBCC DBREINDEX (ShoppingCartItem, " ")
DBCC DBREINDEX (OrderNote, " ")
DBCC DBREINDEX (RecurringPayment, " ")
DBCC DBREINDEX (RewardPointsHistory, " ")
DBCC DBREINDEX ([Order], " ")
DBCC DBREINDEX (ProductAttributeCombination, " ")
DBCC DBREINDEX (RelatedProduct, " ")
DBCC DBREINDEX (ProductAttributeValue, " ")
DBCC DBREINDEX (ProductAttribute, " ")
DBCC DBREINDEX (Picture, " ")
DBCC DBREINDEX (Product_Category_Mapping, " ")
DBCC DBREINDEX (Product, " ")
DBCC DBREINDEX (Product_Picture_Mapping, " ")
DBCC DBREINDEX (Product_ProductAttribute_Mapping, " ")
DBCC DBREINDEX (Product_SpecificationAttribute_Mapping, " ")
DBCC DBREINDEX (ProductReview, " ")
DBCC DBREINDEX (ProductReviewHelpfulness, " ")

Friday, April 22, 2016

SSRS aggregating a text box

Since you're not able to use aggregate functions on text box values. You'll need to do something like this. You'll get an error similar to this "The Value expression for the text box '***' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers."

Code (Within report properties):
Dim public total as Integer

Public Function AddToTotal(ByVal balance AS Integer ) AS Integer
                total = total + balance
                return balance
End Function

Public Function GetTotal()
                return total
End Function

Expression on the text box that is repeating:
=Code.AddToTotal(your value)

Expression on your total text box:
=Code.GetTotalImpliedMonth()