protected void Page_Load(object sender, EventArgs e)
        {
            // Log page
            AppUtility.Utility.LogPage();

            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            SqlParameter[] sqlParameters = new SqlParameter[16];

            // First, fill out blank parameters.  If a parameter is going to be used, it will be filled out below.
            // SqlParemeterCollection can't have nulls in it.
            sqlParameters[0] = new SqlParameter("Name", null);
            sqlParameters[1] = new SqlParameter("DescriptionAndNotes", null);
            sqlParameters[2] = new SqlParameter("CategoryID", null);
            sqlParameters[3] = new SqlParameter("FlavorID", null);
            sqlParameters[4] = new SqlParameter("CountryID", null);
            sqlParameters[5] = new SqlParameter("BrandID", null);
            sqlParameters[6] = new SqlParameter("AlcoholProof1", null);
            sqlParameters[7] = new SqlParameter("AlcoholProof2", null);
            sqlParameters[8] = new SqlParameter("LADRating1", null);
            sqlParameters[9] = new SqlParameter("LADRating2", null);
            sqlParameters[10] = new SqlParameter("COMRating1", null);
            sqlParameters[11] = new SqlParameter("COMRating2", null);
            sqlParameters[12] = new SqlParameter("PageNum", 1);
            sqlParameters[13] = new SqlParameter("PageSize", 5000);

            // We just want ingredients that have a review.  So look for ingredients that have a review rating between 0 and 100
            sqlParameters[8] = new SqlParameter("LADRating1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "LADRating1", DataRowVersion.Current, 0);
            sqlParameters[9] = new SqlParameter("LADRating2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "LADRating2", DataRowVersion.Current, 100);

            // Add output parameters
            sqlParameters[14] = new SqlParameter("TotalPages", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalPages", DataRowVersion.Current, 0);
            sqlParameters[15] = new SqlParameter("TotalRows", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalRows", DataRowVersion.Current, 0);

            // Get the list
            _repeaterIngredient.DataSource = simpleData.FetchSP("SearchIngredients", sqlParameters);

            // Light up the ingredients to ingredient repeater
            _repeaterIngredient.DataBind();

            // Module title
            ModuleConfiguration.ModuleTitle = "Liquor/Mixer Reviews";

            // Widgets
            // Send a message to any widget modules that are listening.
            ModuleCommunicationEventArgs args = new ModuleCommunicationEventArgs();
            args.Sender = "Headlines";
            args.Target = "Widget";
            args.Value = new List<string>() {AppUtility.AdRotator.GetAdsenseCode("adsense.list.200x90.linkunit")};

            if (ModuleCommunication != null)
            {
                ModuleCommunication(this, args);
            }

            DoSEO();
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            _drArticle = simpleData.FetchSP("GetArticle", new SqlParameter[] { new SqlParameter("ArticleID", Request.QueryString["pk"]) }).Rows[0];

            // Load fields
            this.Title = (string)_drArticle["Title"];
            _subtitleLiteral.Text = (string)_drArticle["Subtitle"];
            _postedLiteral.Text = ((DateTime)_drArticle["Posted"]).ToString("MMMM d, yyyy");

            string body = WebUtility.ConvertDBArticleBodyToHTML((String)_drArticle["Body"]);

            // Make first letter big
            int firstParagraphIndex = body.IndexOf("<p");
            if (firstParagraphIndex >= 0) body = body.Insert(firstParagraphIndex + 2, @" class=""FirstChar"" ");

            _bodyLiteral.Text = body;

            _updatedLiteral.Text = ((DateTime)_drArticle["Updated"]).ToString("d");

            // Get article links in right column
            DataTable dtArticleLinks = simpleData.FetchSP("GetArticleLinks", new SqlParameter[] { new SqlParameter("ArticleID", Request.QueryString["pk"]) });

            this.RightColumn.Controls.Add(new LiteralControl(CharlesThompson.LiquorAndDrink.AppUI.Content.GetLinkBoxHtml(dtArticleLinks)));

            // Set page meta tags
            HtmlMeta meta = new HtmlMeta();
            meta.Name = "description";
            string metaContent = AppUI.Content.GetArticleMetaDescription(_drArticle);
            meta.Content = metaContent;
            this.Header.Controls.Add(meta);

            // Set ShareThis header script
            this.Header.Controls.Add(new LiteralControl(CacheManager.GetItem(CacheManager.Cache_FileShareThisHeaderScript)));

            // Do share box button script
            StringBuilder shareScript = new StringBuilder();
            _shareDiv.Controls.Add(new LiteralControl(AppUI.Content.GetShareButtonScript(((string)_drArticle["Title"]).Replace("'", ""),
                                                                                           metaContent,
                                                                                           ConfigurationManager.AppSettings["SiteUrl"] + "Articles/" + Convert.ToString(_drArticle["Article_pk"]) + "-" + Utility.UrlEncode((string)_drArticle["Title"]))));
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            _drBrand = simpleData.FetchSP("GetBrand", new SqlParameter[] { new SqlParameter("BrandID", Request.QueryString["pk"]) }).Rows[0];

            this.Title = (string)_drBrand["Name"];
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            DataTable dtDrinks = simpleData.FetchSP("GetArticles", new SqlParameter[] { new SqlParameter("BlurbLength", 1), new SqlParameter("IncludePrivate", 1) });

            _repeaterArticle.DataSource = dtDrinks;
            _repeaterArticle.DataBind();
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;
            DataTable dataTable;

            dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.Flavor)) });
            _flavorList.DataSource = dataTable;
            _flavorList.DataValueField = "ListItem_pk";
            _flavorList.DataTextField = "Name";
            _flavorList.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (! _showBlankNotes.Checked)
            {
                SimpleData simpleData = new SimpleData();
                ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
                simpleData.ConnectionString = connectionStringSettings.ConnectionString;

                DataTable dtDrinks = simpleData.FetchSP("GetDrinks", null);

                _repeaterDrink.DataSource = dtDrinks;
                _repeaterDrink.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //            long bytecount = System.GC.GetTotalMemory(true);

            if (! _showBlankDescriptions.Checked)
            {
                SimpleData simpleData = new SimpleData();
                ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
                simpleData.ConnectionString = connectionStringSettings.ConnectionString;

                DataTable dtIngredients = simpleData.FetchSP("GetIngredients", null);

             //           bytecount = System.GC.GetTotalMemory(true) - bytecount;

                _repeaterIngredient.DataSource = dtIngredients;
                _repeaterIngredient.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            // Get drink data from cache
            DataView dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                    "GetDrinks",
                                                    "Drink_pk",
                                                     null);

            dataView.RowFilter = "Drink_pk = " + Request.QueryString["pk"];

            if (dataView.Count > 0)
            {
                _drDrinkCache = dataView.ToTable().Rows[0];

                // Get ingredients
                _dtIngredient = simpleData.FetchSP("GetDrinkIngredients", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });

                // Ingredient Profile #####################################
                _dtIngredientProfile = new DataTable();
                _dtIngredientProfile.Columns.Add("Amount", typeof(decimal));
                _dtIngredientProfile.Columns.Add("Name", typeof(string));

                foreach (DataRow row in _dtIngredient.Rows)
                {
                    _dtIngredientProfile.Rows.Add(new object[] { row["AmountWeighted"], row["IngredientName"] });
                }

                _chart.BackgroundImageFileName = Server.MapPath("~") + @"\image\gradient_DrinkProfile.png";
                _chart.ColorModel.CustomPalette = Constant.ChartPalette;
                _chart.ColorModel.ModelStyle = Infragistics.UltraChart.Shared.Styles.ColorModels.CustomLinear;
                _chart.DeploymentScenario.ImageURL = _chart.DeploymentScenario.ImageURL;
                _chart.DataSource = _dtIngredientProfile;
                _chart.DataBind();

                // Load fields
                this.Title = (string)_drDrinkCache["Name"] + " - Ingredient Profile";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            SqlParameter[] sqlParameters = new SqlParameter[16];

            // First, fill out blank parameters.  If a parameter is going to be used, it will be filled out below.
            // SqlParemeterCollection can't have nulls in it.
            sqlParameters[0] = new SqlParameter("Name", null);
            sqlParameters[1] = new SqlParameter("DescriptionAndNotes", null);
            sqlParameters[2] = new SqlParameter("CategoryID", null);
            sqlParameters[3] = new SqlParameter("FlavorID", null);
            sqlParameters[4] = new SqlParameter("CountryID", null);
            sqlParameters[5] = new SqlParameter("BrandID", null);
            sqlParameters[6] = new SqlParameter("AlcoholProof1", null);
            sqlParameters[7] = new SqlParameter("AlcoholProof2", null);
            sqlParameters[8] = new SqlParameter("LADRating1", null);
            sqlParameters[9] = new SqlParameter("LADRating2", null);
            sqlParameters[10] = new SqlParameter("COMRating1", null);
            sqlParameters[11] = new SqlParameter("COMRating2", null);
            sqlParameters[12] = new SqlParameter("PageNum", 1);
            sqlParameters[13] = new SqlParameter("PageSize", 5000);

            // We just want ingredients that have a review.  So look for ingredients that have a review rating between 0 and 100
            sqlParameters[8] = new SqlParameter("LADRating1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "LADRating1", DataRowVersion.Current, 0);
            sqlParameters[9] = new SqlParameter("LADRating2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "LADRating2", DataRowVersion.Current, 100);

            // Add output parameters
            sqlParameters[14] = new SqlParameter("TotalPages", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalPages", DataRowVersion.Current, 0);
            sqlParameters[15] = new SqlParameter("TotalRows", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalRows", DataRowVersion.Current, 0);

            // Get the list
            _repeaterIngredient.DataSource = simpleData.FetchSP("SearchIngredients", sqlParameters);

            // Light up the ingredients to ingredient repeater
            _repeaterIngredient.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;
            _dataTable = simpleData.FetchSP("GetIngredientProfile", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) });

            _dataTableChart = _dataTable.Copy();
            _dataTableChart.Columns.Remove("Ingredient_pk");
            _dataTableChart.Columns.Remove("Name");
            _dataTableChart.Columns.Remove("Proof");
            _dataTableChart.Columns.Remove("Created");
            _dataTableChart.Columns.Remove("Updated");

            _dataTableChart.Columns["Sour"].ColumnName = "Acidity";
            _dataTableChart.Columns["FreshFruit"].ColumnName = "Fresh Fruit";
            _dataTableChart.Columns["DriedFruit"].ColumnName = "Dried Fruit";

            _chart.BackgroundImageFileName = Server.MapPath("~") + @"\image\gradient_IngredientProfile.png";
            _chart.BackgroundImageStyle = Infragistics.UltraChart.Shared.Styles.ImageFitStyle.Tiled;
            _chart.DeploymentScenario.ImageURL = _chart.DeploymentScenario.ImageURL;
            _chart.DataSource = _dataTableChart;
            _chart.DataBind();

            if (_dataTableChart.Rows[0]["Body"] == DBNull.Value &&
                _dataTableChart.Rows[0]["Sweet"] == DBNull.Value &&
                _dataTableChart.Rows[0]["Sour"] == DBNull.Value &&
                _dataTableChart.Rows[0]["Fresh Fruit"] == DBNull.Value &&
                _dataTableChart.Rows[0]["Dried Fruit"] == DBNull.Value &&
                _dataTableChart.Rows[0]["Spice"] == DBNull.Value &&
                _dataTableChart.Rows[0]["Heat"] == DBNull.Value &&
                _dataTableChart.Rows[0]["Wood"] == DBNull.Value)
                _flavorProfileHeader.InnerHtml = "Flavor Profile (not available)";

            this.Title = (string)_dataTable.Rows[0]["Name"] + " - Flavor Profile";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["pk"] == "0")
            {// No primary key--add mode

                _pageMode = Constant.PageMode.Add;
            }
            else
            {// We have a primary key--edit mode

                _pageMode = Constant.PageMode.Edit;
            }

            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            // Get article data from db
            if (_pageMode == Constant.PageMode.Add)
            {
                DataTable dtTemp = simpleData.FetchSP("GetArticle", new SqlParameter[] { new SqlParameter("ArticleID", Request.QueryString["pk"]) });
                _drArticle = dtTemp.NewRow();
            }
            else
            {
                _drArticle = simpleData.FetchSP("GetArticle", new SqlParameter[] { new SqlParameter("ArticleID", Request.QueryString["pk"]) }).Rows[0];
            }

            if (! Page.IsPostBack)
            {// First time

                if (_pageMode == Constant.PageMode.Edit)
                {// Edit

                    _titleLiteral.Text = (string)_drArticle["Title"];
                    _titleText.Text = (string)_drArticle["Title"];
                    _subtitleText.Text = (string)_drArticle["Subtitle"];
                    _iconFileText.Text = (string)_drArticle["IconFile"];
                    _privateCheck.Checked = (bool)_drArticle["Private"];
                    _blurbText.Text = (string)_drArticle["Blurb"];
                    _bodyText.Text = (string)_drArticle["Body"];

                    // ArticleDrink grid
                    _dtArticleDrink = simpleData.FetchSP("GetLinkedDrinksForArticle", new SqlParameter[] { new SqlParameter("ArticleID", Request.QueryString["pk"]) });
                    _articleDrinkGrid.DataSource = _dtArticleDrink;
                    _articleDrinkGrid.DataBind();

                    // ArticleIngredient grid
                    _dtArticleIngredient = simpleData.FetchSP("GetLinkedIngredientsForArticle", new SqlParameter[] { new SqlParameter("ArticleID", Request.QueryString["pk"]) });
                    _articleIngredientGrid.DataSource = _dtArticleIngredient;
                    _articleIngredientGrid.DataBind();

                    // ArticleArticle grid
                    _dtArticleArticle = simpleData.FetchSP("GetLinkedArticlesForArticle", new SqlParameter[] { new SqlParameter("ArticleID", Request.QueryString["pk"]) });
                    _articleArticleGrid.DataSource = _dtArticleArticle;
                    _articleArticleGrid.DataBind();
                }
            }

            // Set up ArticleDrink grid #######################################################################
            _articleDrinkGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _articleDrinkGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _articleDrinkGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _articleDrinkGrid.DisplayLayout.AddNewBox.Hidden = false;
            _articleDrinkGrid.Bands[0].AddButtonCaption = "Add New Drink Link";
            _articleDrinkGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _articleDrinkGrid.Bands[0].Columns.Add("ArticleID", "ArticleID");
                _articleDrinkGrid.Bands[0].Columns.Add("DrinkID", "DrinkID");
            }

            _articleDrinkGrid.Bands[0].Columns.FromKey("ArticleID").Hidden = true;
            _articleDrinkGrid.Bands[0].Columns.FromKey("DrinkID").Width = Unit.Percentage(100);
            _articleDrinkGrid.Bands[0].Columns.FromKey("DrinkID").Type = ColumnType.DropDownList;
            _articleDrinkGrid.Bands[0].Columns.FromKey("DrinkID").DefaultValue = DBNull.Value;

            // Drink valuelist
            _vlDrink = new ValueList();
            _dtDrink = simpleData.FetchSP("GetDrinks", null);
            _vlDrink.DataSource = _dtDrink;
            _vlDrink.DisplayMember = "Name";
            _vlDrink.ValueMember = "Drink_pk";
            _vlDrink.DataBind();
            _vlDrink.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _articleDrinkGrid.Bands[0].Columns.FromKey("DrinkID").ValueList = _vlDrink;

            // Set up ArticleIngredient grid #######################################################################
            _articleIngredientGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _articleIngredientGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _articleIngredientGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _articleIngredientGrid.DisplayLayout.AddNewBox.Hidden = false;
            _articleIngredientGrid.Bands[0].AddButtonCaption = "Add New Ingredient Link";
            _articleIngredientGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _articleIngredientGrid.Bands[0].Columns.Add("ArticleID", "ArticleID");
                _articleIngredientGrid.Bands[0].Columns.Add("IngredientID", "IngredientID");
            }

            _articleIngredientGrid.Bands[0].Columns.FromKey("ArticleID").Hidden = true;
            _articleIngredientGrid.Bands[0].Columns.FromKey("IngredientID").Width = Unit.Percentage(100);
            _articleIngredientGrid.Bands[0].Columns.FromKey("IngredientID").Type = ColumnType.DropDownList;
            _articleIngredientGrid.Bands[0].Columns.FromKey("IngredientID").DefaultValue = DBNull.Value;

            // Ingredient valuelist
            _vlIngredient = new ValueList();
            _dtIngredient = simpleData.FetchSP("GetIngredients", null);
            _vlIngredient.DataSource = _dtIngredient;
            _vlIngredient.DisplayMember = "Name";
            _vlIngredient.ValueMember = "Ingredient_pk";
            _vlIngredient.DataBind();
            _vlIngredient.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _articleIngredientGrid.Bands[0].Columns.FromKey("IngredientID").ValueList = _vlIngredient;

            // Set up ArticleArticle grid #######################################################################
            _articleArticleGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _articleArticleGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _articleArticleGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _articleArticleGrid.DisplayLayout.AddNewBox.Hidden = false;
            _articleArticleGrid.Bands[0].AddButtonCaption = "Add New Article Link";
            _articleArticleGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _articleArticleGrid.Bands[0].Columns.Add("ArticleID1", "ArticleID1");
                _articleArticleGrid.Bands[0].Columns.Add("ArticleID2", "ArticleID2");
            }

            _articleArticleGrid.Bands[0].Columns.FromKey("ArticleID1").Hidden = true;
            _articleArticleGrid.Bands[0].Columns.FromKey("ArticleID2").Width = Unit.Percentage(100);
            _articleArticleGrid.Bands[0].Columns.FromKey("ArticleID2").Type = ColumnType.DropDownList;
            _articleArticleGrid.Bands[0].Columns.FromKey("ArticleID2").DefaultValue = DBNull.Value;

            // Article valuelist
            _vlArticle = new ValueList();
            _dtArticle = simpleData.FetchSP("GetArticles", null);
            _vlArticle.DataSource = _dtArticle;
            _vlArticle.DisplayMember = "Title";
            _vlArticle.ValueMember = "Article_pk";
            _vlArticle.DataBind();
            _vlArticle.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _articleArticleGrid.Bands[0].Columns.FromKey("ArticleID2").ValueList = _vlArticle;
        }
            public static void GetData(string cacheItemKey, 
                                       string storedProcedure, 
                                       string primaryKeyColumn, 
                                       SqlParameter[] sqlParameters)
            {
                // Since each request that saw the cache originally null
                // will eventually get here, need to ensure that it
                // has not already been retrieved by another request
                if (System.Web.HttpRuntime.Cache[cacheItemKey] == null)
                {// Cache is still empty--fill it from the database

                    SimpleData simpleData = new SimpleData();
                    ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
                    simpleData.ConnectionString = connectionStringSettings.ConnectionString;

                    DataTable dataTable = simpleData.FetchSP(storedProcedure, sqlParameters);
                    dataTable.PrimaryKey = new System.Data.DataColumn[] { dataTable.Columns[primaryKeyColumn] };

                    System.Web.HttpRuntime.Cache.Insert(cacheItemKey,
                                                        dataTable,
                                                        null,
                                                        DateTime.Now.AddMinutes(Convert.ToDouble(ConfigurationManager.AppSettings["CacheTimeout"])),
                                                        System.Web.Caching.Cache.NoSlidingExpiration);
                }
            }
        //public const string Cache_GetDrinkStatistics = "GetDrinkStatistics";
        //public const string Cache_GetDrinkStatisticsByProof = "GetDrinkStatisticsByProof";
        //public const string Cache_GetDrinkStatisticsByStrength = "GetDrinkStatisticsByStrength";
        public static DataView GetItem(string cacheItemKey,
                                       string storedProcedure,
                                       string primaryKeyColumn,
                                       SqlParameter[] sqlParameters)
        {
            // cacheItemKey is the cache key and the stored procedure name used to get the contents of the cache

            DataTable dataTable = null;
            //Cache cache = System.Web.HttpRuntime.Cache;

            if (ConfigurationManager.AppSettings["UseCache"] == "0")
            {// Don't use the cache, just hit the db

                SimpleData simpleData = new SimpleData();
                ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
                simpleData.ConnectionString = connectionStringSettings.ConnectionString;

                dataTable = simpleData.FetchSP(storedProcedure, sqlParameters);

                if (primaryKeyColumn.Contains(","))
                {// Dual keys

                    string[] pks = primaryKeyColumn.Split(',');
                    dataTable.PrimaryKey = new System.Data.DataColumn[] { dataTable.Columns[pks[0]], dataTable.Columns[pks[1]] };
                }
                else
                {// Single key

                    dataTable.PrimaryKey = new System.Data.DataColumn[] { dataTable.Columns[primaryKeyColumn] };
                }
            }
            else
            {
                //if (cache[cacheItemKey] == null)
                if (DotNetNuke.Common.Utilities.DataCache.GetCache(cacheItemKey) == null)
                {// Not in cache--refresh the cache from the database

                    // Use the lock statement to ensure that only one request
                    // can be making a call to LockingCacheFiller.GetData () at a time.
                    // If a request comes and the lock is free, it can
                    // immediately enter this section and make the call.
                    // If the lock is not free, this request will wait until
                    // the lock holder completes the LockingCacheFiller.GetData() call.
                    // WARNING:  Once the original lock holder completes,
                    // one of the other requests will be allowed in and
                    // will also attempt to call LockingCacheFiller.GetData.
                    lock (typeof(LockingCacheFiller))
                    {
                        LockingCacheFiller.GetData(cacheItemKey, storedProcedure, primaryKeyColumn, sqlParameters);
                    }
                }

                // We now have our DataTable from the cache.
                dataTable = (DataTable)DotNetNuke.Common.Utilities.DataCache.GetCache(cacheItemKey);
            }

            // Convert it into a DataView
            DataView dataView = new DataView(dataTable);

            // Turn off some stuff we don't need
            dataView.AllowDelete = false;
            dataView.AllowEdit = false;
            dataView.AllowNew = false;

            // Return the DefaultView.
            return dataView;
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            //_ingredientGrid

            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;
            DataTable dataTable;

            // Attributes
            dataTable = simpleData.FetchSP("GetDrinkTagsWithCounts", null);
            _tagList.DataSource = dataTable;
            _tagList.DataValueField = "ListItem_pk";
            _tagList.DataTextField = "Name";
            _tagList.DataBind();

            // Flavors
            dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(List.Flavor)) });
            _flavorList.DataSource = dataTable;
            _flavorList.DataValueField = "ListItem_pk";
            _flavorList.DataTextField = "Name";
            _flavorList.DataBind();
        }
