public static void delete(Docente docente) { int i = -1; string sql = @"DELETE FROM docentes WHERE (legajo = @legajo)"; SqlConnection cn = new SqlConnection(); cn.ConnectionString = "Data Source=ALEBELTRAMEN\\ALEJANDRA;Initial Catalog=ASA;Integrated Security=True"; try { cn.Open(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.AddWithValue("@legajo", docente.legajo); cmd.ExecuteNonQuery(); PersonaDao.delete(docente.docente); } catch (SqlException ex) { throw new ApplicationException("Error al eliminar el Docente" + ex.Message); } finally { cn.Close(); } }
public static void delete(Alumno alumno) { string sql = @"DELETE FROM alumnos WHERE (legajo = @legajo) SELECT CAST(scope_identity() AS int)"; SqlConnection cn = new SqlConnection(); cn.ConnectionString = "Data Source=ALEBELTRAMEN\\ALEJANDRA;Initial Catalog=ASA;Integrated Security=True"; try { cn.Open(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.AddWithValue("@legajo", alumno.legajo); cmd.ExecuteScalar(); PersonaDao.delete(alumno.alumno); PersonaDao.delete(alumno.madre); PersonaDao.delete(alumno.padre); } catch (SqlException ex) { throw new ApplicationException("Error al eliminar el Alumno" + ex.Message); } finally { cn.Close(); } }