我在这里有一些代码:(它基本上检查一个产品是否是一个工具包产品,然后在修改价格时应用新价格)
if (!newItem.m_IsAKit)
{
NewPR = AppLogic.DetermineLevelPrice(newItem.m_VariantID, m_ThisCustomer.CustomerLevelID, out IsOnSale);
Decimal PrMod = AppLogic.GetColorAndSizePriceDelta(DB.RSField(rs, "ChosenColor"), DB.RSField(rs, "ChosenSize"), DB.RSFieldInt(rs, "TaxClassID"), ThisCustomer, true, false);
if (PrMod != System.Decimal.Zero)
{
NewPR += PrMod;
}
}
else
{
NewPR = DB.RSFieldDecimal(rs, "ProductPrice");
if (LevelDiscountPercent != 0.0M)
{
NewPR = AppLogic.GetKitTotalPrice(m_ThisCustomer.CustomerID, m_ThisCustomer.CustomerLevelID, newItem.m_ProductID, newItem.m_VariantID, newItem.m_ShoppingCartRecordID);
}
}我有一个产品,这是一个工具包产品,所以我引用代码后的其他语句。
我需要申请NewPr += PrMod。
NewPr = 22
PrMod =5
我尝试过添加以下代码:
Decimal PrMod = AppLogic.GetColorAndSizePriceDelta(DB.RSField(rs, "ChosenColor"), DB.RSField(rs, "ChosenSize"), DB.RSFieldInt(rs, "TaxClassID"), ThisCustomer, true, false);
if (PrMod != System.Decimal.Zero)
{
NewPR += PrMod;
}但是在调试过程中,PrMod似乎不包含一个值。
你能帮我指出正确的方向吗?
谢谢
我有以下方法,但我似乎看不出问题出在哪里。当产品是一个工具包产品,它的工作良好。
static public decimal GetColorAndSizePriceDelta(String ChosenColor, String ChosenSize, int TaxClassID, Customer ThisCustomer, bool WithDiscount, bool WithVAT)
{
bool VATEnabled = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("VAT.Enabled");
bool VATOn = (VATEnabled && ThisCustomer.VATSettingReconciled == VATSettingEnum.ShowPricesInclusiveOfVAT);
decimal CustLevelDiscountPct = 1.0M;
decimal price = System.Decimal.Zero;
String ColorPriceModifier = String.Empty;
String SizePriceModifier = String.Empty;
if (ThisCustomer.CustomerLevelID > 0 && WithDiscount)
{
decimal LevelDiscountPercent = System.Decimal.Zero;
using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
{
dbconn.Open();
string sSql = string.Format("select LevelDiscountPercent from CustomerLevel with (NOLOCK) where CustomerLevelID={0}", ThisCustomer.CustomerLevelID);
using (IDataReader rs = DB.GetRS(sSql, dbconn))
{
if (rs.Read())
{
LevelDiscountPercent = DB.RSFieldDecimal(rs, "LevelDiscountPercent");
}
}
}
if (LevelDiscountPercent != System.Decimal.Zero)
{
CustLevelDiscountPct -= LevelDiscountPercent / 100.0M;
}
}
if (ChosenColor.IndexOf("[") != -1)
{
int i1 = ChosenColor.IndexOf("[");
int i2 = ChosenColor.IndexOf("]");
if (i1 != -1 && i2 != -1)
{
ColorPriceModifier = ChosenColor.Substring(i1 + 1, i2 - i1 - 1);
}
}
if (ChosenSize.IndexOf("[") != -1)
{
int i1 = ChosenSize.IndexOf("[");
int i2 = ChosenSize.IndexOf("]");
if (i1 != -1 && i2 != -1)
{
SizePriceModifier = ChosenSize.Substring(i1 + 1, i2 - i1 - 1);
}
}
if (ColorPriceModifier.Length != 0)
{
price += Localization.ParseDBDecimal(ColorPriceModifier);
}
if (SizePriceModifier.Length != 0)
{
price += Localization.ParseDBDecimal(SizePriceModifier);
}
if (VATOn && WithVAT)
{
decimal TaxRate = 0.0M;
TaxRate = ThisCustomer.TaxRate(TaxClassID);
Decimal TaxMultiplier = (1.0M + (TaxRate / 100.00M));
price = TaxMultiplier * price;
}
return price * CustLevelDiscountPct;
}发布于 2011-11-03 11:05:12
为什么不初始化变体PrMod tp
您需要删除AppLogic.GetColorAndSizePriceDelta方法,因为如果返回类型是十进制,它至少应该返回一个聋值为0.0M
https://stackoverflow.com/questions/7993617
复制相似问题