private List <Tipoidentificacion> listQuery(SqlCommand stmt) { List <Tipoidentificacion> searchResults = new List <Tipoidentificacion>(); SqlDataReader reader = null; try { int intt = 0; long longg = 0; double doublee = 0; DateTime datee; reader = stmt.ExecuteReader(); while (reader.Read()) { Tipoidentificacion temp = createValueObject(); temp.ID_TIPO_IDENTIFICACION = reader["ID_TIPO_IDENTIFICACION"] != null && long.TryParse(reader["ID_TIPO_IDENTIFICACION"].ToString(), out longg) ? longg : 0; temp.NOM_TIPO_IDENTIFICACION = reader["NOM_TIPO_IDENTIFICACION"] != null ? reader["NOM_TIPO_IDENTIFICACION"].ToString() : null; searchResults.Add(temp); } } finally { if (!reader.IsClosed) { reader.Close(); } if (stmt != null) { stmt.Dispose(); } } return(searchResults); }
public void create(SqlConnection conn, Tipoidentificacion valueObject) { String sql = ""; SqlCommand stmt = null; try { sql = "INSERT INTO TIPO_IDENTIFICACION ( ID_TIPO_IDENTIFICACION," + " NOM_TIPO_IDENTIFICACION)" + "VALUES ( @ID_TIPO_IDENTIFICACION, @NOM_TIPO_IDENTIFICACION)"; stmt = new SqlCommand(sql, conn); stmt.Parameters.AddWithValue("@ID_TIPO_IDENTIFICACION", valueObject.ID_TIPO_IDENTIFICACION); if (valueObject.NOM_TIPO_IDENTIFICACION != null && valueObject.NOM_TIPO_IDENTIFICACION.Length <= 50) { stmt.Parameters.AddWithValue("@NOM_TIPO_IDENTIFICACION", valueObject.NOM_TIPO_IDENTIFICACION); } else { stmt.Parameters.AddWithValue("@NOM_TIPO_IDENTIFICACION", DBNull.Value); } databaseUpdate(stmt); } finally { if (stmt != null) { stmt.Dispose(); } } }
/** * Edita un registro en la tabla * @param Tipoidentificacion obj * @return boolean indicando si se realizo o no la actualizacion */ public TipoidentificacionResponse editarTipoidentificacion(Tipoidentificacion obj) { TipoidentificacionResponse objResponse = new TipoidentificacionResponse(); try { TipoidentificacionDao dao = new TipoidentificacionDao(); conn = conexion.conectar(); dao.save(conn, obj); objResponse.correcto = true; objResponse.error = ""; objResponse.objeto = obj; } catch (Exception e) { objResponse.correcto = false; objResponse.error = e.Message; objResponse.objeto = obj; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(objResponse); }
/** * Elimina un registro de la tabla * @param Tipoidentificacion obj * @return Retorna un boolean indicando si se realizo o no la operacion */ public TipoidentificacionResponse eliminarTipoidentificacion(Tipoidentificacion obj) { TipoidentificacionResponse resultado = new TipoidentificacionResponse(); try { TipoidentificacionDao dao = new TipoidentificacionDao(); conn = conexion.conectar(); dao.delete(conn, obj); resultado.correcto = true; resultado.error = ""; resultado.objeto = obj; } catch (Exception e) { resultado.correcto = false; resultado.error = e.Message; resultado.objeto = obj; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(resultado); }
private void editar() { TipoidentificacionResponse objResponse; try { Tipoidentificacion obj; obj = new Tipoidentificacion(); if (!String.IsNullOrEmpty(txtTipoIdentificacion.Text) && !String.IsNullOrWhiteSpace(txtTipoIdentificacion.Text)) { obj.NOM_TIPO_IDENTIFICACION = txtTipoIdentificacion.Text.Trim(); } obj.ID_TIPO_IDENTIFICACION = tipoidentificacion.ID_TIPO_IDENTIFICACION; objResponse = serviciosTipoidentificacion.editarTipoidentificacion(obj); if (objResponse != null && objResponse.correcto) { Controles.mensajes.mensajeCorrecto("La información del Tipo de Identificación se modificó correctamente"); this.Close(); } else { if (objResponse != null) { Controles.mensajes.errorWebServices(objResponse.error); } } } catch (Exception exp) { Controles.mensajes.mensajeError(exp.Message); } }
/** * Busca los registros que coincidan con los datos enviados * @param Tipoidentificacion obj * @return Retorna la lista de los registros que coinciden */ public Tipoidentificacion[] buscarTipoidentificacion(Tipoidentificacion obj, int pagina, int numRegPagina) { Tipoidentificacion[] result = null; List <Tipoidentificacion> lista = null; if (pagina > 0 && numRegPagina > 0) { pagina--; int limInf = 0; int limSup = 0; limInf = pagina * numRegPagina + 1; limSup = (pagina + 1) * numRegPagina; try { TipoidentificacionDao dao = new TipoidentificacionDao(); conn = conexion.conectar(); lista = dao.searchMatching(conn, obj, limInf, limSup); if (lista != null && lista.Count > 0) { result = lista.ToArray(); } } catch (Exception e) { result = null; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } } return(result); }
private void guardar() { try { TipoidentificacionResponse objResponse; Tipoidentificacion obj = new Tipoidentificacion(); if (!String.IsNullOrEmpty(txtTipoIdentificacion.Text) && !String.IsNullOrWhiteSpace(txtTipoIdentificacion.Text)) { obj.NOM_TIPO_IDENTIFICACION = txtTipoIdentificacion.Text.Trim(); } objResponse = serviciosTipoidentificacion.crearTipoidentificacion(obj); if (objResponse != null && objResponse.correcto) { Controles.mensajes.mensajeCorrecto("Se creo correctamente el Tipo de Identificación " + obj.NOM_TIPO_IDENTIFICACION); txtTipoIdentificacion.Clear(); } else { if (objResponse != null) { Controles.mensajes.errorWebServices(objResponse.error); } } } catch (Exception exp) { Controles.mensajes.mensajeError(exp.Message); } }
/** * Inserta nuevo registro en la tabla * @param Tipoidentificacion obj * @return Retorna el mismo objeto pero con la llave primaria configurada */ public Tipoidentificacion crearTipoidentificacion(Tipoidentificacion obj) { List <Tipoidentificacion> lista = null; Tipoidentificacion obj_new = new Tipoidentificacion(); try { TipoidentificacionDao dao = new TipoidentificacionDao(); conn = conexion.conectar(); int id = Funciones.obtenerId(conn, "TIPO_IDENTIFICACION"); obj.ID_TIPO_IDENTIFICACION = id; dao.create(conn, obj); //verificar existencia obj_new.ID_TIPO_IDENTIFICACION = obj.ID_TIPO_IDENTIFICACION; lista = dao.searchMatching(conn, obj_new); if (lista != null && lista.Count > 0) { obj_new = (Tipoidentificacion)lista[0]; } else { obj_new.ID_TIPO_IDENTIFICACION = -1; } } catch (Exception e) { obj_new.ID_TIPO_IDENTIFICACION = -1; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(obj_new); }
public async Task <IActionResult> Edit(int id, [Bind("IdTipo,Descripcion")] Tipoidentificacion tipoidentificacion) { if (id != tipoidentificacion.IdTipo) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tipoidentificacion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoidentificacionExists(tipoidentificacion.IdTipo)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tipoidentificacion)); }
/** * Busca el primer registro que coincida con los datos enviados * @param Tipoidentificacion obj * @return Retorna el mismo objeto pero con los datos consultados */ public Tipoidentificacion buscarPrimeroTipoidentificacion(Tipoidentificacion obj) { List <Tipoidentificacion> lista = null; try { TipoidentificacionDao dao = new TipoidentificacionDao(); conn = conexion.conectar(); lista = dao.searchMatching(conn, obj); if (lista != null && lista.Count > 0) { obj = (Tipoidentificacion)lista[0]; } else { obj.ID_TIPO_IDENTIFICACION = -1; } } catch (Exception e) { obj.ID_TIPO_IDENTIFICACION = -1; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(obj); }
private void editar() { if (grdTipoIdentificacion.Rows != null && grdTipoIdentificacion.Rows.Count > 0 && grdTipoIdentificacion.SelectedRows != null && grdTipoIdentificacion.SelectedRows.Count > 0) { try { Tipoidentificacion tmpTipo = new Tipoidentificacion(); tmpTipo.ID_TIPO_IDENTIFICACION = long.Parse(grdTipoIdentificacion.SelectedRows[0].Cells["ID_TIPO_IDENTIFICACION"].Value.ToString()); tmpTipo.NOM_TIPO_IDENTIFICACION = grdTipoIdentificacion.SelectedRows[0].Cells["TIPO_DE_IDENTIFICACION"].Value.ToString(); setTipoIdentificacion setTipoIdentificacion = new setTipoIdentificacion(Controles.utilidades.tipoOperacion.Editar, tmpTipo); setTipoIdentificacion.ShowDialog(this); getTipoIdentificacion(); } catch (Exception exp) { Controles.mensajes.mensajeError(exp.Message); } } else { Controles.mensajes.mensajeError("Debe seleccionar un Tipo de Identificación de la lista"); } }
public void save(SqlConnection conn, Tipoidentificacion valueObject) { SqlCommand stmt = null; String sql = ""; try { sql = "UPDATE TIPO_IDENTIFICACION SET NOM_TIPO_IDENTIFICACION = @NOM_TIPO_IDENTIFICACION WHERE (ID_TIPO_IDENTIFICACION= @ID_TIPO_IDENTIFICACION)"; stmt = new SqlCommand(sql, conn); if (valueObject.NOM_TIPO_IDENTIFICACION != null && valueObject.NOM_TIPO_IDENTIFICACION.Length <= 50) { stmt.Parameters.AddWithValue("@NOM_TIPO_IDENTIFICACION", valueObject.NOM_TIPO_IDENTIFICACION); } else { stmt.Parameters.AddWithValue("@NOM_TIPO_IDENTIFICACION", DBNull.Value); } stmt.Parameters.AddWithValue("@ID_TIPO_IDENTIFICACION", valueObject.ID_TIPO_IDENTIFICACION); int rowcount = databaseUpdate(stmt); if (rowcount == 0) { throw new Exception("Object could not be saved! (PrimaryKey not found)"); } } finally { if (stmt != null) { stmt.Dispose(); } } }
public void delete(SqlConnection conn, Tipoidentificacion valueObject) { SqlCommand stmt = null; String sql = ""; try { sql = "DELETE FROM TIPO_IDENTIFICACION WHERE (ID_TIPO_IDENTIFICACION = @ID_TIPO_IDENTIFICACION )"; stmt = new SqlCommand(sql, conn); stmt.Parameters.AddWithValue("@ID_TIPO_IDENTIFICACION", valueObject.ID_TIPO_IDENTIFICACION); int rowcount = databaseUpdate(stmt); if (rowcount == 0) { throw new Exception("Object could not be deleted! (PrimaryKey not found)"); } if (rowcount > 1) { throw new Exception("PrimaryKey Error when updating DB! (Many objects were deleted!)"); } } finally { if (stmt != null) { stmt.Dispose(); } } }
public Tipoidentificacion[] buscarPaginacionTipoidentificacion(Tipoidentificacion obj, int pag, int numReg) { if (autenticacion != null && autenticacion.esValido()) { return(gestionTipoidentificacion.buscarTipoidentificacion(obj, pag, numReg)); } return(null); }
public TipoidentificacionResponse editarTipoidentificacion(Tipoidentificacion obj) { if (autenticacion != null && autenticacion.esValido()) { return(gestionTipoidentificacion.editarTipoidentificacion(obj)); } return(null); }
public bool editarTipoidentificacion(Tipoidentificacion obj) { if (autenticacion != null && autenticacion.esValido()) { return(gestionTipoidentificacion.editarTipoidentificacion(obj)); } return(false); }
public Tipoidentificacion[] buscarTipoidentificacion(Tipoidentificacion obj) { if (autenticacion != null && autenticacion.esValido()) { return(gestionTipoidentificacion.buscarTipoidentificacion(obj)); } return(null); }
public int contarBusquedaTipoidentificacion(Tipoidentificacion obj) { if (autenticacion != null && autenticacion.esValido()) { return(gestionTipoidentificacion.contarBusquedaTipoidentificacion(obj)); } return(-1); }
public setTipoIdentificacion(Controles.utilidades.tipoOperacion tmpOperacion, Tipoidentificacion tmpTipoIdent) { InitializeComponent(); inicializarServicios(); operacion = tmpOperacion; tipoidentificacion = tmpTipoIdent; configuracionInicial(); Controles.utilidades.fijarSize(this); }
public async Task <IActionResult> Create([Bind("IdTipo,Descripcion")] Tipoidentificacion tipoidentificacion) { if (ModelState.IsValid) { _context.Add(tipoidentificacion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tipoidentificacion)); }
public int countSearchMatching(SqlConnection conn, Tipoidentificacion valueObject) { bool first = true; String sql = "SELECT COUNT(*) FROM TIPO_IDENTIFICACION WHERE 1=1 "; if (valueObject.ID_TIPO_IDENTIFICACION != null && valueObject.ID_TIPO_IDENTIFICACION != 0) { if (first) { first = false; } sql += "AND ID_TIPO_IDENTIFICACION= " + valueObject.ID_TIPO_IDENTIFICACION + " "; } if (!String.IsNullOrEmpty(valueObject.NOM_TIPO_IDENTIFICACION)) { if (first) { first = false; } sql += "AND NOM_TIPO_IDENTIFICACION= '" + valueObject.NOM_TIPO_IDENTIFICACION + "' "; } SqlCommand stmt = null; SqlDataReader result = null; int allRows = 0; try { stmt = new SqlCommand(sql, conn); result = stmt.ExecuteReader(); if (result.Read()) { allRows = int.Parse(result[0].ToString()); } } finally { if (!result.IsClosed) { result.Close(); } if (stmt != null) { stmt.Dispose(); } } return(allRows); }
public int contarBusquedaTipoidentificacion(Tipoidentificacion obj) { int cantidad = -1; try { TipoidentificacionDao dao = new TipoidentificacionDao(); conn = conexion.conectar(); cantidad = dao.countSearchMatching(conn, obj); } catch (Exception e) { cantidad = -1; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(cantidad); }
/** * Inserta nuevo registro en la tabla * @param Tipoidentificacion obj * @return Retorna el mismo objeto pero con la llave primaria configurada */ public TipoidentificacionResponse crearTipoidentificacion(Tipoidentificacion obj) { List <Tipoidentificacion> lista = null; Tipoidentificacion obj_new = new Tipoidentificacion(); TipoidentificacionResponse objResponse = new TipoidentificacionResponse(); try { objResponse = new TipoidentificacionResponse(); TipoidentificacionDao dao = new TipoidentificacionDao(); conn = conexion.conectar(); dao.create(conn, obj); //verificar existencia obj_new.NOM_TIPO_IDENTIFICACION = obj.NOM_TIPO_IDENTIFICACION; lista = dao.searchMatching(conn, obj_new); if (lista != null && lista.Count > 0) { obj_new = (Tipoidentificacion)lista[0]; } else { obj_new.ID_TIPO_IDENTIFICACION = -1; } objResponse.correcto = true; objResponse.error = ""; objResponse.objeto = obj_new; } catch (Exception e) { obj_new.ID_TIPO_IDENTIFICACION = -1; objResponse.correcto = false; objResponse.error = e.Message; objResponse.objeto = obj_new; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(objResponse); }
/** * Edita un registro en la tabla * @param Tipoidentificacion obj * @return boolean indicando si se realizo o no la actualizacion */ public bool editarTipoidentificacion(Tipoidentificacion obj) { bool resultado; resultado = false; try { TipoidentificacionDao dao = new TipoidentificacionDao(); conn = conexion.conectar(); dao.save(conn, obj); resultado = true; } catch (Exception e) { resultado = false; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(resultado); }
public void create(SqlConnection conn, Tipoidentificacion valueObject) { String sql = ""; SqlCommand stmt = null; try { sql = "BEGIN TRY " + "INSERT INTO TIPO_IDENTIFICACION ( " + " NOM_TIPO_IDENTIFICACION)" + "VALUES ( @NOM_TIPO_IDENTIFICACION) " + "END TRY " + "BEGIN CATCH " + "DECLARE @ErrorMensage NVARCHAR(4000); " + "DECLARE @ErrorNumero INT; " + "declare @ErrorState INT; " + "SELECT @ErrorMensage = ERROR_MESSAGE(), " + "@ErrorNumero = ERROR_NUMBER(), " + "@ErrorState = ERROR_STATE(); " + "RAISERROR(@ErrorMensage, " + "@ErrorNumero, " + "@ErrorState " + "); " + "END CATCH"; stmt = new SqlCommand(sql, conn); if (valueObject.NOM_TIPO_IDENTIFICACION != null && valueObject.NOM_TIPO_IDENTIFICACION.Length <= 50) { stmt.Parameters.AddWithValue("@NOM_TIPO_IDENTIFICACION", valueObject.NOM_TIPO_IDENTIFICACION); } else { stmt.Parameters.AddWithValue("@NOM_TIPO_IDENTIFICACION", DBNull.Value); } databaseUpdate(stmt); } finally { if (stmt != null) { stmt.Dispose(); } } }
private void eliminarTipoIdentificacion() { if (grdTipoIdentificacion.Rows != null && grdTipoIdentificacion.Rows.Count > 0 && grdTipoIdentificacion.SelectedRows != null && grdTipoIdentificacion.SelectedRows.Count > 0) { try { if (MessageBox.Show("¿Esta seguro(a) que desea eliminar el Tipo de Identificación " + grdTipoIdentificacion.SelectedRows[0].Cells["TIPO_DE_IDENTIFICACION"].Value.ToString() + "?", "Confirmar eliminación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { long tmpLong = 0; Tipoidentificacion tmpTipoIdentificacion = new Tipoidentificacion(); tmpLong = 0; long.TryParse(grdTipoIdentificacion.SelectedRows[0].Cells["ID_TIPO_IDENTIFICACION"].Value.ToString(), out tmpLong); tmpTipoIdentificacion.ID_TIPO_IDENTIFICACION = tmpLong; if (tmpTipoIdentificacion.ID_TIPO_IDENTIFICACION > 0) { TipoidentificacionResponse objResponseTipoidentificacion = serviciosTipoidentificacion.eliminarTipoidentificacion(tmpTipoIdentificacion); if (objResponseTipoidentificacion != null && objResponseTipoidentificacion.correcto) { Controles.mensajes.mensajeCorrecto("Tipo de Identificación eliminada correctamente"); } else { Controles.mensajes.errorWebServices(objResponseTipoidentificacion.error); } getTipoIdentificacion(); } } } catch (Exception exp) { Controles.mensajes.mensajeError(exp.Message); } } else { Controles.mensajes.mensajeError("Debe seleccionar un Tipo de Identificación de la lista"); } }
/** * Busca los registros que coincidan con los datos enviados * @param Tipoidentificacion obj * @return Retorna la lista de los registros que coinciden */ public Tipoidentificacion[] buscarTipoidentificacion(Tipoidentificacion obj) { Tipoidentificacion[] result = null; List <Tipoidentificacion> lista = null; try { TipoidentificacionDao dao = new TipoidentificacionDao(); conn = conexion.conectar(); lista = dao.searchMatching(conn, obj); if (lista != null && lista.Count > 0) { result = lista.ToArray(); } } catch (Exception e) { result = null; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(result); }
public List <Tipoidentificacion> searchMatching(SqlConnection conn, Tipoidentificacion valueObject, int limiteInf, int limiteSup) { List <Tipoidentificacion> searchResults = new List <Tipoidentificacion>(); bool first = true; String sql = "SELECT * FROM TIPO_IDENTIFICACION WHERE 1=1 "; if (valueObject.ID_TIPO_IDENTIFICACION != null && valueObject.ID_TIPO_IDENTIFICACION != 0) { if (first) { first = false; } sql += "AND ID_TIPO_IDENTIFICACION= " + valueObject.ID_TIPO_IDENTIFICACION + " "; } if (!String.IsNullOrEmpty(valueObject.NOM_TIPO_IDENTIFICACION)) { if (first) { first = false; } sql += "AND NOM_TIPO_IDENTIFICACION= '" + valueObject.NOM_TIPO_IDENTIFICACION + "' "; } sql += ") AS CONSULTA WHERE RowNumber >=" + limiteInf + " AND RowNumber <=" + limiteSup; if (first) { searchResults = new List <Tipoidentificacion>(); } else { searchResults = listQuery(new SqlCommand(sql, conn)); } return(searchResults); }