<?php require '../Modelo/Estudiante.php'; require '../DAO/estudianteDAO.php'; isset($_REQUEST['id']) ? $id = $_REQUEST['id'] : ($id = ""); isset($_REQUEST['codigo']) ? $codigo = $_REQUEST['codigo'] : ($codigo = ""); isset($_REQUEST['nombre']) ? $nombre = $_REQUEST['nombre'] : ($nombre = ""); isset($_REQUEST['apellido']) ? $apellido = $_REQUEST['apellido'] : ($apellido = ""); isset($_REQUEST['cedula']) ? $cedula = $_REQUEST['cedula'] : ($cedula = ""); isset($_REQUEST['edad']) ? $edad = $_REQUEST['edad'] : ($edad = ""); isset($_REQUEST['semestre']) ? $semestre = $_REQUEST['semestre'] : ($semestre = ""); isset($_REQUEST['type']) ? $accion = $_REQUEST['type'] : ($accion = ""); $estudiante = new Estudiante($id, $codigo, $nombre, $apellido, $cedula, $edad, $semestre); $dao = new estudianteDAO(); switch ($accion) { case "save": $dao->guardar($estudiante); break; case "list": $dao->listar($estudiante); break; case "search": $dao->buscar($estudiante); break; case "update": $dao->modificar($estudiante); break; case "delete": $dao->eliminar($estudiante); break; }
function hayOpcionChequeada(frm) { arrObjs = frm.elements; for(i=0; i < arrObjs.length; i++){ if(arrObjs[i].type === 'radio' && arrObjs[i].checked === true){ return true; } } return false; } </script> </head> <body> <?php $edao = new estudianteDAO(); $estudiante = $edao->leerTodos(); ?> <form name="form1" method="post" action="ctlEstudiante"> <table width="757" border="1" cellspacing="1" cellpadding="1"> <caption> PERSONAS </caption> <tr> <th width="34" align="center" scope="col"> </th> <th width="139" scope="col">idDocente</th> <th width="135" scope="col">Nombres</th> <th width="137" scope="col">Apellidos</th> <th width="131" scope="col">Telefono</th> <th width="138" scope="col">email</th <th width="148" scope="col">Dirección</th>
public function modificar(estudianteDAO $obj) { $sql = "UPDATE estudiante set codigo=" . $obj->getCodigo() . ",nombre='" . $obj->getNombre() . "',apellido='" . $obj->getApellido() . "',cedula=" . $obj->getCedula() . ",edad=" . $obj->getEdad() . ",semestre=" . $obj->getSemestre() . " where id=" . $obj->getId() . ""; $resultado = $this->objCon->Ejecutar($sql); $this->objCon->respuesta($resultado); }
<?php include '../Modelo/clsEstudiante.php'; include '../DAO/estudianteDAO.php'; isset($_POST['id']) ? $id = $_POST['id'] : ($id = ""); isset($_POST['codigo']) ? $codigo = $_POST['codigo'] : ($codigo = ""); isset($_POST['nombre']) ? $nombre = $_POST['nombre'] : ($nombre = ""); isset($_POST['apellido']) ? $apellido = $_POST['apellido'] : ($apellido = ""); isset($_POST['cedula']) ? $cedula = $_POST['cedula'] : ($cedula = ""); isset($_POST['edad']) ? $edad = $_POST['edad'] : ($edad = ""); isset($_POST['semestre']) ? $semestre = $_POST['semestre'] : ($semestre = ""); isset($_POST['type']) ? $accion = $_POST['type'] : ($accion = ""); $estudiante = new clsEstudiante($id, $codigo, $nombre, $apellido, $cedula, $edad, $semestre); $conex = new estudianteDAO(); switch ($accion) { case "save": $conex->guardar($estudiante); break; case "search": $conex->buscar($estudiante); break; case "delete": $conex->eliminar($estudiante); break; case "update": $conex->modificar($estudiante); break; case "list": $conex->listar(); break; default:
<?php include dirname(__FILE__) . '\\..\\Modelo\\Estudiante.php'; include dirname(__FILE__) . '\\..\\Modelo\\Mapeador.php'; include dirname(__FILE__) . '\\..\\dao\\estudianteDAO.php'; $estudiante = new Estudiante(); $mensaje = ""; $datos = array('idEstudiantes' => $_POST['Estudiante']['idEstudiantes'], 'nombres' => $_POST['Estudiante']['nombres'], 'apellidos' => $_POST['Estudiante']['apellidos'], 'telefono' => $_POST['Estudiante']['telefono'], 'email' => $_POST['Estudiante']['email'], 'direccion' => $_POST['Estudiante']['direccion'], 'fecha' => $_POST['Estudiante']['fecha']); Mapeador::mapearEstudiante($estudiante, $datos); $estudianteDAO = new estudianteDAO(); try { if (array_key_exists("agregar", $_POST)) { $retorno = $estudianteDAO->insertarEstudiante($estudiante); } elseif (array_key_exists("modificar", $_POST)) { $retorno = $estudianteDAO->actualizarEstudiante($estudiante); } elseif (array_key_exists("eliminar", $_POST)) { $retorno = $estudianteDAO->eliminarEstudiante($estudiante); } } catch (Exception $ex) { $mensaje = "HA OCURRIDO UN ERROR!!!: " . $ex->getMessage(); } echo $mensaje . "<p/><a href='../indexEstudiante.php'>Regresar al inicio</a>";