protected void btnProduct_Click(object sender, EventArgs e) { // Collect the inforation string product = txtProduct.Text; string description = txtDescription.Text; string price = txtPrice.Text; string amount = txtAmount.Text; // Save it to the database DBMaster dbm = new DBMaster(); // Craft the query string query = string.Format("INSERT INTO products (productName, description, price, currentAmount) " + "VALUES('{0}', '{1}', '{2}', '{3}')", product, description, price, amount); // Execute the query string id = dbm.ExecuteWithScope(query); //System.Diagnostics.Debug.WriteLine("######### query: " + query); //System.Diagnostics.Debug.WriteLine("######### id: " + id); // Close the connection. dbm.CloseConnection(); // Clear the fields to allow another entry. txtProduct.Text = ""; txtDescription.Text = ""; txtPrice.Text = ""; txtAmount.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Retrieve the user's id. string id = Session["userId"].ToString(); // Create the query string query = "SELECT * FROM person WHERE id = " + id; // Open a connection and execute the query. DBMaster dbm = new DBMaster(); SqlDataReader reader = dbm.GetReader(query); // Read in the information reader.Read(); lblFName.Text = reader["firstName"].ToString(); lblLName.Text = reader["lastName"].ToString(); lblUser.Text = reader["userName"].ToString(); lblPassword.Text = reader["password"].ToString(); lblAddress.Text = reader["address"].ToString(); lblEmail.Text = reader["email"].ToString(); lblPhone.Text = reader["phone"].ToString(); dbm.CloseConnection(); // Close the connection } }
protected void btnUpdate_Click(object sender, EventArgs e) { // Retrieve the "updated" info. string id = Session["userId"].ToString(); string fName = txtFName.Text; string lName = txtLName.Text; string user = txtUser.Text; string password = txtPassword.Text; string address = txtAddress.Text; string email = txtEmail.Text; string phone = txtPhone.Text; // Craft the query (Shouldn't send in plain text!) string query = string.Format( "UPDATE person " + "SET firstName = '{0}', lastName = '{1}', userName = '******', " + "password = '******', address = '{4}', email = '{5}', phone = '{6}' " + "WHERE id = {7}", fName, lName, user, password, address, email, phone, id); DBMaster dbm = new DBMaster(); // Open a connection dbm.ExecuteNonQuery(query); // Execute the query dbm.CloseConnection(); // Close the connection // Move to next web page Response.Redirect("showUserInfo.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { result.Visible = false; } DBMaster dbm = new DBMaster(); SqlDataReader reader = dbm.getReader("SELECT [name],[email] FROM [dbo].[DWUser]"); if (!IsPostBack) { } string temp = ""; while (reader.Read()) { temp += reader["name"].ToString(); temp += "<br/>"; temp += reader["email"].ToString(); temp += "<br/>"; } dbm.closeConnection(); }
protected void submitButton_Click(object sender, EventArgs e) { // get DBM object DBMaster dbm = new DBMaster(); // get vars from input string productName = newProductNameInput.Text, productDescription = newProductDescriptionInput.Text, productPrice = newProductPriceInput.Text, productQuantity = newProductQuantityInput.Text, // generate query query = "INSERT INTO [dbo].[products] ([productName],[description],[price],[currentAmount]) VALUES (\'" + productName + "\',\'" + productDescription + "\',\'" + productPrice + "\',\'" + productQuantity + "\')"; // execute the query dbm.executeQuery(query); // close connection dbm.closeConnection(); // clear text fields newProductNameInput.Text = ""; newProductDescriptionInput.Text = ""; newProductPriceInput.Text = ""; newProductQuantityInput.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Retrieve the info from page 1 string fName = Request.Form["txtFName"]; string lName = Request.Form["txtLName"]; string user = Request.Form["txtUser"]; string password = Request.Form["txtPassword"]; string address = Request.Form["txtAddress"]; string email = Request.Form["txtEmail"]; string phone = Request.Form["txtPhone"]; // Show it to the user lblFName.Text = fName; lblLName.Text = lName; lblUser.Text = user; lblPassword.Text = password; lblAddress.Text = address; lblEmail.Text = email; lblPhone.Text = phone; // Save it to the database DBMaster dbm = new DBMaster(); // Craft the query string values = string.Format("VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}')", fName, lName, user, password, address, email, phone); string query = "INSERT INTO person (firstName, lastName, userName, password, address, email, phone) " + values; // Open a connection & execute the queries string id = dbm.ExecuteWithScope(query); // Save the user's ID for other pages. Session["userID"] = id; // Save the user's name as well, since the main index page responds to userID. Session["fName"] = fName; //System.Diagnostics.Debug.WriteLine("######### query: " + query); //System.Diagnostics.Debug.WriteLine("######### id: " + id.ToString()); // Finally, close the connection. dbm.CloseConnection(); } }
protected void btnLogin_Click(object sender, EventArgs e) { // Get login info string user = txtUser.Text; string password = txtPassword.Text; // Create query string query = string.Format( "SELECT firstName, id FROM person WHERE userName = '******' AND password = '******'", user, password); //System.Diagnostics.Debug.WriteLine("######### query: " + query); // Open connection and execute query DBMaster dbm = new DBMaster(); SqlDataReader reader = dbm.GetReader(query); // If login is successful, reader will have data if (reader.Read()) { // Save user's name & id string fName = reader["firstName"].ToString(); string id = reader["id"].ToString(); // Save session info Session["fName"] = fName; Session["userID"] = id; // Greet user lblGreet.Text = string.Format("Welcome {0}!", fName); // Toggle login box and logout button ShowLogin(false); } else { // Display error message lblGreet.Text = "Sorry, the provided information did not match any of our records."; } // Close the connection dbm.CloseConnection(); }
public void Insert(List<String> groups) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); foreach (var group in groups) { try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); command.CommandText = "INSERT INTO Groups (id_vk) VALUES (\"" + group + "\")"; command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } dbMaster.CloseConnection(); }
public void Insert(List<Friend> friends) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); foreach (var friend in friends) { try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); command.CommandText = "INSERT INTO Friends (id_vk) VALUES (\"" + friend.GetVkId() + "\")"; command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } dbMaster.CloseConnection(); }
public void Insert(int idFriend, List<Group> groups) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); foreach (var group in groups) { try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); command.CommandText = "INSERT INTO Groupsfriends (id_friend, id_group) " + "VALUES (" + idFriend + ", " + group.GetId() + ")"; command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } dbMaster.CloseConnection(); }
public void Insert(List<ListFriends> listFriendses) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); foreach (var listFriends in listFriendses) { try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); command.CommandText = "INSERT INTO ListFriends (id_user, id_friend) " + "VALUES (" + listFriends.GetIdUser() + ", " + listFriends.GetIdFriend() + ")"; command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } dbMaster.CloseConnection(); }
/// <summary> /// ?? /// </summary> public static void Start() { if (!File.Exists(Config.DBMasterPath)) { DBMaster.Create(); } //?????? DBMaster.Open(); ListDB = new List <DatabaseEntity>(); ListDB.Add(DBMaster.DB); //??????? DataTableEntity modelDT = new DataTableEntity { Name = "Database" }; modelDT = DataTableManage.Read(DBMaster.DB, modelDT); string[] listColumn = new string[] { "Name" }; List <DataRowEntity> listDR = DataRowManage.Read(modelDT, new string[] { "ID", "Name", "Path" }, new DataWhereEntity[] { new DataWhereEntity { ColumnName = "ID", Predicate = info => Convert.ToInt32(info) != 1 } }); //???? foreach (DataRowEntity modelDR in listDR) { DatabaseEntity modelDB = new DatabaseEntity { MasterFile = new DataFileEntity { FilePath = modelDR.Contents[2].ToString() } }; DatabaseManage.Read(modelDB); modelDB.ID = Convert.ToInt32(modelDR.Contents[0]); ListDB.Add(modelDB); } IsRun = true; }
public void Insert(Top.Entity.Top top) { DBMaster dbMaster = new DBMaster(); dbMaster.OpenConnection(); try { MySqlCommand command = dbMaster.GetConnection().CreateCommand(); foreach (var lineTop in top.GetDictionaryTops()) { command.CommandText = "INSERT INTO tops (id_group, count, data, id_user) " + "VALUES (" + lineTop.Key + ", " + lineTop.Value + ", DATE_FORMAT(CURRENT_DATE(), '%Y-%m-%d'), " + top.GetUserID() + ")"; command.ExecuteNonQuery(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } dbMaster.CloseConnection(); }
protected void Page_Load(object sender, EventArgs e) { // check if user logged in if (Session["ID"] == null) { Response.Redirect("../index.aspx"); } // Vars string ID = Session["ID"].ToString(), // user ID PID = Request.QueryString["id"], // product id passed from product page query = "select * from [dbo].[person] where id = '" + ID + "'", // query to get personal details of user emailMsg = "", // msg that will be emailed to customer customerName = "", // first name of customer customerAddress = "", // customer's address customerEmail = "", // customer's email productName = "", // name of product with PID productPrice = ""; // price of product with PID uint productAmount = 0; // uint ensures positive values only // Establish DB connection dbm = new DBMaster(); // Get reader for DB SqlDataReader reader = dbm.getReader(query); if (reader.Read()) // ensure that valid id was passed { customerAddress = reader["address"].ToString(); customerName = reader["firstName"].ToString(); customerEmail = reader["email"].ToString(); } else // Session ID is incorrect, force user to log in again { Session["ID"] = null; Response.Redirect("../index.aspx"); } // get new reader for person table reader.Close(); query = "select * from [dbo].[products] where pid = '" + PID + "'"; reader = dbm.getReader(query); if (reader.Read()) { productName = reader["productName"].ToString(); productPrice = reader["price"].ToString(); string temp = reader["currentAmount"].ToString(); // temp storage try // this will fail if currentAmount is not a positive integer { if (!UInt32.TryParse(temp, out productAmount)) { throw new FormatException("invalid database entry 'currentAmount'"); // the conversion did not succeed } // end if (!UInt32.TryParse(temp, out productAmount)) } // end try catch (FormatException error) { reader.Close(); // close reader query = "update [dbo].[products] set [currentAmount] = '0' where pid = '" + PID + "'"; dbm.executeQuery(query); // set currentAmount to 0 to correct this error Msg.Text = "We are sorry, the item you attempted to purchase is out of stock. You will be redirected shortly."; // display error to user Thread.Sleep(5000); // allow time for user to read error dbm.closeConnection(); // close connection to db Response.Redirect("productPage.aspx?error=" + error.Message); // return user to product page } // end catch } // end if (reader.Read()) else // the PID passed was invalid { Response.Redirect("productPage.aspx"); } // update DB to account for the sale query = "update [dbo].[products] set [currentAmount] = '" + (productAmount - 1) + "' where pid = '" + PID + "'"; dbm.executeQuery(query); // close connection dbm.closeConnection(); // send email to customer emailMsg = "Hi " + customerName + " Thank you for your purchase of " + productName + ". <br /> Your credit card on file will be charged $" + productPrice + ", and the item will be shipped to your address at: <br /> " + customerAddress + " <br /> We hope to see you again soon!"; sendEmail(customerEmail, emailMsg); // display message to user that sale was completed Msg.Text = "Thank you for your purchase, " + customerName + ". <br /> Your credit card on file will be charged $" + productPrice + " for your purchase of " + productName + ", and the item will be shipped to your address at: <br /> " + customerAddress + " <br /> We hope to see you again soon! <br /> <br /> <b>Note:</b> A copy of this invoice will also be sent to your email on file."; }
public MasterPresenter(IMasterView oView, DBMaster oGC) : base(oView) { oIGestCat = oGC; oIView.eSearchMenu += SearchUsuario_Presenter; }
protected void Page_Load(object sender, EventArgs e) { // check if user logged in if (Session["ID"] == null) { Response.Redirect("../index.aspx"); } // Connect to DB dbm = new DBMaster(); // vars string query = "select * from [dbo].[products] where currentAmount > 0", productName, productDescription, productPrice, productID; // get reader SqlDataReader reader = dbm.getReader(query); // read from DB while (reader.Read()) { // read values from DB productName = reader["productName"].ToString(); productDescription = reader["description"].ToString(); productPrice = reader["price"].ToString(); productID = reader["pid"].ToString(); // create new row TableRow row = new TableRow(); // create the 4 cells TableCell nCell = new TableCell(); // name TableCell dCell = new TableCell(); // description TableCell pCell = new TableCell(); // price TableCell bCell = new TableCell(); // buy link nCell.Attributes.Add("class", "cells"); dCell.Attributes.Add("class", "cells"); pCell.Attributes.Add("class", "cells"); bCell.Attributes.Add("class", "cells"); // create buy link HtmlAnchor buyLink = new HtmlAnchor(); buyLink.Attributes.Add("style", "color: #003B6F"); // change from default(silver) to blue buyLink.HRef = "buyNow.aspx?id=" + productID; buyLink.InnerText = "Buy Now"; // set cell text nCell.Text = productName; dCell.Text = productDescription; pCell.Text = "$" + productPrice; bCell.Controls.Add(buyLink); // add cells to row row.Cells.Add(nCell); row.Cells.Add(dCell); row.Cells.Add(pCell); row.Cells.Add(bCell); // add row to table productTable.Rows.Add(row); } // end while(reader.Read()) // close connection to db dbm.closeConnection(); } // end method Page_Load(object sender, EventArgs e)
public static void sendPurchaseConfirmation(Yoga_User user, Pass_Log pl, string purchaseType) { DBMaster db = new DBMaster(); Class_Passes pass = db.getClassPasse(pl.Pass_Id); Promotion p = db.getPromotionByPassId(pl.Pass_Id); SmtpClient client = new SmtpClient("smtp.gmail.com", 587); client.EnableSsl = true; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "xkcd1701"); MailMessage msobj = new MailMessage(); msobj.To.Add(user.U_Email); msobj.From = new MailAddress("*****@*****.**"); msobj.Subject = "Confirmation of " + purchaseType + " Purchase from Samsara Yoga"; msobj.IsBodyHtml = true; if (p == null || p.Promo_End < DateTime.Now.Date) { decimal tax = ((pass.Pass_Price) * (decimal).15); msobj.Body = "<h1 style='color:#557ee6;'>Saṃsāra Yoga</h1><p>Thank you for your recent " + purchaseType.ToLower() + " purchase from Samsara Yoga. Details of this transaction are below:</p><br/>Transaction ID: " + pl.Invoice_Number + "<br/>Transaction Date: " + pl.Date_Purchased + "<br/><br/>Purchased Item: " + pass.Pass_Name + "<br/><br/>‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑<br/><br/>Unit Price: " + pass.Pass_Price.ToString("F") + "<br/>Tax: " + tax.ToString("F") + "<br>Total: " + (tax + pass.Pass_Price).ToString("F") + "$"; client.Send(msobj); } else { if (p.Promo_End.Date > DateTime.Today && p.Num_Classes == 0) { decimal discount = decimal.Round((pass.Pass_Price * (decimal)p.Discount * -1), 2); decimal tax = ((pass.Pass_Price + discount) * (decimal).15); msobj.Body = "<h1 style='color:#557ee6;'>Saṃsāra Yoga</h1>" + "<p>Thank you for your recent " + purchaseType.ToLowerInvariant() + " purchase from Samsara Yoga. Details of this transaction are below:</p><br/>Transaction ID: " + pl.Invoice_Number + "<br/>Transaction Date: " + pl.Date_Purchased + "<br/><br/>Purchased Item: " + pass.Pass_Name + "<br/>Promotion: " + p.Promo_Desc + " " + (int)(p.Discount * 100) + "% Off<br/><br>‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑<br/><br/>Unit Price: " + pass.Pass_Price.ToString("F") + "<br/>Discount: " + discount.ToString("F") + "<br/><br/>Subtotal: " + (discount + pass.Pass_Price).ToString("F") + "<br/>Total: " + (tax + pass.Pass_Price + discount).ToString("F") + "$"; client.Send(msobj); } else { decimal tax = ((pass.Pass_Price) * (decimal).15); msobj.Body = "<h1 style='color:#557ee6;'>Saṃsāra Yoga</h1><p>Thank you for your recent " + purchaseType.ToLowerInvariant() + " purchase from Samsara Yoga. Details of this transaction are below:</p><br/>Transaction ID: " + pl.Invoice_Number + "<br/>Transaction Date: " + pl.Date_Purchased + "<br/><br/>Purchased Item: " + pass.Pass_Name + "<br/>Promotion: " + p.Promo_Desc + " +" + p.Num_Classes + " Passes<br/><br/>‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑<br/><br/>Unit Price: " + pass.Pass_Price.ToString("F") + "<br/>Tax: " + tax.ToString("F") + "<br>Total: " + (tax + pass.Pass_Price).ToString("F") + "$"; client.Send(msobj); } } }
protected void Page_Load(object sender, EventArgs e) { // Verify a user is logged in if (Session["userID"] == null) { // Passing status to main page via GET to let it handle // the no logged in user situation. Response.Redirect("~/index.aspx?status=nologin"); } else { //System.Diagnostics.Debug.WriteLine("######### id: " + Session["userID"].ToString()); // Retrieve user's name string user = Session["fName"].ToString(); // Greet user lblGreet.Text = user + ", here are our current products:"; DBMaster dbm = new DBMaster(); // Create Query string query = "SELECT pid, productName, description, price " + "FROM products WHERE currentAmount > 0 ORDER BY productName ASC"; //System.Diagnostics.Debug.WriteLine("######### query: " + query); // Open connection and execute Query. SqlDataReader reader = dbm.GetReader(query); // Display the found products while (reader.Read()) { double price2 = 0.0; // Get the current record string pid = reader["pid"].ToString(); string product = reader["productName"].ToString(); string description = reader["description"].ToString(); string price = reader["price"].ToString(); HtmlAnchor link = new HtmlAnchor(); // Create the link control. link.HRef = "oneclickBuy.aspx?id=" + pid; // Since I'm selling ice cream, humorously saying lick to buy. link.InnerText = "Single Lick Buy\x2122"; // Let's see if I can successfully format the price as 00.00 if (double.TryParse(price, out price2)) { price = string.Format("{0:C}", price2); } else { // The chances of this executing are slim to none since // price is in the database as a number. price = "$" + price; } // Create a Table Row and cells TableRow trRow = new TableRow(); TableCell tcProduct = new TableCell(); TableCell tcDescription = new TableCell(); TableCell tcPrice = new TableCell(); TableCell tcBuy = new TableCell(); // Populate the row cells tcProduct.Text = product; tcDescription.Text = description; tcPrice.Text = price; tcBuy.Controls.Add(link); // Add the cells to the Row trRow.Cells.Add(tcProduct); trRow.Cells.Add(tcDescription); trRow.Cells.Add(tcPrice); trRow.Cells.Add(tcBuy); // And add the row to the table tblProducts.Rows.Add(trRow); } // Close the connection. dbm.CloseConnection(); } }
protected void Page_Load(object sender, EventArgs e) { // Verify a user is logged in if (Session["userID"] == null) { // Passing status to main page via GET to let it handle the no // logged-in user situation. Response.Redirect("~/index.aspx?status=nologin"); } else { const string BUSINESS = "Ice Cream Internet Parlor"; DBMaster dbm = new DBMaster(); SqlDataReader reader = null; string query = ""; string product = ""; string price = ""; string address = ""; string email = ""; string id = Session["UserID"].ToString(); // Retrieve user's name from Session string fName = Session["fName"].ToString(); string lName = ""; // Get id from URL string pid = Request.QueryString["id"]; string message = "Hi! " + fName; double price2 = 0.0; // First, get product name & price query = "SELECT productName, price FROM products WHERE pid = " + pid; // Execute the query reader = dbm.GetReader(query); if (reader.Read()) { product = reader["productName"].ToString(); price = reader["price"].ToString(); // Make Price look like a proper price (2 significant digits) if (double.TryParse(price, out price2)) { price = string.Format("{0:C}", price2); } else { // The chances of this executing are slim to none since // price is in the database as a number. price = "$" + price; } } dbm.CloseReader(); // Done with the reader, for now. // Second, decrement the amount query = "UPDATE products SET currentAmount -= 1 WHERE pid = " + pid; dbm.ExecuteNonQuery(query); // Third, get user's address. query = "SELECT * FROM person WHERE id = " + id; // Get the needed info from the person table. reader = dbm.GetReader(query); if (reader.Read()) { address = reader["address"].ToString(); email = reader["email"].ToString(); lName = reader["lastName"].ToString(); } // We have all the pieces we need from the database. dbm.CloseReader(); dbm.CloseConnection(); // Build up the message; the Greeting line is already added. message += string.Format( "<p>Thank you for purchasing <b>{0}</b>. " + "Your credit card on file will be charged <b>{1}</b><br/>" + "Your purchase will be shipped to: <b>{2}</b></p>" + "<p>Thanks for shopping at {3}! " + "It is a pleasure doing business with you.</p>", product, price, address, BUSINESS); divGreet.InnerHtml = message; /* No point in running the rest of the code if there is no from email and * password - JK * // Get sender credentials * string fromEmail = ""; * string fromPassword = ""; * * // Combine first and last names into one string * string toName = string.Format("{0} {1}", fName, lName); * * // Create a MailMessage object * MailAddress from = new MailAddress(fromEmail, BUSINESS); * MailAddress to = new MailAddress(email, toName); * MailMessage mail = new MailMessage(from, to); * * // Build the email * mail.Subject = "Your order from " + BUSINESS; * mail.Body = message; * // And tell message we're using HTML * mail.IsBodyHtml = true; * * // Set SMTP for gmail * SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587); * * // Provide the credentials * smtp.Credentials = new NetworkCredential(fromEmail, fromPassword); * smtp.EnableSsl = true; * * // Send the email * smtp.Send(mail); */ } }
protected void Page_Load(object sender, EventArgs e) { //Establish connection to database, retrieve the latest entry, just for demonstratino purposes DBMaster dbm = new DBMaster(); SqlDataReader reader = dbm.getReader("SELECT TOP 1 * FROM [dbo].[tblFullname] ORDER BY ID DESC"); string userName = ""; while (reader.Read()) { userName += reader["Fullname"].ToString(); } dbm.closeConnection(); //user Greeting userGreeting.Text += userName; //This retrives the user's tags from the database //string[] userTagArr = new string[100]; List <string> userTagList = new List <string>(); //int n = 0; SqlDataReader reader1 = dbm.getReader("SELECT * FROM tblPersontags WHERE Fullname='" + userName + "'"); while (reader1.Read()) { //userTagArr[n] = reader1["tag"].ToString(); //n++; userTagList.Add(reader1["tag"].ToString().TrimEnd()); } dbm.closeConnection(); //This populates the URL dictionary Dictionary <string, string> siteURL = new Dictionary <string, string>(); SqlDataReader reader2 = dbm.getReader("SELECT * FROM [dbo].[tblSiteurl] ORDER BY ID DESC"); while (reader2.Read()) { string sitenametemp = reader2["Sitename"].ToString(); string sitelinktemp = reader2["Siteurl"].ToString(); siteURL.Add(sitenametemp, sitelinktemp); } dbm.closeConnection(); //This populates the tag dictionary string temp2 = ""; Dictionary <string, int> siteCompatibilityIndex = new Dictionary <string, int>(); foreach (KeyValuePair <string, string> x in siteURL) { //string[] siteTagArr = new string[100]; List <string> siteTagList = new List <string>(); //int i = 0; SqlDataReader reader3 = dbm.getReader("SELECT * FROM tblSitetags WHERE Sitename='" + x.Key + "'"); while (reader3.Read()) { siteTagList.Add(reader3["Sitetag"].ToString().TrimEnd()); //siteTagArr[i] = reader3["Sitetag"].ToString(); //i++; } dbm.closeConnection(); TagHandler tagHandler = new TagHandler(); int compatibilityIndex = userTagList.Intersect(siteTagList).Count(); siteCompatibilityIndex.Add(x.Key.ToString(), compatibilityIndex); //temp2 += x.Key.ToString(); //temp2 += compatibilityIndex; //temp2 += "</br>"; } //lbl_test.Text = temp2; var top5 = siteCompatibilityIndex.OrderByDescending(pair => pair.Value).Take(5) .ToDictionary(pair => pair.Key, pair => pair.Value); //Populate the links with the best-fit sites int recommendedSiteCount = 0; string[] recommendedSites = new string[5]; foreach (KeyValuePair <string, int> x in top5) { recommendedSites[recommendedSiteCount] = x.Key; recommendedSiteCount++; } HyperLink0.Text = recommendedSites[0]; HyperLink0.NavigateUrl = siteURL[recommendedSites[0]]; HyperLink1.Text = recommendedSites[1]; HyperLink1.NavigateUrl = siteURL[recommendedSites[1]]; HyperLink2.Text = recommendedSites[2]; HyperLink2.NavigateUrl = siteURL[recommendedSites[2]]; HyperLink3.Text = recommendedSites[3]; HyperLink3.NavigateUrl = siteURL[recommendedSites[3]]; HyperLink4.Text = recommendedSites[4]; HyperLink4.NavigateUrl = siteURL[recommendedSites[4]]; }
/// <summary> /// ?? /// </summary> public static void Stop() { DBMaster.Close(); IsRun = false; }