public override void Add_Item(Instructor item) { using (ElectiveContext db = new ElectiveContext()) { db.Instructors.Add(item); db.SaveChanges(); } }
public override void Delete_Item(int item) { using (ElectiveContext db = new ElectiveContext()) { db.Students.Remove(db.Students.FirstOrDefault(e => e.Id == item)); db.SaveChanges(); } }
public override void Add_Item(Subject item) { using (ElectiveContext db = new ElectiveContext()) { db.Subjects.Add(item); db.SaveChanges(); } }
/// <summary> /// 更新管理员登录时间 /// </summary> /// <param name="admin">管理员对象</param> public void UpdateLoginTime(SysAdmin admin) { if (admin != null) { admin.LastLoginTime = DateTime.Now; db.Entry(admin).State = EntityState.Modified; db.SaveChanges(); } }
public override void Add_Item(Student item) { using (ElectiveContext db = new ElectiveContext()) { var id = db.Students.Max(p => p.Id); item.Id = ++id; db.Students.Add(item); db.SaveChanges(); } }