/// <summary> /// Metodo que sirve para Obtener la lista de tipo TipoIdentificacion /// </summary> /// <param name="pTipoIdentificacion">Filtro de tipo TipoIdentificacion</param> /// <returns></returns> public RespuestaListaTipoIdentificacion ObtenerListaTipoIdentificacion(TipoIdentificacion pTipoIdentificacion) { var respuesta = new RespuestaListaTipoIdentificacion(); try { RespuestaSesion respS = sesion.ObtenerSesion(new Sesion() { Token = pTipoIdentificacion.UsrtokensAuthenticate }); if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso) { respuesta = dal.ObtenerTipoIdentificacion(pTipoIdentificacion); return(respuesta); } else { return new RespuestaListaTipoIdentificacion { Respuesta = respS.Respuesta, ListaTipoIdentificacion = new List <TipoIdentificacion>() } }; } catch (Exception ex) { ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pTipoIdentificacion); return(new RespuestaListaTipoIdentificacion { Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido) }); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,Acronimo,EsFiscal,FechaCreado,FechaEditado,Nota,Activo")] TipoIdentificacion tipoIdentificacion) { if (id != tipoIdentificacion.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tipoIdentificacion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoIdentificacionExists(tipoIdentificacion.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tipoIdentificacion)); }
public ActionResult Edit(Guid id, TipoIdentificacion tipoIdentificacion) { if (id != tipoIdentificacion.Id_TipoIdentificacion) { return(HttpNotFound()); } if (ModelState.IsValid) { try { db.Entry(tipoIdentificacion).State = EntityState.Modified; db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TipoIdentificacionExists(tipoIdentificacion.Id_TipoIdentificacion)) { return(HttpNotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tipoIdentificacion)); }
// GET: TipoId public ActionResult Index() { try { var dato = ObjTipoIdentificacion.ConsultarTipoIdentificacion(); List <TipoIdentificacion> ListaTipoIdentificaciones = new List <TipoIdentificacion>(); foreach (var item in dato) { TipoIdentificacion tipoidentificacion = new TipoIdentificacion(); tipoidentificacion.IdTipoIdentificacion = item.IdTipoIdentificacion; tipoidentificacion.Identificacion = item.Identificacion; tipoidentificacion.Estado = item.Estado; ListaTipoIdentificaciones.Add(tipoidentificacion); } return(View(ListaTipoIdentificaciones)); } catch (Exception ex) { return(new HttpNotFoundResult("Error al consultar los tipos de Identificacion")); } }
public Response Crear(TipoIdentificacion tipoIdentificacion) { try { var respuesta = Existe(tipoIdentificacion); if (!respuesta.IsSuccess) { tipoIdentificacion.Nombre = tipoIdentificacion.Nombre.TrimStart().TrimEnd().ToUpper(); db.Add(tipoIdentificacion); db.SaveChanges(); return(new Response { IsSuccess = true, Message = "Ok", }); } else { return(new Response { IsSuccess = false, Message = "Existe un tipo de identificación con igual nombre...", }); } } catch (Exception ex) { return(new Response { IsSuccess = false, Message = ex.Message, }); } }
public async Task <IActionResult> PutTipoIdentificacion(int id, TipoIdentificacion tipoIdentificacion) { if (id != tipoIdentificacion.IdTipoIdentificacion) { return(BadRequest()); } _context.Entry(tipoIdentificacion).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoIdentificacionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public List <TipoIdentificacion> obtenerTipos() { List <TipoIdentificacion> retorno = new List <TipoIdentificacion>(); Conexion conn = new Conexion(); SqlConnection cnn = conn.getSqlConnection(); SqlCommand cmd = new SqlCommand("sp_obtener_tipos_identificacion", cnn); cmd.CommandType = CommandType.StoredProcedure; cnn.Open(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { TipoIdentificacion entidad = new TipoIdentificacion(); entidad.id_tipoId = Convert.ToInt32(dr["id_tipoId"].ToString()); entidad.nombre_tipoId = dr["nombre_tipoId"].ToString(); retorno.Add(entidad); } dr.Close(); return(retorno); }
public ActionResult DeleteConfirmed(int id) { TipoIdentificacion tipoIdentificacion = db.TipoIdentificacion.Find(id); db.TipoIdentificacion.Remove(tipoIdentificacion); db.SaveChanges(); return(RedirectToAction("Index")); }
public static TipoIdentificacion Obtener(int idTipoIdentificacion) { List <TipoIdentificacion> lista = new List <TipoIdentificacion>(); lista = TipoIdentificacionLN.ObtenerTodos(); TipoIdentificacion tP = new TipoIdentificacion(); tP = (lista.Find(elemento => elemento.id == idTipoIdentificacion)); return(tP); }
public ActionResult Create(TipoIdentificacion tipoIdentificacion) { if (ModelState.IsValid) { db.TipoIdentificacion.Add(tipoIdentificacion); db.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(tipoIdentificacion)); }
public ActionResult Edit([Bind(Include = "pk_TipoIdentificacion,nomTipoIdentificacion")] TipoIdentificacion tipoIdentificacion) { if (ModelState.IsValid) { db.Entry(tipoIdentificacion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoIdentificacion)); }
public async Task <IActionResult> Create([Bind("Id,Nombre,Acronimo,EsFiscal,FechaCreado,FechaEditado,Nota,Activo")] TipoIdentificacion tipoIdentificacion) { if (ModelState.IsValid) { _context.Add(tipoIdentificacion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tipoIdentificacion)); }
public ActionResult Create([Bind(Include = "pk_TipoIdentificacion,nomTipoIdentificacion")] TipoIdentificacion tipoIdentificacion) { if (ModelState.IsValid) { db.TipoIdentificacion.Add(tipoIdentificacion); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoIdentificacion)); }
public List <TipoIdentificacion> ObtenerComboTipoIdentificacion(TipoIdentificacion Datos) { try { Catalogo_Datos CD = new Catalogo_Datos(); return(CD.ObtenerComboTipoIdentificacion(Datos)); } catch (Exception ex) { throw ex; } }
public async Task <Response> PostTipoIdentificacion([FromBody] TipoIdentificacion TipoIdentificacion) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var respuesta = Existe(TipoIdentificacion); if (!respuesta.IsSuccess) { db.TipoIdentificacion.Add(TipoIdentificacion); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio }); } return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro }); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.SwTH), ExceptionTrace = ex.Message, Message = Mensaje.Excepcion, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "", }); return(new Response { IsSuccess = false, Message = Mensaje.Error, }); } }
public async Task <IActionResult> Create(TipoIdentificacion TipoIdentificacion) { if (!ModelState.IsValid) { InicializarMensaje(null); return(View(TipoIdentificacion)); } Response response = new Response(); try { response = await apiServicio.InsertarAsync(TipoIdentificacion, new Uri(WebApp.BaseAddress), "api/TiposIdentificacion/InsertarTipoIdentificacion"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), ExceptionTrace = null, Message = "Se ha creado un tipo de identificación", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "TipoIdentificacion:", TipoIdentificacion.IdTipoIdentificacion), }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(TipoIdentificacion)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Creando un tipo de identificación", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
/// <summary> /// Consulta en la base de datos la tabla TipoIdentificacion /// </summary> /// <param name="pTipoIdentificacion"></param> /// <returns></returns> public RespuestaListaTipoIdentificacion ObtenerTipoIdentificacion(TipoIdentificacion pTipoIdentificacion) { RespuestaListaTipoIdentificacion respuesta = new RespuestaListaTipoIdentificacion(); respuesta.ListaTipoIdentificacion = new List <TipoIdentificacion>(); //STRORE PROCEDURE DEFINITION DbCommand dbCommand = database1.GetStoredProcCommand(defaultSchema + StoredProcedure.ObtenerTipoIdentificacion); //IN PARAMETERS if (pTipoIdentificacion.IdTipo != 0) { database1.AddInParameter(dbCommand, parameterName(TipoIdentificacion.idTipoProperty), DbType.Int64, pTipoIdentificacion.IdTipo); } if (pTipoIdentificacion.IdPais != 0) { database1.AddInParameter(dbCommand, parameterName(TipoIdentificacion.idPaisProperty), DbType.Int64, pTipoIdentificacion.IdPais); } database1.AddInParameter(dbCommand, parameterName(TipoIdentificacion.descripcionProperty), DbType.AnsiString, pTipoIdentificacion.Descripcion); database1.AddInParameter(dbCommand, parameterName(TipoIdentificacion.formatoProperty), DbType.String, pTipoIdentificacion.Formato); database1.AddInParameter(dbCommand, parameterName(TipoIdentificacion.codigoPaisProperty), DbType.String, pTipoIdentificacion.CodigoPais); //OUT PARAMETERS database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.codErrorProperty), DbType.String, Constantes.BaseDatos.codErrorTamano); database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.mensajeProperty), DbType.String, Constantes.BaseDatos.mensajeTamano); //EXECUTE PROCEDURE - CONVERT ROWS using (IDataReader Reader = database1.ExecuteReader(dbCommand)) { while (Reader.Read()) { respuesta.ListaTipoIdentificacion.Add(new TipoIdentificacion(Reader)); } } //ERROR CODE AND MESSAGE COLLECTOR respuesta.Respuesta = new Respuesta(); respuesta.Respuesta.CodMensaje = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.codErrorProperty))); respuesta.Respuesta.Mensaje = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.mensajeProperty))); if (respuesta.Respuesta.CodMensaje == Respuesta.CodExitoso) { respuesta.Respuesta = new Respuesta(respuesta.Respuesta.CodMensaje); } return(respuesta); }
/// <summary> /// actualiza un registro /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { using (var conexion = new DataModelFE()) { // se declara el objeto a insertar TipoIdentificacion dato = new TipoIdentificacion(); //llena el objeto con los valores de la pantalla dato.codigo = e.NewValues["codigo"] != null ? e.NewValues["codigo"].ToString().ToUpper() : null; //busca el objeto dato = conexion.TipoIdentificacion.Find(dato.codigo); dato.descripcion = e.NewValues["descripcion"] != null ? e.NewValues["descripcion"].ToString().ToUpper() : null; dato.estado = e.NewValues["estado"].ToString(); dato.usuarioModificacion = Session["usuario"].ToString(); dato.fechaModificacion = Date.DateTimeNow(); //modifica objeto conexion.Entry(dato).State = EntityState.Modified; conexion.SaveChanges(); //esto es para el manero del devexpress e.Cancel = true; this.ASPxGridView1.CancelEdit(); } } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); // Join the list to a single string. var fullErrorMessage = string.Join("; ", errorMessages); // Throw a new DbEntityValidationException with the improved exception message. throw new DbEntityValidationException(fullErrorMessage, ex.EntityValidationErrors); } catch (Exception ex) { throw new Exception(Utilidades.validarExepcionSQL(ex), ex.InnerException); } finally { //refescar los datos this.refreshData(); } }
// GET: TipoIdentificaciones/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TipoIdentificacion tipoIdentificacion = db.TipoIdentificacion.Find(id); if (tipoIdentificacion == null) { return(HttpNotFound()); } return(View(tipoIdentificacion)); }
public static List <TipoIdentificacion> ObtenerTodos() { List <TipoIdentificacion> lista = new List <TipoIdentificacion>(); DataSet ds = TipoIdentificacionDatos.SeleccionarTodos(); foreach (DataRow fila in ds.Tables[0].Rows) { TipoIdentificacion registro = new TipoIdentificacion(); registro.id = Convert.ToInt16(fila["ID"]); registro.tipo = Convert.ToString(fila["TIPO"]); registro.estado = Convert.ToInt16(fila["ESTADO"]); lista.Add(registro); } return(lista); }
public async Task <ActionResult <TipoIdentificacionDTO> > PostTipoIdentificacion( TipoIdentificacionDTO tipoIdentificacionDTO) { var tipoIdentificacion = new TipoIdentificacion { Nombre = tipoIdentificacionDTO.Nombre }; _context.TipoIdentificacions.Add(tipoIdentificacion); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetTiposIdentificacion), new { id = tipoIdentificacion.Id }, TipoIdentificacionToDTO(tipoIdentificacion))); }
public async Task <IActionResult> Edit(TipoIdentificacion tipoIdentificacion) { var i = (ClaimsIdentity)User.Identity; if (i.IsAuthenticated) { try { if (ModelState.IsValid) { try { tipoIdentificacion.Codigo = Encriptacion.Decrypt(tipoIdentificacion.Codigo); _context.Update(tipoIdentificacion); await _context.SaveChangesAsync(); await _auditoria.GuardarLogAuditoria(Funciones.ObtenerFechaActual("SA Pacific Standard Time"), i.Name, "TipoIdentificacion", tipoIdentificacion.Codigo, "U"); ViewBag.Message = "Save"; return(View(tipoIdentificacion)); } catch (DbUpdateConcurrencyException) { throw; } } return(View(tipoIdentificacion)); } catch (Exception e) { string mensaje = e.Message; if (e.InnerException != null) { mensaje = MensajesError.UniqueKey(e.InnerException.Message); } ViewBag.Message = mensaje; return(View(tipoIdentificacion)); } } else { return(Redirect("../Identity/Account/Login")); } }
private void LlenarComboIdentificacion() { try { TipoIdentificacion Datos = new TipoIdentificacion { Conexion = Comun.Conexion, IncluirSelect = true }; Catalogo_Negocio CN = new Catalogo_Negocio(); this.cmbDocumento.DataSource = CN.ObtenerComboTipoIdentificacion(Datos); this.cmbDocumento.DisplayMember = "Descripcion"; this.cmbDocumento.ValueMember = "IDTipoIdentificacion"; } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Edit(string id, TipoIdentificacion TipoIdentificacion) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, TipoIdentificacion, new Uri(WebApp.BaseAddress), "api/TiposIdentificacion"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), EntityID = string.Format("{0} : {1}", "Sistema", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un registro sistema", UserName = "******" }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(TipoIdentificacion)); } return(BadRequest()); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Editando un tipo de identificación", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public ActionResult Eliminar(TipoIdentificacion tipoidentificacion) { try { if (ObjTipoIdentificacion.EliminaTipoIdentificacion(tipoidentificacion.IdTipoIdentificacion)) { return(RedirectToAction("Index")); } //else { return(View()); } } catch (Exception ex) { return(new HttpNotFoundResult("Error al consultar la Unidad")); } }
public ActionResult Eliminar(int id) { try { var dato = ObjTipoIdentificacion.ConsultaTipoIdentificacion(id); TipoIdentificacion tipoIdentificacion = new TipoIdentificacion { IdTipoIdentificacion = dato.IdTipoIdentificacion, Estado = dato.Estado }; return(View(tipoIdentificacion)); } catch (Exception) { throw; } }
public TipoIdentificacion ObtenerTipoIdentificacion() { try { TipoIdentificacion TipoID = new TipoIdentificacion(); if (this.cmbDocumento.Items.Count > 0) { if (this.cmbDocumento.SelectedIndex != -1) { TipoID = (TipoIdentificacion)this.cmbDocumento.SelectedItem; } } return(TipoID); } catch (Exception ex) { throw ex; } }
public ActionResult Crear(TipoIdentificacion tipoidentificacion) { try { if (ObjTipoIdentificacion.CrearTipoIdentificacion(tipoidentificacion.Identificacion, tipoidentificacion.Estado)) { return(RedirectToAction("Index")); } else { ViewBag.Unidades = ObjTipoIdentificacion.ConsultarTipoIdentificacion(); return(View()); } } catch (Exception ex) { return(new HttpNotFoundResult("Error al consultar el tipo de Identificacion")); } }
public ActionResult Editar(TipoIdentificacion tipoidentificacion) { try { if (ObjTipoIdentificacion.ActualizaTipoIdentificacion(tipoidentificacion.IdTipoIdentificacion, tipoidentificacion.Identificacion, tipoidentificacion.Estado)) { return(RedirectToAction("Index")); } else { ViewBag.TipoIdentidicaciones = ObjTipoIdentificacion.ConsultarTipoIdentificacion(); return(View()); } } catch (Exception ex) { return(new HttpNotFoundResult("Error al editar EL Tipo de Indentificacion")); } }
public ActionResult Editar(TipoIdentificacion tipoIdentificacion) { try { if (ObjTipoIdentificacion.ActualizaTipoIdentificacion(tipoIdentificacion.IdTipoIdentificacion, tipoIdentificacion.Descripcion, tipoIdentificacion.Estado, Session["Identificacion"].ToString())) { return(RedirectToAction("index")); } else { return(View(tipoIdentificacion)); } } catch (Exception) { return(View(tipoIdentificacion)); throw; } }