public void update(Modelo.Disciplina disciplina) { Delete(disciplina); if (disciplina.existDocumento()) { Insert(disciplina); } }
public void Insert(Modelo.Disciplina obj) { SqlConnection conn = new SqlConnection(connectionString); conn.Open(); if (obj.idDisciplina == 0) { obj.idDisciplina = GetIdMax(); } SqlCommand cmd = new SqlCommand("INSERT INTO Disciplina (IdDisciplina, Disciplina) VALUES(@idDisciplina,@Disciplina)", conn); cmd.Parameters.AddWithValue("@idDisciplina", obj.idDisciplina); cmd.Parameters.AddWithValue("@Disciplina", obj.disciplina); cmd.ExecuteNonQuery(); if (obj.existDocumento()) { new DAL.DALDocumentoDisciplina().Insert(obj); } conn.Close(); }