public int DelHocPhan(string id) { try { HocPhan x = db.HocPhans.Where(s => s.ID_HocPhan.Trim() == id.Trim()).FirstOrDefault(); if (x == null) { return(1); // không tìm thấy học phần } else { if (db.LopHocPhans.Where(s => s.ID_HocPhan.Trim() == id.Trim()).Count() > 0) { return(2); //có lớp học phần ko thể xóa } else { db.HocPhans.Remove(x); db.SaveChanges(); return(0); //Xóa thành công; } } } catch (Exception) { return(3);//lỗi } }
public void Update(HocPhan hp) { temp = db.HocPhans.Where(tp => tp.MaHP.Equals(hp.MaHP)).First(); temp.TenHP = hp.TenHP; temp.SoTietLT = hp.SoTietLT; temp.SoTietTH = hp.SoTietTH; db.SubmitChanges(); }
public eHocPhan AddNewHocPhan(eHocPhan hp) { try { HocPhan x = new HocPhan(); x.ID_HocPhan = hp.ID_HocPhan; x.TenMonHoc = hp.TenMonHoc; x.SoTC = hp.SoTC; db.HocPhans.Add(x); db.SaveChanges(); return(hp); } catch { return(null); } }
public eHocPhan EditHocPhan(string id, eHocPhan hp) { try { HocPhan x = db.HocPhans.Where(m => m.ID_HocPhan == id).FirstOrDefault(); if (x == null) { return(null); } else { x.TenMonHoc = hp.TenMonHoc; x.SoTC = hp.SoTC; db.SaveChanges(); return(hp); } } catch { return(null); } }
partial void DeleteHocPhan(HocPhan instance);
partial void UpdateHocPhan(HocPhan instance);
partial void InsertHocPhan(HocPhan instance);
public void Update(HocPhan hp) { dal.Update(hp); }
public List<HocPhan> Search(HocPhan hp) { return dal.Search(hp); }
public void Insert(HocPhan hp) { dal.Insert(hp); }
public void Delete(HocPhan hp) { dal.Delete(hp); }
public List<HocPhan> Search(HocPhan hp) { return db.HocPhans.Where(tp => tp.MaHP.Equals(hp.MaHP)).ToList(); }
public void Insert(HocPhan hp) { db.HocPhans.InsertOnSubmit(hp); db.SubmitChanges(); }
public void Delete(HocPhan hp) { temp = db.HocPhans.Where(tp=>tp.MaHP.Equals(hp.MaHP)).First(); db.HocPhans.DeleteOnSubmit(temp); db.SubmitChanges(); }