private void Aceptar(object sender, EventArgs e) { errorProvider1.Dispose(); var valido = Validacion.Validar(errorProvider1, new List <object> { txtDescripcion, txtImporte }); if (valido) { if (excepcionId == 0) { Excepcion = new Excepcion(); CargarExcepcion(); Repository.Agregar(Excepcion); } else { CargarExcepcion(); Repository.Modificar(Excepcion); } if (Repository.Commit()) { Mensajes.Guardar(true); } else { Mensajes.Guardar(false); } } }
public TEntity Retrieve(Expression <Func <TEntity, bool> > criterio) { TEntity Result = null; try { Result = EntitySet.FirstOrDefault(criterio); } catch (DbEntityValidationException ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, EntityValidationErrors = ex.EntityValidationErrors }); this.EscribirEnArchivoLog(ex); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite }); this.EscribirEnArchivoLog(ex); } return(Result); }
public TEntity Create(TEntity toCreate) { TEntity Result = null; try { Result = EntitySet.Add(toCreate); Context.SaveChanges(); } catch (DbEntityValidationException ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, EntityValidationErrors = ex.EntityValidationErrors }); this.EscribirEnArchivoLog(ex); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite }); this.EscribirEnArchivoLog(ex); } return(Result); }
public HttpResponseMessage GrupoEdad(long exact_id) { try { var proveedor_id = HttpContext.Current.User.Identity.GetUserId(); var grupoedad = contexto.grupoedad.Where(x => x.exact_id == exact_id && x.exact.configuracion.proveedor_id == proveedor_id).Select(x => new { id = x.id, edaddesde = x.edaddesde, edadhasta = x.edadhasta, genero = x.genero, nombre_configuracion = x.exact.configuracion.nombre }).OrderBy(x => x.edaddesde).ToList(); resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); resp.Contenido = grupoedad; return(resp.ObjectoRespuesta()); } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
private void btnAbrir_Click(object sender, EventArgs e) { try { if (ofdMontosCargas.ShowDialog() == DialogResult.OK) { _archivo = ofdMontosCargas.FileName; this.generarCargas(); btnAceptar.Enabled = dgvCargas.Rows.Count > 0; } else { _archivo = string.Empty; _cartuchos.Clear(); btnAceptar.Enabled = false; } } catch (Excepcion ex) { ex.mostrarMensaje(); } catch (Exception) { Excepcion.mostrarMensaje("ErrorCargasGeneracionFormatoArchivo"); } txtArchivo.Text = _archivo; }
public HttpResponseMessage AnadirIdioma(List <IdiomaExActModel> idiomas) { try { var proveedor_id = HttpContext.Current.User.Identity.GetUserId(); if (contexto.configuracion.Where(x => x.id == idiomas[0].Exact_id && x.proveedor_id == proveedor_id).FirstOrDefault() == null) { resp.Codigo = (int)Codigos.REGISTRO_NO_ENCONTRADO; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.REGISTRO_NO_ENCONTRADO); return(resp.ObjectoRespuesta()); } idiomas.ForEach(x => contexto.idioma_exact.Add(new idioma_exact() { exact_id = x.Exact_id, idioma_id = x.Idioma_id, guia = x.Guia, guia_escrita = x.Guia_escrita, audio_auricular = x.Audio_auricular })); contexto.SaveChanges(); resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); return(resp.ObjectoRespuesta()); } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
public HttpResponseMessage AnadirPunto(List <PuntoModel> puntos) { try { var proveedor_id = HttpContext.Current.User.Identity.GetUserId(); if (contexto.configuracion.Where(x => x.id == puntos[0].Exact_id && x.proveedor_id == proveedor_id).FirstOrDefault() == null) { resp.Codigo = (int)Codigos.REGISTRO_NO_ENCONTRADO; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.REGISTRO_NO_ENCONTRADO); return(resp.ObjectoRespuesta()); } puntos.ForEach(x => contexto.punto_exact.Add(new puntorecogida_exact() { punto_id = x.Punto_id, exact_id = x.Exact_id })); contexto.SaveChanges(); resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); return(resp.ObjectoRespuesta()); } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
/// <summary> /// Clic en el botón de guardar. /// </summary> private void btnGuardar_Click(object sender, EventArgs e) { // Verificar que se hayan seleccionado los datos if (cboInconsistencia.Text.Equals(string.Empty)) { Excepcion.mostrarMensaje("ErrorCamaraDatosRegistro"); return; } try { frmBandejaInconsistenciasFacturacion padre = (frmBandejaInconsistenciasFacturacion)this.Owner; InconsistenciaFacturacion identificador = (InconsistenciaFacturacion)cboInconsistencia.SelectedItem; // Verificar si la camará ya está registrada // Actualizar los datos de la cámara //_tarifa.Inconsistencia = identificador; //padre.actualizarLista(); Mensaje.mostrarMensaje("MensajeCamaraConfirmacionActualizacion"); this.Close(); } catch (Excepcion ex) { ex.mostrarMensaje(); } }
/// <summary> /// Clic en el botón de guardar. /// </summary> private void btnGuardar_Click(object sender, EventArgs e) { if (dgvManifiestos.SelectedRows.Count == 0) { Excepcion.mostrarMensaje("ErrorTulaDatosActualizacion"); return; } try { if (Mensaje.mostrarMensajeConfirmacion("MensajeTulaActualizacionManifiesto") == DialogResult.Yes) { Manifiesto manifiesto = (Manifiesto)dgvManifiestos.SelectedRows[0].DataBoundItem; Tula tula = (Tula)dgvTulas.SelectedRows[0].DataBoundItem; tula.Manifiesto = manifiesto; _atencion.actualizarTulaManifiesto(tula, _coordinador); Mensaje.mostrarMensaje("MensajeTulaConfirmacionActualizacionManifiesto"); this.Close(); } } catch (Excepcion ex) { ex.mostrarMensaje(); } }
private void imprimirBoletaNikelEntregaCola(int id) { DataTable dt = _mantenimiento.obtieneExcelBoletaNikelEntregaCola(id); if (dt.Rows.Count > 0) { try { DocumentoExcel documento = new DocumentoExcel(Application.StartupPath + "\\Plantillas\\plantilla boleta niquel_entrega_cola.xlsx", false); documento.seleccionarHoja(1); documento.seleccionarCelda("C4"); documento.actualizarValorCelda(dt.Rows[0][0]); documento.seleccionarCelda("F4"); documento.actualizarValorCelda(dt.Rows[0][1]); documento.seleccionarCelda("C6"); documento.actualizarValorCelda(dt.Rows[0][2]); documento.seleccionarCelda("C8"); documento.actualizarValorCelda(dt.Rows[0][3]); documento.seleccionarCelda("C10"); documento.actualizarValorCelda(dt.Rows[0][4]); documento.mostrar(); documento.cerrar(); } catch { Excepcion.mostrarMensaje("Error Exel niquel entrega cola"); } } else { MessageBox.Show("Ocurrio un error al obtener los datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public HttpResponseMessage Eliminar(string id) { try { long _id = Int64.Parse(id); var item = contexto.item.Find(_id); if (item == null) { resp.Codigo = (int)Codigos.REGISTRO_NO_ENCONTRADO; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.REGISTRO_NO_ENCONTRADO); return(resp.ObjectoRespuesta()); } contexto.excursion_contiene_item.Where(x => x.item_id == _id).ToList().ForEach(x => contexto.excursion_contiene_item.Remove(x)); contexto.item.Remove(item); contexto.SaveChanges(); resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); return(resp.ObjectoRespuesta()); } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
private void btnAbrir_Click(object sender, EventArgs e) { try { if (ofdDepositos.ShowDialog() == DialogResult.OK) { _archivo = ofdDepositos.FileName; this.generarDepositos(); btnAgregarDepositos.Enabled = _depositos.Count > 0 && _filas_incorrectas.Count == 0; } else { _archivo = string.Empty; _depositos.Clear(); btnAgregarDepositos.Enabled = false; } } catch (Exception) { Excepcion.mostrarMensaje("ErrorCargasGeneracionFormatoArchivo"); } txtArchivo.Text = _archivo; }
/// <summary> /// Clic en el botón de abrir. /// </summary> private void btnAbrir_Click(object sender, EventArgs e) { try { if (ofdArchivoTriales.ShowDialog() == DialogResult.OK) { _archivo = ofdArchivoTriales.FileName; this.leerTriales(); btnAceptar.Enabled = _triales.Count > 0; } else { _archivo = string.Empty; _triales.Clear(); btnAceptar.Enabled = false; } } catch (Exception) { Excepcion.mostrarMensaje("ErrorTrialesImportacionFormatoArchivo"); } txtArchivo.Text = _archivo; }
/// <summary> /// Clic en el botón de guardar. /// </summary> private void btnGuardar_Click(object sender, EventArgs e) { // Verificar que se hayan seleccionado los datos if (txtOficina.Text.Equals(string.Empty)) { Excepcion.mostrarMensaje("ErrorubicacionDatosRegistro"); return; } try { string oficina = txtOficina.Text; string direccion = txtDireccion.Text; string direccion_exacta = txtDireccionExacta.Text; Provincias provincia = (Provincias)cboProvincias.SelectedIndex; frmAdministracionUbicaciones padre = (frmAdministracionUbicaciones)this.Owner; // Verificar si la ubicación ya está registrada if (_ubicacion == null) { // Agregar los datos de la ubicación if (Mensaje.mostrarMensajeConfirmacion("MensajeUbicacionRegistro") == DialogResult.Yes) { Ubicacion nueva = new Ubicacion(oficina, direccion, direccion_exacta: direccion_exacta, provincia: provincia); _mantenimiento.agregarUbicacion(ref nueva); padre.agregarUbicacion(nueva); Mensaje.mostrarMensaje("MensajeUbicacionConfirmacionRegistro"); this.Close(); } } else { // Actualizar los datos de la ubicación Ubicacion copia = new Ubicacion(oficina, direccion, id: _ubicacion.ID, direccion_exacta: direccion_exacta, provincia: provincia); _mantenimiento.actualizarUbicacion(copia); _ubicacion.Oficina = oficina; _ubicacion.Direccion = direccion; _ubicacion.Direccion_exacta = direccion_exacta; _ubicacion.Provincia = provincia; padre.actualizarLista(); Mensaje.mostrarMensaje("MensajeUbicacionConfirmacionActualizacion"); this.Close(); } } catch (Excepcion ex) { ex.mostrarMensaje(); } }
/// <summary> /// Clic en el botón de guardar. /// </summary> private void btnGuardar_Click(object sender, EventArgs e) { if (dgvManifiestos.SelectedRows.Count == 0 || txtCodigo.Text.Equals(string.Empty)) { Excepcion.mostrarMensaje("ErrorTulaDatosRegistro"); return; } try { if (Mensaje.mostrarMensajeConfirmacion("MensajeTulaRegistro") == DialogResult.Yes) { string codigo = txtCodigo.Text; Manifiesto manifiesto = (Manifiesto)dgvManifiestos.SelectedRows[0].DataBoundItem; DateTime fecha = dtpFecha.Value; Tula tula = new Tula(codigo, manifiesto: manifiesto, fecha_ingreso: fecha); _atencion.agregarTula(ref tula, _coordinador); Mensaje.mostrarMensaje("MensajeTulaConfirmacionRegistro"); this.Close(); } } catch (Excepcion ex) { ex.mostrarMensaje(); } }
public bool Update <TEntity>(Expression <Func <TEntity, bool> > criterio, string propertyName, object valor) where TEntity : class { bool Result = false; try { Contexto.Entry <TEntity>(Contexto.Set <TEntity>().FirstOrDefault(criterio)).Property(propertyName).CurrentValue = valor; Result = Save() > 0; } catch (DbUpdateException ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink, Entries = ex.Entries }); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink }); } return(Result); }
public HttpResponseMessage AnadirItem(long item_id, long exact_id) { try { var proveedor_id = HttpContext.Current.User.Identity.GetUserId(); if (contexto.excursion_contiene_item.Where(x => x.exact_id == exact_id && x.item_id == item_id).FirstOrDefault() != null) { resp.Codigo = (int)Codigos.REGISTRO_REPETIDO; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.REGISTRO_REPETIDO); return(resp.ObjectoRespuesta()); } if (contexto.configuracion.Where(x => x.id == exact_id && x.proveedor_id == proveedor_id).FirstOrDefault() == null) { resp.Codigo = (int)Codigos.REGISTRO_NO_ENCONTRADO; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.REGISTRO_NO_ENCONTRADO); return(resp.ObjectoRespuesta()); } contexto.excursion_contiene_item.Add(new excursion_contiene_item() { item_id = item_id, exact_id = exact_id }); contexto.SaveChanges(); resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); return(resp.ObjectoRespuesta()); } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
public TEntity Create <TEntity>(TEntity toCreate) where TEntity : class { TEntity Result = null; try { Result = Contexto.Set <TEntity>().Add(toCreate).Entity; Save(); } catch (DbUpdateException ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink, Entries = ex.Entries }); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink }); } return(Result); }
public HttpResponseMessage EliminarItemFactura(long item_id, long exact_id) { try { var proveedor_id = HttpContext.Current.User.Identity.GetUserId(); var item = contexto.facturaitem_exact.Where(x => x.exact_id == exact_id && x.item_id == item_id && x.exact.configuracion.proveedor_id == proveedor_id).FirstOrDefault(); if (item == null) { resp.Codigo = (int)Codigos.REGISTRO_NO_ENCONTRADO; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.REGISTRO_NO_ENCONTRADO); return(resp.ObjectoRespuesta()); } contexto.facturaitem_exact.Remove(item); contexto.SaveChanges(); resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); return(resp.ObjectoRespuesta()); } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
public IEnumerable <TEntity> Create <TEntity>(IEnumerable <TEntity> toCreate) where TEntity : class { IEnumerable <TEntity> Result = null; try { Contexto.Set <TEntity>().AddRange(toCreate); Save(); Result = toCreate; } catch (DbUpdateException ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink, Entries = ex.Entries }); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink }); } return(Result); }
public HttpResponseMessage EliminarPunto(PuntoModel punto) { try { var proveedor_id = HttpContext.Current.User.Identity.GetUserId(); var _punto = contexto.punto_exact.Where(x => x.exact_id == punto.Exact_id && x.punto_id == punto.Punto_id && x.punto.proveedor_id == proveedor_id).FirstOrDefault(); if (_punto == null) { resp.Codigo = (int)Codigos.REGISTRO_NO_ENCONTRADO; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.REGISTRO_NO_ENCONTRADO); return(resp.ObjectoRespuesta()); } contexto.punto_exact.Remove(_punto); contexto.SaveChanges(); resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); return(resp.ObjectoRespuesta()); } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
public List <TEntity> Filter <TEntity>(Expression <Func <TEntity, bool> > criterio, string include1, string include2, string include3, string include4, string include5, string include6, string include7, string include8, string include9, string include10, bool asNoTrack = false) where TEntity : class { List <TEntity> Result = null; try { if (asNoTrack) { Result = Contexto.Set <TEntity>().AsNoTracking().Include(include1).Include(include2).Include(include3).Include(include4).Include(include5).Include(include6).Include(include7).Include(include10).Where(criterio).ToList(); } else { Result = Contexto.Set <TEntity>().Include(include1).Include(include2).Include(include3).Include(include4).Include(include5).Include(include6).Include(include7).Include(include8).Include(include9).Include(include10).Where(criterio).ToList(); } } catch (DbUpdateException ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink, Entries = ex.Entries }); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink }); } return(Result); }
public HttpResponseMessage Crear(usuario Entidad, ModelStateDictionary modelo) { try { if (modelo.IsValid) { IdentityResult result = mgr.Create(Entidad, Entidad.PasswordHash); if (!result.Succeeded) { resp.Codigo = (int)Codigos.ERROR_DE_VALIDACION; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_VALIDACION); resp.Objetoerror = result.Errors; return(resp.ObjectoRespuesta()); } resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); return(resp.ObjectoRespuesta()); } else { resp.Codigo = (int)Codigos.ERROR_DE_VALIDACION; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_VALIDACION); resp.Objetoerror = modelo; return(resp.ObjectoRespuesta()); } } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
public bool Delete <TEntity>(TEntity toDelete) where TEntity : class { bool Result = false; try { Contexto.Set <TEntity>().Attach(toDelete); Contexto.Set <TEntity>().Remove(toDelete); Result = Save() > 0; } catch (DbUpdateException ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink, Entries = ex.Entries }); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEvenArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, HelpLink = ex.HelpLink }); } return(Result); }
public bool Update(Expression <Func <TEntity, bool> > criterio, string propertyName, object valor) { bool Result = false; try { Context.Entry <TEntity>(EntitySet.FirstOrDefault(criterio)).Property(propertyName).CurrentValue = valor; Result = Context.SaveChanges() > 0; } catch (DbEntityValidationException ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, EntityValidationErrors = ex.EntityValidationErrors }); this.EscribirEnArchivoLog(ex); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite }); this.EscribirEnArchivoLog(ex); } return(Result); }
public HttpResponseMessage Eliminar(string id) { try { long _id = Int64.Parse(id); var cat = contexto.categoriactividad.Where(x => x.id == _id).FirstOrDefault(); if (cat == null) { resp.Codigo = (int)Codigos.REGISTRO_NO_ENCONTRADO; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.REGISTRO_NO_ENCONTRADO); return(resp.ObjectoRespuesta()); } contexto.categoriactividad.Remove(cat); contexto.SaveChanges(); resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); return(resp.ObjectoRespuesta()); } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
public List <TEntity> Filter(Expression <Func <TEntity, bool> > criterio) { List <TEntity> Result = null; try { Result = EntitySet.Where(criterio).ToList(); } catch (DbEntityValidationException ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, EntityValidationErrors = ex.EntityValidationErrors }); this.EscribirEnArchivoLog(ex); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite }); this.EscribirEnArchivoLog(ex); } return(Result); }
public HttpResponseMessage BusquedaPorId(string id) { try { var _id = Int64.Parse(id); var categoriactividad = contexto.categoriactividad.Where(x => x.id == _id).Select(x => new { id = x.id, nombre = x.nombre }).FirstOrDefault(); if (categoriactividad == null) { resp.Codigo = (int)Codigos.REGISTRO_NO_ENCONTRADO; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.REGISTRO_NO_ENCONTRADO); return(resp.ObjectoRespuesta()); } resp.Codigo = (int)Codigos.OK; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.OK); resp.Contenido = categoriactividad; return(resp.ObjectoRespuesta()); } catch (Exception ex) { resp.Codigo = (int)Codigos.ERROR_DE_SERVIDOR; resp.Mensaje = Enum.GetName(typeof(Codigos), (int)Codigos.ERROR_DE_SERVIDOR); resp.Excepcion = Excepcion.Create(ex); return(resp.ObjectoRespuesta()); } }
public bool Update(TEntity toUpdate) { bool Result = false; try { EntitySet.Attach(toUpdate); Context.Entry <TEntity>(toUpdate).State = EntityState.Modified; Result = Context.SaveChanges() > 0; } catch (DbEntityValidationException ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite, EntityValidationErrors = ex.EntityValidationErrors }); this.EscribirEnArchivoLog(ex); } catch (Exception ex) { Excepcion?.Invoke(this, new ExceptionEventArgs() { Message = ex.Message, InnerException = ex.InnerException, Source = ex.Source, StackTrace = ex.StackTrace, TargetSite = ex.TargetSite }); this.EscribirEnArchivoLog(ex); } return(Result); }
/// <summary> /// Clic en el botón de exportar. /// </summary> private void btnExportarExcel_Click(object sender, EventArgs e) { DocumentoExcel documento = null; try { documento = new DocumentoExcel(Application.StartupPath + "\\Plantillas\\plantilla libro mayor atm's.xltx", true); DateTime fecha = dtpFecha.Value; DataTable cargas = _coordinacion.listarCargasATMsLibroMayor(fecha); DataTable descargas = _coordinacion.listarDescargasATMsLibroMayor(fecha); documento.seleccionarHoja(4); documento.seleccionarCelda("B3"); documento.actualizarValoresTabla(cargas); documento.seleccionarHoja(3); documento.seleccionarCelda("B3"); documento.actualizarValoresTabla(descargas); } catch (Excepcion ex) { ex.mostrarMensaje(); } catch (Exception) { Excepcion.mostrarMensaje("ErrorExcel"); } if (documento != null) { documento.mostrar(); documento.cerrar(); } }