public void addFavorit(Favorit f) { //get user event and insert the event to the event table con = new SqlConnection(conString); con.Open(); string sqlString = "INSERT INTO FavoritTable (UserName,BusName)" + "VALUES ('" + f.UserName + "','" + f.BusName + "');"; SqlCommand com = new SqlCommand(sqlString, con); com.ExecuteReader(); con.Close(); }
protected void addFav_Click(object sender, EventArgs e) { Favorit f = new Favorit(user, busN); try { eBL.addFavorit(f); favText.Text = "Adding succeeded favorites"; } catch { favText.Text = "This page exists in favorites"; } }
public void deleteFavorit(Favorit f) { //get user event and delete this event con = new SqlConnection(conString); con.Open(); string sqlString = "DELETE FROM FavoritTable WHERE UserName='******' AND BusName= '" + f.BusName + "';"; SqlCommand com = new SqlCommand(sqlString, con); try { com.ExecuteReader(); con.Close(); } catch { con.Close(); } }
public LinkedList <Favorit> getFavorit(string user) { con.Open(); string sqlString = "Select * from FavoritTable where UserName='******';"; SqlCommand com = new SqlCommand(sqlString, con); SqlDataReader rdr = com.ExecuteReader(); LinkedList <Favorit> favorits = new LinkedList <Favorit>(); Favorit f; while (rdr.Read()) { f = new Favorit((string)rdr[0], (string)rdr[1]); favorits.AddFirst(f); } con.Close(); return(favorits); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.CompareTo("deleterow") == 0) { int row = int.Parse(e.CommandArgument.ToString()); string name = table.Rows[row].Cells[colName].Text.Trim(); Favorit f = new Favorit((string)(Session["user"]), name); eBL.deleteFavorit(f); Response.Redirect("~/myFavorit.aspx"); } if (e.CommandName.CompareTo("linkRow") == 0) { int row = int.Parse(e.CommandArgument.ToString()); string name = table.Rows[row].Cells[colName].Text.Trim(); Session.Add("nameBuss", name); Response.Redirect("~/business.aspx"); } }
public void addFavorit(Favorit f) { eventD.addFavorit(f); }
public void deleteFavorit(Favorit f) { eventD.deleteFavorit(f); }