public ActionResult AddMaster(master_table data) { db.master_table.RemoveRange(db.master_table); db.master_table.Add(data); db.SaveChanges(); return(RedirectToAction("Master", "Master")); }
public ActionResult Delete() { DB_Model db = new DB_Model(); db.tableData.RemoveRange(db.tableData); db.SaveChanges(); return(RedirectToAction("CurrentDataPage", "CurrentDataPage")); }
private void AddRecordToDataBase(Product product) { using (DB_Model db = new DB_Model()) { db.Product.Add(product); db.SaveChanges(); } this.DialogResult = DialogResult.OK; this.Close(); }
private void RemoveProductFromDB(object sender, EventArgs e) { Product product = ((sender as MetroButton).Parent as SearchedProducts_Control).Product; GiveUserInfo_Form form = new GiveUserInfo_Form("Czy chcesz trwale usunąć element '" + product.Name + "' z bazy?"); if (form.DialogResult == DialogResult.OK) { using (var db = new DB_Model()) { db.Entry(product).State = EntityState.Deleted; db.SaveChanges(); } splitContainer1.Panel2.Controls.Clear(); } }