private void addFavourite(int shopID) { string userName = Request.Cookies["user"].Value; db = new DbLayer(); int nMaxFavourite = db.getMaxFavouriteID(); db.insertFavourite(nMaxFavourite, userName, shopID); }
protected void Button1_Click(object sender, EventArgs e) { LinkButton btn = (LinkButton)sender; string userName = Request.Cookies["user"].Value; db = new DbLayer(); int nMaxFavourite = db.getMaxFavouriteID() + 1; if (!db.insertFavourite(nMaxFavourite, userName, int.Parse(btn.CommandArgument.ToString()))) { string script = "alert(\"Already Add Favourite!\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); return; } Response.Redirect("Search.aspx"); }