Exemple #15
0
        public static string GetSimilarIngredientsHtmlOld(int ingredientID, int categoryID, int brandID, int flavor1ID, int flavor2ID)
        {
            // First, get the ingredient's name
            DataView dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredients,
                                                    "GetIngredients",
                                                    "Ingredient_pk",
                                                     null);

            dataView.RowFilter = "Ingredient_pk = " + Convert.ToString(ingredientID);
            string ingredientName = (string)dataView[0]["Name"];

            // Now get similar drinks/ingredients
            StringBuilder sb = new StringBuilder();
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            DataTable dtSimilar = simpleData.FetchSP("GetIngredientSimilar", new SqlParameter[] { new SqlParameter("IngredientID", ingredientID),
                                                                                                  new SqlParameter("CategoryID", categoryID),
                                                                                                  new SqlParameter("BrandID", brandID),
                                                                                                  new SqlParameter("Flavor1ID", flavor1ID),
                                                                                                  new SqlParameter("Flavor2ID", flavor2ID) });
            DataRow[] matchedRows;

            // Drinks that use this ingredient
            matchedRows = dtSimilar.Select("SimilarType = 'drink'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Drinks that use " + ingredientName + "</h4>");
                sb.Append(@"<ul class=""unstyled"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""");
                    sb.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    sb.Append(@"drinks/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.Utility.UrlEncode((string)row["Description"]));
                    sb.Append(@""">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            if (matchedRows.Length == 0)
            {// There are no drinks that directly use this ingredient--find drinks that use child category ingredients

                matchedRows = dtSimilar.Select("SimilarType = 'drinkchildren'", "Description ASC");
                if (matchedRows.Length > 0)
                {
                    // Get ingredient category name
                    DataView dv = CacheManager.GetItem(CacheManager.Cache_GetDrinkCategories,
                                                      "GetListItems",
                                                      "ListItem_pk",
                                                       new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.IngredientCategory)) });

                    dv.RowFilter = "ListItem_pk = " + Convert.ToString(categoryID);
                    string categoryName = (string)dv[0]["Name"];

                    sb.Append("<h4>Drinks that use " + categoryName + "</h4>");
                    sb.Append(@"<ul class=""unstyled"">");

                    foreach (DataRow row in matchedRows)
                    {
                        sb.Append(@"<li>");
                        sb.Append(@"<a href=""");
                        sb.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                        sb.Append(@"drinks/");
                        sb.Append(Convert.ToString(row["PK"]));
                        sb.Append("-");
                        sb.Append(AppUtility.Utility.UrlEncode((string)row["Description"]));
                        sb.Append(@""">");
                        sb.Append((string)row["Description"]);
                        sb.Append(@"</a></li>");
                    }

                    sb.Append(@"</ul>");
                }
            }

            // Ingredients with the same category
            matchedRows = dtSimilar.Select("SimilarType = 'category'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Ingredients in the same category</h4>");
                sb.Append(@"<ul class=""unstyled"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""");
                    sb.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    sb.Append(@"ingredients/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.Utility.UrlEncode((string)row["Description"]));
                    sb.Append(@""">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            // Ingredients with the same brand
            matchedRows = dtSimilar.Select("SimilarType = 'brand'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Ingredients from the same brand</h4>");
                sb.Append(@"<ul class=""unstyled"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""");
                    sb.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    sb.Append(@"ingredients/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.Utility.UrlEncode((string)row["Description"]));
                    sb.Append(@""">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            // Ingredients with the same flavors
            matchedRows = dtSimilar.Select("SimilarType = 'flavor'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Ingredients with similar flavors</h4>");
                sb.Append(@"<ul class=""unstyled"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""");
                    sb.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    sb.Append(@"ingredients/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.Utility.UrlEncode((string)row["Description"]));
                    sb.Append(@""">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            return sb.ToString();
        }
Exemple #16
0
        public static DataTable GetSimilarIngredientsDataTable(int ingredientID, int categoryID, int brandID, int flavor1ID, int flavor2ID)
        {
            // First, get the ingredient's name
            DataView dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredients,
                                                    "GetIngredients",
                                                    "Ingredient_pk",
                                                     null);

            dataView.RowFilter = "Ingredient_pk = " + Convert.ToString(ingredientID);
            string ingredientName = (string)dataView[0]["IngredientName"];

            // Now get similar drinks/ingredients
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            DataTable dtSimilar = simpleData.FetchSP("GetIngredientSimilar", new SqlParameter[] { new SqlParameter("IngredientID", ingredientID),
                                                                                                  new SqlParameter("CategoryID", categoryID),
                                                                                                  new SqlParameter("BrandID", brandID),
                                                                                                  new SqlParameter("Flavor1ID", flavor1ID),
                                                                                                  new SqlParameter("Flavor2ID", flavor2ID) });
            return dtSimilar;
        }
Exemple #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dataTable;
            DataRow foundRow;
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            _dtList = simpleData.FetchSP("GetListItem", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Request.QueryString["pk"])) });

            //_dtDrinkAttributes = simpleData.FetchSP("GetDrinkAttributes", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
            //_dtDrinkAttributes.PrimaryKey = new DataColumn[] { _dtDrinkAttributes.Columns["ListItem_pk"] };
            //_dtDrinkFlavors = simpleData.FetchSP("GetDrinkFlavors", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
            //_dtDrinkFlavors.PrimaryKey = new DataColumn[] { _dtDrinkFlavors.Columns["ListItem_pk"] };

            //// Title
            //if (_drDrink["Name"] != DBNull.Value) _titleLiteral.Text = (string)_drDrink["Name"];

            //// Load combo items #############################################################################
            //// Category
            //dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.DrinkCategory)) });
            //_categoryCombo.DataSource = dataTable;
            //_categoryCombo.DataBind();

            //// Family
            //dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.Family)) });
            //_familyCombo.DataSource = dataTable;
            //_familyCombo.DataBind();
            //_familyCombo.Items.Insert(0, new ListItem(Constant.NotSpecifiedDescription, Convert.ToString(Constant.NotSpecifiedValue)));

            //// Structure
            //dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.Structure)) });
            //_structureCombo.DataSource = dataTable;
            //_structureCombo.DataBind();
            //_structureCombo.Items.Insert(0, new ListItem(Constant.NotSpecifiedDescription, Convert.ToString(Constant.NotSpecifiedValue)));

            //// Glasses
            //dataTable = simpleData.FetchSP("GetGlasses", null);
            //_glassCombo.DataSource = dataTable;
            //_glassCombo.DataBind();

            //// Temp
            //dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.Temperature)) });
            //_tempCombo.DataSource = dataTable;
            //_tempCombo.DataBind();

            //// Source
            //dataTable = simpleData.FetchSP("GetSources", null);
            //_sourceCombo.DataSource = dataTable;
            //_sourceCombo.DataBind();

            //// Private Source
            //dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.PrivateSource)) });
            //_privateSourceCombo.DataSource = dataTable;
            //_privateSourceCombo.DataBind();

            //// Set control states ############################################################################
            //if (Page.IsPostBack)
            //{// In postback

            //    // Grab dropdown values from form object (so we don't need to use viewstate)
            //    _categoryCombo.SelectedValue = Request.Form[_categoryCombo.UniqueID];
            //    _familyCombo.SelectedValue = Request.Form[_familyCombo.UniqueID];
            //    _structureCombo.SelectedValue = Request.Form[_structureCombo.UniqueID];
            //    _glassCombo.SelectedValue = Request.Form[_glassCombo.UniqueID];
            //    _tempCombo.SelectedValue = Request.Form[_tempCombo.UniqueID];
            //    _sourceCombo.SelectedValue = Request.Form[_sourceCombo.UniqueID];
            //    _privateSourceCombo.SelectedValue = Request.Form[_privateSourceCombo.UniqueID];
            //    _instructionsText.Text = Request.Form[_instructionsText.UniqueID];
            //    _notesText.Text = Request.Form[_notesText.UniqueID];
            //}
            //else
            //{// Not in postback

            //    if (_pageMode == Constant.PageMode.Edit)
            //    {// Edit

            //        // Name
            //        _nameText.Text = (string)_drDrink["Name"];

            //        // Private
            //        _privateCheck.Checked = (bool)_drDrink["Private"];

            //        // Servings
            //        _servingsNumber.Value = (decimal)_drDrink["Servings"];

            //        // Dilution ratio
            //        _dilutionRatioNumber.Value = (decimal)_drDrink["DilutionRatio"];

            //        // Instructions
            //        _instructionsText.Text = (string)_drDrink["Instructions"];

            //        // Notes
            //        _notesText.Text = (string)_drDrink["Notes"];

            //        if (_drDrink["CategoryID"] == DBNull.Value) _categoryCombo.SelectedIndex = 0;
            //        else _categoryCombo.SelectedValue = Convert.ToString(_drDrink["CategoryID"]);

            //        if (_drDrink["FamilyID"] == DBNull.Value) _familyCombo.SelectedIndex = 0;
            //        else _familyCombo.SelectedValue = Convert.ToString(_drDrink["FamilyID"]);

            //        if (_drDrink["StructureID"] == DBNull.Value) _structureCombo.SelectedIndex = 0;
            //        else _structureCombo.SelectedValue = Convert.ToString(_drDrink["StructureID"]);

            //        foreach (ListItem li in _attributeList.Items)
            //        {
            //            foundRow = _dtDrinkAttributes.Rows.Find(li.Value);
            //            if (foundRow != null) li.Selected = true;
            //        }

            //        foreach (ListItem li in _flavorList.Items)
            //        {
            //            foundRow = _dtDrinkFlavors.Rows.Find(li.Value);
            //            if (foundRow != null) li.Selected = true;
            //        }

            //        if (_drDrink["GlassID"] == DBNull.Value) _glassCombo.SelectedIndex = 0;
            //        else _glassCombo.SelectedValue = Convert.ToString(_drDrink["GlassID"]);

            //        if (_drDrink["TempID"] == DBNull.Value) _tempCombo.SelectedIndex = 0;
            //        else _tempCombo.SelectedValue = Convert.ToString(_drDrink["TempID"]);

            //        if (_drDrink["SourceID"] == DBNull.Value) _sourceCombo.SelectedIndex = 0;
            //        else _sourceCombo.SelectedValue = Convert.ToString(_drDrink["SourceID"]);

            //        if (_drDrink["PrivateSourceID"] == DBNull.Value) _privateSourceCombo.SelectedIndex = 0;
            //        else _privateSourceCombo.SelectedValue = Convert.ToString(_drDrink["PrivateSourceID"]);

            //        // Ingredient grid
            //        _dtDrinkIngredient = simpleData.FetchSP("GetDrinkIngredients2", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
            //        _ingredientGrid.DataSource = _dtDrinkIngredient;
            //        _ingredientGrid.DataBind();
            //    }
            //    else
            //    {// Add

            //        _servingsNumber.Value = 1;
            //        _dilutionRatioNumber.Value = .85;
            //        _glassCombo.SelectedValue = "20";
            //        _tempCombo.SelectedValue = "88";
            //        _sourceCombo.SelectedValue = "1";
            //        _privateSourceCombo.SelectedValue = "140";
            //    }
            //}

            //// Set up ingredient grid #######################################################################
            //_ingredientGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            //_ingredientGrid.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes;
            //_ingredientGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            //_ingredientGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            //_ingredientGrid.DisplayLayout.AddNewBox.Hidden = false;
            //_ingredientGrid.Bands[0].AddButtonCaption = "Add New Ingredient";
            //_ingredientGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            //if (_pageMode == Constant.PageMode.Add)
            //{// Add mode--need to build columns

            //    _ingredientGrid.Bands[0].Columns.Add("DrinkID", "DrinkID");
            //    _ingredientGrid.Bands[0].Columns.Add("Sort", "Sort");
            //    _ingredientGrid.Bands[0].Columns.Add("Prefix", "Prefix");
            //    _ingredientGrid.Bands[0].Columns.Add("Amount", "Amount");
            //    _ingredientGrid.Bands[0].Columns.Add("UnitID", "UnitID");
            //    _ingredientGrid.Bands[0].Columns.Add("IngredientID", "IngredientID");
            //    _ingredientGrid.Bands[0].Columns.Add("Suffix", "Suffix");
            //    _ingredientGrid.Bands[0].Columns.Add("Principal", "Principal");
            //}

            //_ingredientGrid.Bands[0].Columns.FromKey("DrinkID").Hidden = true;
            //_ingredientGrid.Bands[0].Columns.FromKey("Sort").Width = Unit.Percentage(6);
            //_ingredientGrid.Bands[0].Columns.FromKey("Prefix").Width = Unit.Percentage(13);
            //_ingredientGrid.Bands[0].Columns.FromKey("Amount").Width = Unit.Percentage(10);
            //_ingredientGrid.Bands[0].Columns.FromKey("UnitID").Type = ColumnType.DropDownList;
            //_ingredientGrid.Bands[0].Columns.FromKey("UnitID").Width = Unit.Percentage(13);
            //_ingredientGrid.Bands[0].Columns.FromKey("IngredientID").Type = ColumnType.DropDownList;
            //_ingredientGrid.Bands[0].Columns.FromKey("IngredientID").Width = Unit.Percentage(35);
            //_ingredientGrid.Bands[0].Columns.FromKey("Suffix").Width = Unit.Percentage(13);
            //_ingredientGrid.Bands[0].Columns.FromKey("Principal").Width = Unit.Percentage(10);

            //// Ingredient valuelist
            //_vlIngredient = new ValueList();
            //_dtIngredient = simpleData.FetchSP("GetIngredients", null);
            //_vlIngredient.DataSource = _dtIngredient;
            //_vlIngredient.DisplayMember = "IngredientName";
            //_vlIngredient.ValueMember = "Ingredient_pk";
            //_vlIngredient.DataBind();
            //_vlIngredient.DisplayStyle = ValueListDisplayStyle.DisplayText;
            //_ingredientGrid.Bands[0].Columns.FromKey("IngredientID").ValueList = _vlIngredient;

            //// Unit valuelist
            //_vlUnit = new ValueList();
            //_dtUnit = simpleData.FetchSP("GetUnits", null);
            //_vlUnit.DataSource = _dtUnit;
            //_vlUnit.DisplayMember = "Name";
            //_vlUnit.ValueMember = "Unit_pk";
            //_vlUnit.DataBind();
            //_vlUnit.DisplayStyle = ValueListDisplayStyle.DisplayText;
            //_ingredientGrid.Bands[0].Columns.FromKey("UnitID").ValueList = _vlUnit;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["pk"] == "0")
            {// No primary key--add mode

                _pageMode = Constant.PageMode.Add;
            }
            else
            {// We have a primary key--edit mode

                _pageMode = Constant.PageMode.Edit;
            }

            DataTable dataTable;
            DataRow foundRow;
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            // Get drink data from db
            if (_pageMode == Constant.PageMode.Add)
            {
                DataTable dtTemp = simpleData.FetchSP("GetDrink", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
                _drDrink = dtTemp.NewRow();
            }
            else
            {
                _drDrink = simpleData.FetchSP("GetDrink", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) }).Rows[0];
            }
            _dtDrinkAttributes = simpleData.FetchSP("GetDrinkAttributes", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
            _dtDrinkAttributes.PrimaryKey = new DataColumn[] { _dtDrinkAttributes.Columns["ListItem_pk"] };
            _dtDrinkFlavors = simpleData.FetchSP("GetDrinkFlavors", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
            _dtDrinkFlavors.PrimaryKey = new DataColumn[] { _dtDrinkFlavors.Columns["ListItem_pk"] };

            // Title
            if (_drDrink["Name"] != DBNull.Value) _titleLiteral.Text = (string)_drDrink["Name"];

            // Load combo items #############################################################################
            // Category
            dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.DrinkCategory)) });
            _categoryCombo.DataSource = dataTable;
            _categoryCombo.DataBind();

            // Family
            dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.Family)) });
            _familyCombo.DataSource = dataTable;
            _familyCombo.DataBind();
            _familyCombo.Items.Insert(0, new ListItem(Constant.NotSpecifiedDescription, Convert.ToString(Constant.NotSpecifiedValue)));

            // Structure
            dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.Structure)) });
            _structureCombo.DataSource = dataTable;
            _structureCombo.DataBind();
            _structureCombo.Items.Insert(0, new ListItem(Constant.NotSpecifiedDescription, Convert.ToString(Constant.NotSpecifiedValue)));

            // Glasses
            dataTable = simpleData.FetchSP("GetGlasses", null);
            _glassCombo.DataSource = dataTable;
            _glassCombo.DataBind();

            // Temp
            dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.Temperature)) });
            _tempCombo.DataSource = dataTable;
            _tempCombo.DataBind();

            // Private Source
            dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.PrivateSource)) });
            _privateSourceCombo.DataSource = dataTable;
            _privateSourceCombo.DataBind();

            // Set control states ############################################################################
            if (Page.IsPostBack)
            {// In postback

                // Grab dropdown values from form object (so we don't need to use viewstate)
                _categoryCombo.SelectedValue = Request.Form[_categoryCombo.UniqueID];
                _familyCombo.SelectedValue = Request.Form[_familyCombo.UniqueID];
                _structureCombo.SelectedValue = Request.Form[_structureCombo.UniqueID];
                _glassCombo.SelectedValue = Request.Form[_glassCombo.UniqueID];
                _tempCombo.SelectedValue = Request.Form[_tempCombo.UniqueID];
                _privateSourceCombo.SelectedValue = Request.Form[_privateSourceCombo.UniqueID];
                _instructionsText.Text = Request.Form[_instructionsText.UniqueID];
                _notesText.Text = Request.Form[_notesText.UniqueID];
            }
            else
            {// Not in postback

                if (_pageMode == Constant.PageMode.Edit)
                {// Edit

                    // Name
                    _nameText.Text = (string)_drDrink["Name"];

                    // Private
                    _privateCheck.Checked = (bool)_drDrink["Private"];

                    // Servings
                    _servingsNumber.Value = (decimal)_drDrink["Servings"];

                    // Dilution ratio
                    _dilutionRatioNumber.Value = (decimal)_drDrink["DilutionRatio"];

                    // Instructions
                    _instructionsText.Text = (string)_drDrink["Instructions"];

                    // Notes
                    _notesText.Text = (string)_drDrink["Notes"];

                    if (_drDrink["CategoryID"] == DBNull.Value) _categoryCombo.SelectedIndex = 0;
                    else _categoryCombo.SelectedValue = Convert.ToString(_drDrink["CategoryID"]);

                    if (_drDrink["FamilyID"] == DBNull.Value) _familyCombo.SelectedIndex = 0;
                    else _familyCombo.SelectedValue = Convert.ToString(_drDrink["FamilyID"]);

                    if (_drDrink["StructureID"] == DBNull.Value) _structureCombo.SelectedIndex = 0;
                    else _structureCombo.SelectedValue = Convert.ToString(_drDrink["StructureID"]);

                    foreach (ListItem li in _attributeList.Items)
                    {
                        foundRow = _dtDrinkAttributes.Rows.Find(li.Value);
                        if (foundRow != null) li.Selected = true;
                    }

                    foreach (ListItem li in _flavorList.Items)
                    {
                        foundRow = _dtDrinkFlavors.Rows.Find(li.Value);
                        if (foundRow != null) li.Selected = true;
                    }

                    if (_drDrink["GlassID"] == DBNull.Value) _glassCombo.SelectedIndex = 0;
                    else _glassCombo.SelectedValue = Convert.ToString(_drDrink["GlassID"]);

                    if (_drDrink["TempID"] == DBNull.Value) _tempCombo.SelectedIndex = 0;
                    else _tempCombo.SelectedValue = Convert.ToString(_drDrink["TempID"]);

                    if (_drDrink["PrivateSourceID"] == DBNull.Value) _privateSourceCombo.SelectedIndex = 0;
                    else _privateSourceCombo.SelectedValue = Convert.ToString(_drDrink["PrivateSourceID"]);

                    // Ingredient grid
                    _dtDrinkIngredient = simpleData.FetchSP("GetDrinkIngredients2", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
                    _ingredientGrid.DataSource = _dtDrinkIngredient;
                    _ingredientGrid.DataBind();

                    // DrinkSource grid
                    _dtDrinkSource = simpleData.FetchSP("GetSourcesForDrink", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
                    _drinkSourceGrid.DataSource = _dtDrinkSource;
                    _drinkSourceGrid.DataBind();

                    // DrinkIngredient grid
                    _dtDrinkIngredient2 = simpleData.FetchSP("GetLinkedIngredientsForDrink", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
                    _drinkIngredientGrid.DataSource = _dtDrinkIngredient2;
                    _drinkIngredientGrid.DataBind();

                    // DrinkDrink grid
                    _dtDrinkDrink = simpleData.FetchSP("GetLinkedDrinksForDrink", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
                    _drinkDrinkGrid.DataSource = _dtDrinkDrink;
                    _drinkDrinkGrid.DataBind();

                    // DrinkArticle grid
                    _dtDrinkArticle = simpleData.FetchSP("GetLinkedArticlesForDrink", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
                    _drinkArticleGrid.DataSource = _dtDrinkArticle;
                    _drinkArticleGrid.DataBind();
                }
                else
                {// Add

                    _servingsNumber.Value = 1;
                    _dilutionRatioNumber.Value = .85;
                    _glassCombo.SelectedValue = "20";
                    _tempCombo.SelectedValue = "88";
                    _privateSourceCombo.SelectedValue = "140";
                }
            }

            // Set up ingredient grid #######################################################################
            _ingredientGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _ingredientGrid.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes;
            _ingredientGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _ingredientGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _ingredientGrid.DisplayLayout.AddNewBox.Hidden = false;
            _ingredientGrid.Bands[0].AddButtonCaption = "Add New Ingredient";
            _ingredientGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;
            //_ingredientGrid.DisplayLayout.ClientSideEvents.InitializeRowHandler = "InitializeRow";

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _ingredientGrid.Bands[0].Columns.Add("DrinkID", "DrinkID");
                _ingredientGrid.Bands[0].Columns.Add("Sort", "Sort");
                _ingredientGrid.Bands[0].Columns.Add("Prefix", "Prefix");
                _ingredientGrid.Bands[0].Columns.Add("Amount", "Amount");
                _ingredientGrid.Bands[0].Columns.Add("UnitID", "UnitID");
                _ingredientGrid.Bands[0].Columns.Add("IngredientID", "IngredientID");
                _ingredientGrid.Bands[0].Columns.Add("Suffix", "Suffix");
                _ingredientGrid.Bands[0].Columns.Add("Principal", "Principal");
            }

            _ingredientGrid.Bands[0].Columns.FromKey("DrinkID").Hidden = true;
            _ingredientGrid.Bands[0].Columns.FromKey("Sort").Width = Unit.Percentage(6);
            _ingredientGrid.Bands[0].Columns.FromKey("Prefix").Width = Unit.Percentage(13);
            _ingredientGrid.Bands[0].Columns.FromKey("Amount").Width = Unit.Percentage(10);
            _ingredientGrid.Bands[0].Columns.FromKey("UnitID").Type = ColumnType.DropDownList;
            _ingredientGrid.Bands[0].Columns.FromKey("UnitID").Width = Unit.Percentage(13);
            _ingredientGrid.Bands[0].Columns.FromKey("IngredientID").Type = ColumnType.DropDownList;
            _ingredientGrid.Bands[0].Columns.FromKey("IngredientID").Width = Unit.Percentage(35);
            _ingredientGrid.Bands[0].Columns.FromKey("Suffix").Width = Unit.Percentage(13);
            _ingredientGrid.Bands[0].Columns.FromKey("Principal").Width = Unit.Percentage(10);

            // Ingredient valuelist
            _vlIngredient = new ValueList();
            _dtIngredient = simpleData.FetchSP("GetIngredients", null);
            _vlIngredient.DataSource = _dtIngredient;
            _vlIngredient.DisplayMember = "Name";
            _vlIngredient.ValueMember = "Ingredient_pk";
            _vlIngredient.DataBind();
            _vlIngredient.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _ingredientGrid.Bands[0].Columns.FromKey("IngredientID").ValueList = _vlIngredient;

            // Unit valuelist
            _vlUnit = new ValueList();
            _dtUnit = simpleData.FetchSP("GetUnits", null);
            _vlUnit.DataSource = _dtUnit;
            _vlUnit.DisplayMember = "Name";
            _vlUnit.ValueMember = "Unit_pk";
            _vlUnit.DataBind();
            _vlUnit.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _ingredientGrid.Bands[0].Columns.FromKey("UnitID").ValueList = _vlUnit;

            // Set up DrinkSource grid #######################################################################
            _drinkSourceGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _drinkSourceGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _drinkSourceGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _drinkSourceGrid.DisplayLayout.AddNewBox.Hidden = false;
            _drinkSourceGrid.Bands[0].AddButtonCaption = "Add New Source";
            _drinkSourceGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _drinkSourceGrid.Bands[0].Columns.Add("DrinkID", "DrinkID");
                _drinkSourceGrid.Bands[0].Columns.Add("SourceID", "SourceID");
            }

            _drinkSourceGrid.Bands[0].Columns.FromKey("DrinkID").Hidden = true;
            _drinkSourceGrid.Bands[0].Columns.FromKey("SourceID").Width = Unit.Percentage(100);
            _drinkSourceGrid.Bands[0].Columns.FromKey("SourceID").Type = ColumnType.DropDownList;
            _drinkSourceGrid.Bands[0].Columns.FromKey("SourceID").DefaultValue = DBNull.Value;

            // Source valuelist
            _vlSource = new ValueList();
            _dtSource = simpleData.FetchSP("GetSources", null);
            _vlSource.DataSource = _dtSource;
            _vlSource.DisplayMember = "Name";
            _vlSource.ValueMember = "Source_pk";
            _vlSource.DataBind();
            _vlSource.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _drinkSourceGrid.Bands[0].Columns.FromKey("SourceID").ValueList = _vlSource;

            // Set up DrinkIngredient grid #######################################################################
            _drinkIngredientGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _drinkIngredientGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _drinkIngredientGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _drinkIngredientGrid.DisplayLayout.AddNewBox.Hidden = false;
            _drinkIngredientGrid.Bands[0].AddButtonCaption = "Add New Ingredient Link";
            _drinkIngredientGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _drinkIngredientGrid.Bands[0].Columns.Add("DrinkID", "DrinkID");
                _drinkIngredientGrid.Bands[0].Columns.Add("IngredientID", "IngredientID");
            }

            _drinkIngredientGrid.Bands[0].Columns.FromKey("DrinkID").Hidden = true;
            _drinkIngredientGrid.Bands[0].Columns.FromKey("IngredientID").Width = Unit.Percentage(100);
            _drinkIngredientGrid.Bands[0].Columns.FromKey("IngredientID").Type = ColumnType.DropDownList;
            _drinkIngredientGrid.Bands[0].Columns.FromKey("IngredientID").DefaultValue = DBNull.Value;

            // Ingredient valuelist
            //_vlIngredient = new ValueList();
            //_dtIngredient = simpleData.FetchSP("GetIngredients", null);
            //_vlIngredient.DataSource = _dtIngredient;
            //_vlIngredient.DisplayMember = "Name";
            //_vlIngredient.ValueMember = "Ingredient_pk";
            //_vlIngredient.DataBind();
            //_vlIngredient.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _drinkIngredientGrid.Bands[0].Columns.FromKey("IngredientID").ValueList = _vlIngredient;

            // Set up DrinkDrink grid #######################################################################
            _drinkDrinkGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _drinkDrinkGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _drinkDrinkGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _drinkDrinkGrid.DisplayLayout.AddNewBox.Hidden = false;
            _drinkDrinkGrid.Bands[0].AddButtonCaption = "Add New Drink Link";
            _drinkDrinkGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _drinkDrinkGrid.Bands[0].Columns.Add("DrinkID1", "DrinkID1");
                _drinkDrinkGrid.Bands[0].Columns.Add("DrinkID2", "DrinkID2");
            }

            _drinkDrinkGrid.Bands[0].Columns.FromKey("DrinkID1").Hidden = true;
            _drinkDrinkGrid.Bands[0].Columns.FromKey("DrinkID2").Width = Unit.Percentage(100);
            _drinkDrinkGrid.Bands[0].Columns.FromKey("DrinkID2").Type = ColumnType.DropDownList;
            _drinkDrinkGrid.Bands[0].Columns.FromKey("DrinkID2").DefaultValue = DBNull.Value;

            // Drink valuelist
            _vlDrink = new ValueList();
            _dtDrink = simpleData.FetchSP("GetDrinks", null);
            _vlDrink.DataSource = _dtDrink;
            _vlDrink.DisplayMember = "Name";
            _vlDrink.ValueMember = "Drink_pk";
            _vlDrink.DataBind();
            _vlDrink.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _drinkDrinkGrid.Bands[0].Columns.FromKey("DrinkID2").ValueList = _vlDrink;

            // Set up DrinkArticle grid #######################################################################
            _drinkArticleGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _drinkArticleGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _drinkArticleGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _drinkArticleGrid.DisplayLayout.AddNewBox.Hidden = false;
            _drinkArticleGrid.Bands[0].AddButtonCaption = "Add New Article Link";
            _drinkArticleGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _drinkArticleGrid.Bands[0].Columns.Add("DrinkID", "DrinkID");
                _drinkArticleGrid.Bands[0].Columns.Add("ArticleID", "ArticleID");
            }

            _drinkArticleGrid.Bands[0].Columns.FromKey("DrinkID").Hidden = true;
            _drinkArticleGrid.Bands[0].Columns.FromKey("ArticleID").Width = Unit.Percentage(100);
            _drinkArticleGrid.Bands[0].Columns.FromKey("ArticleID").Type = ColumnType.DropDownList;
            _drinkArticleGrid.Bands[0].Columns.FromKey("ArticleID").DefaultValue = DBNull.Value;

            // Article valuelist
            _vlArticle = new ValueList();
            _dtArticle = simpleData.FetchSP("GetArticles", null);
            _vlArticle.DataSource = _dtArticle;
            _vlArticle.DisplayMember = "Title";
            _vlArticle.ValueMember = "Article_pk";
            _vlArticle.DataBind();
            _vlArticle.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _drinkArticleGrid.Bands[0].Columns.FromKey("ArticleID").ValueList = _vlArticle;
        }
Exemple #19
0
        public static string GetSimilarIngredientsHtml(int ingredientID, int categoryID, int brandID, int flavor1ID, int flavor2ID)
        {
            StringBuilder sb = new StringBuilder();
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            DataTable dtSimilar = simpleData.FetchSP("GetIngredientSimilar", new SqlParameter[] { new SqlParameter("IngredientID", ingredientID),
                                                                                                  new SqlParameter("CategoryID", categoryID),
                                                                                                  new SqlParameter("BrandID", brandID),
                                                                                                  new SqlParameter("Flavor1ID", flavor1ID),
                                                                                                  new SqlParameter("Flavor2ID", flavor2ID) });
            DataRow[] matchedRows;

            // Drinks that use this ingredient
            matchedRows = dtSimilar.Select("SimilarType = 'drink'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Drinks that use this ingredient</h4>");
                sb.Append(@"<ul class=""nobullet"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""Drinks/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.UrlEncode((string)row["Description"]));
                    sb.Append(@"/"">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            // Ingredients with the same category
            matchedRows = dtSimilar.Select("SimilarType = 'category'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Ingredients in the same category</h4>");
                sb.Append(@"<ul class=""nobullet"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""Ingredients/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.UrlEncode((string)row["Description"]));
                    sb.Append(@"/"">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            // Ingredients with the same brand
            matchedRows = dtSimilar.Select("SimilarType = 'brand'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Ingredients from the same brand</h4>");
                sb.Append(@"<ul class=""nobullet"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""Ingredients/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.UrlEncode((string)row["Description"]));
                    sb.Append(@"/"">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            // Ingredients with the same flavors
            matchedRows = dtSimilar.Select("SimilarType = 'flavor'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Ingredients with similar flavors</h4>");
                sb.Append(@"<ul class=""nobullet"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""Ingredients/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.UrlEncode((string)row["Description"]));
                    sb.Append(@"/"">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            return sb.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            // Get drink data from db
            _drDrink = simpleData.FetchSP("GetDrink", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) }).Rows[0];

            // Get drink data from cache
            DataView dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                    "GetDrinks",
                                                    "Drink_pk",
                                                     null);

            dataView.RowFilter = "Drink_pk = " + Request.QueryString["pk"];

            // Get source data from cache
            DataView sourceView = CacheManager.GetItem(CacheManager.Cache_GetSourcesPublic,
                                                       "GetSourcesPublic",
                                                       "Source_pk",
                                                       null);

            if (dataView.Count > 0)
            {
                _drDrinkCache = dataView.ToTable().Rows[0];

                // Populate fields ##############################################################################
                this.Title = (string)_drDrinkCache["Name"];

                _servingsLiteral.Text = ((Decimal)_drDrinkCache["Servings"]).ToString("###.#");

                _categoryLink.NavigateUrl = @"Drinks/Browse/Category/" + Convert.ToString(_drDrinkCache["CategoryID"]) + "-" + AppUtility.Utility.UrlEncode((string)_drDrinkCache["CategoryName"]) + "/";
                _categoryLink.Text = (string)_drDrinkCache["CategoryName"];

                _familyLink.Text = (string)_drDrinkCache["FamilyName"];
                if (_familyLink.Text.Trim().Length > 0) _familyLink.NavigateUrl = @"Drinks/Browse/Family/" + Convert.ToString(_drDrinkCache["FamilyID"]) + "-" + AppUtility.Utility.UrlEncode((string)_drDrinkCache["FamilyName"]) + "/";

                _structureLink.Text = (string)_drDrinkCache["StructureName"];
                if (_structureLink.Text.Trim().Length > 0) _structureLink.NavigateUrl = @"Drinks/Browse/Structure/" + Convert.ToString(_drDrinkCache["StructureID"]) + "-" + AppUtility.Utility.UrlEncode((string)_drDrinkCache["StructureName"]) + "/";

                // Attributes are down below

                _proofLiteral.Text = ((Decimal)_drDrinkCache["FinalProof"]).ToString("###.#");

                _strengthLiteral.Text = ((Decimal)_drDrinkCache["Strength"]).ToString("###.#");

                // Flavors are down below

                _glassLink.NavigateUrl = @"Drinks/Browse/Glass/" + Convert.ToString(_drDrinkCache["GlassID"]) + "-" + AppUtility.Utility.UrlEncode((string)_drDrinkCache["GlassName"]) + "/";
                _glassLink.Text = (string)_drDrinkCache["GlassName"];

                _tempLink.NavigateUrl = @"Drinks/Browse/Temp/" + Convert.ToString(_drDrinkCache["TempID"]) + "-" + AppUtility.Utility.UrlEncode((string)_drDrinkCache["TempName"]) + "/";
                _tempLink.Text = (string)_drDrinkCache["TempName"];

                // Sources ###############################################
                DataTable dtDrinkSource = simpleData.FetchSP("GetSourcesForDrink", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
                StringBuilder sourceList = new StringBuilder();

                foreach (DataRow row in dtDrinkSource.Rows)
                {
                    if ((int)row["SourceID"] != 1)  // Hide if Charles is the source
                    {
                        sourceView.RowFilter = "Source_pk = " + Convert.ToString(row["SourceID"]);

                        sourceList.Append(@"<a href=""");
                        sourceList.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                        sourceList.Append(@"Resources/");
                        sourceList.Append(Convert.ToString(row["SourceID"]));
                        sourceList.Append("-");
                        sourceList.Append(AppUtility.Utility.UrlEncode(Convert.ToString(sourceView[0]["Name"])));
                        sourceList.Append(@"/"">");
                        sourceList.Append(Convert.ToString(sourceView[0]["Name"]));
                        sourceList.Append(@"</a>, ");
                    }
                }

                // Chop off trailing comma
                if (sourceList.Length > 0) sourceList.Remove(sourceList.Length - 2, 2);

                if (sourceList.Length > 0) _sourceLiteral.Text = sourceList.ToString();
                else _sourceRow.Visible = false;                                            // no sources so hide this field

                _instructionsLiteral.Text = WebUtility.ConvertDBDescriptionToHTML((string)_drDrink["Instructions"]);

                if (((string)_drDrink["Notes"]).Trim() != string.Empty)
                    _notesLiteral.Text = WebUtility.ConvertDBDescriptionToHTML((string)_drDrink["Notes"]);
                else
                    _notesH2.Visible = false;

                // Get ingredients
                _dtIngredient = simpleData.FetchSP("GetDrinkIngredients", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });
                _ingredients.DataSource = _dtIngredient;
                _ingredients.DataBind();

                // Ingredient Profile #####################################
                _dtIngredientProfile = new DataTable();
                _dtIngredientProfile.Columns.Add("Amount", typeof(decimal));
                _dtIngredientProfile.Columns.Add("Name", typeof(string));

                foreach (DataRow row in _dtIngredient.Rows)
                {
                    _dtIngredientProfile.Rows.Add(new object[] { row["AmountWeighted"], row["IngredientName"] });
                }

                _chart.BackgroundImageFileName = Server.MapPath("~") + @"\image\gradient_Drink.png";
                _chart.ColorModel.CustomPalette = AppUtility.Constant.ChartPalette;
                _chart.ColorModel.ModelStyle = Infragistics.UltraChart.Shared.Styles.ColorModels.CustomLinear;
                _chart.DeploymentScenario.ImageURL = ConfigurationManager.AppSettings["SiteUrl"] + _chart.DeploymentScenario.ImageURL;
                _chart.DataSource = _dtIngredientProfile;
                _chart.DataBind();

                // Attributes ################################################
                DataTable dataTableAttributes = simpleData.FetchSP("GetDrinkAttributes", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });

                StringBuilder attributes = new StringBuilder();
                foreach (DataRow row in dataTableAttributes.Rows)
                {
                    attributes.Append(@"<a href=""");
                    attributes.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    attributes.Append(@"Drinks/Browse/Attribute/");
                    attributes.Append(Convert.ToString(row["ListItem_pk"]));
                    attributes.Append("-");
                    attributes.Append(AppUtility.Utility.UrlEncode(Convert.ToString(row["Name"])));
                    attributes.Append(@"/"">");
                    attributes.Append(Convert.ToString(row["Name"]));
                    attributes.Append(@"</a>, ");
                }

                // Chop off trailing comma
                if (attributes.Length > 0) attributes.Remove(attributes.Length - 2, 2);

                _attributesLiteral.Text = attributes.ToString();

                // Flavors ################################################
                DataTable dtFlavors = simpleData.FetchSP("GetDrinkFlavors", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });

                StringBuilder flavors = new StringBuilder();
                foreach (DataRow row in dtFlavors.Rows)
                {
                    flavors.Append(@"<a href=""");
                    flavors.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    flavors.Append(@"Drinks/Browse/Flavor/");
                    flavors.Append(Convert.ToString(row["ListItem_pk"]));
                    flavors.Append("-");
                    flavors.Append(AppUtility.Utility.UrlEncode(Convert.ToString(row["Name"])));
                    flavors.Append(@"/"">");
                    flavors.Append(Convert.ToString(row["Name"]));
                    flavors.Append(@"</a>, ");
                }

                // Chop off trailing comma
                if (flavors.Length > 0) flavors.Remove(flavors.Length - 2, 2);

                _flavorsLiteral.Text = flavors.ToString();

                // Do right column content targeted to this ingredient
                int flavor1ID = -1;
                int flavor2ID = -1;
                int flavor3ID = -1;
                if (dtFlavors.Rows.Count > 0) flavor1ID = (int)dtFlavors.Rows[0]["ListItem_pk"];
                if (dtFlavors.Rows.Count > 1) flavor2ID = (int)dtFlavors.Rows[1]["ListItem_pk"];
                if (dtFlavors.Rows.Count > 2) flavor2ID = (int)dtFlavors.Rows[2]["ListItem_pk"];

                this.RightColumn.Controls.Add(new LiteralControl(CharlesThompson.LiquorAndDrink.AppUI.Content.GetSimilarDrinksHtmlOld(Convert.ToInt32(Request.QueryString["pk"]),
                                                                                                                                  (int)_drDrinkCache["CategoryID"],
                                                                                                                                  (int)_drDrinkCache["FamilyID"],
                                                                                                                                  (int)_drDrinkCache["StructureID"],
                                                                                                                                   flavor1ID,
                                                                                                                                   flavor2ID,
                                                                                                                                   flavor3ID,
                                                                                                                                  (int)_drDrinkCache["GlassID"])));
                // Log this drink
                LogDrink(Convert.ToInt32(Request.QueryString["pk"]));

                // Get drink links in right column
                DataTable dtDrinkLinks = simpleData.FetchSP("GetDrinkLinks", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });

                this.RightColumn.Controls.Add(new LiteralControl(CharlesThompson.LiquorAndDrink.AppUI.Content.GetLinkBoxHtml(dtDrinkLinks)));

                // Set page meta tags
                HtmlMeta meta = new HtmlMeta();
                meta.Name = "description";
                string metaContent = AppUI.Content.GetDrinkMetaDescription(_drDrink, _dtIngredient);
                meta.Content = metaContent;
                this.Header.Controls.Add(meta);

                // Set ShareThis header script
                this.Header.Controls.Add(new LiteralControl(CacheManager.GetItem(CacheManager.Cache_FileShareThisHeaderScript)));

                // Do share box button script
                StringBuilder shareScript = new StringBuilder();
                _shareDiv.Controls.Add(new LiteralControl(AppUI.Content.GetShareButtonScript(((string)_drDrinkCache["Name"]).Replace("'", ""),
                                                                                               metaContent,
                                                                                               ConfigurationManager.AppSettings["SiteUrl"] + "Drinks/" + Convert.ToString(_drDrink["Drink_pk"]) + "-" + Utility.UrlEncode((string)_drDrink["Name"]))));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["pk"] == "0")
            {// No primary key--add mode

                _pageMode = Constant.PageMode.Add;
            }
            else
            {// We have a primary key--edit mode

                _pageMode = Constant.PageMode.Edit;
            }

            DataTable dataTable;
            DataRow foundRow;
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            // Get ingredient data from db
            if (_pageMode == Constant.PageMode.Add)
            {
                DataTable dtTemp = simpleData.FetchSP("GetIngredient", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) });
                _drIngredient = dtTemp.NewRow();
            }
            else
            {
                _drIngredient = simpleData.FetchSP("GetIngredient", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) }).Rows[0];
            }

            _dtIngredientFlavors = simpleData.FetchSP("GetIngredientFlavors", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) });
            _dtIngredientFlavors.PrimaryKey = new DataColumn[] { _dtIngredientFlavors.Columns["ListItem_pk"] };

            // Title
            if (_drIngredient["IngredientName"] != DBNull.Value) _titleLiteral.Text = (string)_drIngredient["IngredientName"];

            // Load combo items #############################################################################
            // Category
            dataTable = simpleData.FetchSP("GetListItemsTreeDepthFirst", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.IngredientCategory)) });
            _categoryCombo.DataSource = dataTable;
            _categoryCombo.DataBind();

            // Brands
            dataTable = simpleData.FetchSP("GetBrands", null);
            _brandCombo.DataSource = dataTable;
            _brandCombo.DataBind();
            _brandCombo.Items.Insert(0, new ListItem(Constant.NotSpecifiedDescription, Convert.ToString(Constant.NotSpecifiedValue)));

            // Countries
            dataTable = simpleData.FetchSP("GetListItems", new SqlParameter[] { new SqlParameter("ListID", Convert.ToInt32(Constant.List.Country)) });
            _countryCombo.DataSource = dataTable;
            _countryCombo.DataBind();
            _countryCombo.Items.Insert(0, new ListItem(Constant.NotSpecifiedDescription, Convert.ToString(Constant.NotSpecifiedValue)));

            // Flavors are done in Page_Init

            // Set control states ############################################################################
            if (Page.IsPostBack)
            {// In postback

                // Grab dropdown values from form object (so we don't need to use viewstate)
                _categoryCombo.SelectedValue = Request.Form[_categoryCombo.UniqueID];
                _brandCombo.SelectedValue = Request.Form[_brandCombo.UniqueID];
                _countryCombo.SelectedValue = Request.Form[_countryCombo.UniqueID];
                _descriptionText.Text = Request.Form[_descriptionText.UniqueID];
                _notesText.Text = Request.Form[_notesText.UniqueID];
            }
            else
            {// Not in postback

                if (_pageMode == Constant.PageMode.Edit)
                {// Edit

                    // Name
                    _nameText.Text = (string)_drIngredient["IngredientName"];

                    // Name Plural
                    _namePluralText.Text = (string)_drIngredient["IngredientNamePlural"];

                    // Category
                    if (_drIngredient["CategoryID"] == DBNull.Value) _categoryCombo.SelectedIndex = 0;
                    else _categoryCombo.SelectedValue = Convert.ToString(_drIngredient["CategoryID"]);

                    // Brand
                    if (_drIngredient["BrandID"] == DBNull.Value) _brandCombo.SelectedIndex = 0;
                    else _brandCombo.SelectedValue = Convert.ToString(_drIngredient["BrandID"]);

                    // Country
                    if (_drIngredient["CountryID"] == DBNull.Value) _countryCombo.SelectedIndex = 0;
                    else _countryCombo.SelectedValue = Convert.ToString(_drIngredient["CountryID"]);

                    // Flavors
                    foreach (ListItem li in _flavorList.Items)
                    {
                        foundRow = _dtIngredientFlavors.Rows.Find(li.Value);
                        if (foundRow != null) li.Selected = true;
                    }

                    // Proof
                    _proofNumber.Value = (decimal)_drIngredient["Proof"];

                    // Dissolved Volume Ratio
                    _dissolvedVolumeRatioNumber.Value = (decimal)_drIngredient["DissolvedVolumeRatio"];

                    // URL
                    _urlText.Text = (string)_drIngredient["IngredientURL"];

                    // Flavor profile
                    if (_drIngredient["Body"] != DBNull.Value) _bodyNumber.Value = (decimal)_drIngredient["Body"];
                    if (_drIngredient["Sweet"] != DBNull.Value) _sweetNumber.Value = (decimal)_drIngredient["Sweet"];
                    if (_drIngredient["Sour"] != DBNull.Value) _sourNumber.Value = (decimal)_drIngredient["Sour"];
                    if (_drIngredient["FreshFruit"] != DBNull.Value) _freshFruitNumber.Value = (decimal)_drIngredient["FreshFruit"];
                    if (_drIngredient["DriedFruit"] != DBNull.Value) _driedFruitNumber.Value = (decimal)_drIngredient["DriedFruit"];
                    if (_drIngredient["Spice"] != DBNull.Value) _spiceNumber.Value = (decimal)_drIngredient["Spice"];
                    if (_drIngredient["Heat"] != DBNull.Value) _heatNumber.Value = (decimal)_drIngredient["Heat"];
                    if (_drIngredient["Wood"] != DBNull.Value) _woodNumber.Value = (decimal)_drIngredient["Wood"];

                    // Description
                    _descriptionText.Text = (string)_drIngredient["Description"];

                    // Notes
                    _notesText.Text = (string)_drIngredient["Notes"];

                    // IngredientDrink grid
                    _dtIngredientDrink2 = simpleData.FetchSP("GetLinkedDrinksForIngredient", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) });
                    _ingredientDrinkGrid.DataSource = _dtIngredientDrink2;
                    _ingredientDrinkGrid.DataBind();

                    // IngredientIngredient grid
                    _dtIngredientIngredient = simpleData.FetchSP("GetLinkedIngredientsForIngredient", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) });
                    _ingredientIngredientGrid.DataSource = _dtIngredientIngredient;
                    _ingredientIngredientGrid.DataBind();

                    // IngredientArticle grid
                    _dtIngredientArticle = simpleData.FetchSP("GetLinkedArticlesForIngredient", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) });
                    _ingredientArticleGrid.DataSource = _dtIngredientArticle;
                    _ingredientArticleGrid.DataBind();
                }
                else
                {// Add

                    _dissolvedVolumeRatioNumber.Value = 1;
                }
            }

            // Set up IngredientDrink grid #######################################################################
            _ingredientDrinkGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _ingredientDrinkGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _ingredientDrinkGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _ingredientDrinkGrid.DisplayLayout.AddNewBox.Hidden = false;
            _ingredientDrinkGrid.Bands[0].AddButtonCaption = "Add New Drink Link";
            _ingredientDrinkGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _ingredientDrinkGrid.Bands[0].Columns.Add("IngredientID", "IngredientID");
                _ingredientDrinkGrid.Bands[0].Columns.Add("DrinkID", "DrinkID");
            }

            _ingredientDrinkGrid.Bands[0].Columns.FromKey("IngredientID").Hidden = true;
            _ingredientDrinkGrid.Bands[0].Columns.FromKey("DrinkID").Width = Unit.Percentage(100);
            _ingredientDrinkGrid.Bands[0].Columns.FromKey("DrinkID").Type = ColumnType.DropDownList;
            _ingredientDrinkGrid.Bands[0].Columns.FromKey("DrinkID").DefaultValue = DBNull.Value;

            // Drink valuelist
            _vlDrink = new ValueList();
            _dtDrink = simpleData.FetchSP("GetDrinks", null);
            _vlDrink.DataSource = _dtDrink;
            _vlDrink.DisplayMember = "Name";
            _vlDrink.ValueMember = "Drink_pk";
            _vlDrink.DataBind();
            _vlDrink.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _ingredientDrinkGrid.Bands[0].Columns.FromKey("DrinkID").ValueList = _vlDrink;

            // Set up IngredientIngredient grid #######################################################################
            _ingredientIngredientGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _ingredientIngredientGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _ingredientIngredientGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _ingredientIngredientGrid.DisplayLayout.AddNewBox.Hidden = false;
            _ingredientIngredientGrid.Bands[0].AddButtonCaption = "Add New Ingredient Link";
            _ingredientIngredientGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _ingredientIngredientGrid.Bands[0].Columns.Add("IngredientID1", "IngredientID1");
                _ingredientIngredientGrid.Bands[0].Columns.Add("IngredientID2", "IngredientID2");
            }

            _ingredientIngredientGrid.Bands[0].Columns.FromKey("IngredientID1").Hidden = true;
            _ingredientIngredientGrid.Bands[0].Columns.FromKey("IngredientID2").Width = Unit.Percentage(100);
            _ingredientIngredientGrid.Bands[0].Columns.FromKey("IngredientID2").Type = ColumnType.DropDownList;
            _ingredientIngredientGrid.Bands[0].Columns.FromKey("IngredientID2").DefaultValue = DBNull.Value;

            // Drink valuelist
            _vlDrink = new ValueList();
            _dtDrink = simpleData.FetchSP("GetIngredients", null);
            _vlDrink.DataSource = _dtDrink;
            _vlDrink.DisplayMember = "Name";
            _vlDrink.ValueMember = "Ingredient_pk";
            _vlDrink.DataBind();
            _vlDrink.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _ingredientIngredientGrid.Bands[0].Columns.FromKey("IngredientID2").ValueList = _vlDrink;

            // Set up IngredientArticle grid #######################################################################
            _ingredientArticleGrid.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
            _ingredientArticleGrid.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;
            _ingredientArticleGrid.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
            _ingredientArticleGrid.DisplayLayout.AddNewBox.Hidden = false;
            _ingredientArticleGrid.Bands[0].AddButtonCaption = "Add New Article Link";
            _ingredientArticleGrid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;

            if (_pageMode == Constant.PageMode.Add)
            {// Add mode--need to build columns

                _ingredientArticleGrid.Bands[0].Columns.Add("IngredientID", "IngredientID");
                _ingredientArticleGrid.Bands[0].Columns.Add("ArticleID", "ArticleID");
            }

            _ingredientArticleGrid.Bands[0].Columns.FromKey("IngredientID").Hidden = true;
            _ingredientArticleGrid.Bands[0].Columns.FromKey("ArticleID").Width = Unit.Percentage(100);
            _ingredientArticleGrid.Bands[0].Columns.FromKey("ArticleID").Type = ColumnType.DropDownList;
            _ingredientArticleGrid.Bands[0].Columns.FromKey("ArticleID").DefaultValue = DBNull.Value;

            // Article valuelist
            _vlArticle = new ValueList();
            _dtArticle = simpleData.FetchSP("GetArticles", null);
            _vlArticle.DataSource = _dtArticle;
            _vlArticle.DisplayMember = "Title";
            _vlArticle.ValueMember = "Article_pk";
            _vlArticle.DataBind();
            _vlArticle.DisplayStyle = ValueListDisplayStyle.DisplayText;
            _ingredientArticleGrid.Bands[0].Columns.FromKey("ArticleID").ValueList = _vlArticle;
        }
