using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.Data; using NationalJeweler.JSMartenV10.BusinessObjects.Collections; namespace NationalJeweler.JSMartenV10.BraceletConfigurator { /// /// Summary description for BracletConfiguratorPricing. /// public class BraceletConfiguratorPricing { //var _loadData; protected Hashtable _pricing; protected Hashtable _codeToSkuLookup; static BraceletConfiguratorPricing _instance = null; public BraceletConfiguratorPricing() { /* lookup table to relate existing code to skus for DB lookup */ /* hammer set diamonds */ _codeToSkuLookup= new Hashtable(); _codeToSkuLookup["6f"]="MOTH050D"; _codeToSkuLookup["6g"]="MOTH033D"; _codeToSkuLookup["6d"]="MOTH025D"; _codeToSkuLookup["6c"]="MOTH020D"; _codeToSkuLookup["6b"]="MOTH015D"; _codeToSkuLookup["6a"]="MOTH010D"; /* standard size diamonds and charms */ _codeToSkuLookup["500D"]="MOTH500L"; _codeToSkuLookup["250D"]="MOTH250L"; _codeToSkuLookup["375D"]="MOTH375L"; /* additional codes to relate to base prices */ _codeToSkuLookup["500"]="MOTH500"; _codeToSkuLookup["250"]="MOTH250"; _codeToSkuLookup["375"]="MOTH375"; /*white gold sku*/ _codeToSkuLookup["WGLD"]="MOTHWGLD"; } static string sqlSelect= @"SELECT * FROM bvc_Product WHERE (ID LIKE 'Moth%') "; public static ProductCollection getMothersPriceList() { SqlConnection connection = new SqlConnection( BusinessObjects.DataSource.ConnectionString ); SqlCommand command = new SqlCommand(sqlSelect); command.CommandType = CommandType.Text; command.Connection=connection; // Put user code to initialize the page here ProductCollection mothers = new ProductCollection(); mothers.Fill( command ); return mothers; } public static string getProductsTable(ProductCollection c) { string result="ID\tDescription\tPrice\n"; foreach(BusinessObjects.Product p in c) { result+=p.ID + "\t"; result+=p.ProductName + "\t"; result+=p.SitePrice + "\t\n"; } return result; } public static BraceletConfiguratorPricing instance() { if ( _instance==null) { _instance= new BraceletConfiguratorPricing(); _instance.setPricing( BraceletConfiguratorPricing.getMothersPriceList() ); } return _instance; } /* look up the price for a code */ public string codeToSku(string code,string braceletSize) { //NationalJeweler.JSMartenV10.BraceletConfigurator._Default.thePage.Response.Write(code + "," + braceletSize); /* bracelet size is 500,250, or 375 (1/2,1/4,3/8) */ if ( _codeToSkuLookup[code]!=null) { return _codeToSkuLookup[code].ToString(); } else if (code.Substring(1)=="d") /* it's a diamond or charm */ { return _codeToSkuLookup[braceletSize + "D"].ToString(); } else { return "0"; } } /* get a price from the code */ public double codeToPrice(string code,string braceletSize) { string sku=codeToSku(code,braceletSize); BusinessObjects.Product item; if (sku=="0") { return 0; } else { //trace("codeToPrice:" + sku + ":" + _pricing[sku]["Price"]); item = (BusinessObjects.Product) _pricing[sku]; return item.SitePrice; } } void setPricing(ProductCollection c) { _pricing = new Hashtable(); foreach(BusinessObjects.Product p in c) { _pricing[p.ID]=p; } /* _pricing = []; var item; for (var i=0;i