private void btnthem_Click(object sender, EventArgs e) { int sonv = 0; if (txtMaDA.Text.Trim() == "") { MessageBox.Show("Mã dự án không được để trống !"); } else if (txtTenDA.Text.Trim() == "") { MessageBox.Show("Tên dự án không được để trống !"); } else { DUAN da = new DUAN(); da.id_Da = txtMaDA.Text; da.name_Da = txtTenDA.Text; da.sonv_Da = Convert.ToInt32(txtSoNVDA.Text); da.mota_Da = txtMotaDA.Text; db.DUANs.Add(da); db.SaveChanges(); } Quanliduan_Load(sender, e); }
private void btnLuu_Click(object sender, EventArgs e) { try { DUAN da = new DUAN(); //gán giá trị từ textbox vào các biến da.MaDuAn = int.Parse(txtMaDA.Text); da.TenDuAn = txtTenDA.Text; da.DiaDiem = txtDiaDiem.Text; da.MaPhongBan = int.Parse(txtMaPB.Text); da.TongSoGio = int.Parse(txtTongSoGio.Text); //thêm hoặc apdate bản ghi dự án db.DUANs.AddOrUpdate(da); //lưu thay đổi db.SaveChanges(); MessageBox.Show("Thêm dữ liệu thành công!"); btnLamMoi_Click(sender, e); } catch (Exception) { MessageBox.Show("Một hoặc nhiều thông tin đang trống!\nXin hãy kiểm tra lại."); return; } }
public ActionResult DeleteConfirmed(string id) { DUAN dUAN = db.DUANs.Find(id); db.DUANs.Remove(dUAN); db.SaveChanges(); return(RedirectToAction("Index")); }
private void btnXoa_Click(object sender, EventArgs e) { DUAN da = db.DUANs.FirstOrDefault(da1 => da1.id_Da == txtMaDA.Text); db.DUANs.Remove(da); db.SaveChanges(); Quanliduan_Load(sender, e); }
public ActionResult Edit([Bind(Include = "MaDuAn,TenDuAn,MaNhanVien,Ngaybatdau,Ngaygiahan,Ngayketthuc,SoLuong,DonGia,ChietKhau")] DUAN dUAN) { if (ModelState.IsValid) { db.Entry(dUAN).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dUAN)); }
public ActionResult Create([Bind(Include = "MaDuAn,TenDuAn,MaNhanVien,Ngaybatdau,Ngaygiahan,Ngayketthuc,SoLuong,DonGia,ChietKhau")] DUAN dUAN) { if (ModelState.IsValid) { db.DUANs.Add(dUAN); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dUAN)); }
public ActionResult Edit([Bind(Include = "MaDA,TenDA,DiaDiem,MaPB")] DUAN dUAN) { if (ModelState.IsValid) { db.Entry(dUAN).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaPB = new SelectList(db.PHONGBANs, "MaPB", "TenPB", dUAN.MaPB); return(View(dUAN)); }
public ActionResult Edit([Bind(Include = "TenDuAn,MaDuAn,MaNV")] DUAN dUAN) { if (ModelState.IsValid) { db.Entry(dUAN).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaDuAn = new SelectList(db.CHITIETDUANs, "MaDuAn", "TenDuAn", dUAN.MaDuAn); return(View(dUAN)); }
public ActionResult Create([Bind(Include = "MaDA,TenDA,DiaDiem,MaPB")] DUAN dUAN) { if (ModelState.IsValid) { db.DUANs.Add(dUAN); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaPB = new SelectList(db.PHONGBANs, "MaPB", "TenPB", dUAN.MaPB); return(View(dUAN)); }
public ActionResult Create([Bind(Include = "TenDuAn,MaDuAn,MaNV")] DUAN dUAN) { if (ModelState.IsValid) { db.DUANs.Add(dUAN); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaDuAn = new SelectList(db.CHITIETDUANs, "MaDuAn", "TenDuAn", dUAN.MaDuAn); return(View(dUAN)); }
private void btnSua_Click(object sender, EventArgs e) { DUAN da = db.DUANs.FirstOrDefault(da1 => da1.id_Da == txtMaDA.Text); da.id_Da = txtMaDA.Text; da.name_Da = txtTenDA.Text; da.sonv_Da = Convert.ToInt32(txtSoNVDA.Text); da.mota_Da = txtMotaDA.Text; db.SaveChanges(); Quanliduan_Load(sender, e); }
// GET: DUANs/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DUAN dUAN = db.DUANs.Find(id); if (dUAN == null) { return(HttpNotFound()); } return(View(dUAN)); }
public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DUAN dUAN = db.DUANs.Find(id); if (dUAN == null) { return(HttpNotFound()); } ViewBag.MaPB = new SelectList(db.PHONGBANs, "MaPB", "TenPB", dUAN.MaPB); return(View(dUAN)); }