Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
proyecto-estandar
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Israel Gutierrez Salazar
proyecto-estandar
Commits
082e885b
Commit
082e885b
authored
Jan 10, 2018
by
Alonso Moreno Postigo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Arreglado bug al realizar acciones en la fila
parent
79700058
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
57 deletions
+63
-57
PersonaSqlserverDAO.java
src/java/demojsoncrud/sqlserverdao/PersonaSqlserverDAO.java
+39
-37
ResponseHelper.java
src/java/demojsoncrud/utils/ResponseHelper.java
+12
-11
persona.js
web/js/pages/persona.js
+12
-9
No files found.
src/java/demojsoncrud/sqlserverdao/PersonaSqlserverDAO.java
View file @
082e885b
...
@@ -36,15 +36,15 @@ public class PersonaSqlserverDAO implements PersonaDAO {
...
@@ -36,15 +36,15 @@ public class PersonaSqlserverDAO implements PersonaDAO {
try
{
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
String
sql
=
"select "
=
"select "
+
"a.codigo, "
+
"a.codigo, "
+
"a.dni, "
+
"a.dni, "
+
"a.apellidos, "
+
"a.apellidos, "
+
"a.nombres, "
+
"a.nombres, "
+
"a.edad, "
+
"a.edad, "
+
"a.correo, "
+
"a.correo, "
+
"a.estado "
+
"a.estado "
+
"from persona a "
;
+
"from persona a "
;
psListarPersona
=
connection
.
prepareStatement
(
sql
);
psListarPersona
=
connection
.
prepareStatement
(
sql
);
rsListarPersona
=
psListarPersona
.
executeQuery
();
rsListarPersona
=
psListarPersona
.
executeQuery
();
...
@@ -63,7 +63,10 @@ public class PersonaSqlserverDAO implements PersonaDAO {
...
@@ -63,7 +63,10 @@ public class PersonaSqlserverDAO implements PersonaDAO {
data
.
put
(
obj
);
data
.
put
(
obj
);
}
}
response
.
setData
(
data
);
JSONObject
jsonData
=
new
JSONObject
();
jsonData
.
put
(
"personas"
,
data
);
response
.
setData
(
jsonData
);
response
.
setMessage
(
"Listado correcto!"
);
response
.
setMessage
(
"Listado correcto!"
);
response
.
setStatus
(
true
);
response
.
setStatus
(
true
);
...
@@ -116,18 +119,18 @@ public class PersonaSqlserverDAO implements PersonaDAO {
...
@@ -116,18 +119,18 @@ public class PersonaSqlserverDAO implements PersonaDAO {
try
{
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
String
sql
=
"select top "
+
length
+
" "
=
"select top "
+
length
+
" "
+
"a.codigo, "
+
"a.codigo, "
+
"a.dni, "
+
"a.dni, "
+
"a.apellidos, "
+
"a.apellidos, "
+
"a.nombres, "
+
"a.nombres, "
+
"a.edad, "
+
"a.edad, "
+
"a.correo, "
+
"a.correo, "
+
"a.estado "
+
"a.estado "
+
"from persona a "
+
"from persona a "
+
"where a.codigo not in (select top "
+
start
+
" b.codigo from persona b order by 1 desc) "
+
"where a.codigo not in (select top "
+
start
+
" b.codigo from persona b order by 1 desc) "
+
condicion
+
" "
+
condicion
+
" "
+
"order by 1 desc"
;
+
"order by 1 desc"
;
psListarPersona
=
connection
.
prepareStatement
(
sql
);
psListarPersona
=
connection
.
prepareStatement
(
sql
);
rsListarPersona
=
psListarPersona
.
executeQuery
();
rsListarPersona
=
psListarPersona
.
executeQuery
();
...
@@ -143,7 +146,6 @@ public class PersonaSqlserverDAO implements PersonaDAO {
...
@@ -143,7 +146,6 @@ public class PersonaSqlserverDAO implements PersonaDAO {
personaBean
.
setCorreo
(
rsListarPersona
.
getString
(
c
++));
personaBean
.
setCorreo
(
rsListarPersona
.
getString
(
c
++));
personaBean
.
setEstado
(
rsListarPersona
.
getString
(
c
++));
personaBean
.
setEstado
(
rsListarPersona
.
getString
(
c
++));
JSONObject
obj
=
new
JSONObject
(
personaBean
);
JSONObject
obj
=
new
JSONObject
(
personaBean
);
obj
.
put
(
"item"
,
numeroFilas
++);
data
.
put
(
obj
);
data
.
put
(
obj
);
}
}
...
@@ -205,8 +207,8 @@ public class PersonaSqlserverDAO implements PersonaDAO {
...
@@ -205,8 +207,8 @@ public class PersonaSqlserverDAO implements PersonaDAO {
if
(
resultDni
==
0
)
{
if
(
resultDni
==
0
)
{
String
sql
String
sql
=
"insert into persona (dni, apellidos, nombres, edad, correo, estado) values "
=
"insert into persona (dni, apellidos, nombres, edad, correo, estado) values "
+
"(?,RTRIM(UPPER(?)),RTRIM(UPPER(?)),?,RTRIM(UPPER(?)),1)"
;
+
"(?,RTRIM(UPPER(?)),RTRIM(UPPER(?)),?,RTRIM(UPPER(?)),1)"
;
int
c
=
1
;
//contador para las columnas
int
c
=
1
;
//contador para las columnas
psInsertarPersona
=
connection
.
prepareStatement
(
sql
);
psInsertarPersona
=
connection
.
prepareStatement
(
sql
);
psInsertarPersona
.
setString
(
c
++,
bean
.
getDni
());
psInsertarPersona
.
setString
(
c
++,
bean
.
getDni
());
...
@@ -262,12 +264,12 @@ public class PersonaSqlserverDAO implements PersonaDAO {
...
@@ -262,12 +264,12 @@ public class PersonaSqlserverDAO implements PersonaDAO {
try
{
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
String
sql
=
"update persona "
=
"update persona "
+
"set apellidos = RTRIM(UPPER(?)), "
+
"set apellidos = RTRIM(UPPER(?)), "
+
"nombres = RTRIM(UPPER(?)), "
+
"nombres = RTRIM(UPPER(?)), "
+
"edad = ?, "
+
"edad = ?, "
+
"correo = RTRIM(UPPER(?)) "
+
"correo = RTRIM(UPPER(?)) "
+
"where codigo = ?"
;
+
"where codigo = ?"
;
psEditarPersona
=
connection
.
prepareStatement
(
sql
);
psEditarPersona
=
connection
.
prepareStatement
(
sql
);
int
q
=
1
;
// CONTADOR PARA LAS COLUMNAS
int
q
=
1
;
// CONTADOR PARA LAS COLUMNAS
...
@@ -320,9 +322,9 @@ public class PersonaSqlserverDAO implements PersonaDAO {
...
@@ -320,9 +322,9 @@ public class PersonaSqlserverDAO implements PersonaDAO {
try
{
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
String
sql
=
"update persona "
=
"update persona "
+
"set estado = 1 "
+
"set estado = 1 "
+
"where codigo = ?"
;
+
"where codigo = ?"
;
psEditarPersona
=
connection
.
prepareStatement
(
sql
);
psEditarPersona
=
connection
.
prepareStatement
(
sql
);
...
@@ -371,9 +373,9 @@ public class PersonaSqlserverDAO implements PersonaDAO {
...
@@ -371,9 +373,9 @@ public class PersonaSqlserverDAO implements PersonaDAO {
try
{
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
String
sql
=
"update persona "
=
"update persona "
+
"set estado = 0 "
+
"set estado = 0 "
+
"where codigo = ?"
;
+
"where codigo = ?"
;
psEditarPersona
=
connection
.
prepareStatement
(
sql
);
psEditarPersona
=
connection
.
prepareStatement
(
sql
);
psEditarPersona
.
setString
(
1
,
bean
.
getCodigo
());
psEditarPersona
.
setString
(
1
,
bean
.
getCodigo
());
...
...
src/java/demojsoncrud/utils/ResponseHelper.java
View file @
082e885b
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
package
demojsoncrud
.
utils
;
package
demojsoncrud
.
utils
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
org.json.JSONObject
;
/**
/**
*
*
...
@@ -13,7 +14,7 @@ import java.io.Serializable;
...
@@ -13,7 +14,7 @@ import java.io.Serializable;
*/
*/
public
class
ResponseHelper
implements
Serializable
{
public
class
ResponseHelper
implements
Serializable
{
private
Object
data
;
private
JSON
Object
data
;
private
boolean
status
;
private
boolean
status
;
private
String
message
;
private
String
message
;
...
@@ -21,28 +22,28 @@ public class ResponseHelper implements Serializable {
...
@@ -21,28 +22,28 @@ public class ResponseHelper implements Serializable {
}
}
public
boolean
isStatus
()
{
public
JSONObject
getData
()
{
return
status
;
return
data
;
}
}
public
void
setStatus
(
boolean
status
)
{
public
boolean
isStatus
(
)
{
this
.
status
=
status
;
return
status
;
}
}
public
String
getMessage
()
{
public
String
getMessage
()
{
return
message
;
return
message
;
}
}
public
void
set
Message
(
String
message
)
{
public
void
set
Data
(
JSONObject
data
)
{
this
.
message
=
message
;
this
.
data
=
data
;
}
}
public
Object
getData
(
)
{
public
void
setStatus
(
boolean
status
)
{
return
data
;
this
.
status
=
status
;
}
}
public
void
set
Data
(
Object
data
)
{
public
void
set
Message
(
String
message
)
{
this
.
data
=
data
;
this
.
message
=
message
;
}
}
}
}
web/js/pages/persona.js
View file @
082e885b
...
@@ -36,8 +36,13 @@ function listarPersonaTest() {
...
@@ -36,8 +36,13 @@ function listarPersonaTest() {
beforeSend
:
function
(
xhr
)
{
beforeSend
:
function
(
xhr
)
{
// console.log('Antes de...');
// console.log('Antes de...');
},
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
},
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
// console.log(data);
console
.
log
(
data
);
// console.log("listadoTest");
// var personas = data.data.personas;
// for (var i = 0; i < personas.length; i++) {
// var persona = personas[i];
// console.log(persona.apellidos);
// }
//// console.log("listadoTest");
},
complete
:
function
(
jqXHR
,
textStatus
)
{
},
complete
:
function
(
jqXHR
,
textStatus
)
{
// console.log('Siempre ejecutará esta función');
// console.log('Siempre ejecutará esta función');
}
}
...
@@ -88,8 +93,8 @@ function registrarPersona() {
...
@@ -88,8 +93,8 @@ function registrarPersona() {
var
status
=
data
.
status
;
var
status
=
data
.
status
;
if
(
status
)
{
if
(
status
)
{
imprimirAlerta
(
'Correcto!'
,
data
.
message
,
'success'
);
imprimirAlerta
(
'Correcto!'
,
data
.
message
,
'success'
);
var
table
=
$
(
'#tabla_persona'
).
DataTable
();
//
var table = $('#tabla_persona').DataTable();
table
.
ajax
.
reload
();
//
table.ajax.reload();
recargarTabla
();
recargarTabla
();
$
(
'#modal_registrar_persona'
).
modal
(
'hide'
);
$
(
'#modal_registrar_persona'
).
modal
(
'hide'
);
}
else
{
}
else
{
...
@@ -194,7 +199,7 @@ function listarPersona() {
...
@@ -194,7 +199,7 @@ function listarPersona() {
ScrollCollapse
:
true
,
ScrollCollapse
:
true
,
columns
:
[
columns
:
[
{
data
:
"
item
"
},
{
data
:
"
codigo
"
},
{
data
:
"dni"
},
{
data
:
"dni"
},
{
{
data
:
null
,
data
:
null
,
...
@@ -254,8 +259,7 @@ $('#tabla_persona tbody').on('click', '.desactivarPersona', function () {
...
@@ -254,8 +259,7 @@ $('#tabla_persona tbody').on('click', '.desactivarPersona', function () {
var
json
=
{
var
json
=
{
codigo
:
data_row
.
codigo
codigo
:
data_row
.
codigo
};
};
alert
(
data_row
.
codigo
);
console
.
log
(
data_row
.
codigo
);
swal
({
swal
({
title
:
"¿Estás seguro?"
,
title
:
"¿Estás seguro?"
,
text
:
"¿Desea desactivar a "
+
data_row
.
apellidos
+
", "
+
data_row
.
nombres
+
" ?"
,
text
:
"¿Desea desactivar a "
+
data_row
.
apellidos
+
", "
+
data_row
.
nombres
+
" ?"
,
...
@@ -299,8 +303,7 @@ $('#tabla_persona tbody').on('click', '.activarPersona', function () {
...
@@ -299,8 +303,7 @@ $('#tabla_persona tbody').on('click', '.activarPersona', function () {
var
json
=
{
var
json
=
{
codigo
:
data_row
.
codigo
codigo
:
data_row
.
codigo
};
};
console
.
log
(
data_row
.
codigo
);
alert
(
data_row
.
codigo
);
swal
({
swal
({
title
:
"¿Estás seguro?"
,
title
:
"¿Estás seguro?"
,
text
:
"¿Desea activar a "
+
data_row
.
apellidos
+
", "
+
data_row
.
nombres
+
" ?"
,
text
:
"¿Desea activar a "
+
data_row
.
apellidos
+
", "
+
data_row
.
nombres
+
" ?"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment