public ActionResult DeleteConfirmed(int id) { catalogue catalogue = db.catalogues.Find(id); db.catalogues.Remove(catalogue); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(catalogue catalogue) { if (ModelState.IsValid) { db.catalogues.Add(catalogue); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catalogue)); }
private void btnSave_Click(object sender, EventArgs e) { try { catalogue cat = new catalogue(); CatalogueDB catDB = new CatalogueDB(); cat.catalogueID = txtID.Text; cat.description = txtDescription.Text; cat.status = ComboFIll.getStatusCode(cmbCatalogueStatus.SelectedItem.ToString()); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btn.Text; btnText = btnSave.Text; if (btnText.Equals("Update")) { if (catDB.updateCatalogue(cat)) { MessageBox.Show("Catalogue updated"); closeAllPanels(); ListCatalogue(); } else { MessageBox.Show("Failed to update Catalogue Status"); } } else if (btnText.Equals("Save")) { if (catDB.validateCatalogue(cat)) { if (catDB.insertCatalogue(cat)) { MessageBox.Show("Catalogue Added"); closeAllPanels(); ListCatalogue(); } else { MessageBox.Show("Failed to Insert Catalogue"); } } else { MessageBox.Show("Catalogue Data Validation failed"); } } } catch (Exception) { MessageBox.Show("Failed Adding / Editing User Data"); } }
public ActionResult Edit(catalogue catalogue) { if (ModelState.IsValid) { var tem = db.catalogues.Where(m => m.Id == catalogue.Id).FirstOrDefault(); tem.CatalogueCode = catalogue.CatalogueCode; tem.CatalogueName = catalogue.CatalogueName; tem.MetaGroupId = catalogue.MetaGroupId; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catalogue)); }
// GET: /Catalogue/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } catalogue catalogue = db.catalogues.Find(id); if (catalogue == null) { return(HttpNotFound()); } return(View(catalogue)); }
// GET: /Catalogue/Edit/5 public ActionResult Edit(int?id) { ViewBag.ListMetagroup = db.metagrups.ToList(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } catalogue catalogue = db.catalogues.Find(id); if (catalogue == null) { return(HttpNotFound()); } return(View(catalogue)); }
private void Catalogue_Click(object sender, RoutedEventArgs e) { catalogue cat = new catalogue(); cat.Show(); }