/// <summary> /// 根据学员对象发生异常 /// </summary> /// <param name="student"></param> /// <returns></returns> public int DeleteStudent(Students student) { return(db.Delete(student)); var sql = "delete from Students where StudentId=" + student.StudentId; try { return(SQLHelper.ExecuteNonQuery(sql, null)); } catch (SqlException ex) { if (ex.Number == 547) { throw new Exception("该学员被其他数据表引用,不能直接删除"); } else { throw new Exception("删除学员时数据库操作异常:\r\n" + ex.Message); } } catch (Exception ex) { throw ex; } }