Ejemplo n.º 1
0
        public bool Deshacer_EventoTempOperador(int eventoidDeshacer)
        {
            bool Deshacer = false;

            try
            {
                //Obtenemos los valores de los eventos sin modificar para actualizar la tabla de eventos temporal
                var evt          = new Eventos();
                var eventoSinMod = evt.GetSingle(x => x.EV_COD_EVENTO == eventoidDeshacer);

                //Obtenermos la tabla evento temporal para actualizar los datos con la tabla sin modificar
                var evtmp            = new EventosTemp();
                var eventotempactual = evtmp.GetSingle(x => x.EV_COD_EVENTO == eventoSinMod.EV_COD_EVENTO);

                using (var trx = new TransactionScope())
                {
                    if (eventotempactual != null && eventoSinMod != null)
                    {
                        evtmp.Update(eventotempactual, mapeoEntidadEventoTemporal(eventoSinMod, eventotempactual.EV_COD_EVENTO_TEMP, Convert.ToInt32(RegistryState.Aprobado)));
                        eventoSinMod.EV_ESTATUS = Convert.ToInt32(RegistryState.Aprobado);
                        evt.Attach(eventoSinMod);
                    }
                    trx.Complete();
                    Deshacer = true;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(Deshacer);
        }
Ejemplo n.º 2
0
 public Eventos()
     : this(new SaxRepositoryContext())
 {
     evtempService  = new EventosTemp();
     InjectIemp     = new Empresa();
     InjectIareaOpe = new AreaOperativa();
     InjectIctaCont = new CuentaContable();
 }
Ejemplo n.º 3
0
 public SAX_EVENTO_TEMP Consulta_EventoTempOperador(int eventoidConsulta)
 {
     try
     {
         var evtmp = new EventosTemp();
         eventotempactual = evtmp.GetSingle(x => x.EV_COD_EVENTO == eventoidConsulta);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return(eventotempactual);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Actualiza la tabal Evento temporal con valores nuevos y actualiza el status de la tabla evento
        /// con status = 0 = Pendiente
        /// </summary>
        /// <param name="eventoTempNuevo"></param>
        /// <returns></returns>
        public int Update_EventoTempOperador(SAX_EVENTO_TEMP eventoTempNuevo)
        {
            int actualizado = 0;

            try
            {
                using (var trx = new TransactionScope())
                {
                    //Actualizamos tabla Evento con status = 0 = pendiente
                    var evt          = new Eventos();
                    var eventoactual = evt.GetSingle(x => x.EV_COD_EVENTO == eventoTempNuevo.EV_COD_EVENTO);
                    if (eventoactual != null)
                    {
                        var eventonuevo = eventoactual;
                        eventonuevo.EV_ESTATUS = Convert.ToInt32(RegistryState.Pendiente);
                        evt.Update(eventoactual, eventonuevo);
                    }

                    //Actualizamos tabla EventoTemp con valores nuevos y con status = 2 = por aprobar
                    var evtmp            = new EventosTemp();
                    var eventotempactual = evtmp.GetSingle(x => x.EV_COD_EVENTO == eventoTempNuevo.EV_COD_EVENTO);
                    if (eventotempactual != null)
                    {
                        eventoTempNuevo.EV_USUARIO_CREACION  = eventotempactual.EV_USUARIO_CREACION;
                        eventoTempNuevo.EV_COD_EVENTO_TEMP   = eventotempactual.EV_COD_EVENTO_TEMP;
                        eventoTempNuevo.EV_USUARIO_APROBADOR = eventotempactual.EV_USUARIO_APROBADOR;
                        eventoTempNuevo.EV_FECHA_APROBACION  = eventotempactual.EV_FECHA_APROBACION;
                        eventoTempNuevo.EV_ESTATUS           = Convert.ToInt32(RegistryState.PorAprobar);
                        //eventoTempNuevo.EV_REFERENCIA_CREDITO = eventotempactual.EV_REFERENCIA_CREDITO;
                        //eventoTempNuevo.EV_REFERENCIA_DEBITO = eventotempactual.EV_REFERENCIA_DEBITO;
                        evtmp.Update(eventotempactual, eventoTempNuevo);
                    }

                    trx.Complete();
                    if (eventotempactual == null && eventoactual == null)
                    {
                        actualizado = 0;
                    }
                    else
                    {
                        actualizado = eventoTempNuevo.EV_COD_EVENTO;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(actualizado);
        }
Ejemplo n.º 5
0
        public int Insert_Eventos_EventosTempOperador(SAX_EVENTO evento)
        {
            int result = 0;

            try
            {
                DBModelEntities db           = new DBModelEntities();
                var             validaEvento = db.Validar_eventoxcrear(evento.CE_ID_EMPRESA, evento.EV_ID_AREA, evento.EV_CUENTA_DEBITO, evento.EV_CUENTA_CREDITO);
                int             procede      = validaEvento.FirstOrDefault().Value;
                if (procede == 1)
                {
                    using (var trx = new TransactionScope())
                    {
                        var evnttemp     = new EventosTemp();
                        var eventoExiste = evnttemp.GetSingle(x => x.EV_COD_EVENTO == evento.EV_COD_EVENTO);
                        if (eventoExiste == null)
                        {
                            //Insertamos Evento
                            var ev = new Eventos();
                            evento.EV_ESTATUS = Convert.ToInt32(RegistryState.Pendiente);
                            ev.Insert(evento);

                            //Insertamos EventoTemp
                            int id    = evento.EV_COD_EVENTO;
                            var evtmp = mapeoEntidadEventoTemporal(evento, id, Convert.ToInt32(RegistryState.PorAprobar));
                            evtempService.Insert(evtmp);

                            trx.Complete();
                            result = id;
                        }
                        else
                        {
                            var eventoTemp = evtempService.GetSingle(x => x.EV_COD_EVENTO == evento.EV_COD_EVENTO);
                            evtempService.Update(eventoTemp, mapeoEntidadEventoTemporal(evento, evento.EV_COD_EVENTO, Convert.ToInt32(RegistryState.PorAprobar)));
                        }
                    }
                }
                else
                {
                    result = -1 * procede;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(result);
        }
Ejemplo n.º 6
0
        public int SupervidorRechaza_Evento(int eventoIdRechaza, string userId)
        {
            try
            {
                var evtmpRechazo = new EventosTemp();
                var evRechazo    = evtmpRechazo.GetSingle(x => x.EV_USUARIO_APROBADOR == null &&
                                                          x.EV_COD_EVENTO == eventoIdRechaza);

                if (evRechazo != null)
                {
                    int rechazado = 0;
                    //Obtenermos la tabla evento para actualizar los datos con la tabla sin modificar
                    var evt          = new Eventos();
                    var eventoActual = evt.GetSingle(x => x.EV_COD_EVENTO == eventoIdRechaza);
                    //Obtenermos la tabla evento Temporal para actualizar los datos con la tabla sin modificar
                    var evtmp            = new EventosTemp();
                    var eventoTempActual = evtmp.GetSingle(x => x.EV_COD_EVENTO == eventoIdRechaza);
                    //Iniciamos la transacción
                    using (var trx = new TransactionScope())
                    {
                        if (eventoActual != null && eventoTempActual != null)
                        {
                            //Evento Temporal actualizado con valores de evento
                            var evtmporal = mapeoEntidadEventoTemporal(eventoActual, eventoTempActual.EV_COD_EVENTO_TEMP, Convert.ToInt16(RegistryState.Eliminado));
                            evtmporal.EV_FECHA_APROBACION  = DateTime.Now.Date;
                            evtmporal.EV_USUARIO_APROBADOR = userId;
                            evtmporal.EV_ESTATUS           = Convert.ToInt32(RegistryState.Eliminado);
                            evtmp.Update(eventoTempActual, evtmporal);
                            //Evento actualizado con estatus aprobado
                            var ev = evt.GetSingle(x => x.EV_COD_EVENTO == eventoIdRechaza);
                            if (ev.EV_USUARIO_APROBADOR == null)
                            {
                                ev.EV_ESTATUS = Convert.ToInt32(RegistryState.Eliminado);
                            }
                            else
                            {
                                ev.EV_ESTATUS = Convert.ToInt32(RegistryState.Aprobado);
                            }
                            ev.EV_FECHA_APROBACION  = DateTime.Now.Date;
                            ev.EV_USUARIO_APROBADOR = userId;

                            evt.Update(eventoActual, ev);
                            //commit de la transacción
                            trx.Complete();
                            rechazado = eventoIdRechaza;
                        }
                    }
                    return(rechazado);
                }
                else
                {
                    int rechazado = 0;
                    //Obtenermos la tabla evento para actualizar los datos con la tabla sin modificar
                    var evt          = new Eventos();
                    var eventoActual = evt.GetSingle(x => x.EV_COD_EVENTO == eventoIdRechaza);
                    //Obtenermos la tabla evento Temporal para actualizar los datos con la tabla sin modificar
                    var evtmp            = new EventosTemp();
                    var eventoTempActual = evtmp.GetSingle(x => x.EV_COD_EVENTO == eventoIdRechaza);
                    //Iniciamos la transacción
                    using (var trx = new TransactionScope())
                    {
                        if (eventoActual != null && eventoTempActual != null)
                        {
                            //Evento Temporal actualizado con valores de evento
                            var evtmporal = mapeoEntidadEventoTemporal(eventoActual, eventoTempActual.EV_COD_EVENTO_TEMP, Convert.ToInt16(RegistryState.Aprobado));
                            evtmporal.EV_FECHA_APROBACION  = DateTime.Now.Date;
                            evtmporal.EV_USUARIO_APROBADOR = userId;
                            evtmporal.EV_ESTATUS           = Convert.ToInt32(RegistryState.Eliminado);
                            evtmp.Update(eventoTempActual, evtmporal);
                            //Evento actualizado con estatus aprobado
                            var ev = evt.GetSingle(x => x.EV_COD_EVENTO == eventoIdRechaza);
                            if (ev.EV_USUARIO_APROBADOR == null)
                            {
                                ev.EV_ESTATUS = Convert.ToInt32(RegistryState.Eliminado);
                            }
                            else
                            {
                                ev.EV_ESTATUS = Convert.ToInt32(RegistryState.Aprobado);
                            }
                            ev.EV_FECHA_APROBACION  = DateTime.Now.Date;
                            ev.EV_USUARIO_APROBADOR = userId;

                            evt.Update(eventoActual, ev);
                            //commit de la transacción
                            trx.Complete();
                            rechazado = eventoIdRechaza;
                        }
                    }
                    return(rechazado);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 7
0
        public int SupervidorAprueba_Evento(int eventoIdAprueba, string userId)
        {
            try
            {
                //Obtenermos la tabla evento para actualizar los datos con la tabla sin modificar
                var evt          = new Eventos();
                var eventoActual = evt.GetSingle(x => x.EV_COD_EVENTO == eventoIdAprueba);
                //Obtenermos la tabla evento Temporal para actualizar los datos con la tabla sin modificar
                var             evtmp            = new EventosTemp();
                var             eventoTempActual = evtmp.GetSingle(x => x.EV_COD_EVENTO == eventoIdAprueba);
                DBModelEntities db      = new DBModelEntities();
                int             procede = 0;
                using (var trx = new TransactionScope())
                {
                    if (eventoActual != null && eventoTempActual != null)
                    {
                        var ev = mapeoEntidadEvento(eventoTempActual, eventoIdAprueba, Convert.ToInt16(RegistryState.Aprobado));
                        if (eventoTempActual != null)
                        {
                            if (eventoTempActual.EV_ESTATUS_ACCION == "0")
                            {
                                eventoActual.EV_ESTATUS = 0;
                                ev.EV_ESTATUS           = 0;
                                procede = 1;
                            }
                        }
                        ev.EV_USUARIO_APROBADOR = userId;
                        ev.EV_FECHA_APROBACION  = DateTime.Now.Date;
                        if (procede != 1)
                        {
                            var validaEvento = db.Validar_eventoxcrear(eventoTempActual.CE_ID_EMPRESA, eventoTempActual.EV_ID_AREA, eventoTempActual.EV_CUENTA_DEBITO, eventoTempActual.EV_CUENTA_CREDITO);
                            procede = validaEvento.FirstOrDefault().Value;
                        }
                        if (procede == 1)
                        //Actualizamos Evento con valores de Eventos Temporal
                        {
                            evt.Update(eventoActual, ev);

                            //Actualizamos Evento temporal
                            var evtmporal = mapeoEntidadEventoTemporal(eventoTempActual);
                            evtmporal.EV_FECHA_APROBACION  = DateTime.Now.Date;
                            evtmporal.EV_USUARIO_APROBADOR = userId;
                            evtmp.Update(eventoTempActual, evtmporal);
                            trx.Complete();
                            return(eventoTempActual.EV_COD_EVENTO);
                        }
                        else
                        {
                            return(-11);
                        }
                    }
                    else
                    {
                        throw new Exception("No se encuentra, Evento para Aprobar");
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }