Line 1: using System;
Line 2: using System.Data;
Line 3: using System.Configuration;
Line 4: using System.Web;
Line 5: using System.Web.Security;
Line 6: using System.Web.UI;
Line 7: using System.Web.UI.WebControls;
Line 8: using System.Web.UI.WebControls.WebParts;
Line 9: using System.Web.UI.HtmlControls;
Line 10: using System.Globalization;
Line 11: using System.Net.Mail;
Line 12: using System.Data.SqlClient;
Line 13: using System.Text;
Line 14: using System.Text.RegularExpressions;
Line 15: using System.IO;
Line 16:
Line 17: /// <summary>
Line 18: /// Summary description for functions
Line 19: /// </summary>
Line 20: public class functions
Line 21: {
Line 22: public static string dbconn = "data source=216.26.146.52;initial catalog=brhd_live;user id=brucerossSA;password=jgiwlanmbusqonplok;persist security info=True;packet size=4096";
Line 23: public static string DEVELOPER_EMAIL = "jguardino@cfl.rr.com";
Line 24: public static string ERROR_EMAIL = "error@dimepinchers.com";
Line 25: public static string REGISTRATION_SUBJECT = "Dimepincher's Member Registration";
Line 26: public static string FROM_WELCOME_EMAIL = "customercare@dimepinchers.com";
Line 27: public static string MEMBERSERVICES_EMAIL = "memberservices@dimepinchers.com";
Line 28: public static string SMTP_SERVER = "smtp-server.cfl.rr.com";
Line 29: public static string ERROR_EMAIL_SUBJECT = "Websiste: Dimepinchers.com Errors Found";
Line 30: public static string HTTP_ACTIVATION_LINK = "http://www.dimepinchers.com/activation.aspx";
Line 31: private static int RANDOM_STRING_SIZE = 15;
Line 32: public static int COOKIE_EXPIRES = 180;
Line 33:
Line 34: public functions()
Line 35: {
Line 36:
Line 37: }
Line 38:
Line 39: /// <summary>
Line 40: /// Generates a random string with the given length
Line 41: /// </summary>
Line 42: /// <param name="size">Size of the string</param>
Line 43: /// <param name="lowerCase">If true, generate lowercase string</param>
Line 44: /// <returns>Random string</returns>
Line 45: private static string RandomString(int size, bool lowerCase)
Line 46: {
Line 47: StringBuilder builder = new StringBuilder();
Line 48: Random random = new Random();
Line 49: char ch;
Line 50: for (int i = 0; i < size; i++)
Line 51: {
Line 52: ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
Line 53: builder.Append(ch);
Line 54: }
Line 55: if (lowerCase)
Line 56: return builder.ToString().ToLower();
Line 57: return builder.ToString();
Line 58: }
Line 59:
Line 60: private static int RandomInt(int min, int max)
Line 61: {
Line 62: Random random = new Random();
Line 63: return random.Next(min, max);
Line 64: }
Line 65:
Line 66: public static string GetPassword()
Line 67: {
Line 68: StringBuilder builder = new StringBuilder();
Line 69: builder.Append(RandomString(4, true));
Line 70: builder.Append(RandomInt(1000, 9999));
Line 71: builder.Append(RandomString(2, false));
Line 72: return builder.ToString();
Line 73: }
Line 74:
Line 75: public static bool isEmail(string inputEmail)
Line 76: {
Line 77: inputEmail = NulltoString(inputEmail);
Line 78: string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
Line 79: @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
Line 80: @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
Line 81: Regex re = new Regex(strRegex);
Line 82: if (re.IsMatch(inputEmail))
Line 83: return (true);
Line 84: else
Line 85: return (false);
Line 86: }
Line 87:
Line 88: private static string NulltoString(string str)
Line 89: {
Line 90: return (str == null) ? "" : str;
Line 91: }
Line 92:
Line 93: public static bool IsDecimal(string numberString)
Line 94: {
Line 95: if (numberString == string.Empty) return false;
Line 96: char[] ca = numberString.ToCharArray();
Line 97: for (int i = 0; i < ca.Length; i++)
Line 98: {
Line 99: if ((ca[i] > 57 || ca[i] < 46) && ca[i] != 47)
Line 100: return false;
Line 101: }
Line 102: return true;
Line 103: }
Line 104:
Line 105: public static bool IsNumeric(string numberString)
Line 106: {
Line 107: if (numberString == string.Empty) return false;
Line 108: char[] ca = numberString.ToCharArray();
Line 109: for (int i = 0; i < ca.Length; i++)
Line 110: {
Line 111: if (ca[i] > 57 || ca[i] < 48)
Line 112: return false;
Line 113: }
Line 114: return true;
Line 115: }
Line 116:
Line 117: public static string WordsToUpper(string str)
Line 118: {
Line 119: int x;
Line 120: string[] temp = new string[] { };
Line 121: string return_value = null;
Line 122:
Line 123: temp = str.Split(' ');
Line 124: for (x = 0; x < temp.GetUpperBound(0) + 1; x++)
Line 125: {
Line 126: temp[x] = temp[x].Substring(0, 1).ToUpper() + temp[x].Substring(1);
Line 127: return_value += temp[x] + " ";
Line 128: };
Line 129: return return_value.Trim();
Line 130: }
Line 131:
Line 132: public static string LoadCategoriesList(int customerID, int type)
Line 133: {
Line 134: string catnav = "<br/>";
Line 135:
Line 136: SqlConnection conn = new SqlConnection(dbconn);
Line 137: SqlCommand cmd = new SqlCommand("jg_GetCategoryList", conn);
Line 138: cmd.CommandType = CommandType.StoredProcedure;
Line 139:
Line 140: conn.Open();
Line 141: SqlDataReader reader = cmd.ExecuteReader();
Line 142:
Line 143: string temp;
Line 144:
Line 145: while (reader.Read())
Line 146: {
Line 147: if (reader["Name"].ToString().Length > 30)
Line 148: temp = reader["Name"].ToString().Substring(0, 30) + "...";
Line 149: else temp = reader["Name"].ToString();
Line 150: if (type == 0)
Line 151: { catnav += " <img src='skins/skin_(!SKINID!)/images/barrow.jpg' /> "; }
Line 152: else
Line 153: { catnav += " <img src='images/barrow.jpg' /> "; }
Line 154:
Line 155: catnav += "<a class='leftnav' href='skins/skin_(!SKINID!)/categories.aspx?siteID=" + RandomString(RANDOM_STRING_SIZE, true) + "&customerID=" + customerID + "&parentid=0&page=1&categoryid=" +
Line 156: reader["CategoryID"].ToString() + "'>" + WordsToUpper(temp) + "</a><br/>";
Line 157: }
Line 158: catnav += "<br/>";
Line 159: conn.Close();
Line 160: conn.Dispose();
Line 161:
Line 162: return catnav;
Line 163: }
Line 164:
Line 165: public static string GetHalfOffItem()
Line 166: {
Line 167: string html = "<br/>";
Line 168:
Line 169: SqlConnection conn = new SqlConnection(dbconn);
Line 170: SqlCommand cmd = new SqlCommand("jg_GetHalfOffItems", conn);
Line 171: cmd.CommandType = CommandType.StoredProcedure;
Line 172:
Line 173: conn.Open();
Line 174: SqlDataReader reader = cmd.ExecuteReader();
Line 175:
Line 176: reader.Read();
Line 177:
Line 178: string webpath = "http://www.dimepinchers.com/images/product/medium/" + reader["ProductID"].ToString() + ".jpg";
Line 179: decimal fprice = Convert.ToDecimal(reader["Price"].ToString());
Line 180: decimal msrp = Convert.ToDecimal(reader["msrp"].ToString());
Line 181: string http = "p-" + reader["ProductID"].ToString() + "-.aspx";
Line 182:
Line 183: html += "<table border='0' cellpadding='0' cellspacing='0' style='width: 100%'>";
Line 184: html += " <tr>";
Line 185: html += " <td>";
Line 186: html += " <a target='_parent' href='" + http + "'><img border='0'src='" + webpath + "' width='150'/></a></td>";
Line 187: html += " </tr>";
Line 188: html += " <tr>";
Line 189: html += " <td align='center'>";
Line 190: html += " <table border='0' cellpadding='0' cellspacing='0' style='width: 80%'>";
Line 191: html += " <tr>";
Line 192: html += " <td align='center' style='height: 35px' valign='middle'>";
Line 193: html += " <a target='_parent' href='" + http + "'>";
Line 194: html += " " + reader["name"].ToString() + "</a>";
Line 195: html += " </tr>";
Line 196: html += " <tr>";
Line 197: html += " <td align='center' style='height: 50px' valign='top'>";
Line 198: html += " <span style='font-size: 10pt'><span style='color: #ff0000'><span style='font-family: Arial'>";
Line 199: html += " MSRP: $<STRIKE>" + msrp.ToString("#,###,###.00") + "</STRIKE><br/>";
Line 200: html += " <span style='font-size: 10pt'>Your Price <br/><strong>$" + fprice.ToString("#,###,###.00") + "</span></strong></span></span></span></td>";
Line 201: html += " </tr>";
Line 202: html += " </table>";
Line 203: html += " </td>";
Line 204: html += " </tr>";
Line 205: html += "</table>";
Line 206:
Line 207: conn.Close();
Line 208: conn.Dispose();
Line 209:
Line 210: return html;
Line 211: }
Line 212:
Line 213: public static string GetTemplateHeader(int customerID)
Line 214: {
Line 215: string html=null;
Line 216:
Line 217: //html += "<form style=margin-top: 0px; margin-bottom: 0px;' id='topsearchform' name='topsearchform' method='POST' action='/skins/skin_1/search.aspx?siteID=" + RandomString(RANDOM_STRING_SIZE, true) + "&customerID=" + customerID + "'>";
Line 218: //html += "<div align='left' class='OrangeTitles'>";
Line 219: //html += " <input name='SearchText' type='text' class='searchBox' size='15' style='width: 163px' >";
Line 220: //html += " <img src='skins/skin_(!SKINID!)/images/GOarrow.jpg' width='28' height='28' align='absmiddle' style='cursor: hand' onClick='document.topsearchform.submit()' border='0'/></div>";
Line 221: //html += "<div align='left'><span style='font-size: 10pt; color: royalblue; font-family: Arial'>Quick Search:</span></div>";
Line 222: //html += "</form>";
Line 223:
Line 224: html += "<table width='100%'>";
Line 225: html += " <tr>";
Line 226: html += " <td>";
Line 227: html += " <img src='skins/skin_(!SKINID!)/images/search.jpg' />";
Line 228: html += " </td>";
Line 229: html += " </tr>";
Line 230: html += " <tr>";
Line 231: html += " <td>";
Line 232: html += " <span style='font-size: 10pt; color: #4169e1; font-family: Arial'> Quick Search:</span>";
Line 233: html += " </td>";
Line 234: html += " </tr>";
Line 235: html += " <tr>";
Line 236: html += " <td style='height: 19px'>";
Line 237: html += " <form id='topsearchform' name='topsearchform' method='POST' action='skins/skin_(!SKINID!)/search.aspx?siteID=" + RandomString(RANDOM_STRING_SIZE, true) + "&customerID=" + customerID + "'>";
Line 238: html += " <input style='height: 25px' name='SearchText' type='text' class='searchBox' size='13' style='width: 120px' >";
Line 239: html += " <img src='skins/skin_(!SKINID!)/images/GOarrow.jpg' width='28' height='28'";
Line 240: html += " align='absmiddle' style='cursor: hand' onClick='document.topsearchform.submit()' border='0'/>";
Line 241: html += " </form>";
Line 242: html += " </td>";
Line 243: html += " </tr>";
Line 244: html += " </table>";
Line 245:
Line 246: return html;
Line 247: }
Line 248:
Line 249: public static string SearchItemsHome(int customerID, int type)
Line 250: {
Line 251: string html = null;
Line 252:
Line 253: if (type == 0) html += "<form id='topsearchform' name='topsearchform' method='POST' action='search.aspx?siteID=" + RandomString(RANDOM_STRING_SIZE, true) + "&customerID=" + customerID + "'>";
Line 254: else html += "<form id='topsearchform' name='topsearchform' method='POST' action='search.aspx?siteID=" + RandomString(RANDOM_STRING_SIZE, true) + "&customerID=" + customerID + "'>";
Line 255: html += "<table width='100%'>";
Line 256: html += " <tr>";
Line 257: html += " <td height='30' valign='bottom'>";
Line 258: html += " <span style='font-size: 10pt; color: #363634; font-family: Arial'><b> Search Products</b></span>";
Line 259: html += " </td>";
Line 260: html += " </tr>";
Line 261: html += " <tr>";
Line 262: html += " <td style='height: 30px' valign='bottom'>";
Line 263: html += " <input style='height: 22px' name='SearchText' type='text' class='searchBox' style='width: 140px' >";
Line 264: if (type == 0) html += " <img src='skins/skin_(!SKINID!)/images/GO.gif' width='28' height='28'";
Line 265: else html += " <img src='images/GO.gif' width='28' height='28'";
Line 266: html += " align='absmiddle' style='cursor: hand' onClick='document.topsearchform.submit()' border='0'/>";
Line 267: html += " </td>";
Line 268: html += " </tr>";
Line 269: html += " <tr>";
Line 270: html += " <td valign='top' height='25'>";
Line 271: html += " <span style='font-size: 8pt; color: #FFDA0B; font-family: Arial'> For best results enter multiple words<br/> separated by a comma.</span>";
Line 272: html += " </td>";
Line 273: html += " </tr>";
Line 274: html += " </table>";
Line 275: html += " </form>";
Line 276:
Line 277: ///skins/skin_(!SKINID!)/
Line 278: return html;
Line 279: }
Line 280:
Line 281: public static string GetSearchBoxCat(int customerID)
Line 282: {
Line 283: string html = null;
Line 284:
Line 285: html += "<table width='100%'>";
Line 286: html += " <tr>";
Line 287: html += " <td>";
Line 288: html += " <img src='images/search.jpg' />";
Line 289: html += " </td>";
Line 290: html += " </tr>";
Line 291: html += " <tr>";
Line 292: html += " <td>";
Line 293: html += " <span style='font-size: 10pt; color: #4169e1; font-family: Arial'> Quick Search:</span>";
Line 294: html += " </td>";
Line 295: html += " </tr>";
Line 296: html += " <tr>";
Line 297: html += " <td style='height: 19px'>";
Line 298: html += " <form id='topsearchform' name='topsearchform' method='POST' action='/skins/skin_1/search.aspx?siteID=" + RandomString(RANDOM_STRING_SIZE, true) + "&customerID=" + customerID + "'>";
Line 299: html += " <input style='height: 17px' name='SearchText' type='text' class='searchBox' size='15' style='width: 145px' >";
Line 300: html += " <img src='images/GOarrow.jpg' width='28' height='28'";
Line 301: html += " align='absmiddle' style='cursor: hand' onClick='document.topsearchform.submit()' border='0'/>";
Line 302: html += " </form>";
Line 303: html += " </td>";
Line 304: html += " </tr>";
Line 305: html += " </table>";
Line 306:
Line 307: return html;
Line 308: }
Line 309:
Line 310: public static string GetMiniCartInfoCat(int customerID)
Line 311: {
Line 312: try
Line 313: {
Line 314: decimal total = 0;
Line 315: decimal quantity = 0;
Line 316: string _customerID = Convert.ToString(customerID);
Line 317: int recordCount = GetMiniCartRecordCount(customerID);
Line 318: string result = null;
Line 319: string title = null;
Line 320:
Line 321: result += "<table align='center'>";
Line 322: result += "<tr>";
Line 323: result += " <td><img src='images/shoppingcart.jpg'/></td>";
Line 324: result += "</tr>";
Line 325:
Line 326: if (recordCount > 0)
Line 327: {
Line 328: SqlConnection conn = new SqlConnection(dbconn);
Line 329: SqlCommand cmd = new SqlCommand("jg_GetMiniCartList", conn);
Line 330: cmd.CommandType = CommandType.StoredProcedure;
Line 331:
Line 332: SqlParameter param1 = new
Line 333: SqlParameter("@CustomerID", SqlDbType.Int);
Line 334: param1.Direction = ParameterDirection.Input;
Line 335: param1.Value = customerID;
Line 336: cmd.Parameters.Add(param1);
Line 337:
Line 338: conn.Open();
Line 339: SqlDataReader reader = cmd.ExecuteReader();
Line 340:
Line 341: result += "<tr>";
Line 342: result += "<td height='30'>";
Line 343: result += " <span style='font-size: 8pt; color: #2b63ba'><br/>";
Line 344: result += " <b style='color: #777777'>You have " + recordCount + " items in Cart</b><br/><br/>";
Line 345:
Line 346: while (reader.Read())
Line 347: {
Line 348: quantity = decimal.Parse(reader["Quantity"].ToString()) * decimal.Parse(reader["ProductPrice"].ToString());
Line 349: total += quantity;
Line 350:
Line 351: if (reader["Name"].ToString().Length > 20) title = "<b>" + reader["Quantity"].ToString() + "</b> - " + reader["Name"].ToString().Substring(0, 20);
Line 352: else title = "<b>" + reader["Quantity"].ToString() + "</b> - " + reader["Name"].ToString();
Line 353: result += " <img src='images/narrow.jpg' /> <a class='leftnav' href='../../p-" + reader["ProductID"].ToString() + "-.aspx'>" + title + "</a><br/>";
Line 354: }
Line 355:
Line 356: total = Math.Ceiling(total);
Line 357:
Line 358: result += " <br/><span style='Color: #777777'> Shopping Cart Total: <b>$" + total.ToString("#,###,###.00") + "</b></span><br/><br/>";
Line 359: result += " <b> <a style='color: Red;' href='../../shoppingcart.aspx'>Check Out Now...</a></b>";
Line 360: result += " </span>";
Line 361: result += "</td>";
Line 362: result += "</tr>";
Line 363: result += "</table>";
Line 364:
Line 365: conn.Close();
Line 366: }
Line 367: else
Line 368: {
Line 369: result += "<tr>";
Line 370: result += "<td height='30'>";
Line 371: result += " <span style='font-size: 8pt; color: #2b63ba'><br/>";
Line 372: result += " <b style='color: black'>You have 0 items in Cart</b><br/><br/>";
Line 373: result += " </span>";
Line 374: result += "</td>";
Line 375: result += "</tr>";
Line 376: result += "</table>";
Line 377: }
Line 378:
Line 379: return result;
Line 380: }
Line 381: catch (Exception ex)
Line 382: {
Line 383: HttpContext.Current.Response.Write(ex.Message);
Line 384: }
Line 385:
Line 386: return string.Empty;
Line 387: }
Line 388:
Line 389: public static string GetMiniCartInfo(int customerID)
Line 390: {
Line 391: try
Line 392: {
Line 393: decimal total=0;
Line 394: decimal quantity = 0;
Line 395: string _customerID = Convert.ToString(customerID);
Line 396: int recordCount = GetMiniCartRecordCount(customerID);
Line 397: string result = null;
Line 398: string title = null;
Line 399:
Line 400: result += "<tr>";
Line 401: result += " <td><img src='skins/skin_(!SKINID!)/images/shoppingcart.jpg'/></td>";
Line 402: result += "</tr>";
Line 403:
Line 404: if (recordCount > 0)
Line 405: {
Line 406: SqlConnection conn = new SqlConnection(dbconn);
Line 407: SqlCommand cmd = new SqlCommand("jg_GetMiniCartList", conn);
Line 408: cmd.CommandType = CommandType.StoredProcedure;
Line 409:
Line 410: SqlParameter param1 = new
Line 411: SqlParameter("@CustomerID", SqlDbType.Int);
Line 412: param1.Direction = ParameterDirection.Input;
Line 413: param1.Value = customerID;
Line 414: cmd.Parameters.Add(param1);
Line 415:
Line 416: conn.Open();
Line 417: SqlDataReader reader = cmd.ExecuteReader();
Line 418:
Line 419: result += "<tr>";
Line 420: result += "<td height='30'>";
Line 421: result += " <span style='font-size: 8pt; color: #2b63ba'><br/>";
Line 422: result += " <b style='color: #777777'>You have " + recordCount + " items in Cart</b><br/><br/>";
Line 423:
Line 424: while (reader.Read())
Line 425: {
Line 426: quantity = decimal.Parse(reader["Quantity"].ToString()) * decimal.Parse(reader["ProductPrice"].ToString());
Line 427: total += quantity;
Line 428:
Line 429: if (reader["Name"].ToString().Length > 20) title = "<b>" + reader["Quantity"].ToString() + "</b> - " + reader["Name"].ToString().Substring(0, 20);
Line 430: else title = "<b>" + reader["Quantity"].ToString() + "</b> - " + reader["Name"].ToString();
Line 431: result += " <img src='skins/skin_(!SKINID!)/images/narrow.jpg' /> <a class='leftnav' href='p-" + reader["ProductID"].ToString() + "-.aspx'>" + title + "</a><br/>";
Line 432: }
Line 433:
Line 434: total = Math.Ceiling(total);
Line 435:
Line 436: result += " <br/> <span style='Color: #777777'>Shopping Cart Total: <b>$" + total.ToString("#,###,###.00") + "</b></span><br/><br/>";
Line 437: result += " <b> <a style='color: Red;' href='../../shoppingcart.aspx'>Check Out Now...</a></b>";
Line 438: result += " </span>";
Line 439: result += "</td>";
Line 440: result += "</tr>";
Line 441:
Line 442: conn.Close();
Line 443: }
Line 444: else
Line 445: {
Line 446: result += "<tr>";
Line 447: result += "<td height='30'>";
Line 448: result += " <span style='font-size: 8pt; color: #2b63ba'><br/>";
Line 449: result += " <b style='color: black'>You have 0 items in Cart</b><br/><br/>";
Line 450: result += " </span>";
Line 451: result += "</td>";
Line 452: result += "</tr>";
Line 453: }
Line 454:
Line 455: return result;
Line 456: }
Line 457: catch (Exception ex)
Line 458: {
Line 459: HttpContext.Current.Response.Write(ex.Message);
Line 460: }
Line 461:
Line 462: return string.Empty;
Line 463: }
Line 464:
Line 465: public static string GetMiniBasketInfo(int customerID,int type)
Line 466: {
Line 467: try
Line 468: {
Line 469: decimal total = 0;
Line 470: decimal quantity = 0;
Line 471: string _customerID = Convert.ToString(customerID);
Line 472: int recordCount = GetMiniCartRecordCount(customerID);
Line 473: string result = null;
Line 474: string title = null;
Line 475:
Line 476: if (recordCount > 0)
Line 477: {
Line 478: SqlConnection conn = new SqlConnection(dbconn);
Line 479: SqlCommand cmd = new SqlCommand("jg_GetMiniCartList", conn);
Line 480: cmd.CommandType = CommandType.StoredProcedure;
Line 481:
Line 482: SqlParameter param1 = new
Line 483: SqlParameter("@CustomerID", SqlDbType.Int);
Line 484: param1.Direction = ParameterDirection.Input;
Line 485: param1.Value = customerID;
Line 486: cmd.Parameters.Add(param1);
Line 487:
Line 488: conn.Open();
Line 489: SqlDataReader reader = cmd.ExecuteReader();
Line 490:
Line 491: result += "<tr>";
Line 492: result += "<td height='30'>";
Line 493: result += " <span style='font-size: 8pt; color: #2b63ba'><br/>";
Line 494: result += " <b style='color: #333333'>You have " + recordCount + " items in Cart</b><br/><br/>";
Line 495:
Line 496: while (reader.Read())
Line 497: {
Line 498: quantity = decimal.Parse(reader["Quantity"].ToString()) * decimal.Parse(reader["ProductPrice"].ToString());
Line 499: total += quantity;
Line 500:
Line 501: if (reader["Name"].ToString().Length > 20) title = "<b>" + reader["Quantity"].ToString() + "</b> - " + reader["Name"].ToString().Substring(0, 20);
Line 502: else title = "<b>" + reader["Quantity"].ToString() + "</b> - " + reader["Name"].ToString();
Line 503:
Line 504: if(type == 0)
Line 505: result += " <img src='skins/skin_(!SKINID!)/images/barrow.jpg' /> <a class='leftnav' href='p-" + reader["ProductID"].ToString() + "-.aspx'>" + title + "</a><br/>";
Line 506: else
Line 507: result += " <img src='images/barrow.jpg' /> <a class='leftnav' href='p-" + reader["ProductID"].ToString() + "-.aspx'>" + title + "</a><br/>";
Line 508: }
Line 509:
Line 510: total = Math.Ceiling(total);
Line 511:
Line 512: result += " <br/> <span style='Color: #333333'>Shopping Cart Total: <b>$" + total.ToString("#,###,###.00") + "</b></span><br/><br/>";
Line 513: result += " <b> <a style='color: #ffff00;' href='../../shoppingcart.aspx'>Check Out Now...</a></b><br/><br/>";
Line 514: result += " </span>";
Line 515: result += "</td>";
Line 516: result += "</tr>";
Line 517:
Line 518: conn.Close();
Line 519: }
Line 520: else
Line 521: {
Line 522: result += "<tr>";
Line 523: result += "<td height='30'>";
Line 524: result += " <span style='font-size: 8pt; color: #2b63ba'><br/>";
Line 525: result += " <b style='color: black'>You have 0 items in Cart</b><br/><br/>";
Line 526: result += " </span>";
Line 527: result += "</td>";
Line 528: result += "</tr>";
Line 529: }
Line 530:
Line 531: return result;
Line 532: }
Line 533: catch (Exception ex)
Line 534: {
Line 535: HttpContext.Current.Response.Write(ex.Message);
Line 536: }
Line 537:
Line 538: return string.Empty;
Line 539: }
Line 540:
Line 541: public static int GetMiniCartRecordCount(int customerID)
Line 542: {
Line 543: try
Line 544: {
Line 545: SqlConnection conn = new SqlConnection(dbconn);
Line 546: SqlCommand cmd = new SqlCommand("jg_GetMiniCartRecordCount", conn);
Line 547: cmd.CommandType = CommandType.StoredProcedure;
Line 548:
Line 549: SqlParameter paramReturnValue = new
Line 550: SqlParameter("@return_value", SqlDbType.Int);
Line 551: paramReturnValue.Direction = ParameterDirection.ReturnValue;
Line 552: cmd.Parameters.Add(paramReturnValue);
Line 553:
Line 554: SqlParameter param1 = new
Line 555: SqlParameter("@CustomerID", SqlDbType.NChar);
Line 556: param1.Direction = ParameterDirection.Input;
Line 557: param1.Value = customerID;
Line 558: cmd.Parameters.Add(param1);
Line 559:
Line 560: conn.Open();
Line 561: cmd.ExecuteNonQuery();
Line 562:
Line 563: int returnValue = (int)cmd.Parameters["@return_value"].Value;
Line 564:
Line 565: conn.Close(); // alternatively, conn.Dispose
Line 566:
Line 567: return returnValue;
Line 568: }
Line 569: catch (Exception ex)
Line 570: {
Line 571: HttpContext.Current.Response.Write(ex.Message);
Line 572: }
Line 573:
Line 574: return 0;
Line 575: }
Line 576:
Line 577: public static bool IsValidDate(string date)
Line 578: {
Line 579: try
Line 580: {
Line 581: CultureInfo format = new CultureInfo("en-US", true);
Line 582: DateTime datetime = DateTime.Parse(date, format);
Line 583: return true;
Line 584: }
Line 585: catch(Exception)
Line 586: {
Line 587: // HttpContext.Current.Response.Write(ex.Message);
Line 588: return false;
Line 589: }
Line 590: }
Line 591:
Line 592: public string GetHttpImage(Int16 page)
Line 593: {
Line 594: try
Line 595: {
Line 596: SqlConnection conn = new SqlConnection(dbconn);
Line 597: SqlCommand cmd = new SqlCommand("spGetImage", conn);
Line 598: cmd.CommandType = CommandType.StoredProcedure;
Line 599:
Line 600: //SqlParameter paramReturnValue = new
Line 601: //SqlParameter("@return_value", SqlDbType.NVarChar);
Line 602: //paramReturnValue.Direction = ParameterDirection.ReturnValue;
Line 603: //cmd.Parameters.Add(paramReturnValue);
Line 604:
Line 605: SqlParameter param1 = new
Line 606: SqlParameter("@imageid", SqlDbType.SmallInt);
Line 607: param1.Direction = ParameterDirection.Input; // optional
Line 608: param1.Value = page;
Line 609: cmd.Parameters.Add(param1);
Line 610:
Line 611: //cmd.Parameters.Add("@uid", System.Data.SqlDbType.Int, 0);
Line 612:
Line 613: conn.Open();
Line 614: SqlDataReader reader = cmd.ExecuteReader();
Line 615: reader.Read();
Line 616:
Line 617: return reader["imagename"].ToString();
Line 618:
Line 619: //string returnValue = (string)cmd.Parameters["@imagename"].Value;
Line 620:
Line 621: conn.Close();
Line 622: conn.Dispose();
Line 623: }
Line 624: catch (Exception ex)
Line 625: {
Line 626: //HttpContext.Current.Response.Write(ex.Message);
Line 627: //sendEmail(ERROR_EMAIL, DEVELOPER_EMAIL, ex.Message + " " + ex.Source + " " + ex.StackTrace, ERROR_EMAIL_SUBJECT);
Line 628: }
Line 629: return string.Empty;
Line 630: }
Line 631:
Line 632: public static string GetHomePageItems(string sqltxt)
Line 633: {
Line 634: string html = null;
Line 635:
Line 636: try
Line 637: {
Line 638: //string[] categories = new string[] { };
Line 639: string webpath;
Line 640: decimal fprice;
Line 641: string name;
Line 642: string http;
Line 643: decimal msrp;
Line 644:
Line 645: SqlConnection conn = new SqlConnection(dbconn);
Line 646: SqlCommand cmd = new SqlCommand(sqltxt, conn);
Line 647: cmd.CommandType = CommandType.StoredProcedure;
Line 648:
Line 649: conn.Open();
Line 650: SqlDataReader reader = cmd.ExecuteReader();
Line 651:
Line 652: html += "<table border='0' cellpadding='0' cellspacing='0' style='width: 500px'>";
Line 653: html += " <tr>";
Line 654:
Line 655: while (reader.Read())
Line 656: {
Line 657: webpath = "http://www.dimepinchers.com/images/product/icon/" + reader["ProductID"].ToString() + ".jpg";
Line 658: fprice = Convert.ToDecimal(reader["Price"].ToString());
Line 659: if (reader["Name"].ToString().Length > 25) name = reader["Name"].ToString().Substring(0, 22) + "...";
Line 660: else name = reader["Name"].ToString();
Line 661: http = "p-" + reader["ProductID"].ToString() + "-.aspx";
Line 662:
Line 663: html += " <td>";
Line 664: html += "<table border='0' cellpadding='0' cellspacing='0' style='width: 90px'>";
Line 665: html += " <tr>";
Line 666: html += " <td height='100' width='100' align='center'><img alt='home' border='0' src='" + webpath + "'> </td>";
Line 667: html += " </tr>";
Line 668: html += " <tr>";
Line 669: html += " <td valign='top' width='100' align='center' style='height: 30px'>";
Line 670: html += " <span style='font-size: 8pt; color: #0000ff; font-family: Arial'><a href='" + http + "'";
Line 671: html += " target='_parent'>" + name + "</a></span></td>";
Line 672: html += " </tr>";
Line 673: html += " <tr>";
Line 674: html += " <td align='center' style='height: 18px'>";
Line 675: html += " <span style='font-family: Arial'><span style='font-size: 8pt'><strong>NOW:</strong>";
Line 676: html += " <span style='color: #ff0000'>$<b>" + fprice.ToString("#,###,###.00") + "</b></span></span></span><br/><br/></td>";
Line 677: html += " </tr>";
Line 678: html += "</table>";
Line 679: html += " </td>";
Line 680: }
Line 681: html += " </tr>";
Line 682: html += "</table>";
Line 683: // alternatively, conn.Dispose
Line 684: conn.Close();
Line 685:
Line 686: return html;
Line 687: }
Line 688: catch (Exception ex)
Line 689: {
Line 690: HttpContext.Current.Response.Write(ex.Message);
Line 691: }
Line 692: return string.Empty;
Line 693: }
Line 694:
Line 695: public static string HarleyHomePageItems(int CategoryID)
Line 696: {
Line 697: SqlConnection conn = new SqlConnection(dbconn);
Line 698: SqlCommand cmd = new SqlCommand("jg_LoadHomeRNDItems", conn);
Line 699: cmd.CommandType = CommandType.StoredProcedure;
Line 700:
Line 701: //SqlParameter paramReturnValue = new SqlParameter("@return_value", SqlDbType.Int);
Line 702: //paramReturnValue.Direction = ParameterDirection.ReturnValue;
Line 703: //cmd.Parameters.Add(paramReturnValue);
Line 704:
Line 705: SqlParameter param1 = new SqlParameter("@CategoryID", SqlDbType.Int);
Line 706: param1.Direction = ParameterDirection.Input;
Line 707: param1.Value = CategoryID;
Line 708: cmd.Parameters.Add(param1);
Line 709:
Line 710: int index = 0;
Line 711: string filename;
Line 712: string serverpath;
Line 713: string html = null;
Line 714:
Line 715: conn.Open();
Line 716: SqlDataReader reader = cmd.ExecuteReader();
Line 717:
Line 718: if (reader.Read() != null)
Line 719: {
Line 720:
Line 721: html += "<table align='center' border='0' cellpadding='3' cellspacing='0'>";
Line 722:
Line 723: html += "<tr>";
Line 724: html += "<td colspan=\"6\">";
Line 725: html += "<div style=\"padding-left: 7px; background-image: url(skins/skin_(!SKINID!)/images/HPProductHeader.jpg);";
Line 726: html += "padding-top: 7px; background-repeat: no-repeat; height: 24px\">";
Line 727: html += "<span style=\"font-weight: bold; font-size: 12px; color: #ffffff\">" + reader["CategoryName"].ToString() + "</span></div>";
Line 728: html += "</td>";
Line 729: html += "</tr>";
Line 730:
Line 731: html += " <tr>";
Line 732:
Line 733: do
Line 734: {
Line 735: serverpath = @"c:\inetpub\websites\brucerossmeyer_com\images\product\icon\";
Line 736: if (File.Exists(serverpath + reader["ProductID"].ToString() + ".jpg") || File.Exists(serverpath + reader["ProductID"].ToString() + ".gif"))
Line 737: {
Line 738: BuildHtml(
Line 739: reader["ProductID"].ToString(),
Line 740: reader["SEName"].ToString(),
Line 741: reader["Name"].ToString(),
Line 742: reader["Price"].ToString(),
Line 743: ref html,
Line 744: index++);
Line 745: }
Line 746: if (index > 5) break;
Line 747: }
Line 748: while (reader.Read());
Line 749: }
Line 750:
Line 751: html += " </tr>";
Line 752: html += "</table>";
Line 753:
Line 754: conn.Close();
Line 755: conn.Dispose();
Line 756: return html;
Line 757: }
Line 758:
Line 759: public static void BuildHtml(string productid, string sename, string productname, string price, string categoryname, ref string html, int index)
Line 760: {
Line 761: decimal fprice = Convert.ToDecimal(price);
Line 762: string http = "../../p-" + productid + "-" + sename + ".aspx";
Line 763:
Line 764: string filename;
Line 765: string serverpath = @"c:\inetpub\websites\brucerossmeyer_com\images\product\icon\";
Line 766: if (File.Exists(serverpath + productid + ".jpg"))
Line 767:
Line 768: filename = productid + ".jpg";
Line 769:
Line 770: else if (File.Exists(serverpath + productid + ".gif"))
Line 771:
Line 772: filename = productid + ".gif";
Line 773:
Line 774: else filename = "nopictureicon.gif";
Line 775:
Line 776: //Server.MapPath("/images/product/icon/")
Line 777: string webpath = "https://www.brucerossmeyer.com/images/product/icon/" + filename;
Line 778:
Line 779: //if (productname.Length > 25) productname = productname.Substring(0, 22) + "...";
Line 780:
Line 781: //if (index % 5 == 0) html += "<tr>";
Line 782:
Line 783: html += " <td>";
Line 784: html += "<table border='0' cellpadding='0' cellspacing='0' style='width: 110px'>";
Line 785: html += " <tr>";
Line 786: html += " <td height='125' width='110' align='center'> <a href='" + http + "'";
Line 787: html += " target='_parent'><img alt='home' border='0' src='" + webpath + "'></a> </td>";
Line 788: html += " </tr>";
Line 789: html += " <tr>";
Line 790: html += " <td width='110' align='center' valign='top' style='height: 40px'>";
Line 791: html += " <span style='font-size: 8pt; color: #0000ff; font-family: Arial'><a href='" + http + "'";
Line 792: html += " target='_parent'>" + productname + "</a></span></td>";
Line 793: html += " </tr>";
Line 794: /* html += " <tr>";
Line 795: html += " <td align='center' style='height: 20px'>";
Line 796: html += " <span style='font-family: Arial'><span style='font-size: 8pt'><strong>NOW:</strong>";
Line 797: html += " <span style='color: #ff0000'>$<b>" + fprice.ToString("#,###,###.00") + "</b></span></span></span></td>";
Line 798: html += " </tr>";*/
Line 799: html += "</table>";
Line 800: html += " </td>";
Line 801:
Line 802: //if (index % 6 == 0) html += "</tr>";
Line 803: }
Line 804: }
Line 805:
|