private void insertAccountBtn_Click(object sender, EventArgs e) { Food aa = new Food(); aa.FoodId = this.textBox1.Text; aa.FoodName = this.textBox2.Text; aa.FoodPrice = float.Parse(this.textBox4.Text); //aa.D FoodRepository re = new FoodRepository(); if (re.Insert(aa)) { // List<Account> accList = accRepo.GetAllAccounts(); // this.accountGridView.DataSource = accList MessageBox.Show("Insert Complete"); textBox1.Text = " "; textBox2.Text = " "; textBox4.Text = " "; } else { MessageBox.Show("Insert Not Complete", "Error"); } }
protected void btnSave_Click(object sender, EventArgs e) { try { fm.FoodGroupId = Convert.ToInt32(FoodGroupDropDown.SelectedItem.Value); fm.CookingLevel = CookingLevelDropDown.SelectedItem.Value; //fm.NotFriendly = NotFriendlyForDropDown.SelectedItem.Value; fm.Name = Name.Text.ToLower().ToString(); fm.Calorie = Calorie.Text.ToString(); fm.Materials = Materials.Text.ToLower().ToString(); fm.Servings = Servings.Text.ToString(); fm.Recipe = Recipe.Text.ToLower().ToString(); fm.IslamUse = CheckBox1.Checked; fm.INCUse = CheckBox2.Checked; bool res = fr.Insert(fm); if (res) { string message = "Saving info was successfully"; string script = "window.onload = function(){ alert('"; script += message; script += "')};"; ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Inserted Successfully')", true); } else { string message = "Saving info was not successfully"; string script = "window.onload = function(){ alert('"; script += message; script += "')};"; ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true); } GetData(); addNew.Visible = false; showList.Visible = true; } catch (Exception ex) { le.SaveLogError(ex); } }
public int Insert(Food cat) { return(foodRepo.Insert(cat)); }