using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; // State variables using System.Data.Sql; using System.Data.SqlClient;// Database using System.Globalization; public partial class business_consulting : System.Web.UI.Page { public int adid1; public int adid2; public int adid3; public int adid4; public bool bnow1 = true; public bool bnow2 = true; public bool bnow3 = true; public bool bnow4 = true; public const string conString = "Server=208.81.134.9; Database=lamarve_users;User ID=lamarve;Password=NCTCSales2012;Trusted_Connection=False"; protected void Page_Load(object sender, EventArgs e) { try { Readpagedata(conString); } catch { //Label1.Text = e.ToString; Console.WriteLine("test"); } } public void Readpagedata(string connectionString) { string queryString = "SELECT * from catagory1;"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(queryString, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); // Call Read before accessing data. string adpos = ""; string testlabel = ""; int readpid = 0; while (reader.Read()) { try { adpos = reader[2].ToString(); testlabel = reader[3].ToString(); readpid = Convert.ToInt32(reader[4].ToString()); dynamicads(adpos, testlabel, readpid); } catch { Console.WriteLine("Error"); } } // Call Close when done reading. reader.Close(); } } protected void dynamicads(string labelname, string labelcontents, int readpid) { bool result; string pprice = "Price: 0.00"; switch (labelname.ToString()) { case "homeNA011L": homeNA011L.Text = labelcontents.ToString(); adid1 = readpid; break; case "homeNA012I": homeNA012I.ImageUrl = labelcontents.ToString(); break; case "homeNA013L": homeNA013L.Text = labelcontents.ToString(); break; case "homeNA014L": result = pprice == labelcontents; if (result) { Buynow1.Text = "Get a quote now"; bnow1 = false; homeNA014L.Text = ""; } else { Buynow1.Text = "Buy Now"; bnow1 = true; homeNA014L.Text = labelcontents.ToString(); } break; case "homeNA021L": homeNA021L.Text = labelcontents.ToString(); adid2 = readpid; break; case "homeNA022I": homeNA022I.ImageUrl = labelcontents.ToString(); break; case "homeNA023L": homeNA023L.Text = labelcontents.ToString(); break; case "homeNA024L": result = pprice == labelcontents; if (result) { Buynow2.Text = "Get a quote now"; bnow2 = false; homeNA024L.Text = ""; } else { Buynow2.Text = "Buy Now"; bnow2 = true; homeNA024L.Text = labelcontents.ToString(); } break; case "homeNA031L": homeNA031L.Text = labelcontents.ToString(); adid3 = readpid; break; case "homeNA032I": homeNA032I.ImageUrl = labelcontents.ToString(); break; case "homeNA033L": homeNA033L.Text = labelcontents.ToString(); break; case "homeNA034L": result = pprice == labelcontents; if (result) { Buynow3.Text = "Get a quote now"; bnow3 = false; homeNA034L.Text = ""; } else { Buynow3.Text = "Buy Now"; bnow3 = true; homeNA034L.Text = labelcontents.ToString(); } break; case "homeNA041L": homeNA041L.Text = labelcontents.ToString(); adid4 = readpid; break; case "homeNA042I": homeNA042I.ImageUrl = labelcontents.ToString(); break; case "homeNA043L": homeNA043L.Text = labelcontents.ToString(); break; case "homeNA044L": result = pprice == labelcontents; if (result) { Buynow4.Text = "Get a quote now"; bnow4 = false; homeNA044L.Text = ""; } else { Buynow4.Text = "Buy Now"; bnow4 = true; homeNA044L.Text = labelcontents.ToString(); } break; default: break; } } protected void homeNA012I_Click(object sender, ImageClickEventArgs e) { try { Session["partno"] = adid1.ToString(); Server.Transfer("~/productviewer.aspx"); } catch (Exception ex) { //mess.Text = ex.ToString(); Console.WriteLine(ex.ToString()); } } protected void homeNA022I_Click(object sender, ImageClickEventArgs e) { try { Session["partno"] = adid2.ToString(); Server.Transfer("~/productviewer.aspx"); } catch (Exception ex) { //mess.Text = ex.ToString(); Console.WriteLine(ex.ToString()); } } protected void homeNA032I_Click(object sender, ImageClickEventArgs e) { try { Session["partno"] = adid3.ToString(); Server.Transfer("~/productviewer.aspx"); } catch (Exception ex) { //mess.Text = ex.ToString(); Console.WriteLine(ex.ToString()); } } protected void homeNA042I_Click(object sender, ImageClickEventArgs e) { try { Session["partno"] = adid4.ToString(); Server.Transfer("~/productviewer.aspx"); } catch (Exception ex) { //mess.Text = ex.ToString(); Console.WriteLine(ex.ToString()); } } protected void Buynow1_Click(object sender, EventArgs e) { try { Session["partno"] = adid1.ToString(); if (bnow1) { Server.Transfer("~/salesinfo.aspx"); } else { Server.Transfer("~/quoteinfo.aspx"); } } catch (Exception ex) { //mess.Text = ex.ToString(); Console.WriteLine(ex.ToString()); } } protected void Buynow2_Click(object sender, EventArgs e) { try { Session["partno"] = adid2.ToString(); if (bnow2) { Server.Transfer("~/salesinfo.aspx"); } else { Server.Transfer("~/quoteinfo.aspx"); } } catch (Exception ex) { //mess.Text = ex.ToString(); Console.WriteLine(ex.ToString()); } } protected void Buynow3_Click(object sender, EventArgs e) { try { Session["partno"] = adid3.ToString(); if (bnow3) { Server.Transfer("~/salesinfo.aspx"); } else { Server.Transfer("~/quoteinfo.aspx"); } } catch (Exception ex) { //mess.Text = ex.ToString(); Console.WriteLine(ex.ToString()); } } protected void Buynow4_Click(object sender, EventArgs e) { try { Session["partno"] = adid4.ToString(); if (bnow4) { Server.Transfer("~/salesinfo.aspx"); } else { Server.Transfer("~/quoteinfo.aspx"); } } catch (Exception ex) { //mess.Text = ex.ToString(); Console.WriteLine(ex.ToString()); } } protected void Register_Click(object sender, EventArgs e) { Session["partno"] = "12"; Server.Transfer("~/sellnow/Quotenow.aspx"); } }