correccion en numerod e cuenta null
This commit is contained in:
+38
-36
@@ -52,55 +52,57 @@ app.post('/registroPersona', async(req, res) => {
|
||||
// console.log(results.length);
|
||||
|
||||
if (results.length == 0) {
|
||||
if (req.body.noCuenta != null) {
|
||||
await connection.query(`select * from persona where noCuenta=${req.body.noCuenta};`,
|
||||
async(error, results, fields) => {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error al verificar el numero de cuenta' });
|
||||
if (req.query.noCuenta == null)
|
||||
req.query.noCuenta = -999;
|
||||
await connection.query(`select * from persona where noCuenta=${req.body.noCuenta};`,
|
||||
async(error, results, fields) => {
|
||||
if (error) {
|
||||
res.status(400).json({ err: true, mjs: 'error al verificar el numero de cuenta' });
|
||||
|
||||
return;
|
||||
}
|
||||
if (results.length > 0) {
|
||||
res.status(400).json({ err: true, mjs: 'el numero de cuenta ya esta registrado' });
|
||||
return;
|
||||
}
|
||||
if (results.length > 0) {
|
||||
res.status(400).json({ err: true, mjs: 'el numero de cuenta ya esta registrado' });
|
||||
|
||||
return;
|
||||
} else {
|
||||
await connection.query(`insert into persona values (${req.body.est}, '${req.body.noCuenta}', ${req.body.promedio},
|
||||
return;
|
||||
} else { //insert into persona values(null, '312312', 8.9, 'daniel', 'ramirez', 'homrbe', 21, 'daniel|gmail.com','avanzado', 'externo', 'dasdasda', 'chido', 'acturia', )
|
||||
if (req.query.noCuenta == -999)
|
||||
req.query.noCuenta = null;
|
||||
await connection.query(`insert into persona values (${req.body.est}, '${req.body.noCuenta}', ${req.body.promedio},
|
||||
'${req.body.nombre}', '${req.body.apellidos}', '${req.body.sexo}', ${req.body.edad}, '${req.body.correo}',
|
||||
'${req.body.nivelIngles}', '${req.body.comunidad}' , '${pass}', '${req.body.facultad}' , '${req.body.gradoAcademico}',
|
||||
'${req.body.nombrePrograma}' , '${req.body.semestre}', ${req.body.titulado}, ${req.body.recibir_info} );`,
|
||||
function(e, r, f) {
|
||||
if (e) {
|
||||
res.status(400).json({ err: true, mjs: 'error al registrar en la base' });
|
||||
function(e, r, f) {
|
||||
if (e) {
|
||||
res.status(400).json({ err: true, mjs: 'error al registrar en la base' });
|
||||
|
||||
return;
|
||||
return;
|
||||
|
||||
}
|
||||
let id = 2;
|
||||
connection.query(`select idPersona from persona where correo='${req.body.correo}';`,
|
||||
}
|
||||
let id = 2;
|
||||
connection.query(`select idPersona from persona where correo='${req.body.correo}';`,
|
||||
|
||||
function(e, r, f) {
|
||||
if (e) {
|
||||
res.status(400).json({
|
||||
err: true,
|
||||
mjs: 'error al registrar en select '
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
// console.log(r);
|
||||
//id = r[0];
|
||||
res.status(200).json({ err: false, idPersona: r[0].idPersona, msj: 'Registro completo' });
|
||||
function(e, r, f) {
|
||||
if (e) {
|
||||
res.status(400).json({
|
||||
err: true,
|
||||
mjs: 'error al registrar en select '
|
||||
});
|
||||
|
||||
return;
|
||||
});
|
||||
}
|
||||
// console.log(r);
|
||||
//id = r[0];
|
||||
res.status(200).json({ err: false, idPersona: r[0].idPersona, msj: 'Registro completo' });
|
||||
|
||||
});
|
||||
return;
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user