public ActionResult DeleteConfirmed(string id) { NhaXB nhaXB = db.NhaXBs.Find(id); db.NhaXBs.Remove(nhaXB); db.SaveChanges(); return(RedirectToAction("Index")); }
private void _btnsaveNXB_Click(object sender, RoutedEventArgs e) { MessageBoxResult re; re = MessageBox.Show("Bạn có muốn sửa không", "Lưu NXB", MessageBoxButton.YesNo, MessageBoxImage.Question); if (re == MessageBoxResult.Yes) { try { if (!_txtmanxb.Text.Equals("")) { NhaXB nxb = new NhaXB(); nxb = nxbControll.GetById(_txtmanxb.Text); nxb.TenNhaXB = _txttennxb.Text; string warning = ""; if (String.IsNullOrWhiteSpace(_txtmanxb.Text)) { warning += "Vui lòng nhập NXB." + '\n'; } if (String.IsNullOrWhiteSpace(_txttennxb.Text)) { warning += "Vui lòng nhập tên NXB." + '\n'; } if (!warning.Equals("")) { MessageBox.Show( warning, "Thêm mới thể loại", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (nxbControll.Edit(nxb)) { MessageBox.Show( "Cập nhật thành công", "Cập Nhật Thể Loại", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show( "Cập nhật thất bại", "Cập Nhật Thể Loại", MessageBoxButton.OK, MessageBoxImage.Information); } LoadNXBTable(); } } catch { } } }
public ActionResult Edit([Bind(Include = "TenNhaXB,MaNhaXB,DiaChi")] NhaXB nhaXB) { if (ModelState.IsValid) { db.Entry(nhaXB).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nhaXB)); }
private void gridNXB_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e) { try { NhaXuatBanModel select = gridNXB.SelectedItem as NhaXuatBanModel; NhaXB nxb = nxbControll.GetById(select.MaNXB); _txtmanxb.Text = nxb.MaNXB; _txttennxb.Text = nxb.TenNhaXB; } catch { } }
public ActionResult Create([Bind(Include = "TenNhaXB,MaNhaXB,DiaChi")] NhaXB nhaXB) { if (ModelState.IsValid) { db.NhaXBs.Add(nhaXB); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nhaXB)); }
public bool Insert(NhaXB NhaXB) { try { db.NhaXBs.Add(NhaXB); db.SaveChanges(); return(true); } catch { return(false); } }
public bool Update(NhaXB NhaXB) { try { NhaXB temp = getById(NhaXB.MaNXB); temp.TenNhaXB = NhaXB.TenNhaXB; db.SaveChanges(); return(true); } catch { return(false); } }
// GET: NhaXBs/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NhaXB nhaXB = db.NhaXBs.Find(id); if (nhaXB == null) { return(HttpNotFound()); } return(View(nhaXB)); }
// update public bool Update(NhaXB entity) { try { var xb = db.NhaXBs.Find(entity.MaNXB); xb.MaNXB = entity.MaNXB; xb.TenNXB = entity.TenNXB; xb.MoTa = entity.MoTa; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public JsonResult Delete(int id) { bool result = false; Sach ct = db.Saches.Where(x => x.MaNXB == id).FirstOrDefault(); if (ct == null) { NhaXB s = db.NhaXBs.Where(x => x.MaNXB == id).SingleOrDefault(); if (s != null) { new PublisherDao().Delete(id); db.SaveChanges(); result = true; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(NhaXB tt) { if (ModelState.IsValid) { var dao = new PublisherDao(); long id = dao.Insert(tt); if (id > 0) { SetAlert("Thêm nhà xuất bản thành công", "success"); return(RedirectToAction("Index", "Publisher")); } else { ModelState.AddModelError("", "Thêm nhà xuất bản không thành công"); } } return(View("Index")); }
public ActionResult Edit(NhaXB xb) { if (ModelState.IsValid) { var dao = new PublisherDao(); var result = dao.Update(xb); if (result) { SetAlert("Sửa thông tin nhà xuất bản thành công", "success"); return(RedirectToAction("Index", "Publisher")); } else { ModelState.AddModelError("", "Cập nhật thông tin nhà xuất bản không thành công"); } } return(View("Index")); }
private void LoadDB() { List <LinhVuc> listlv = lvbll.DSLV(); LinhVuc.DataSource = listlv; LinhVuc.DataTextField = "TenLinhVuc"; LinhVuc.DataValueField = "MaLinhVuc"; LinhVuc.DataBind(); List <TheLoai> listtl = tlbll.DSTL(); TheLoai.DataSource = listtl; TheLoai.DataTextField = "TenTheLoai"; TheLoai.DataValueField = "MaTheLoai"; TheLoai.DataBind(); List <NgonNgu> listnn = ngvbll.DSNgonNgu(); NgonNgu.DataSource = listnn; NgonNgu.DataTextField = "TenNgonNgu"; NgonNgu.DataValueField = "MaNgonNgu"; NgonNgu.DataBind(); List <TacGia> listtg = tgbll.DSTacGia(); tacgia.DataTextField = "HoTenTacGia"; tacgia.DataValueField = "MaTacGia"; tacgia.DataSource = listtg; tacgia.DataBind(); List <NhaXuatBan> listnxb = nxbbll.DSNXB(); NhaXB.DataSource = listnxb; NhaXB.DataTextField = "TenNXB"; NhaXB.DataValueField = "MaNXB"; NhaXB.DataBind(); List <Sach> mylist = sbll.DSSach(); grvSach.DataSource = mylist; grvSach.DataBind(); }
// Insert public long Insert(NhaXB entity) { db.NhaXBs.Add(entity); db.SaveChanges(); return(entity.MaNXB); }
public bool Add(NhaXB NhaXB) { return(_NhaXuatBanControls.Insert(NhaXB)); }
public bool Edit(NhaXB NhaXB) { return(_NhaXuatBanControls.Update(NhaXB)); }
private void _btnaddNXB_Click(object sender, RoutedEventArgs e) { try { if (_btnaddNXB.Content.Equals("Add new")) { _btnaddNXB.Content = "Hoàn tất"; _btnaddNXB_cancel.IsEnabled = true; _btnaddNXB_cancel.Visibility = Visibility.Visible; _btnsaveNXB.IsEnabled = false; _btndeleteNXB.IsEnabled = false; _btndeleteNXB.IsEnabled = false; _btnloadNXB.IsEnabled = false; gridNXB.IsEnabled = false; _txtmanxb.IsReadOnly = false; _txttennxb.Clear(); _txtmanxb.Clear(); return; } NhaXB nxb = new NhaXB(); nxb.MaNXB = _txtmanxb.Text.ToUpper(); nxb.TenNhaXB = _txttennxb.Text; string warning = ""; if (String.IsNullOrWhiteSpace(_txtmanxb.Text)) { warning += "Vui lòng nhập Mã NXB." + '\n'; } if (String.IsNullOrWhiteSpace(_txttennxb.Text)) { warning += "Vui lòng nhập tên NXB." + '\n'; } if (!warning.Equals("")) { MessageBox.Show( warning, "Thêm mới NXB", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (nxbControll.Add(nxb)) { MessageBox.Show( "Thêm mới thành công", "Thêm mới NXB", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show( "Thêm mới thất bại", "Thêm mới NXB", MessageBoxButton.OK, MessageBoxImage.Error); } _btnaddNXB.Content = "Add new"; _btnaddNXB_cancel.IsEnabled = false; _btnaddNXB_cancel.Visibility = Visibility.Hidden; _btnsaveNXB.IsEnabled = true; _btndeleteNXB.IsEnabled = true; _btndeleteNXB.IsEnabled = true; _btnloadNXB.IsEnabled = true; _txtmanxb.IsReadOnly = true; gridNXB.IsEnabled = true; LoadNXBTable(); } catch { } }