public bool addJiaoWu(string JiaoWuName, int JiaoWuID, int JiaoWuMajorID) { SsContext db = new SsContext(); JiaoWu j = new JiaoWu(); j.UserID = addUser(JiaoWuName, 1, JiaoWuID.ToString()); j.JiaoWuID = JiaoWuID; j.JiaoWuMajorID = JiaoWuMajorID; j.JiaoWuName = JiaoWuName; db.JiaoWus.Add(j); db.SaveChanges(); return(true); }
private bool testJiaoWu(int userId, string Passwd) { List <JiaoWu> ps = dbhelper.getJiaoWuByJId(userId); //dbhelper.getProfessorByProId(userId); if (ps.Count == 0) { return(false); } else { JiaoWu p = ps[0]; User u = dbhelper.getUserByUserId(p.UserID); if (u.UserPassword == Passwd) { return(true); } } return(false); }
public bool deleteJiaoWuById(int id) { try { SsContext db = new SsContext(); List <JiaoWu> ps = db.JiaoWus.Where(s => s.UserID == id).ToList(); JiaoWu p = null; for (int i = 0; i < ps.Count; i++) { p = ps[i]; db.JiaoWus.Remove(p); } deleteUserById(id); db.SaveChanges(); } catch (Exception e) { return(false); } return(true); }