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 {
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
=
"select "
+
"a.codigo, "
+
"a.dni, "
+
"a.apellidos, "
+
"a.nombres, "
+
"a.edad, "
+
"a.correo, "
+
"a.estado "
+
"from persona a "
;
=
"select "
+
"a.codigo, "
+
"a.dni, "
+
"a.apellidos, "
+
"a.nombres, "
+
"a.edad, "
+
"a.correo, "
+
"a.estado "
+
"from persona a "
;
psListarPersona
=
connection
.
prepareStatement
(
sql
);
rsListarPersona
=
psListarPersona
.
executeQuery
();
...
...
@@ -63,7 +63,10 @@ public class PersonaSqlserverDAO implements PersonaDAO {
data
.
put
(
obj
);
}
response
.
setData
(
data
);
JSONObject
jsonData
=
new
JSONObject
();
jsonData
.
put
(
"personas"
,
data
);
response
.
setData
(
jsonData
);
response
.
setMessage
(
"Listado correcto!"
);
response
.
setStatus
(
true
);
...
...
@@ -116,18 +119,18 @@ public class PersonaSqlserverDAO implements PersonaDAO {
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
=
"select top "
+
length
+
" "
+
"a.codigo, "
+
"a.dni, "
+
"a.apellidos, "
+
"a.nombres, "
+
"a.edad, "
+
"a.correo, "
+
"a.estado "
+
"from persona a "
+
"where a.codigo not in (select top "
+
start
+
" b.codigo from persona b order by 1 desc) "
+
condicion
+
" "
+
"order by 1 desc"
;
=
"select top "
+
length
+
" "
+
"a.codigo, "
+
"a.dni, "
+
"a.apellidos, "
+
"a.nombres, "
+
"a.edad, "
+
"a.correo, "
+
"a.estado "
+
"from persona a "
+
"where a.codigo not in (select top "
+
start
+
" b.codigo from persona b order by 1 desc) "
+
condicion
+
" "
+
"order by 1 desc"
;
psListarPersona
=
connection
.
prepareStatement
(
sql
);
rsListarPersona
=
psListarPersona
.
executeQuery
();
...
...
@@ -143,7 +146,6 @@ public class PersonaSqlserverDAO implements PersonaDAO {
personaBean
.
setCorreo
(
rsListarPersona
.
getString
(
c
++));
personaBean
.
setEstado
(
rsListarPersona
.
getString
(
c
++));
JSONObject
obj
=
new
JSONObject
(
personaBean
);
obj
.
put
(
"item"
,
numeroFilas
++);
data
.
put
(
obj
);
}
...
...
@@ -205,8 +207,8 @@ public class PersonaSqlserverDAO implements PersonaDAO {
if
(
resultDni
==
0
)
{
String
sql
=
"insert into persona (dni, apellidos, nombres, edad, correo, estado) values "
+
"(?,RTRIM(UPPER(?)),RTRIM(UPPER(?)),?,RTRIM(UPPER(?)),1)"
;
=
"insert into persona (dni, apellidos, nombres, edad, correo, estado) values "
+
"(?,RTRIM(UPPER(?)),RTRIM(UPPER(?)),?,RTRIM(UPPER(?)),1)"
;
int
c
=
1
;
//contador para las columnas
psInsertarPersona
=
connection
.
prepareStatement
(
sql
);
psInsertarPersona
.
setString
(
c
++,
bean
.
getDni
());
...
...
@@ -262,12 +264,12 @@ public class PersonaSqlserverDAO implements PersonaDAO {
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
=
"update persona "
+
"set apellidos = RTRIM(UPPER(?)), "
+
"nombres = RTRIM(UPPER(?)), "
+
"edad = ?, "
+
"correo = RTRIM(UPPER(?)) "
+
"where codigo = ?"
;
=
"update persona "
+
"set apellidos = RTRIM(UPPER(?)), "
+
"nombres = RTRIM(UPPER(?)), "
+
"edad = ?, "
+
"correo = RTRIM(UPPER(?)) "
+
"where codigo = ?"
;
psEditarPersona
=
connection
.
prepareStatement
(
sql
);
int
q
=
1
;
// CONTADOR PARA LAS COLUMNAS
...
...
@@ -320,9 +322,9 @@ public class PersonaSqlserverDAO implements PersonaDAO {
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
=
"update persona "
+
"set estado = 1 "
+
"where codigo = ?"
;
=
"update persona "
+
"set estado = 1 "
+
"where codigo = ?"
;
psEditarPersona
=
connection
.
prepareStatement
(
sql
);
...
...
@@ -371,9 +373,9 @@ public class PersonaSqlserverDAO implements PersonaDAO {
try
{
connection
=
SqlserverDAOFactory
.
obtenerConexion
(
base
);
String
sql
=
"update persona "
+
"set estado = 0 "
+
"where codigo = ?"
;
=
"update persona "
+
"set estado = 0 "
+
"where codigo = ?"
;
psEditarPersona
=
connection
.
prepareStatement
(
sql
);
psEditarPersona
.
setString
(
1
,
bean
.
getCodigo
());
...
...
src/java/demojsoncrud/utils/ResponseHelper.java
View file @
082e885b
...
...
@@ -6,6 +6,7 @@
package
demojsoncrud
.
utils
;
import
java.io.Serializable
;
import
org.json.JSONObject
;
/**
*
...
...
@@ -13,7 +14,7 @@ import java.io.Serializable;
*/
public
class
ResponseHelper
implements
Serializable
{
private
Object
data
;
private
JSON
Object
data
;
private
boolean
status
;
private
String
message
;
...
...
@@ -21,28 +22,28 @@ public class ResponseHelper implements Serializable {
}
public
boolean
isStatus
()
{
return
status
;
public
JSONObject
getData
()
{
return
data
;
}
public
void
setStatus
(
boolean
status
)
{
this
.
status
=
status
;
public
boolean
isStatus
(
)
{
return
status
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
set
Message
(
String
message
)
{
this
.
message
=
message
;
public
void
set
Data
(
JSONObject
data
)
{
this
.
data
=
data
;
}
public
Object
getData
(
)
{
return
data
;
public
void
setStatus
(
boolean
status
)
{
this
.
status
=
status
;
}
public
void
set
Data
(
Object
data
)
{
this
.
data
=
data
;
public
void
set
Message
(
String
message
)
{
this
.
message
=
message
;
}
}
web/js/pages/persona.js
View file @
082e885b
...
...
@@ -36,8 +36,13 @@ function listarPersonaTest() {
beforeSend
:
function
(
xhr
)
{
// console.log('Antes de...');
},
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
// console.log(data);
// console.log("listadoTest");
console
.
log
(
data
);
// 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
)
{
// console.log('Siempre ejecutará esta función');
}
...
...
@@ -88,8 +93,8 @@ function registrarPersona() {
var
status
=
data
.
status
;
if
(
status
)
{
imprimirAlerta
(
'Correcto!'
,
data
.
message
,
'success'
);
var
table
=
$
(
'#tabla_persona'
).
DataTable
();
table
.
ajax
.
reload
();
//
var table = $('#tabla_persona').DataTable();
//
table.ajax.reload();
recargarTabla
();
$
(
'#modal_registrar_persona'
).
modal
(
'hide'
);
}
else
{
...
...
@@ -194,7 +199,7 @@ function listarPersona() {
ScrollCollapse
:
true
,
columns
:
[
{
data
:
"
item
"
},
{
data
:
"
codigo
"
},
{
data
:
"dni"
},
{
data
:
null
,
...
...
@@ -254,8 +259,7 @@ $('#tabla_persona tbody').on('click', '.desactivarPersona', function () {
var
json
=
{
codigo
:
data_row
.
codigo
};
alert
(
data_row
.
codigo
);
console
.
log
(
data_row
.
codigo
);
swal
({
title
:
"¿Estás seguro?"
,
text
:
"¿Desea desactivar a "
+
data_row
.
apellidos
+
", "
+
data_row
.
nombres
+
" ?"
,
...
...
@@ -299,8 +303,7 @@ $('#tabla_persona tbody').on('click', '.activarPersona', function () {
var
json
=
{
codigo
:
data_row
.
codigo
};
console
.
log
(
data_row
.
codigo
);
alert
(
data_row
.
codigo
);
swal
({
title
:
"¿Estás seguro?"
,
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