private Respuesta <Inscripcion> reInscribir() { Respuesta <Inscripcion> res = new Respuesta <Inscripcion>(); res.codigo = 1; res.mensaje = "Ocurrio un Error en base de datos"; res.data = new Inscripcion(); try { using (var tr = new TransactionScope()) { using (var db = new EntitiesEVE01()) { //SE ACTUALIZA EL CAMPO DEL ESTADO_REGISTRO AL VALOR "A" var ob = db.EVE01_INSCRIPCION. Where(i => i.EVENTO == MvcApplication.idEvento && i.PARTICIPANTE == this.idParticipante). Select(i => i).SingleOrDefault(); ob.ESTADO_REGISTRO = "A"; ob.USUARIO_CREACION = MvcApplication.UserName; ob.FECHA_CREACION = DateTime.Now; int re_ob = db.SaveChanges(); if (re_ob <= 0) { Transaction.Current.Rollback(); res.codigo = 2; res.mensaje = "No fue Posible Registrar la Inscripcion"; return(res); } //SE AGREGAN LAS OPCIONES A LA INSCRIPCION InscripcionOpcion agregar = new InscripcionOpcion(); Respuesta <InscripcionOpcion> objOpciones = agregar.agregarOpcionesInscripcion(this); if (objOpciones.codigo != 0) { Transaction.Current.Rollback(); res.codigo = objOpciones.codigo; res.mensaje = objOpciones.mensaje; return(res); } } tr.Complete(); res.codigo = 0; res.mensaje = "Se realizo la Inscripcion de Forma Correcta"; return(res); } } catch (Exception ex) { res.codigo = -1; res.mensaje = "Ocurrio una excepcion al momento de la inscripcion, Ref: " + ex.ToString(); res.mensajeError = ex.ToString(); return(res); } }
private Respuesta <Inscripcion> insertInscripcion() { Respuesta <Inscripcion> res = new Respuesta <Inscripcion>(); res.codigo = 1; res.mensaje = "Ocurrio un Error en base de datos"; res.data = new Inscripcion(); try { using (var tr = new TransactionScope()) { using (var db = new EntitiesEVE01()) { //SE INSERTA EN LA TABLA DE EVE01_INSCRIPCION PARA QUE SE CUMPLA LA INSCRIPCION EVE01_INSCRIPCION ob = new EVE01_INSCRIPCION(); ob.EVENTO = MvcApplication.idEvento; ob.PARTICIPANTE = this.idParticipante; ob.FECHA_INSCRIPCION = DateTime.Now; ob.ESTADO_REGISTRO = "A"; ob.USUARIO_CREACION = MvcApplication.UserName; ob.FECHA_CREACION = DateTime.Now; db.EVE01_INSCRIPCION.Add(ob); int re_ob = db.SaveChanges(); if (re_ob <= 0) { Transaction.Current.Rollback(); res.codigo = 2; res.mensaje = "No fue Posible Registrar la Inscripcion"; return(res); } //SE AGREGAN LAS OPCIONES A LA INSCRIPCION InscripcionOpcion agregar = new InscripcionOpcion(); Respuesta <InscripcionOpcion> objOpciones = agregar.agregarOpcionesInscripcion(this); if (objOpciones.codigo != 0) { Transaction.Current.Rollback(); res.codigo = objOpciones.codigo; res.mensaje = objOpciones.mensaje; return(res); } } tr.Complete(); res.codigo = 0; res.mensaje = "Se realizo la Inscripcion de Forma Correcta"; return(res); } } catch (Exception ex) { res.codigo = -1; res.mensaje = "Ocurrio una excepcion al momento de la inscripcion, Ref: " + ex.ToString(); res.mensajeError = ex.ToString(); return(res); } }
public Respuesta <SaldoParticipante> actualizarSaldos(InscripcionOpcion data) { Respuesta <SaldoParticipante> result = new Respuesta <SaldoParticipante>(); result.codigo = 1; result.mensaje = "Ocurrio un Error en Base de datos"; result.data = new SaldoParticipante(); try { using (var db = new EntitiesEVE01()) { var total = (from io in db.EVE01_INSCRIPCION_OPCION join oe in db.EVE01_EVENTO_OPCION on new { io.EVENTO, io.OPCION } equals new { oe.EVENTO, oe.OPCION } where io.EVENTO == MvcApplication.idEvento && io.PARTICIPANTE == data.idParticipante && io.ESTADO_REGISTRO == "A" select oe.PRECIO).Sum(); var Abonos = (from s in db.EVE01_MOVIMIENTO where s.EVENTO == MvcApplication.idEvento && s.PARTICIPANTE == data.idParticipante && s.TIPO_MOVIMIENTO == "AB" select s.CANTIDAD).Sum(); Abonos = Abonos == null ? 0 : Abonos; var Cargos = (from s in db.EVE01_MOVIMIENTO where s.EVENTO == MvcApplication.idEvento && s.PARTICIPANTE == data.idParticipante && s.TIPO_MOVIMIENTO == "CR" select s.CANTIDAD).Sum(); Cargos = Cargos == null ? 0 : Cargos; var saldoAbonado = Abonos - Cargos; //CUANDO YA SE TENGA LA TABLA DE MOVIMIENTO, DE AHI SE OBTIENE EL SALDO ABONADO var saldoPendiente = total - saldoAbonado; var saldo = (from s in db.EVE01_PARTICIPANTE_SALDO where s.EVENTO == MvcApplication.idEvento && s.PARTICIPANTE == data.idParticipante select s).SingleOrDefault(); saldo.TOTAL = total; saldo.SALDO_ABONADO = saldoAbonado; saldo.SALDO_PENDIENTE = saldoPendiente; saldo.USUARIO_MODIFICACION = MvcApplication.UserName.ToUpper(); saldo.FECHA_MODIFICACION = DateTime.Now; db.SaveChanges(); } result.codigo = 0; result.mensaje = "Ok"; return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una Excepcion al actualizar los Saldos, ref: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
public Respuesta <Inscripcion> AnularInscripcion() { Respuesta <Inscripcion> result = new Respuesta <Inscripcion>(); result.codigo = 1; result.mensaje = "Ocurrio un Error en base de datos"; result.data = new Inscripcion(); try { using (var tr = new TransactionScope()) { using (var db = new EntitiesEVE01()) { var anular = db.EVE01_INSCRIPCION. Where(a => a.PARTICIPANTE == this.idParticipante && a.EVENTO == MvcApplication.idEvento). Select(a => a).SingleOrDefault(); //SE CAMBIA EL ESTADO_REGISTRO A "B" PARA INDICAR QUE FUE ANULADA LA INSCRIPCION anular.ESTADO_REGISTRO = "B"; anular.USUARIO_MODIFICACION = MvcApplication.UserName; anular.FECHA_MODIFICACION = DateTime.Now; int resp = db.SaveChanges(); if (resp <= 0) { Transaction.Current.Rollback(); result.codigo = -2; result.mensaje = "No fue Posible anular la inscripcion"; result.data = new Inscripcion(); return(result); } //SE ELIMINAN LOS REGISTROS DE LAS OPCIONES DE LA INSCRIPCION InscripcionOpcion objAnular = new InscripcionOpcion(); Respuesta <InscripcionOpcion> delOpciones = objAnular.eliminarOpcionesInscripcion(this); if (delOpciones.codigo != 0) { Transaction.Current.Rollback(); result.codigo = delOpciones.codigo; result.mensaje = delOpciones.mensaje; return(result); } //SE ELIMINA EL REGISTRO DE SALDO DEL PARTICIPANTE SaldoParticipante AnularSaldo = new SaldoParticipante(); Respuesta <SaldoParticipante> respuesta = AnularSaldo.anulacionSaldos(this); if (respuesta.codigo != 0) { Transaction.Current.Rollback(); result.codigo = respuesta.codigo; result.mensaje = respuesta.mensaje; return(result); } //SE ANULAN LOS MOVIMIENTOS REALIZADOS Movimiento anularMov = new Movimiento(); Respuesta <Movimiento> respuestaMov = anularMov.anularMovimientos(this.idParticipante); if (respuestaMov.codigo != 0) { Transaction.Current.Rollback(); result.codigo = respuestaMov.codigo; result.mensaje = respuestaMov.mensaje; return(result); } //SE ANULA SILLA ASIGNADA SillaAnulada anularSilla = new SillaAnulada(); anularSilla.idParticipante = this.idParticipante; Respuesta <SillaAnulada> respuestaSilla = anularSilla.desasignarSillaAnulada(); if (respuestaSilla.codigo != 0) { Transaction.Current.Rollback(); result.codigo = respuestaSilla.codigo; result.mensaje = respuestaSilla.mensaje; return(result); } } tr.Complete(); result.codigo = 0; result.mensaje = "Se Anulo correctamente la Inscripcion"; return(result); } } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una Excepcion al Momento de Anular la Inscripcion, Ref: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }