// GET: Admin/HocViManagement/Delete/5 public ActionResult Delete(int id) { HocVi hocVi = hocViRepository.GetById(id); hocViRepository.Delete(hocVi); return(RedirectToAction("Index")); }
private void buttonThem_Click(object sender, EventArgs e) { try { HocVi hocvi = new HocVi(); hocvi.HocViId = 1; hocvi.TenHocVi = TenHocViTextEdit.Text; DialogResult dr = XtraMessageBox.Show($"Bạn có chắc chắn muốn thêm học vị '{TenHocViTextEdit.Text} không?'", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); switch (dr) { case DialogResult.Yes: _hocViRepository.Add(hocvi); XtraMessageBox.Show("Thêm học vị thành công"); this.Close(); break; case DialogResult.No: XtraMessageBox.Show("Huỷ thêm học vị"); break; } } catch (Exception ex) { XtraMessageBox.Show($"Thêm học vị thất bại.... Lỗi {ex.ToString()}", "Lỗi ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task <ActionResult> DeleteConfirmed(int id) { HocVi hocVi = await db.HocVis.FindAsync(id); db.HocVis.Remove(hocVi); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult Edit(HocVi hocVi) { if (ModelState.IsValid) { hocViRepository.Update(hocVi); return(RedirectToAction("Index")); } return(View(hocVi)); }
public async Task <ActionResult> Edit([Bind(Include = "MaHocVi,TenVietTat,TenHocVi")] HocVi hocVi) { if (ModelState.IsValid) { db.Entry(hocVi).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(hocVi)); }
public HttpResponseMessage PostHocVi([FromBody] HocVi HocVi) { try { _repository.Add(HocVi); return(Request.CreateResponse(HttpStatusCode.OK, HocVi)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Lỗi không xác định", ex)); } }
public async Task <ActionResult> Create([Bind(Include = "MaHocVi,TenVietTat,TenHocVi")] HocVi hocVi) { if (ModelState.IsValid) { db.HocVis.Add(hocVi); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(hocVi)); }
// GET: AdminHocVi/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HocVi hocVi = await db.HocVis.FindAsync(id); if (hocVi == null) { return(HttpNotFound()); } return(View(hocVi)); }
public ActionResult DonViCharts(string viettat_hocham_hocvi) { List <List <Object> > data = new List <List <Object> >(); List <DonViQL> listDVQL = db.DonViQLs.ToList(); HocVi hvi = db.HocVis.SingleOrDefault(p => p.TenVietTat == viettat_hocham_hocvi); if (hvi != null) { foreach (var item_donVi in listDVQL) { List <Object> row = new List <Object>() { item_donVi.TenDonVI }; var hocViTheoDonVi = db.NhaKhoaHocs.Where(nkh => nkh.MaDonViQL == item_donVi.MaDonVi) .Join( db.HocVis.Where(hv => hv.TenVietTat == viettat_hocham_hocvi), nkh => nkh.MaHocVi, hocvis => hocvis.MaHocVi, (nkh, hocvis) => new { nkh.MaNKH }) .Select(nkh_hvis => new { nkh_hvis.MaNKH }); var soHV_theoDonVi = hocViTheoDonVi.Count(); row.Add(soHV_theoDonVi); data.Add(row); } } else { foreach (var item_donVi in listDVQL) { List <Object> row = new List <Object>() { item_donVi.TenDonVI }; var hocHamTheoDonVi = db.NhaKhoaHocs.Where(nkh => nkh.MaDonViQL == item_donVi.MaDonVi) .Join( db.HocHams.Where(hh => hh.TenVietTat == viettat_hocham_hocvi), nkh => nkh.MaHocVi, hochams => hochams.MaHocHam, (nkh, hocvis) => new { nkh.MaNKH }) .Select(nkh_hvis => new { nkh_hvis.MaNKH }); var soHH_theoDonVi = hocHamTheoDonVi.Count(); row.Add(soHH_theoDonVi); data.Add(row); } } return(PartialView(data)); }
public IList <HocVi> LayTatCaHocVi(string maGV) { IList <HocVi> listHocVi = new List <HocVi>(); string str = "LayHocViChuaNhan '" + maGV + "'"; DataTable data = new DataTable(); data = Server.LayDuLieuBang(str); foreach (DataRow item in data.Rows) { HocVi = new HocVi { MaHocVi = item["MaHocVi"].ToString(), TenHocVi = item["TenHocVi"].ToString() }; listHocVi.Add(HocVi); } return(listHocVi); }
public HttpResponseMessage Put([FromBody] HocVi HocVi, int id) { var HocViCheck = _repository.Get(id); try { if (HocViCheck != null) { _repository.Update(HocVi, id); return(Request.CreateResponse(HttpStatusCode.OK, HocVi)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "HocVi Not Found")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Lỗi không xác định", ex)); } }
private void btnThenHV_Click(object sender, EventArgs e) { if (dtpNgayNhanHV.Checked && cbbHocVi.Text != "") { string maHV = ((HocVi)cbbHocVi.SelectedItem).MaHocVi; if (new GiaoVienDAL().ThemHocVi(maGV, maHV, dtpNgayNhanHV.Text)) { HocVi hv = new HocVi { MaHocVi = maHV, TenHocVi = cbbHocVi.Text, NgayNhan = dtpNgayNhanHV.Text }; ttHocVi.Add(hv); taiTTHocVi(); LyLichKhoaHoc(); MessageBox.Show("Cập nhật thành công"); } else { MessageBox.Show("Lỗi! Cập nhật thất bại"); } } }
// GET: Admin/HocViManagement/Edit/5 public ActionResult Edit(int id) { HocVi hocVi = hocViRepository.GetById(id); return(View(hocVi)); }