protected void Insert(DocenteCurso docCurso) { try { this.OpenConnection(); SqlCommand cmdSave = new SqlCommand( "INSERT INTO docentes_cursos (id_curso, id_docente, cargo)" + "values(@id_curso, @id_docente, @cargo)" + "select @@identity", SqlConn); cmdSave.Parameters.Add("@id", SqlDbType.Int).Value = docCurso.ID; cmdSave.Parameters.Add("@id_curso", SqlDbType.Int).Value = docCurso.IDCurso; cmdSave.Parameters.Add("@id_docente", SqlDbType.Int).Value = docCurso.IDDocente; cmdSave.Parameters.Add("@cargo", SqlDbType.Int).Value = docCurso.GetIDTipoCargo(); docCurso.ID = Decimal.ToInt32((decimal)cmdSave.ExecuteScalar()); } catch (Exception Ex) { Exception ExcepcionManejada = new Exception("Error al insertar el docente_curso", Ex); throw ExcepcionManejada; } finally { this.CloseConnection(); } }
protected void Update(DocenteCurso docCurso) { try { this.OpenConnection(); SqlCommand cmdSave = new SqlCommand("UPDATE docentes_cursos SET " + "id_curso = @id_curso, " + "id_docente = @id_docente, " + "cargo = @cargo " + "WHERE id_dictado=@id", SqlConn); cmdSave.Parameters.Add("@id", SqlDbType.Int).Value = docCurso.ID; cmdSave.Parameters.Add("@id_curso", SqlDbType.Int).Value = docCurso.IDCurso; cmdSave.Parameters.Add("@id_docente", SqlDbType.Int).Value = docCurso.IDDocente; cmdSave.Parameters.Add("@cargo", SqlDbType.Int).Value = docCurso.GetIDTipoCargo(); cmdSave.ExecuteNonQuery(); } catch (Exception Ex) { Exception ExcepcionManejada = new Exception("Error al actualizar el docente_curso", Ex); throw ExcepcionManejada; } finally { this.CloseConnection(); } }