コード例 #1
0
        // don't return any quotes, single quotes, or carraige returns in this string!
        static public String GetQuantityDiscountDisplayTable(int DID, int SkinID)
        {
            String CacheName = "GetQuantityDiscountDisplayTable_" + DID.ToString() + "_" + SkinID.ToString();

            if (AppLogic.CachingOn)
            {
                String CacheData = (String)HttpContext.Current.Cache.Get(CacheName);
                if (CacheData != null)
                {
                    if (CommonLogic.ApplicationBool("DumpSQL"))
                    {
                        HttpContext.Current.Response.Write("Cache Hit Found!");
                    }
                    return(CacheData);
                }
            }
            Customer      ThisCustomer  = HttpContext.Current.GetCustomer();
            bool          fixedDiscount = isFixedQuantityDiscount(DID);
            StringBuilder tmpS          = new StringBuilder(10000);
            String        sql           = "select * from dbo.QuantityDiscountTable  with (NOLOCK)  where QuantityDiscountID=" + DID.ToString() + " order by LowQuantity";

            tmpS.Append("<table class=\"table table-striped quantity-discount-table\">");
            tmpS.Append("<tr class=\"table-header\"><th scope=\"col\">" + AppLogic.GetString("common.cs.34", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</th><th scope=\"col\">" + CommonLogic.IIF(fixedDiscount, AppLogic.GetString("shoppingcart.cs.116", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + " ", "") + AppLogic.GetString("common.cs.35", SkinID, Thread.CurrentThread.CurrentUICulture.Name) + "</th></tr>");
            using (var con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (var rs = DB.GetRS(sql, con))
                {
                    while (rs.Read())
                    {
                        tmpS.Append("<tr class=\"table-row\">");
                        tmpS.Append("<th scope=\"row\" class=\"quantity-cell table-row-header\">");
                        tmpS.Append(DB.RSFieldInt(rs, "LowQuantity").ToString() + CommonLogic.IIF(DB.RSFieldInt(rs, "HighQuantity") > 9999, "+", "-" + DB.RSFieldInt(rs, "HighQuantity").ToString()));
                        tmpS.Append("</th>");
                        tmpS.Append("<td class=\"discount-cell\">");
                        if (fixedDiscount)
                        {
                            tmpS.Append(Localization.CurrencyStringForDisplayWithExchangeRate(DB.RSFieldDecimal(rs, "DiscountPercent"), ThisCustomer.CurrencySetting));
                        }
                        else
                        {
                            tmpS.Append(DB.RSFieldDecimal(rs, "DiscountPercent").ToString("N" + AppLogic.AppConfigNativeInt("QuantityDiscount.PercentDecimalPlaces")) + "%");
                        }
                        tmpS.Append("</td>");
                        tmpS.Append("</tr>");
                    }
                }
            }

            tmpS.Append("</table>");

            if (AppLogic.CachingOn)
            {
                HttpContext.Current.Cache.Insert(CacheName, tmpS.ToString(), null, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
            }
            return(tmpS.ToString());
        }