예제 #1
0
        public Respuesta <InscripcionOpcion> modificarEstadoOpcion()
        {
            Respuesta <InscripcionOpcion> result = new Respuesta <InscripcionOpcion>();

            result.codigo  = 1;
            result.mensaje = "Ocurrio un Error en Base de Datos";
            result.data    = new InscripcionOpcion();

            try
            {
                using (var tr = new TransactionScope())
                {
                    using (var db = new EntitiesEVE01())
                    {
                        var opcion = (from o in db.EVE01_INSCRIPCION_OPCION
                                      where o.EVENTO == MvcApplication.idEvento &&
                                      o.PARTICIPANTE == this.idParticipante &&
                                      o.OPCION == this.idOpcion
                                      select o).SingleOrDefault();


                        if (!this.estadoopcion && transporte(opcion.OPCION)) //SE REALIZA LA VALIDACION DE TRANSPORTE
                        {
                            if (validaFechaAnulacionTransporte())            //SE REALIZA LA VALIDACION DE LA FECHA LIMITE PARA ANULAR TRASPORTE
                            {
                                result.codigo  = -1;
                                result.mensaje = "No es permitido cambiar el trasporte";
                                return(result);
                            }
                            else
                            {
                                //SI EN LAS OPCIONES TIENE ASIGNADO BUS SE PROCEDE A ELIMINAR Y ACTUALIZAR LA DISPONIBILIDAD DE BUS PARA OTRO PARTICIPANTE
                                var tienebusAsignado = (from ob in db.EVE01_INSCRIPCION_BUS
                                                        where ob.EVENTO == MvcApplication.idEvento &&
                                                        ob.PARTICIPANTE == this.idParticipante
                                                        select ob).SingleOrDefault();

                                if (tienebusAsignado != null)
                                {
                                    //SE PROCEDE A ACTUALIZAR LA DISPONIBILIDAD DE LOS BUSES
                                    var actualizarInfoBus = (from aib in db.EVE01_EVENTO_BUS
                                                             where aib.EVENTO == tienebusAsignado.EVENTO &&
                                                             aib.BUS == tienebusAsignado.BUS
                                                             select aib).SingleOrDefault();

                                    actualizarInfoBus.DISPONIBLE++;
                                    actualizarInfoBus.OCUPADO--;
                                    actualizarInfoBus.USUARIO_MODIFICACION = MvcApplication.UserName;
                                    actualizarInfoBus.FECHA_MODIFICACION   = DateTime.Now;
                                    int rba = db.SaveChanges();

                                    if (rba <= 0)
                                    {
                                        Transaction.Current.Rollback();
                                        result.codigo  = -2;
                                        result.mensaje = "No fue posible Actualizar Informacion el Bus Anterior";
                                        return(result);
                                    }

                                    var busAsignado = (from ba in db.EVE01_INSCRIPCION_BUS
                                                       where ba.EVENTO == tienebusAsignado.EVENTO &&
                                                       ba.PARTICIPANTE == tienebusAsignado.PARTICIPANTE &&
                                                       ba.BUS == tienebusAsignado.BUS
                                                       select ba).SingleOrDefault();
                                    db.EVE01_INSCRIPCION_BUS.Remove(busAsignado);
                                    int re = db.SaveChanges();

                                    if (re <= 0)
                                    {
                                        Transaction.Current.Rollback();
                                        result.codigo  = -2;
                                        result.mensaje = "No fue posible eliminar el bus de la Inscripcion";
                                        return(result);
                                    }
                                }
                                //SE CAMBIA EL ESTADO DE LA OPCION DE TRANSPORTE
                                opcion.ESTADO_REGISTRO = "B";
                            }
                        }
                        else if (this.estadoopcion)
                        {
                            opcion.ESTADO_REGISTRO = "A";
                        }
                        else
                        {
                            opcion.ESTADO_REGISTRO = "B";
                        }

                        opcion.USUARIO_MODIFICACION = MvcApplication.UserName;
                        opcion.FECHA_MODIFICACION   = DateTime.Now;
                        int res_m = db.SaveChanges();

                        if (res_m <= 0)
                        {
                            Transaction.Current.Rollback();
                            result.codigo  = -2;
                            result.mensaje = "No fue posible actualizar el estado de la opcion";
                            return(result);
                        }

                        //MODIFICACION DE SALDOS DEL PARTICIPANTE
                        SaldoParticipante             modificar = new SaldoParticipante();
                        Respuesta <SaldoParticipante> respuesta = modificar.actualizarSaldos(this);

                        if (respuesta.codigo != 0)
                        {
                            Transaction.Current.Rollback();
                            result.codigo  = respuesta.codigo;
                            result.mensaje = respuesta.mensaje;
                            return(result);
                        }
                    }
                    tr.Complete();
                    result.codigo  = 0;
                    result.mensaje = "Ok";
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.codigo       = -1;
                result.mensaje      = "Ocurrio una Excepcion al cambiar el estado dela opcion, 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);
            }
        }
예제 #3
0
        public Respuesta <InscripcionOpcion> agregarOpcionesInscripcion(Inscripcion data)
        {
            Respuesta <InscripcionOpcion> result = new Respuesta <InscripcionOpcion>();

            result.codigo  = 1;
            result.mensaje = "Ocurrio un Error en Base de Datos";
            result.data    = new InscripcionOpcion();

            try
            {
                using (var tr = new TransactionScope())
                {
                    using (var db = new EntitiesEVE01())
                    {
                        //SE OBTIENE EL LISTADO DE OPCIONES REGISTRADAS PARA EL EVENTO ACTUAL
                        var listadoOpciones = db.EVE01_EVENTO_OPCION.
                                              Where(o => o.EVENTO == MvcApplication.idEvento &&
                                                    o.ESTADO_REGISTRO == "A").
                                              Select(o => o).ToList();

                        //SE EVALUA SI EXISTEN LAS OPCIONES
                        if (listadoOpciones.Count == 0)
                        {
                            result.codigo  = 1;
                            result.mensaje = "No existen Opciones para este Evento";
                            return(result);
                        }
                        else
                        {
                            //SE RECORRE EL LISTADO DE LAS OPCIONES Y POR CADA UNA QUE SE ENCUENTRA SE INSERTAN EN LA TABLA EVE01_INSCRIPCION_OPCION
                            foreach (var item in listadoOpciones)
                            {
                                EVE01_INSCRIPCION_OPCION opcion = new EVE01_INSCRIPCION_OPCION();
                                opcion.PARTICIPANTE = data.idParticipante;
                                opcion.EVENTO       = MvcApplication.idEvento;
                                opcion.OPCION       = item.OPCION;
                                //SI LA OPCION ES OBLIGATORIA, SE REGISTRA EN ESTADO "A" DE LO CONTRARIO EN ESTADO "B"
                                if (item.OBLIGATORIO == "S")
                                {
                                    opcion.ESTADO_REGISTRO = "A";
                                }
                                else
                                {
                                    opcion.ESTADO_REGISTRO = "B";
                                }
                                opcion.USUARIO_CREACION = MvcApplication.UserName;
                                opcion.FECHA_CREACION   = DateTime.Now;
                                db.EVE01_INSCRIPCION_OPCION.Add(opcion);
                                int res_op = db.SaveChanges();

                                if (res_op <= 0)
                                {
                                    Transaction.Current.Rollback();
                                    result.codigo  = 2;
                                    result.mensaje = "No fue Posible Registrar las Opciones";
                                    return(result);
                                }
                            }
                        }

                        //SE REGISTRA EL SALDO INICIAL
                        SaldoParticipante             nuevo     = new SaldoParticipante();
                        Respuesta <SaldoParticipante> respuesta = nuevo.registrarSaldoInicial(data);

                        if (respuesta.codigo != 0)
                        {
                            Transaction.Current.Rollback();
                            result.codigo  = respuesta.codigo;
                            result.mensaje = respuesta.mensajeError;
                            return(result);
                        }
                    }
                    tr.Complete();
                    result.codigo  = 0;
                    result.mensaje = "Se agregaron correctamente las opciones del Evento";
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.codigo  = -1;
                result.mensaje = "Ocurrio una excepcion al momento de agregar las opciones del Evento, Ref:" + ex.ToString();
                return(result);
            }
        }