2014-06-09 1 views
0

AspDotNetStoreFront를 사용하여 사이트를 실행하고 있습니다. 제품이 판매중인 경우 코드의 일부로 전체 가격, 판매 가격 및 절약 비율을 보여줍니다. 이 비율을 계산하는 코드는 고객의 수준에서 일부 고객을위한 코드도 있습니다AspDotNetStorefront에서 고객 수준의 백분율 계산

if (m_VATOn) 
    { 
     vatPrice = TaxMultiplier * Price; 
     vatSalePrice = TaxMultiplier * SalePrice; 
     vatExtPrice = TaxMultiplier * ExtPrice; 
    } 
    int saving = (int)(100*((vatPrice - vatSalePrice)/vatPrice)); 

입니다. 백분율보다는 오히려 그들은 일정한 가격을 보여주고 결국 할인 된 가격을받습니다. 그들은 자동으로 담요 할인을받습니다. 하지만 위 판매 제품과 같이 표시 할 백분율을 얻기 위해 노력하고 있어요 그래서 그들은 정상 가격 고객 수준의 가격 비율은 가격 - SalePrice입니다

내가 이것을 계산하는 생각 공식을 저장

가지고/고객 레벨 가격. 하지만 내 인생을 위해 나는이 선을 복사하고 적응시켜 계산할 수 없다.

int saving = (int)(100*((vatPrice - vatSalePrice)/vatPrice)); 

아래에 표시된 다른 코드는 아래에 나와있다. 아무도 공식을 도울 수 없다면 나는 행복 할 것이다!

decimal LevelDiscountPct = 0; 
     if (ThisCustomer.CustomerLevelID != 0) 
     { 
      LevelDiscountPct = Prices.LevelDiscount(ThisCustomer.CustomerLevelID, VariantID); 
     } 
     if (LevelDiscountPct == 0) 
     { 
      LevelDiscountPct = ThisCustomer.LevelDiscountPct; 
     } 


     if (ThisCustomer.CustomerLevelID == 0 || (LevelDiscountPct == 0.0M && ExtPrice == 0.0M)) 
     { 
      if (ThisCustomer.CustomerLevelID == 0 && AppLogic.AppConfigBool("WholesaleOnlySite")) 
      { 
       results.Append(" "); 
      } 
      else 
      { 
       // show consumer pricing (e.g. level 0): 
       String PriceString = "<span class=\"RegularPrice\">" + Localization.CurrencyStringForDisplayWithoutExchangeRate(vatPrice, ThisCustomer.CurrencySetting) + "</span>"; 
       if (SalePrice == Decimal.Zero || ThisCustomer.CustomerLevelID > 0) 
       { 
        PriceString = "<span class=\"RegularPrice\">" + CommonLogic.IIF(Showpricelabel, AppLogic.GetString("showproduct.aspx.26", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), "") + NCCurrencyDisplay(vatPrice, ThisCustomer.CurrencySetting) + "</span>"; 
       } 
       else 
       { 
        PriceString = "<span class=\"SalePrice\" >" + SalesPromptName + "&nbsp;" + NCCurrencyDisplay(vatSalePrice, ThisCustomer.CurrencySetting) + "</span>"; 
        PriceString += "<span class=\"Saving\" >&nbsp;Saving&nbsp;" + saving.ToString() + "&#37;</span>"; 
       } 

       results.Append(PriceString); 

       if (m_VATEnabled) 
       { 
        results.Append("&nbsp;" + CommonLogic.IIF(m_VATOn, AppLogic.GetString("setvatsetting.aspx.6", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("setvatsetting.aspx.7", ThisCustomer.SkinID, ThisCustomer.LocaleSetting))); 
       } 
      } 
     } 
     else 
     { 
      decimal CustLvlPrice = CommonLogic.IIF(ExtPrice == 0.0M, Price, ExtPrice); 
      if (LevelDiscountPct != 0.0M && (ExtPrice == 0.0M || (ExtPrice > 0.0M && ThisCustomer.DiscountExtendedPrices))) 
      { 
       CustLvlPrice = CustLvlPrice * (decimal)(1.00M - (LevelDiscountPct/100.0M)) * CommonLogic.IIF(m_VATOn, TaxMultiplier, 1.0M); 
      } 

      // show level pricing: 
      String PriceString = "<span class=\"RegularPrice\" >" + CommonLogic.IIF(Showpricelabel, AppLogic.GetString("showproduct.aspx.27", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "&nbsp;", "") + NCCurrencyDisplay(vatPrice, ThisCustomer.CurrencySetting) + "</span> "; 
      // 10.05.14 Fix the sale price 0.00 issue 
      if (SalePrice > Decimal.Zero) 
      { 
       /* NEW*/ PriceString += "<span class=\"SalePrice\" >" + SalesPromptName + "&nbsp;" + NCCurrencyDisplay(vatSalePrice, ThisCustomer.CurrencySetting) + "</span><br />"; 

      } 
      PriceString += "<br /><span class=\"LevelPrice\" style=\"color:" + AppLogic.AppConfig("OnSaleForTextColor") + "\">" + CommonLogic.IIF(Showpricelabel, ThisCustomer.CustomerLevelName + " " + AppLogic.GetString("showproduct.aspx.26", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "&nbsp;", "") + NCCurrencyDisplay(CustLvlPrice, ThisCustomer.CurrencySetting) + "</span>"; 
      PriceString += "<span class=\"Saving\" >&nbsp;Saving&nbsp;" + practsaving.ToString() + "&#37;</span>"; 
      PriceString += CommonLogic.IIF(AppLogic.AppConfigBool("MicroPay.ShowPointsWithPrices"), "(" + Points.ToString() + " Points)", ""); 
      results.Append(PriceString); 
      if (m_VATEnabled) 
      { 
       results.Append("&nbsp;" + CommonLogic.IIF(m_VATOn, AppLogic.GetString("setvatsetting.aspx.6", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("setvatsetting.aspx.7", ThisCustomer.SkinID, ThisCustomer.LocaleSetting))); 
      } 
     } 
    } 

답변

0

대답 누군가가

int practsaving = (int)(100*((vatPrice - CustLvlPrice)/vatPrice)); 
입니다 필요가있는 경우