Example #1
0
<?php

include dirname(__FILE__) . '\\..\\Modelo\\Asignatura.php';
include dirname(__FILE__) . '\\..\\Modelo\\Mapeador.php';
include dirname(__FILE__) . '\\..\\dao\\AsignaturaDAO.php';
$persona = new Asignatura();
$mensaje = "";
$datos = array('idAsignatura' => $_POST['Asignatura']['idAsignatura'], 'nombre' => $_POST['Asignatura']['Nombre'], 'contenido' => $_POST['Asignatura']['Contenido'], 'metodologia' => $_POST['Asignatura']['Metodologia'], 'bibliografia' => $_POST['Asignatura']['Bibliografia'], 'fecha' => $_POST['Asignatura']['Fecha']);
Mapeador::mapearAsignatura($persona, $datos);
$personaDAO = new AsignaturaDAO();
try {
    if (array_key_exists("agregar", $_POST)) {
        $retorno = $personaDAO->insertarAsignatura($persona);
    } elseif (array_key_exists("modificar", $_POST)) {
        $retorno = $personaDAO->actualizarAsignatura($persona);
    } elseif (array_key_exists("eliminar", $_POST)) {
        $retorno = $personaDAO->eliminarAsignatura($persona);
    }
} catch (Exception $ex) {
    $mensaje = "HA OCURRIDO UN ERROR!!!: " . $ex->getMessage();
}
echo $mensaje . "<p/><a href='../indexAsignatura.php'>Regresar al inicio</a>";
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title> Reporte de Asignaturas</title>
        <script type="text/javascript">
            
           function agregar(obj){
                var frm = obj.form;
                frm.action = 'Paginas/Agregar_asignatura.html';
                frm.submit();
            }
        </script>
    </head>
    <body>
        <?php 
$pdao = new AsignaturaDAO();
$personas = $pdao->leerTodos();
?>
    <form name="form1" method="post" action="">
    <table width="757" border="1" cellspacing="1" cellpadding="1">
      <caption>
        ASIGNATURAS
      </caption>
      <tr>
        <th width="34" align="center" scope="col">&nbsp;</th>
        <th width="139" scope="col">idAsignatura</th>
        <th width="135" scope="col">Nombre</th>
        <th width="137" scope="col">Contenido</th>
        <th width="138" scope="col">Metodologia</th>
        <th width="140" scope="col">Bibliografia</th>
        <th width="131" scope="col">fecha</th>