public ActionResult DeleteConfirmed(string id) { HeDaoTao heDaoTao = contextHDT.GetById(id); contextHDT.Delete(id); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(string id) { HeDaoTao heDaoTao = db.HeDaoTaos.Find(id); db.HeDaoTaos.Remove(heDaoTao); db.SaveChanges(); return(RedirectToAction("Index")); }
private void btnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { heDaoTao = new HeDaoTao(txtMaHe.Text, txtTenHe.Text); if (BUS.HeDaoTaoDAO.Instance.Remove(heDaoTao) > 0) { loadHeDaoTao(); clear(); } }
private void btnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { heDaoTao = new HeDaoTao(txtMaHe.Text, txtTenHe.Text); if (BUS.HeDaoTaoDAO.Instance.Update(heDaoTao, maHeDaoTaoOld) > 0) { loadHeDaoTao(); clear(); } }
public ActionResult Edit([Bind(Include = "MaHDT,TenHDT,GhiChu")] HeDaoTao heDaoTao) { if (ModelState.IsValid) { contextHDT.Edit(heDaoTao); return(RedirectToAction("Index")); } return(View(heDaoTao)); }
public ActionResult Edit([Bind(Include = "MaHeDaoTao,TenHeDaoTao")] HeDaoTao heDaoTao) { if (ModelState.IsValid) { db.Entry(heDaoTao).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(heDaoTao)); }
public ActionResult Create([Bind(Include = "MaHeDaoTao,TenHeDaoTao")] HeDaoTao heDaoTao) { if (ModelState.IsValid) { db.HeDaoTaos.Add(heDaoTao); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(heDaoTao)); }
// GET: HeDaoTaos/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HeDaoTao heDaoTao = db.HeDaoTaos.Find(id); if (heDaoTao == null) { return(HttpNotFound()); } return(View(heDaoTao)); }
public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HeDaoTao heDaoTao = contextHDT.GetById(id); if (heDaoTao == null) { return(HttpNotFound()); } return(View(heDaoTao)); }
public void Edit(HeDaoTao hdt) { if (hdt == null) { return; } try { contextHdt.Edit(hdt); } catch (Exception ex) { Console.WriteLine(ex); } }
public HeDaoTao GetById(string id) { HeDaoTaoDAO context = new HeDaoTaoDAO(); try { HeDaoTao hdt = contextHdt.GetById(id); return(hdt); } catch (Exception ex) { Console.WriteLine(ex); return(null); } }
public bool Delete(string maHdt) { if (string.IsNullOrEmpty(maHdt)) { return(false); } try { HeDaoTao gv = contextHdt.GetById(maHdt); if (gv != null) { contextHdt.Delete(maHdt); return(true); } return(false); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
public int Create(HeDaoTao hdt) { if (hdt == null) { return(-1); } try { HeDaoTao gv = contextHdt.GetById(hdt.MaHDT); if (gv != null) { return(0); } contextHdt.Create(hdt); return(1); } catch (Exception ex) { Console.WriteLine(ex); return(2); } }
//Thêm private void button1_Click(object sender, EventArgs e) { string err = ""; if (txtName.Text == "") { err += "\nTên hệ đào tạo không được để trống"; } if (txtSem.Text == "") { err += "\nSố học kỳ không được để trống"; } else { try { if (int.Parse(txtSem.Text) <= 0) { err += "\nSố học kỳ phải lớn hơn 0"; } } catch (Exception) { err += "\nSố học kỳ phải là số"; } } if (err.Length == 0) { HeDaoTao hdt = new HeDaoTao(); hdt.tenHeDaoTao = txtName.Text; hdt.soHocKy = Convert.ToInt32(txtSem.Text); if (rdoShow.Checked) { hdt.trangThai = 1; } else { hdt.trangThai = 0; } //Thêm và DB _ctx.HeDaoTaos.InsertOnSubmit(hdt); try { //lưu thay đổi trên DB _ctx.SubmitChanges(); //Thông báo MessageBox.Show("Thêm mới thành công", "Hệ thống", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { MessageBox.Show("Thêm mới thất bại", "Hệ thống", MessageBoxButtons.OK, MessageBoxIcon.Information); } //load load_HDT(); resetForm(); } else { MessageBox.Show(err, "Hệ thống", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }