protected void btnAddListItemIngredient_Click1(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var ing = from fdc in db.Ingredients.Where(fdc => fdc.IngredientName == txtIngredient.Text) select fdc; //checks to see if the item is in the database if (ing.Any()) { //If something exists, then don't add //print error message lblIngredientInsert.Text = "Ingredient Is Already In the Hotel Restaurant"; lblIngredientInsert.Visible = true; //reset txtIngredient to " " txtCategory.Text = ""; } else { //add ingredient to database Ingredient addIngredient = new Ingredient(); addIngredient.IngredientName = txtIngredient.Text; //addIngredient.IngredientDescription = txtIngredientComments.Text; db.Ingredients.InsertOnSubmit(addIngredient); db.SubmitChanges(); lblIngredientInsert.Text = "Insert Successful"; lblIngredientInsert.Visible = true; ddlIngredients.DataBind(); txtIngredient.Text = ""; txtIngredientComments.Text = ""; //make text box invisible again. //make text box } }
partial void UpdateIngredient(Ingredient instance);
partial void DeleteIngredient(Ingredient instance);
partial void InsertIngredient(Ingredient instance);