public int addstudent(string stunum, string sname, int gender, string startyear, int collegeid) { UserService userService = new UserService(); int uid, sid = 0; uid = userService.insert(stunum, "123456", 1); if (uid != 0) { StudentService studentService = new StudentService(); sid = studentService.insert(uid, stunum, sname, gender, startyear, collegeid); } return sid; }
public int addteacher(TeacherModel teacherModel) { UserService userService = new UserService(); int uid, tid = 0; uid = userService.insert(teacherModel.Tname, "123456", 2); if (uid != 0) { teacherModel.Uid = uid; TeacherService teacherService = new TeacherService(); tid = teacherService.insert(teacherModel); //这里将来要模拟实现事务,如果tid为0,则删除user表里的记录 } return tid; }