Exemple #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["desc"] != null)
            {// This is not a generic search--it is a browse filter--figure out page title

                if (Request.QueryString["filter"] == "search")
                {// Doing a one parameter search to impersonate a browse

                    if (Request.QueryString["attr"] != null)
                        Page.Title = "Browse Drinks - By Attribute - " + CharlesThompson.LiquorAndDrink.AppUtility.Shared.UrlDecode(Request.QueryString["desc"]);

                    else if (Request.QueryString["ingred"] != null)
                        Page.Title = "Browse Drinks - By Ingredient - " + Shared.UrlDecode(Request.QueryString["desc"]);

                    else if (Request.QueryString["brand"] != null)
                        Page.Title = "Browse Drinks - By Ingredient Brand - " + Shared.UrlDecode(Request.QueryString["desc"]);

                    else if (Request.QueryString["flavor"] != null)
                        Page.Title = "Browse Drinks - By Flavor - " + Shared.UrlDecode(Request.QueryString["desc"]);
                }
                else
                {// Doing an actual browse

                    if (Request.QueryString["filter"] == "cat")
                        Page.Title = "Browse Drinks - By Category - " + Shared.UrlDecode(Request.QueryString["desc"]);

                    else if (Request.QueryString["filter"] == "family")
                        Page.Title = "Browse Drinks - By Family - " + Shared.UrlDecode(Request.QueryString["desc"]);

                    else if (Request.QueryString["filter"] == "struct")
                        Page.Title = "Browse Drinks - By Structure - " + Shared.UrlDecode(Request.QueryString["desc"]);

                    else if (Request.QueryString["filter"] == "glass")
                        Page.Title = "Browse Drinks - By Glass - " + Shared.UrlDecode(Request.QueryString["desc"]);

                    else if (Request.QueryString["filter"] == "temp")
                        Page.Title = "Browse Drinks - By Temperature - " + Shared.UrlDecode(Request.QueryString["desc"]);
                }
            }
            else
            {// These don't use a desc

                if (Request.QueryString["filter"] == "proof")
                {
                    if (Request.QueryString["value2"] == "0")
                        Page.Title = "Browse Drinks - By Alcohol Proof - No Alcohol";
                    else
                        Page.Title = "Browse Drinks - By Alcohol Proof - " + Request.QueryString["value1"] + " to " + Request.QueryString["value2"] + " Proof";
                }

                else if (Request.QueryString["filter"] == "strength")
                {
                    switch (Request.QueryString["value2"])
                    {
                        case "0": Page.Title = "Browse Drinks - By Alcohol Strength - No Alcohol"; break;
                        case "0.5": Page.Title = "Browse Drinks - By Alcohol Strength - Weak"; break;
                        case "1.5": Page.Title = "Browse Drinks - By Alcohol Strength - Single"; break;
                        case "2.5": Page.Title = "Browse Drinks - By Alcohol Strength - Double"; break;
                        case "3.5": Page.Title = "Browse Drinks - By Alcohol Strength - Triple"; break;
                        case "4.5": Page.Title = "Browse Drinks - By Alcohol Strength - Quadruple"; break;
                    }
                }

                else if (Request.QueryString["filter"] == "name")
                    Page.Title = "Browse Drinks - By Name";

                else
                {// Must be a genuine search

                    Page.Title = "Search Drinks - Results";
                }
            }

            SqlParameter[] sqlParameters = new SqlParameter[19];

            // First, fill out blank parameters.  If a parameter is going to be used, it will be filled out below.
            // SqlParemeterCollection can't have nulls in it.
            sqlParameters[0] = new SqlParameter("Name", null);
            sqlParameters[1] = new SqlParameter("InstructionsAndNotes", null);
            sqlParameters[2] = new SqlParameter("CategoryID", null);
            sqlParameters[3] = new SqlParameter("FamilyID", null);
            sqlParameters[4] = new SqlParameter("StructureID", null);
            sqlParameters[5] = new SqlParameter("AttributeID", null);
            sqlParameters[6] = new SqlParameter("IngredientID", null);
            sqlParameters[7] = new SqlParameter("IngredientBrandID", null);
            sqlParameters[8] = new SqlParameter("AlcoholProof1", null);
            sqlParameters[9] = new SqlParameter("AlcoholProof2", null);
            sqlParameters[10] = new SqlParameter("AlcoholStrength1", null);
            sqlParameters[11] = new SqlParameter("AlcoholStrength2", null);
            sqlParameters[12] = new SqlParameter("FlavorID", null);
            sqlParameters[13] = new SqlParameter("GlassID", null);
            sqlParameters[14] = new SqlParameter("TempID", null);
            sqlParameters[15] = new SqlParameter("PageNum", 1);
            sqlParameters[16] = new SqlParameter("PageSize", 5000);

            if (Request.QueryString["name"] != null)
            {
                sqlParameters[0] = new SqlParameter("Name", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 0, 0, "Name", DataRowVersion.Current, Request.QueryString["name"]);
            }

            if (Request.QueryString["in"] != null)
            {
                sqlParameters[1] = new SqlParameter("InstructionsAndNotes", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 0, 0, "InstructionsAndNotes", DataRowVersion.Current, Request.QueryString["in"]);
            }

            if (Request.QueryString["cat"] != null)
            {
                sqlParameters[2] = new SqlParameter("CategoryID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "CategoryID", DataRowVersion.Current, Request.QueryString["cat"]);
            }

            if (Request.QueryString["fam"] != null)
            {
                sqlParameters[3] = new SqlParameter("FamilyID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "FamilyID", DataRowVersion.Current, Request.QueryString["fam"]);
            }

            if (Request.QueryString["struct"] != null)
            {
                sqlParameters[4] = new SqlParameter("StructureID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "StructureID", DataRowVersion.Current, Request.QueryString["struct"]);
            }

            if (Request.QueryString["attr"] != null)
            {
                sqlParameters[5] = new SqlParameter("AttributeID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AttributeID", DataRowVersion.Current, Request.QueryString["attr"]);
            }

            if (Request.QueryString["ingred"] != null)
            {
                sqlParameters[6] = new SqlParameter("IngredientID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "PrincipalIngredientID", DataRowVersion.Current, Request.QueryString["ingred"]);
            }

            if (Request.QueryString["brand"] != null)
            {
                sqlParameters[7] = new SqlParameter("IngredientBrandID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "PrincipalIngredientBrandID", DataRowVersion.Current, Request.QueryString["brand"]);
            }

            if (Request.QueryString["proof1"] != null)
            {
                sqlParameters[8] = new SqlParameter("AlcoholProof1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AlcoholProof1", DataRowVersion.Current, Request.QueryString["proof1"]);
            }

            if (Request.QueryString["proof2"] != null)
            {
                sqlParameters[9] = new SqlParameter("AlcoholProof2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AlcoholProof2", DataRowVersion.Current, Request.QueryString["proof2"]);
            }

            if (Request.QueryString["strength1"] != null)
            {
                sqlParameters[10] = new SqlParameter("AlcoholStrength1", SqlDbType.Decimal, 0, ParameterDirection.Input, true, 5, 1, "AlcoholStrength1", DataRowVersion.Current, Request.QueryString["strength1"]);
            }

            if (Request.QueryString["strength2"] != null)
            {
                sqlParameters[11] = new SqlParameter("AlcoholStrength2", SqlDbType.Decimal, 0, ParameterDirection.Input, true, 5, 1, "AlcoholStrength2", DataRowVersion.Current, Request.QueryString["strength2"]);
            }

            if (Request.QueryString["flavor"] != null)
            {
                sqlParameters[12] = new SqlParameter("FlavorID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "FlavorID", DataRowVersion.Current, Request.QueryString["flavor"]);
            }

            if (Request.QueryString["glass"] != null)
            {
                sqlParameters[13] = new SqlParameter("GlassID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "GlassID", DataRowVersion.Current, Request.QueryString["glass"]);
            }

            if (Request.QueryString["temp"] != null)
            {
                sqlParameters[14] = new SqlParameter("TempID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "TempID", DataRowVersion.Current, Request.QueryString["temp"]);
            }

            // Add output parameters
            sqlParameters[17] = new SqlParameter("TotalPages", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalPages", DataRowVersion.Current, 0);
            sqlParameters[18] = new SqlParameter("TotalRows", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalRows", DataRowVersion.Current, 0);

            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            if (Request.QueryString["filter"] == "search")
            {// Full search requested--crank the search stored procedure

                _repeater.DataSource = simpleData.FetchSP("SearchDrinks", sqlParameters);
            }
            else
            {// Browse requested--filter on one column (hopefully from the cache)

                DataView dataView;

                switch (Request.QueryString["filter"])
                {
                    case "name":
                    // Filter by name (just show all)

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = String.Empty;
                        _repeater.DataSource = dataView;

                        break;

                    case "cat":
                    // Filter by category

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "CategoryID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        break;

                    case "family":
                    // Filter by family

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "FamilyID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        break;

                    case "struct":
                    // Filter by structure

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "StructureID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        break;

                    case "proof":
                    // Filter by alcohol proof

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "FinalProof >= " + Request.QueryString["value1"] + " AND FinalProof <= " + Request.QueryString["value2"];
                        _repeater.DataSource = dataView;

                        break;

                    case "strength":
                    // Filter by alcohol strength

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "Strength >= " + Request.QueryString["value1"] + " AND Strength <= " + Request.QueryString["value2"];
                        _repeater.DataSource = dataView;

                        break;

                    case "glass":
                    // Filter by glass

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "GlassID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        break;

                    case "temp":
                    // Filter by temperature

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "TempID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        break;
                }
            }

            _repeater.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int rowCount = 0;

            // Log page
            AppUtility.Utility.LogPage();

            if (Request.QueryString["desc"] != null)
            {// This is not a generic search--it is a browse filter--figure out page title

                if (Request.QueryString["filter"] == "search")
                {// Doing a one parameter search to impersonate a browse

                    if (Request.QueryString["cat"] != null)
                        ModuleConfiguration.ModuleTitle = "Liquor/Mixers - Category - " + WebUtility.TitleCase(AppUtility.Utility.UrlDecode(Request.QueryString["desc"]));

                    else if (Request.QueryString["flavor"] != null)
                        ModuleConfiguration.ModuleTitle = "Liquor/Mixers - Flavor - " + WebUtility.TitleCase(AppUtility.Utility.UrlDecode(Request.QueryString["desc"]));
                }
                else
                {// Doing an actual browse

                    if (Request.QueryString["filter"] == "brand")
                        ModuleConfiguration.ModuleTitle = "Liquor/Mixers - Brand - " + WebUtility.TitleCase(AppUtility.Utility.UrlDecode(Request.QueryString["desc"]));

                    else if (Request.QueryString["filter"] == "country")
                        ModuleConfiguration.ModuleTitle = "Liquor/Mixers - Country of Origin - " + WebUtility.TitleCase(AppUtility.Utility.UrlDecode(Request.QueryString["desc"]));
                }
            }
            else
            {// These don't use a desc

                if (Request.QueryString["filter"] == "proof")
                {
                    if (Request.QueryString["value2"] == "0")
                        ModuleConfiguration.ModuleTitle = "Liquor/Mixers - Alcohol Proof - No Alcohol";
                    else
                        ModuleConfiguration.ModuleTitle = "Liquor/Mixers - Alcohol Proof - " + Request.QueryString["value1"] + " to " + Request.QueryString["value2"] + " Proof";
                }

                else if (Request.QueryString["filter"] == "name")
                {
                    ModuleConfiguration.ModuleTitle = "Cocktail Ingredients";
                    _metaDescription = "A huge list of cocktail ingredients.";
                }
                else if (Request.QueryString["filter"] == "inusebydrinks")
                {// drinks/browse/ingredient, browse drinks by ingredient, showing all ingredients in use in drinks

                    ModuleConfiguration.ModuleTitle = "Cocktail Ingredients";
                    _metaDescription = "A huge list of cocktail ingredients.";
                    _subheadParagraph.InnerText = "Click on a cocktail ingredient to see which drink recipes use it.";
                }
                else
                {// Must be a genuine search

                    ModuleConfiguration.ModuleTitle = "Liquor/Mixers - Search Results";
                }
            }

            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            SqlParameter[] sqlParameters = new SqlParameter[16];

            // First, fill out blank parameters.  If a parameter is going to be used, it will be filled out below.
            // SqlParemeterCollection can't have nulls in it.
            sqlParameters[0] = new SqlParameter("Name", null);
            sqlParameters[1] = new SqlParameter("DescriptionAndNotes", null);
            sqlParameters[2] = new SqlParameter("CategoryID", null);
            sqlParameters[3] = new SqlParameter("FlavorID", null);
            sqlParameters[4] = new SqlParameter("CountryID", null);
            sqlParameters[5] = new SqlParameter("BrandID", null);
            sqlParameters[6] = new SqlParameter("AlcoholProof1", null);
            sqlParameters[7] = new SqlParameter("AlcoholProof2", null);
            sqlParameters[8] = new SqlParameter("LADRating1", null);
            sqlParameters[9] = new SqlParameter("LADRating2", null);
            sqlParameters[10] = new SqlParameter("COMRating1", null);
            sqlParameters[11] = new SqlParameter("COMRating2", null);
            sqlParameters[12] = new SqlParameter("PageNum", 1);
            sqlParameters[13] = new SqlParameter("PageSize", 5000);

            if (Request.QueryString["name"] != null)
            {
                sqlParameters[0] = new SqlParameter("Name", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 0, 0, "Name", DataRowVersion.Current, Request.QueryString["name"]);
            }

            if (Request.QueryString["dn"] != null)
            {
                sqlParameters[1] = new SqlParameter("DescriptionAndNotes", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 0, 0, "DescriptionAndNotes", DataRowVersion.Current, Request.QueryString["dn"]);
            }

            if (Request.QueryString["cat"] != null)
            {
            //                DataTable dtCategory = simpleData.FetchSP("GetListItemsTreeAllChildren",
            //                                                           new SqlParameter[] { new SqlParameter("ListItemID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "ListItemID", DataRowVersion.Current, Request.QueryString["cat"]) });

                sqlParameters[2] = new SqlParameter("CategoryID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "CategoryID", DataRowVersion.Current, Request.QueryString["cat"]);
            }

            if (Request.QueryString["flavor"] != null)
            {
                sqlParameters[3] = new SqlParameter("FlavorID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "FlavorID", DataRowVersion.Current, Request.QueryString["flavor"]);
            }

            if (Request.QueryString["country"] != null)
            {
                sqlParameters[4] = new SqlParameter("CountryID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "CountryID", DataRowVersion.Current, Request.QueryString["country"]);
            }

            if (Request.QueryString["brand"] != null)
            {
                sqlParameters[5] = new SqlParameter("BrandID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "BrandID", DataRowVersion.Current, Request.QueryString["brand"]);
            }

            if (Request.QueryString["proof1"] != null)
            {
                sqlParameters[6] = new SqlParameter("AlcoholProof1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AlcoholProof1", DataRowVersion.Current, Request.QueryString["proof1"]);
            }

            if (Request.QueryString["proof2"] != null)
            {
                sqlParameters[7] = new SqlParameter("AlcoholProof2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AlcoholProof2", DataRowVersion.Current, Request.QueryString["proof2"]);
            }

            if (Request.QueryString["ladrating1"] != null)
            {
                sqlParameters[8] = new SqlParameter("LADRating1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "LADRating1", DataRowVersion.Current, Request.QueryString["ladrating1"]);
            }

            if (Request.QueryString["ladrating2"] != null)
            {
                sqlParameters[9] = new SqlParameter("LADRating2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "LADRating2", DataRowVersion.Current, Request.QueryString["ladrating2"]);
            }

            if (Request.QueryString["comrating1"] != null)
            {
                sqlParameters[10] = new SqlParameter("COMRating1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "COMRating1", DataRowVersion.Current, Request.QueryString["comrating1"]);
            }

            if (Request.QueryString["comrating2"] != null)
            {
                sqlParameters[11] = new SqlParameter("COMRating2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "COMRating2", DataRowVersion.Current, Request.QueryString["comrating2"]);
            }

            // Add output parameters
            sqlParameters[14] = new SqlParameter("TotalPages", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalPages", DataRowVersion.Current, 0);
            sqlParameters[15] = new SqlParameter("TotalRows", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalRows", DataRowVersion.Current, 0);

            if (Request.QueryString["filter"] == "search")
            {// Full search requested--crank the search stored procedure

                _repeaterIngredient.DataSource = simpleData.FetchSP("SearchIngredients", sqlParameters);
                rowCount = ((DataTable)_repeaterIngredient.DataSource).Rows.Count;
            }
            else
            {// Browse requested--filter on one column (hopefully from the cache)

                DataView dataView = null;

                switch (Request.QueryString["filter"])
                {
                    case "name":
                    // Filter by name--just show all

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredientsWithDetailPage,
                                                       "GetIngredientsWithDetailPage",
                                                       "Ingredient_pk",
                                                        null);

                        dataView.RowFilter = String.Empty;
                        _repeaterIngredient.DataSource = dataView;
                        break;

                    case "cat":
                    // Filter by category--this is actually done as a one parameter search above
                        break;

                    case "country":
                    // Filter by country

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredientsWithDetailPage,
                                                       "GetIngredientsWithDetailPage",
                                                       "Ingredient_pk",
                                                        null);

                        dataView.RowFilter = "CountryID = " + Request.QueryString["value"];
                        _repeaterIngredient.DataSource = dataView;
                        break;

                    case "brand":
                    // Filter by brand

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredientsWithDetailPage,
                                                       "GetIngredientsWithDetailPage",
                                                       "Ingredient_pk",
                                                        null);

                        dataView.RowFilter = "BrandID = " + Request.QueryString["value"];
                        _repeaterIngredient.DataSource = dataView;
                        break;

                    case "proof":
                    // Filter by alcohol proof

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredientsWithDetailPage,
                                                       "GetIngredientsWithDetailPage",
                                                       "Ingredient_pk",
                                                        null);

                        dataView.RowFilter = "Proof >= " + Request.QueryString["value1"] + " AND Proof <= " + Request.QueryString["value2"];
                        _repeaterIngredient.DataSource = dataView;
                        break;

                    case "inusebydrinks":
                    // Filter by ingredients in use in drinks

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredientsInUseByDrinks,
                                                       "GetIngredientsInUseByDrinks",
                                                       "Ingredient_pk",
                                                        null);

                        _repeaterDrink.DataSource = dataView;
                        break;
                }

                rowCount = dataView.Count;
            }

            if (Request.QueryString["filter"] == "inusebydrinks")
            {// Browse drinks by ingredient

                // Light up the ingredient/brand to drink repeater
                _repeaterDrink.DataBind();
            }
            else
            {// Browse ingredients by filter passed in

                if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "brand")
                {// A browse request was made for a list of ingredients that belong to a particular brand.  We do not do
                 // this kind of browsing anymore so throw a 404 instead.

                        HttpContext.Current.Response.StatusCode = 404;
                        HttpContext.Current.Response.End();
                }

                if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "country")
                {// A browse request was made for a list of ingredients from a particular country.  We do not do
                 // this kind of browsing anymore so throw a 404 instead.

                        HttpContext.Current.Response.StatusCode = 404;
                        HttpContext.Current.Response.End();
                }

                if (rowCount == 0)
                {// No records returned

                    if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "search" && Request.QueryString["cat"] != null)
                    {// A request was made for a list of ingredients for a particlar ingredient category.  We have cleaned
                     // out a long of categories.  If the request is for one of the categories that no longer exists, the
                     // page would just show a blank list.  This is not good for SEO so we need to throw a 404 instead.

                        HttpContext.Current.Response.StatusCode = 404;
                        HttpContext.Current.Response.End();
                    }

                    if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "search" && Request.QueryString["flavor"] != null)
                    {// A request was made for a list of ingredients with a particular flavor.  We have cleaned
                     // out a lot of flavors.  If the request is for one of the categories that no longer exists, the
                     // page would just show a blank list.  This is not good for SEO so we need to throw a 404 instead.

                        HttpContext.Current.Response.StatusCode = 404;
                        HttpContext.Current.Response.End();
                    }
                }

                // Light up the ingredients to ingredient repeater
                _repeaterIngredient.DataBind();
            }

            // Widgets
            // Send a message to any widget modules that are listening.
            ModuleCommunicationEventArgs args = new ModuleCommunicationEventArgs();
            args.Sender = "Headlines";
            args.Target = "Widget";
            args.Value = new List<string>() {AppUtility.AdRotator.GetAdsenseCode("adsense.list.200x90.linkunit")};

            if (ModuleCommunication != null)
            {
                ModuleCommunication(this, args);
            }

            // Log page
            AppUtility.Utility.LogPage();

            DoSEO();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];

            // Ingredient
            SimpleData simpleData = new SimpleData();
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;
            _dataRow = simpleData.FetchSP("GetIngredient", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) }).Rows[0];

            // Load fields
            this.Title = (string)_dataRow["IngredientName"];

            // Categories
            // Get all parents of this category.  We will display the parents as a hierarchy.
            DataTable _parentCategories = simpleData.FetchSP("GetListItemsTreeAllParents", new SqlParameter[] { new SqlParameter("ListItemID", Convert.ToInt32(_dataRow["CategoryID"])) });
            StringBuilder sb = new StringBuilder();
            int counter = 0;

            sb.Append(@"<p style=""line-height: 1.25em"">");

            for (int i = _parentCategories.Rows.Count - 1; i >= 0; i--)
            {
                for (int x = 0; x < counter * 2; x++)
                {
                    sb.Append("&nbsp;");
                }

                sb.Append(@"<a href=""");
                sb.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                sb.Append("Ingredients/Browse/Category/");
                sb.Append(Convert.ToString(_parentCategories.Rows[i]["ListItem_pk"]));
                sb.Append("-");
                sb.Append(AppUtility.Utility.UrlEncode((string)_parentCategories.Rows[i]["Name"]));
                sb.Append(@"/"">");
                sb.Append((string)_parentCategories.Rows[i]["Name"]);
                sb.Append(@"</a><br>");

                counter++;
            }
            sb.Append(@"</p>");

            _categoryLiteral.Text = sb.ToString();

            // Ingredient name

            if ((int)_dataRow["BrandID"] != 0)
            {
                _brandLink.NavigateUrl = ConfigurationManager.AppSettings["SiteUrl"] + "Ingredients/Browse/Brand/" + Convert.ToString(_dataRow["BrandID"]) + "-" + AppUtility.Utility.UrlEncode((string)_dataRow["BrandName"]) + "/";
                _brandLink.Text = (string)_dataRow["BrandName"];
            }
            else
            {// No brand--don't show the field

                _brandRow.Visible = false;
            }

            if ((int)_dataRow["CountryID"] != 0)
            {
                _countryLink.NavigateUrl = ConfigurationManager.AppSettings["SiteUrl"] + "Ingredients/Browse/Country/" + Convert.ToString(_dataRow["CountryID"]) + "-" + AppUtility.Utility.UrlEncode((string)_dataRow["CountryName"]) + "/";
                _countryLink.Text = (string)_dataRow["CountryName"];
            }
            else
            {// No country--don't show the field

                _countryRow.Visible = false;
            }

            _proofLink.NavigateUrl = ConfigurationManager.AppSettings["SiteUrl"] + "Ingredients/Browse/Proof/" + String.Format("{0:##0.##}", _dataRow["Proof"]) + "-" + String.Format("{0:##0.##}", _dataRow["Proof"]) + "/";
            _proofLink.Text = String.Format("{0:##0.##}", _dataRow["Proof"]) + " (" + String.Format("{0:##0.##%}", (decimal)_dataRow["Proof"] * (decimal).5 / 100) +")";

            // More information
            sb = new StringBuilder();
            bool moreInformationAvailable = false;

            if (_dataRow["IngredientURL"] != DBNull.Value && (string)_dataRow["IngredientURL"] != String.Empty)
            {// We have an ingredient URL--use it

                sb.Append(@"<a target=""_blank"" href=""");
                sb.Append(AppUtility.Utility.ExternalUrlEncode((string)_dataRow["IngredientURL"]));
                sb.Append(@""">");
                sb.Append((string)_dataRow["IngredientName"]);
                sb.Append(@"</a>");
                moreInformationAvailable = true;
            }

            if (_dataRow["BrandURL"] != DBNull.Value && (string)_dataRow["BrandURL"] != String.Empty)
            {// We have an brand URL--use it

                if (sb.Length > 0) sb.Append("<br>");
                sb.Append(@"<a target=""_blank"" href=""");
                sb.Append(AppUtility.Utility.ExternalUrlEncode((string)_dataRow["BrandURL"]));
                sb.Append(@""">");
                sb.Append((string)_dataRow["BrandName"]);
                sb.Append(@"</a>");
                moreInformationAvailable = true;
            }

            if (moreInformationAvailable)
                _moreInformationLiteral.Text = sb.ToString();
            else
            {// More information not available--hide the field

                _moreInformationRow.Visible = false;
            }

            // Flavors ##########################################################################
            DataTable dtFlavors = simpleData.FetchSP("GetIngredientFlavors", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) });

            StringBuilder flavors = new StringBuilder();
            foreach (DataRow row in dtFlavors.Rows)
            {
                flavors.Append(@"<a href=""");
                flavors.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                flavors.Append(@"Ingredients/Browse/Flavor/");
                flavors.Append(Convert.ToString(row["ListItem_pk"]));
                flavors.Append("-");
                flavors.Append(AppUtility.Utility.UrlEncode(Convert.ToString(row["Name"])));
                flavors.Append(@"/"">");
                flavors.Append(Convert.ToString(row["Name"]));
                flavors.Append(@"</a>, ");
            }

            // Chop off trailing comma
            if (flavors.Length > 0) flavors.Remove(flavors.Length - 2, 2);

            if (dtFlavors.Rows.Count > 0)
            {
                _flavorsLiteral.Text = flavors.ToString();
            }
            else
            {// No flavors--don't show the field

                _flavorsRow.Visible = false;
            }

            // Price #######################################################
            if (_dataRow["Price"] != DBNull.Value)
            {
                StringBuilder price = new StringBuilder();
                price.Append(String.Format("{0:$##0.##}", _dataRow["Price"]));
                price.Append(" / ");
                price.Append(String.Format("{0:##0.##}", _dataRow["PriceQuantity"]));
                price.Append(" ");
                price.Append((Decimal)_dataRow["PriceQuantity"] > 1 ? (string)_dataRow["UnitAbbreviationPlural"] : (string)_dataRow["UnitAbbreviation"]);
                _priceLiteral.Text = price.ToString();

                _countryLink.Text = (string)_dataRow["CountryName"];
            }
            else
            {// No price--don't show the field

                _priceRow.Visible = false;
            }

            // Ratings ##################################################
            _dtReviews = simpleData.FetchSP("GetIngredientRatings", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) });

            if (_dtReviews.Rows.Count > 0)
            {
                _repeaterRatings.DataSource = _dtReviews;
                _repeaterRatings.DataBind();
            }
            else _reviewDiv.Visible = false;

            // Description ##############################################
            if (((string)_dataRow["Description"]).Trim() != string.Empty)
                _descriptionLiteral.Text = WebUtility.ConvertDBDescriptionToHTML((string)_dataRow["Description"]);
            else
                _descriptionDiv.Visible = false;

            // Notes ####################################################
            if (((string)_dataRow["Notes"]).Trim() != string.Empty)
                _notesLiteral.Text = WebUtility.ConvertDBDescriptionToHTML((string)_dataRow["Notes"]);
            else
                _notesDiv.Visible = false;

            // Flavor Profile ########################################################
            DataTable dtFlavorProfile = new DataTable();
            dtFlavorProfile.Columns.Add("Body", typeof(decimal));
            dtFlavorProfile.Columns.Add("Sweet", typeof(decimal));
            dtFlavorProfile.Columns.Add("Acidity", typeof(decimal));
            dtFlavorProfile.Columns.Add("Fresh Fruit", typeof(decimal));
            dtFlavorProfile.Columns.Add("Dried Fruit", typeof(decimal));
            dtFlavorProfile.Columns.Add("Spice", typeof(decimal));
            dtFlavorProfile.Columns.Add("Heat", typeof(decimal));
            dtFlavorProfile.Columns.Add("Wood", typeof(decimal));

            dtFlavorProfile.Rows.Add(new object[] {_dataRow["Body"],
                                                   _dataRow["Sweet"],
                                                   _dataRow["Sour"],
                                                   _dataRow["FreshFruit"],
                                                   _dataRow["DriedFruit"],
                                                   _dataRow["Spice"],
                                                   _dataRow["Heat"],
                                                   _dataRow["Wood"]});

            _chart.BackgroundImageFileName = Server.MapPath("~") + @"\image\gradient_Ingredient.png";
            _chart.BackgroundImageStyle = Infragistics.UltraChart.Shared.Styles.ImageFitStyle.Centered;
            _chart.DeploymentScenario.ImageURL = ConfigurationManager.AppSettings["SiteUrl"] + _chart.DeploymentScenario.ImageURL;
            _chart.DataSource = dtFlavorProfile;
            _chart.DataBind();

            if (_dataRow["Body"] == DBNull.Value &&
                _dataRow["Sweet"] == DBNull.Value &&
                _dataRow["Sour"] == DBNull.Value &&
                _dataRow["FreshFruit"] == DBNull.Value &&
                _dataRow["DriedFruit"] == DBNull.Value &&
                _dataRow["Spice"] == DBNull.Value &&
                _dataRow["Heat"] == DBNull.Value &&
                _dataRow["Wood"] == DBNull.Value)
            {// No flavor profile information so hide the profile

                _profileDiv.Visible = false;
                _flavorProfileHeader.Visible = false;
                _chart.Visible = false;
            }

            DoSEO();

            // Do right column content targeted to this ingredient
            int flavor1ID = -1;
            int flavor2ID = -1;
            if (dtFlavors.Rows.Count > 0) flavor1ID = (int)dtFlavors.Rows[0]["ListItem_pk"];
            if (dtFlavors.Rows.Count > 1) flavor2ID = (int)dtFlavors.Rows[1]["ListItem_pk"];

            //this.RightColumn.Controls.Add(new LiteralControl(CharlesThompson.LiquorAndDrink.AppUI.Content.GetSimilarIngredientsHtml(Convert.ToInt32(Request.QueryString["pk"]),
            //                                                                                                                        (int)_dataRow["CategoryID"],
            //                                                                                                                        (int)_dataRow["BrandID"],
            //                                                                                                                        flavor1ID,
            //                                                                                                                        flavor2ID)));

            // Log this ingredient
            LogIngredient(Convert.ToInt32(Request.QueryString["pk"]));

            // Get ingredient links in right column
            DataTable dtIngredientLinks = simpleData.FetchSP("GetIngredientLinks", new SqlParameter[] { new SqlParameter("IngredientID", Request.QueryString["pk"]) });

            this.RightColumn.Controls.Add(new LiteralControl(CharlesThompson.LiquorAndDrink.AppUI.Content.GetLinkBoxHtml(dtIngredientLinks)));

            // Set page meta tags
            HtmlMeta meta = new HtmlMeta();
            meta.Name = "description";
            string metaContent = AppUI.Content.GetIngredientMetaDescription(_dataRow);
            meta.Content = metaContent;
            this.Header.Controls.Add(meta);

            // Set ShareThis header script
            this.Header.Controls.Add(new LiteralControl(CacheManager.GetItem(CacheManager.Cache_FileShareThisHeaderScript)));

            // Do share box button script
            StringBuilder shareScript = new StringBuilder();
            _shareDiv.Controls.Add(new LiteralControl(AppUI.Content.GetShareButtonScript(((string)_dataRow["IngredientName"]).Replace("'", ""),
                                                                                           metaContent,
                                                                                           ConfigurationManager.AppSettings["SiteUrl"] + "Ingredients/" + Convert.ToString(_dataRow["Ingredient_pk"]) + "-" + Utility.UrlEncode((string)_dataRow["IngredientName"]))));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["desc"] != null)
            {// This is not a generic search--it is a browse filter--figure out page title

                if (Request.QueryString["filter"] == "search")
                {// Doing a one parameter search to impersonate a browse

                    if (Request.QueryString["cat"] != null)
                        this.Title = "Browse Liquor/Mixers - By Category - " + AppUtility.Utility.UrlDecode(Request.QueryString["desc"]);

                    else if (Request.QueryString["flavor"] != null)
                        this.Title = "Browse Liquor/Mixers - By Flavor - " + AppUtility.Utility.UrlDecode(Request.QueryString["desc"]);
                }
                else
                {// Doing an actual browse

                    if (Request.QueryString["filter"] == "brand")
                        this.Title = "Browse Liquor/Mixers - By Brand - " + AppUtility.Utility.UrlDecode(Request.QueryString["desc"]);

                    else if (Request.QueryString["filter"] == "country")
                        this.Title = "Browse Liquor/Mixers - By Country of Origin - " + AppUtility.Utility.UrlDecode(Request.QueryString["desc"]);
                }
            }
            else
            {// These don't use a desc

                if (Request.QueryString["filter"] == "proof")
                {
                    if (Request.QueryString["value2"] == "0")
                        this.Title = "Browse Liquor/Mixers - By Alcohol Proof - No Alcohol";
                    else
                        this.Title = "Browse Liquor/Mixers - By Alcohol Proof - " + Request.QueryString["value1"] + " to " + Request.QueryString["value2"] + " Proof";
                }

                else if (Request.QueryString["filter"] == "name")
                    this.Title = "Browse Liquor/Mixers - By Name";

                else
                {// Must be a genuine search

                    this.Title = "Search Liquor/Mixers - Results";
                }
            }

            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            SqlParameter[] sqlParameters = new SqlParameter[16];

            // First, fill out blank parameters.  If a parameter is going to be used, it will be filled out below.
            // SqlParemeterCollection can't have nulls in it.
            sqlParameters[0] = new SqlParameter("Name", null);
            sqlParameters[1] = new SqlParameter("DescriptionAndNotes", null);
            sqlParameters[2] = new SqlParameter("CategoryID", null);
            sqlParameters[3] = new SqlParameter("FlavorID", null);
            sqlParameters[4] = new SqlParameter("CountryID", null);
            sqlParameters[5] = new SqlParameter("BrandID", null);
            sqlParameters[6] = new SqlParameter("AlcoholProof1", null);
            sqlParameters[7] = new SqlParameter("AlcoholProof2", null);
            sqlParameters[8] = new SqlParameter("LADRating1", null);
            sqlParameters[9] = new SqlParameter("LADRating2", null);
            sqlParameters[10] = new SqlParameter("COMRating1", null);
            sqlParameters[11] = new SqlParameter("COMRating2", null);
            sqlParameters[12] = new SqlParameter("PageNum", 1);
            sqlParameters[13] = new SqlParameter("PageSize", 5000);

            if (Request.QueryString["name"] != null)
            {
                sqlParameters[0] = new SqlParameter("Name", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 0, 0, "Name", DataRowVersion.Current, Request.QueryString["name"]);
            }

            if (Request.QueryString["dn"] != null)
            {
                sqlParameters[1] = new SqlParameter("DescriptionAndNotes", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 0, 0, "DescriptionAndNotes", DataRowVersion.Current, Request.QueryString["dn"]);
            }

            if (Request.QueryString["cat"] != null)
            {
            //                DataTable dtCategory = simpleData.FetchSP("GetListItemsTreeAllChildren",
            //                                                           new SqlParameter[] { new SqlParameter("ListItemID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "ListItemID", DataRowVersion.Current, Request.QueryString["cat"]) });

                sqlParameters[2] = new SqlParameter("CategoryID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "CategoryID", DataRowVersion.Current, Request.QueryString["cat"]);
            }

            if (Request.QueryString["flavor"] != null)
            {
                sqlParameters[3] = new SqlParameter("FlavorID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "FlavorID", DataRowVersion.Current, Request.QueryString["flavor"]);
            }

            if (Request.QueryString["country"] != null)
            {
                sqlParameters[4] = new SqlParameter("CountryID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "CountryID", DataRowVersion.Current, Request.QueryString["country"]);
            }

            if (Request.QueryString["brand"] != null)
            {
                sqlParameters[5] = new SqlParameter("BrandID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "BrandID", DataRowVersion.Current, Request.QueryString["brand"]);
            }

            if (Request.QueryString["proof1"] != null)
            {
                sqlParameters[6] = new SqlParameter("AlcoholProof1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AlcoholProof1", DataRowVersion.Current, Request.QueryString["proof1"]);
            }

            if (Request.QueryString["proof2"] != null)
            {
                sqlParameters[7] = new SqlParameter("AlcoholProof2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AlcoholProof2", DataRowVersion.Current, Request.QueryString["proof2"]);
            }

            if (Request.QueryString["ladrating1"] != null)
            {
                sqlParameters[8] = new SqlParameter("LADRating1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "LADRating1", DataRowVersion.Current, Request.QueryString["ladrating1"]);
            }

            if (Request.QueryString["ladrating2"] != null)
            {
                sqlParameters[9] = new SqlParameter("LADRating2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "LADRating2", DataRowVersion.Current, Request.QueryString["ladrating2"]);
            }

            if (Request.QueryString["comrating1"] != null)
            {
                sqlParameters[10] = new SqlParameter("COMRating1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "COMRating1", DataRowVersion.Current, Request.QueryString["comrating1"]);
            }

            if (Request.QueryString["comrating2"] != null)
            {
                sqlParameters[11] = new SqlParameter("COMRating2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "COMRating2", DataRowVersion.Current, Request.QueryString["comrating2"]);
            }

            // Add output parameters
            sqlParameters[14] = new SqlParameter("TotalPages", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalPages", DataRowVersion.Current, 0);
            sqlParameters[15] = new SqlParameter("TotalRows", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalRows", DataRowVersion.Current, 0);

            if (Request.QueryString["filter"] == "search")
            {// Full search requested--crank the search stored procedure

                _repeaterIngredient.DataSource = simpleData.FetchSP("SearchIngredients", sqlParameters);
            }
            else
            {// Browse requested--filter on one column (hopefully from the cache)

                DataView dataView;

                switch (Request.QueryString["filter"])
                {
                    case "name":
                    // Filter by name--just show all

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredients,
                                                       "GetIngredients",
                                                       "Ingredient_pk",
                                                        null);

                        dataView.RowFilter = String.Empty;
                        _repeaterIngredient.DataSource = dataView;
                        break;

                    case "cat":
                    // Filter by category--this is actually done as a one parameter search above
                        break;

                    case "country":
                    // Filter by country

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredients,
                                                       "GetIngredients",
                                                       "Ingredient_pk",
                                                        null);

                        dataView.RowFilter = "CountryID = " + Request.QueryString["value"];
                        _repeaterIngredient.DataSource = dataView;
                        break;

                    case "brand":
                    // Filter by brand

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredients,
                                                       "GetIngredients",
                                                       "Ingredient_pk",
                                                        null);

                        dataView.RowFilter = "BrandID = " + Request.QueryString["value"];
                        _repeaterIngredient.DataSource = dataView;
                        break;

                    case "proof":
                    // Filter by alcohol proof

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredients,
                                                       "GetIngredients",
                                                       "Ingredient_pk",
                                                        null);

                        dataView.RowFilter = "Proof >= " + Request.QueryString["value1"] + " AND Proof <= " + Request.QueryString["value2"];
                        _repeaterIngredient.DataSource = dataView;
                        break;

                    case "inusebydrinks":
                    // Filter by ingredients in use in drinks

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetIngredientsInUseByDrinks,
                                                       "GetIngredientsInUseByDrinks",
                                                       "Ingredient_pk",
                                                        null);

                        _repeaterDrink.DataSource = dataView;
                        break;
                }
            }

            if (Request.QueryString["filter"] == "inusebydrinks")
            {// Browse drinks by ingredient

                // Light up the ingredient/brand to drink repeater
                _repeaterDrink.DataBind();
            }
            else
            {// Browse ingredients by filter passed in

                // Light up the ingredients to ingredient repeater
                _repeaterIngredient.DataBind();
            }
        }
            public static void GetData(string cacheItemKey, 
                                       string storedProcedure, 
                                       string primaryKeyColumn, 
                                       SqlParameter[] sqlParameters)
            {
                // Since each request that saw the cache originally null
                // will eventually get here, need to ensure that it
                // has not already been retrieved by another request

                //if (System.Web.HttpRuntime.Cache[cacheItemKey] == null)
                if (DotNetNuke.Common.Utilities.DataCache.GetCache(cacheItemKey) == null)
                {// Cache is still empty--fill it from the database

                    SimpleData simpleData = new SimpleData();
                    ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
                    simpleData.ConnectionString = connectionStringSettings.ConnectionString;

                    DataTable dataTable = simpleData.FetchSP(storedProcedure, sqlParameters);

                    if (primaryKeyColumn.Contains(","))
                    {// Dual keys

                        string[] pks = primaryKeyColumn.Split(',');
                        dataTable.PrimaryKey = new System.Data.DataColumn[] { dataTable.Columns[pks[0]], dataTable.Columns[pks[1]] };
                    }
                    else
                    {// Single key

                        dataTable.PrimaryKey = new System.Data.DataColumn[] { dataTable.Columns[primaryKeyColumn] };
                    }

                    DotNetNuke.Common.Utilities.DataCache.SetCache(cacheItemKey,
                                                                   dataTable,
                                                                   DateTime.UtcNow.AddMinutes(Convert.ToDouble(ConfigurationManager.AppSettings["CacheTimeout"])));
                }
            }
Exemple #27
0
        public static DataTable GetSimilarDrinksDataTable(int drinkID, int structureID, int glassID)
        {
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            DataTable dtSimilar = simpleData.FetchSP("GetDrinkSimilar", new SqlParameter[] { new SqlParameter("DrinkID", drinkID),
                                                                                             new SqlParameter("StructureID", structureID),
                                                                                             new SqlParameter("GlassID", glassID) });
            return dtSimilar;
        }
Exemple #28
0
        public static string GetSimilarDrinksHtmlOld(int drinkID, int categoryID, int familyID, int structureID, int flavor1ID, int flavor2ID, int flavor3ID, int glassID)
        {
            StringBuilder sb = new StringBuilder();
            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            DataTable dtSimilar = simpleData.FetchSP("GetDrinkSimilar", new SqlParameter[] { new SqlParameter("DrinkID", drinkID),
                                                                                             new SqlParameter("CategoryID", categoryID),
                                                                                             new SqlParameter("FamilyID", familyID),
                                                                                             new SqlParameter("StructureID", structureID),
                                                                                             new SqlParameter("Flavor1ID", flavor1ID),
                                                                                             new SqlParameter("Flavor2ID", flavor2ID),
                                                                                             new SqlParameter("Flavor3ID", flavor3ID),
                                                                                             new SqlParameter("GlassID", glassID) });
            DataRow[] matchedRows;

            // Drinks in the same category (using structure under the covers)
            matchedRows = dtSimilar.Select("SimilarType = 'structure'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Drinks in the same category</h4>");
                sb.Append(@"<ul class=""unstyled"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""");
                    sb.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    sb.Append(@"drinks/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.Utility.UrlEncode((string)row["Description"]));
                    sb.Append(@""">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            // Drinks with the same flavors
            matchedRows = dtSimilar.Select("SimilarType = 'flavor'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Drinks with similar flavors</h4>");
                sb.Append(@"<ul class=""unstyled"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""");
                    sb.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    sb.Append(@"drinks/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.Utility.UrlEncode((string)row["Description"]));
                    sb.Append(@""">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            // Drinks with the same glass
            matchedRows = dtSimilar.Select("SimilarType = 'glass'", "Description ASC");
            if (matchedRows.Length > 0)
            {
                sb.Append("<h4>Drinks served in the same glass</h4>");
                sb.Append(@"<ul class=""unstyled"">");

                foreach (DataRow row in matchedRows)
                {
                    sb.Append(@"<li>");
                    sb.Append(@"<a href=""");
                    sb.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    sb.Append(@"drinks/");
                    sb.Append(Convert.ToString(row["PK"]));
                    sb.Append("-");
                    sb.Append(AppUtility.Utility.UrlEncode((string)row["Description"]));
                    sb.Append(@""">");
                    sb.Append((string)row["Description"]);
                    sb.Append(@"</a></li>");
                }

                sb.Append(@"</ul>");
            }

            return sb.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int rowCount = 0;

            // Log page
            AppUtility.Utility.LogPage();

            if (Request.QueryString["desc"] != null)
            {// This is not a generic search--it is a browse filter--figure out page title

                if (Request.QueryString["filter"] == "search")
                {// Doing a one parameter search to impersonate a browse

                    if (Request.QueryString["tag"] != null)
                        ModuleConfiguration.ModuleTitle = "Drinks - Tag - " + WebUtility.TitleCase(CharlesThompson.LiquorAndDrink.AppUtility.Utility.UrlDecode(Request.QueryString["desc"]));

                    else if (Request.QueryString["ingred"] != null)
                    {
                        ModuleConfiguration.ModuleTitle = WebUtility.TitleCase(Utility.UrlDecode(Request.QueryString["desc"])) + " Drinks";
                        _metaDescription = "A delicious list of drinks that use " +  WebUtility.TitleCase(Utility.UrlDecode(Request.QueryString["desc"])) + ".";
                    }
                    else if (Request.QueryString["brand"] != null)
                        ModuleConfiguration.ModuleTitle = "Drinks - Ingredient Brand - " + WebUtility.TitleCase(Utility.UrlDecode(Request.QueryString["desc"]));

                    else if (Request.QueryString["flavor"] != null)
                        ModuleConfiguration.ModuleTitle = "Drinks - Flavor - " + WebUtility.TitleCase(Utility.UrlDecode(Request.QueryString["desc"]));
                }
                else
                {// Doing an actual browse

                    if (Request.QueryString["filter"] == "cat")
                        ModuleConfiguration.ModuleTitle = "Drinks - Category - " + WebUtility.TitleCase(Utility.UrlDecode(Request.QueryString["desc"]));

                    else if (Request.QueryString["filter"] == "family")
                        ModuleConfiguration.ModuleTitle = "Drinks - Family - " + WebUtility.TitleCase(Utility.UrlDecode(Request.QueryString["desc"]));

                    else if (Request.QueryString["filter"] == "struct")
                        ModuleConfiguration.ModuleTitle = "Drinks - Structure - " + WebUtility.TitleCase(Utility.UrlDecode(Request.QueryString["desc"]));

                    else if (Request.QueryString["filter"] == "glass")
                        ModuleConfiguration.ModuleTitle = "Drinks - Glass - " + WebUtility.TitleCase(Utility.UrlDecode(Request.QueryString["desc"]));

                    else if (Request.QueryString["filter"] == "temp")
                        ModuleConfiguration.ModuleTitle = "Drinks - Temperature - " + WebUtility.TitleCase(Utility.UrlDecode(Request.QueryString["desc"]));
                }
            }
            else
            {// These don't use a desc

                if (Request.QueryString["filter"] == "proof")
                {
                    if (Request.QueryString["value2"] == "0")
                        ModuleConfiguration.ModuleTitle = "Drinks - Alcohol Proof - No Alcohol";
                    else
                        ModuleConfiguration.ModuleTitle = "Drinks - Alcohol Proof - " + Request.QueryString["value1"] + " to " + Request.QueryString["value2"] + " Proof";
                }

                else if (Request.QueryString["filter"] == "strength")
                {
                    switch (Request.QueryString["value2"])
                    {
                        case "0": ModuleConfiguration.ModuleTitle = "Drinks - Alcohol Strength - No Alcohol"; break;
                        case "0.5": ModuleConfiguration.ModuleTitle = "Drinks - Alcohol Strength - Weak"; break;
                        case "1.5": ModuleConfiguration.ModuleTitle = "Drinks - Alcohol Strength - Single"; break;
                        case "2.5": ModuleConfiguration.ModuleTitle = "Drinks - Alcohol Strength - Double"; break;
                        case "3.5": ModuleConfiguration.ModuleTitle = "Drinks - Alcohol Strength - Triple"; break;
                        case "4.5": ModuleConfiguration.ModuleTitle = "Drinks - Alcohol Strength - Quadruple"; break;
                    }
                }

                else if (Request.QueryString["filter"] == "name")
                    ModuleConfiguration.ModuleTitle = "Drinks - By Name";

                else
                {// Must be a genuine search

                    ModuleConfiguration.ModuleTitle = "Drinks - Search Results";
                }
            }

            SqlParameter[] sqlParameters = new SqlParameter[19];

            // First, fill out blank parameters.  If a parameter is going to be used, it will be filled out below.
            // SqlParemeterCollection can't have nulls in it.
            sqlParameters[0] = new SqlParameter("Name", null);
            sqlParameters[1] = new SqlParameter("InstructionsAndNotes", null);
            sqlParameters[2] = new SqlParameter("CategoryID", null);
            sqlParameters[3] = new SqlParameter("FamilyID", null);
            sqlParameters[4] = new SqlParameter("StructureID", null);
            sqlParameters[5] = new SqlParameter("AttributeID", null);
            sqlParameters[6] = new SqlParameter("IngredientID", null);
            sqlParameters[7] = new SqlParameter("IngredientBrandID", null);
            sqlParameters[8] = new SqlParameter("AlcoholProof1", null);
            sqlParameters[9] = new SqlParameter("AlcoholProof2", null);
            sqlParameters[10] = new SqlParameter("AlcoholStrength1", null);
            sqlParameters[11] = new SqlParameter("AlcoholStrength2", null);
            sqlParameters[12] = new SqlParameter("FlavorID", null);
            sqlParameters[13] = new SqlParameter("GlassID", null);
            sqlParameters[14] = new SqlParameter("TempID", null);
            sqlParameters[15] = new SqlParameter("PageNum", 1);
            sqlParameters[16] = new SqlParameter("PageSize", 5000);

            if (Request.QueryString["name"] != null)
            {
                sqlParameters[0] = new SqlParameter("Name", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 0, 0, "Name", DataRowVersion.Current, Request.QueryString["name"]);
            }

            if (Request.QueryString["in"] != null)
            {
                sqlParameters[1] = new SqlParameter("InstructionsAndNotes", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 0, 0, "InstructionsAndNotes", DataRowVersion.Current, Request.QueryString["in"]);
            }

            // Retired...category now really hits the structures
            //if (Request.QueryString["cat"] != null)
            //{
            //    sqlParameters[2] = new SqlParameter("CategoryID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "CategoryID", DataRowVersion.Current, Request.QueryString["cat"]);
            //}

            if (Request.QueryString["fam"] != null)
            {
                sqlParameters[3] = new SqlParameter("FamilyID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "FamilyID", DataRowVersion.Current, Request.QueryString["fam"]);
            }

            // Category is now driven by structures
            if (Request.QueryString["cat"] != null)
            {
                sqlParameters[4] = new SqlParameter("StructureID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "StructureID", DataRowVersion.Current, Request.QueryString["cat"]);
            }

            // Attributes now called Tags
            if (Request.QueryString["tag"] != null)
            {
                sqlParameters[5] = new SqlParameter("AttributeID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AttributeID", DataRowVersion.Current, Request.QueryString["tag"]);
            }

            if (Request.QueryString["ingred"] != null)
            {
                sqlParameters[6] = new SqlParameter("IngredientID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "PrincipalIngredientID", DataRowVersion.Current, Request.QueryString["ingred"]);
            }

            if (Request.QueryString["brand"] != null)
            {
                sqlParameters[7] = new SqlParameter("IngredientBrandID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "PrincipalIngredientBrandID", DataRowVersion.Current, Request.QueryString["brand"]);
            }

            if (Request.QueryString["proof1"] != null)
            {
                sqlParameters[8] = new SqlParameter("AlcoholProof1", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AlcoholProof1", DataRowVersion.Current, Request.QueryString["proof1"]);
            }

            if (Request.QueryString["proof2"] != null)
            {
                sqlParameters[9] = new SqlParameter("AlcoholProof2", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "AlcoholProof2", DataRowVersion.Current, Request.QueryString["proof2"]);
            }

            if (Request.QueryString["strength1"] != null)
            {
                sqlParameters[10] = new SqlParameter("AlcoholStrength1", SqlDbType.Decimal, 0, ParameterDirection.Input, true, 5, 1, "AlcoholStrength1", DataRowVersion.Current, Request.QueryString["strength1"]);
            }

            if (Request.QueryString["strength2"] != null)
            {
                sqlParameters[11] = new SqlParameter("AlcoholStrength2", SqlDbType.Decimal, 0, ParameterDirection.Input, true, 5, 1, "AlcoholStrength2", DataRowVersion.Current, Request.QueryString["strength2"]);
            }

            if (Request.QueryString["flavor"] != null)
            {
                sqlParameters[12] = new SqlParameter("FlavorID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "FlavorID", DataRowVersion.Current, Request.QueryString["flavor"]);
            }

            if (Request.QueryString["glass"] != null)
            {
                sqlParameters[13] = new SqlParameter("GlassID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "GlassID", DataRowVersion.Current, Request.QueryString["glass"]);
            }

            if (Request.QueryString["temp"] != null)
            {
                sqlParameters[14] = new SqlParameter("TempID", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, "TempID", DataRowVersion.Current, Request.QueryString["temp"]);
            }

            // Add output parameters
            sqlParameters[17] = new SqlParameter("TotalPages", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalPages", DataRowVersion.Current, 0);
            sqlParameters[18] = new SqlParameter("TotalRows", SqlDbType.Int, 0, ParameterDirection.Output, true, 0, 0, "TotalRows", DataRowVersion.Current, 0);

            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            if (Request.QueryString["filter"] == "search")
            {// Full search requested--crank the search stored procedure

                _repeater.DataSource = simpleData.FetchSP("SearchDrinks", sqlParameters);
                rowCount = ((DataTable)_repeater.DataSource).Rows.Count;
            }
            else
            {// Browse requested--filter on one column (hopefully from the cache)

                DataView dataView = null;

                switch (Request.QueryString["filter"])
                {
                    case "name":
                    // Filter by name (just show all)

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = String.Empty;
                        _repeater.DataSource = dataView;

                        break;

                    case "cat":
                    // Filter by category

                        // Category now driven by the structure list
                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "StructureID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        //dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                        //                               "GetDrinks",
                        //                               "Drink_pk",
                        //                                null);

                        //dataView.RowFilter = "CategoryID = " + Request.QueryString["value"];
                        //_repeater.DataSource = dataView;

                        break;

                    case "family":
                    // Filter by family

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "FamilyID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        break;

                    case "struct":
                    // Filter by structure

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "StructureID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        break;

                    case "proof":
                    // Filter by alcohol proof

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "FinalProof >= " + Request.QueryString["value1"] + " AND FinalProof <= " + Request.QueryString["value2"];
                        _repeater.DataSource = dataView;

                        break;

                    case "strength":
                    // Filter by alcohol strength

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "Strength >= " + Request.QueryString["value1"] + " AND Strength <= " + Request.QueryString["value2"];
                        _repeater.DataSource = dataView;

                        break;

                    case "glass":
                    // Filter by glass

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "GlassID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        break;

                    case "temp":
                    // Filter by temperature

                        dataView = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                       "GetDrinks",
                                                       "Drink_pk",
                                                        null);

                        dataView.RowFilter = "TempID = " + Request.QueryString["value"];
                        _repeater.DataSource = dataView;

                        break;
                }

                rowCount = dataView.Count;
             }

            if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "family" && Request.QueryString["value"] != null)
            {// A browse request was made for a list of drinks that belong to a particular family.  We do not do
             // this kind of browsing anymore so throw a 404 instead.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "glass")
            {// A browse request was made for a list of drinks by glass.  We do not do
             // this kind of browsing anymore so throw a 404 instead.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "proof")
            {// A browse request was made for a list of drinks that are in a certain proof range.  We do not do
             // this kind of browsing anymore so throw a 404 instead.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "search" && Request.QueryString["brand"] != null)
            {// A browse request was made for a list of drinks that use a particular ingredient brand.  We do not do
             // this kind of browsing anymore so throw a 404 instead.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "search" && Request.QueryString["flavor"] != null)
            {// A browse request was made for a list of drinks that have a particular flavor.  We do not do
             // this kind of browsing anymore so throw a 404 instead.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "strength")
            {// A browse request was made for a list of drinks that are a certain strength.  We do not do
             // this kind of browsing anymore so throw a 404 instead.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "struct" && Request.QueryString["value"] != null)
            {// A browse request was made for a list of drinks that belong to a particular structure.  We do not do
             // this kind of browsing anymore so throw a 404 instead.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "temp")
            {// A browse request was made for a list of drinks that are a certain temperature.  We do not do
             // this kind of browsing anymore so throw a 404 instead.

                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (rowCount == 0 && Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "cat" && Request.QueryString["value"] != null)
            {// A browse request was made for a list of drinks that belong to a particular category.  We have consolidated
             // drink categories.  If the request is for one of the categories that no longer exists, the
             // page would just show a blank list.  This is not good for SEO so we need to throw a 404 instead.
             // We know that the drink category requested does not exist because we only show in use categories
             // in the browse list.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (rowCount == 0 && Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "search" && Request.QueryString["tag"] != null)
            {// A browse request was made for a list of drinks that belong to a particular tag.  We have consolidated
             // drink tags.  If the request is for one of the tags that no longer exists, the
             // page would just show a blank list.  This is not good for SEO so we need to throw a 404 instead.
             // We know that the drink tag requested does not exist because we only show in use tags
             // in the browse list.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            if (rowCount == 0 && Request.QueryString["type"] == "browse" && Request.QueryString["filter"] == "search" && Request.QueryString["ingred"] != null)
            {// A browse request was made for a list of drinks that use a particular ingredient.  We have cleaned
             // out a long of ingredients.  If the request is for one of the ingredients that no longer exists, the
             // page would just show a blank list.  This is not good for SEO so we need to throw a 404 instead.
             // We know that the drink ingredient requested does not exist because we only show in use ingredients
             // in the browse list.

                    HttpContext.Current.Response.StatusCode = 404;
                    HttpContext.Current.Response.End();
            }

            _repeater.DataBind();

            // Widgets
            // Send a message to any widget modules that are listening.
            ModuleCommunicationEventArgs args = new ModuleCommunicationEventArgs();
            args.Sender = "Headlines";
            args.Target = "Widget";
            args.Value = new List<string>() {AppUtility.AdRotator.GetAdsenseCode("adsense.list.200x90.linkunit")};

            if (ModuleCommunication != null)
            {
                ModuleCommunication(this, args);
            }

            DoSEO();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // The CommentsPlus module from SunBlogNuke should take care of this
            //// See if we need to set the Disqus comments into development mode
            //if (ConfigurationManager.AppSettings["disqus_developer"] == "1")
            //{// Yes, set to development mode so the comments will work under localhost

            //    Page.ClientScript.RegisterStartupScript(this.GetType(), "Disqus_Developer", @"var disqus_developer = 1; // developer mode is on;", true);
            //}

            // Log page
            AppUtility.Utility.LogPage();

            SimpleData simpleData = new SimpleData();
            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["db"];
            simpleData.ConnectionString = connectionStringSettings.ConnectionString;

            // Get drink data from cache
            DataView dv = CacheManager.GetItem(CacheManager.Cache_GetDrinks,
                                                    "GetDrinks",
                                                    "Drink_pk",
                                                     null);

            _drDrink = dv.Table.Rows.Find(Convert.ToInt32(Request.QueryString["pk"]));

            if (_drDrink == null)
            {// We did not find the drink using it's pk--it has probably been culled as a low quality page--send a 404

                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.StatusCode = 404;
                HttpContext.Current.Response.End();

                //HttpContext.Current.Response.Clear();
                //HttpContext.Current.Response.StatusCode = 404;
                //HttpContext.Current.Items.Remove("ClientDependencyLoader");
                //Server.Transfer("liquoranddrink_dotnetnuke6/http-404", false);
                //DotNetNuke.Common.Globals.NavigateURL(136);
            }
            else
            {// Found the drink--continue

                string calledUrl = ConfigurationManager.AppSettings["SiteDomain"] + HttpContext.Current.Request.RawUrl;
                string correctUrl = CharlesThompson.LiquorAndDrink.AppUtility.Drink.GetUrl((int)_drDrink["Drink_pk"], (string)_drDrink["Slug"]);

                if (calledUrl != correctUrl)
                {// The url used to get to this page is different than the correct url for this page.  This is usually because the slug is different (the text after
                 // the pk).  The slug may have changed for SEO reasons.  Anyway, we want Google (and anyone else) to use the current, correct url for this page so
                 // we need to 301 to the correct url.

                    Response.RedirectPermanent(correctUrl, true);
                }

                // Thumbnail microdata
                if (CharlesThompson.LiquorAndDrink.AppUtility.Drink.HasThumbnailFilename((int)_drDrink["Drink_pk"]))
                {// We have a thumbnail image for this drink--stick it in the microdata

                    _thumbnailImageMetaLiteral.Text = @"<meta itemprop=""thumbnailUrl"" content=""" +
                                                      CharlesThompson.LiquorAndDrink.AppUtility.Drink.GetThumbnailFilenameUrl((int)_drDrink["Drink_pk"]) +
                                                      @""" />";
                }

                // Do page title
                Control h1 = this.FindControl("_H1");

                if (h1 != null)
                {// H1 heading found--set it to the page title

                    ((HtmlGenericControl)h1).InnerText = (string)_drDrink["Keywords"];
                }

                _prepTimeLiteral.Text = CharlesThompson.LiquorAndDrink.AppUtility.Drink.GetPrepTimeAsMicrodataTag((int)_drDrink["Drink_pk"]) + CharlesThompson.LiquorAndDrink.AppUtility.Drink.GetPrepTimeAsString((int)_drDrink["Drink_pk"]);

                _servingsLiteral.Text = ((Decimal)_drDrink["Servings"]).ToString("###.#");

                // Category (structure under the covers)
                _structureLink.Text = (string)_drDrink["StructureName"];
                if (_structureLink.Text.Trim().Length > 0) _structureLink.NavigateUrl = ConfigurationManager.AppSettings["SiteUrl"] + @"drinks/browse/category/" + Convert.ToString(_drDrink["StructureID"]) + "-" + CharlesThompson.LiquorAndDrink.AppUtility.Utility.UrlEncode((string)_drDrink["StructureName"]);

                // Tags are down below

                _proofLiteral.Text = ((Decimal)_drDrink["FinalProof"]).ToString("###.#");

                _strengthLiteral.Text = ((Decimal)_drDrink["Strength"]).ToString("###.#");

                // Flavors are down below

                _glassLiteral.Text = (string)_drDrink["GlassName"];

                _tempLiteral.Text = (string)_drDrink["TempName"];

                //// Sources ###############################################
                //// Get source data from cache
                //DataView sourceView = CacheManager.GetItem(CacheManager.Cache_GetDrinkSourcesAll,
                //                                           "GetDrinkSourcesAll",
                //                                           "DrinkID,SourceID",
                //                                           null);
                //DataRow[] sourceRows = sourceView.Table.Select("DrinkID = " + Request.QueryString["pk"], "SourceName ASC");
                //StringBuilder sourceList = new StringBuilder();

                //foreach (DataRow row in sourceRows)
                //{
                //    if ((int)row["SourceID"] != 1)  // Hide if Charles is the source
                //    {
                //        sourceView.RowFilter = "Source_pk = " + Convert.ToString(row["SourceID"]);

                //        sourceList.Append(@"<a href=""");
                //        sourceList.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                //        sourceList.Append(@"/resources/");
                //        sourceList.Append(Convert.ToString(row["SourceID"]));
                //        sourceList.Append("-");
                //        sourceList.Append(CharlesThompson.LiquorAndDrink.AppUtility.Utility.UrlEncode(Convert.ToString(sourceView[0]["SourceName"])));
                //        sourceList.Append(@""">");
                //        sourceList.Append(Convert.ToString(sourceView[0]["SourceName"]));
                //        sourceList.Append(@"</a>, ");
                //    }
                //}

                //// Chop off trailing comma
                //if (sourceList.Length > 0) sourceList.Remove(sourceList.Length - 2, 2);

                //if (sourceList.Length > 0) _sourceLiteral.Text = sourceList.ToString();
                //else _sourceRow.Visible = false;                                            // no sources so hide this field

                // Instructions #############################################
                if (((string)_drDrink["Instructions"]).Trim() != string.Empty && ! ((string)_drDrink["Instructions"]).Contains("<p>"))
                {// Description is present and does not have any html in it.  This is an older description that needs to have
                 // html formatting added

                    _instructionsLiteral.Text = Utility.ReplaceTokens(WebUtility.ConvertDBDescriptionToHTML((string)_drDrink["Instructions"]));
                }
                else if (((string)_drDrink["Instructions"]).Trim() != string.Empty && ((string)_drDrink["Instructions"]).Contains("<p>"))
                {// Description is present and has html in it.  This is a newer description where we store the html in it.

                    _instructionsLiteral.Text = Utility.ReplaceTokens((string)_drDrink["Instructions"]);
                }
                //_instructionsLiteral.Text = WebUtility.ConvertDBDescriptionToHTML((string)_drDrink["Instructions"]);

                // Ratings ##################################################
                // Get rating data from cache
                DataView ratingsView = CacheManager.GetItem(CacheManager.Cache_GetDrinkRatingsAll,
                                                           "GetDrinkRatingsAll",
                                                           "Rating_pk",
                                                           null);

                ratingsView.RowFilter = "DrinkID = " + Request.QueryString["pk"];
                ratingsView.Sort = "SourceID ASC";

                if (ratingsView.Count > 0)
                {
                    _repeaterRatings.DataSource = ratingsView;
                    _repeaterRatings.DataBind();
                }
                else _reviewDiv.Visible = false;

                // Notes
                string notes = CharlesThompson.LiquorAndDrink.AppUtility.Drink.GetNotesWithAdsAndImages((int)_drDrink["Drink_pk"]);

                if (notes.Length > 0) _notesDiv.InnerHtml = notes;
                else _notesDiv.Visible = false;

                // Get ingredients
                // Get ingredient data from cache
                _ingredientsView = CacheManager.GetItem(CacheManager.Cache_GetDrinkIngredientsAll,
                                                               "GetDrinkIngredientsAll",
                                                               "Drink_pk,Ingredient_pk",
                                                                null);

                _ingredientsView.RowFilter = "Drink_pk = " + Request.QueryString["pk"];
                _ingredientsView.Sort = "Sort ASC";

                _ingredients.DataSource = _ingredientsView;
                _ingredients.DataBind();

                // Tags (attributes under the covers) ################################################
                // Get tag data from cache
                DataView tagsView = CacheManager.GetItem(CacheManager.Cache_GetDrinkTagsAll,
                                                           "GetDrinkTagsAll",
                                                           "Drink_pk,ListItem_pk",
                                                           null);

                tagsView.RowFilter = "Drink_pk = " + Request.QueryString["pk"];
                tagsView.Sort = "TagName ASC";

                StringBuilder tags = new StringBuilder();
                foreach (DataRowView row in tagsView)
                {
                    tags.Append(@"<a href=""");
                    tags.Append(ConfigurationManager.AppSettings["SiteUrl"]);
                    tags.Append(@"drinks/browse/tag/");
                    tags.Append(Convert.ToString(row["ListItem_pk"]));
                    tags.Append("-");
                    tags.Append(CharlesThompson.LiquorAndDrink.AppUtility.Utility.UrlEncode(Convert.ToString(row["TagName"])));
                    tags.Append(@""">");
                    tags.Append(Convert.ToString(row["TagName"]));
                    tags.Append(@"</a>, ");
                }

                // Chop off trailing comma
                if (tags.Length > 0) tags.Remove(tags.Length - 2, 2);

                _tagsLiteral.Text = tags.ToString();

                // ##############################
                // Do right column widgets content for this drink
                // ##############################
                // Get drink links in right column
                DataTable dtDrinkLinks = simpleData.FetchSP("GetDrinkLinks", new SqlParameter[] { new SqlParameter("DrinkID", Request.QueryString["pk"]) });

                // Send a message to any widget modules that are listening.  This message contains data about the drink being shown on the page.
                ModuleCommunicationEventArgs args = new ModuleCommunicationEventArgs();
                args.Sender = "Drink";
                args.Target = "WidgetSimilarDrinks";
                args.Value = new List<object>() {Convert.ToInt32(Request.QueryString["pk"]),
                                                    _drDrink["StructureID"],
                                                    _drDrink["GlassID"],
                                                    dtDrinkLinks};

                if (ModuleCommunication != null)
                {
                    ModuleCommunication(this, args);
                }

                // Log this drink
                // No don't do this.  We are trying not to hit the db for performance reasons and the LogPage table gives us this info anyway
                //LogDrink(Convert.ToInt32(Request.QueryString["pk"]));

                // Microdata
                _microdataUrlMeta.Attributes.Add("content", CharlesThompson.LiquorAndDrink.AppUtility.Drink.GetUrl(Convert.ToInt32(Request.QueryString["pk"]), (string)_drDrink["Slug"]));

                // Social buttons
                if (ConfigurationManager.AppSettings["ShowSocialButtons"] == "1") _socialButtons.Text = AppUI.Content.GetSocialSharingButtons();

                DoSEO();
            }
        }