Beispiel #1
0
        public Mensaje <Evento> RegistrarEvento(MET01_EVENTO ev)
        {
            Mensaje <Evento> result = new Mensaje <Evento>();

            result.codigo  = 1;
            result.mensaje = "Ocurrio un Error en base de datos al tratar de registrar el Evento";
            result.data    = new Evento();

            try
            {
                using (var db = new EntitiesMetro())
                {
                    var     valcorrelativo = (from li in db.MET01_EVENTO select li.EVENTO).ToList();
                    decimal correlativo    = 0;

                    if (valcorrelativo.Count > 0)
                    {
                        correlativo = valcorrelativo.Max() + 1;
                    }
                    else
                    {
                        correlativo = 1;
                    }

                    MET01_EVENTO nuevoEvento = new MET01_EVENTO()
                    {
                        EVENTO          = correlativo,
                        NOMBRE          = ev.NOMBRE,
                        ESTADO_REGISTRO = ev.ESTADO_REGISTRO,
                        //USUARIO_CREACION = Global.usuario,
                        USUARIO_CREACION = "MET01",
                        FECHA_CREACION   = DateTime.Now
                    };

                    db.MET01_EVENTO.Add(nuevoEvento);
                    db.SaveChanges();
                }
                result.codigo  = 0;
                result.mensaje = "Se ha registrado correctamente el Evento: " + ev.NOMBRE;
                return(result);
            }
            catch (Exception ex)
            {
                result.codigo  = -1;
                result.mensaje = "Ocurrio una excepcion, Referencia: " + ex.ToString();
                result.error   = ex.ToString();
                return(result);
            }
        }
Beispiel #2
0
        public Mensaje <ReciboOficina> registrarReciboOficina()
        {
            Mensaje <ReciboOficina> result = new Mensaje <ReciboOficina>();

            result.codigo  = 1;
            result.mensaje = "Ocurrio un error en base de datos al tratar de registrar el recibo";
            result.data    = new ReciboOficina();

            try
            {
                using (var db = new EntitiesMetro())
                {
                    MET01_RECIBO_OFICINA nuevoRecibo = new MET01_RECIBO_OFICINA();

                    var correlativo = (from c in db.MET01_CORRELATIVO
                                       where c.CORRELATIVO == 1
                                       select c).Single();

                    nuevoRecibo.RECIBO           = Convert.ToDecimal(correlativo.CORRELATIVO_ACTUAL);
                    nuevoRecibo.RECIBO_OFICINA   = this.reciboOficina;
                    nuevoRecibo.NOMBRE           = this.nombre.ToUpper();
                    nuevoRecibo.TOTAL            = this.cantidad;
                    nuevoRecibo.TOTAL_LETRAS     = NumeroLetras.NumeroALetras(this.cantidad.ToString()).ToUpper();
                    nuevoRecibo.CONCEPTO         = this.conceptoRecibo.ToUpper();
                    nuevoRecibo.EVENTO           = Global.evento;
                    nuevoRecibo.IGLESIA          = this.idIglesia;
                    nuevoRecibo.ESTADO_REGISTRO  = "A";
                    nuevoRecibo.USUARIO_CREACION = Global.usuario;
                    nuevoRecibo.FECHA_CREACION   = DateTime.Now;

                    db.MET01_RECIBO_OFICINA.Add(nuevoRecibo);
                    correlativo.CORRELATIVO_ACTUAL++;
                    db.SaveChanges();
                    result.mensaje = "Se registro el recibo Numero: " + nuevoRecibo.RECIBO + ",\nA nombre de: " + nuevoRecibo.NOMBRE + " de forma Exitosa...!!!";
                }
                result.codigo = 0;
                return(result);
            }
            catch (Exception ex)
            {
                result.codigo  = -1;
                result.mensaje = "Ocurrio una Excepcion, referencia: " + ex.ToString();
                result.error   = ex.ToString();
                return(result);
            }
        }
Beispiel #3
0
        public Mensaje <Evento> ActualizarRegistroEvento(MET01_EVENTO ev)
        {
            Mensaje <Evento> result = new Mensaje <Evento>();

            result.codigo  = 1;
            result.mensaje = "Ocurrio un Error en base de datos al Actualizar el registro del Evento " + ev.NOMBRE;
            result.data    = new Evento();

            try
            {
                using (var db = new EntitiesMetro())
                {
                    MET01_EVENTO nuevoEvento = (from e in db.MET01_EVENTO
                                                where e.EVENTO == ev.EVENTO
                                                select e).SingleOrDefault();

                    if (nuevoEvento == null)
                    {
                        result.codigo  = -1;
                        result.mensaje = "No existe ningun registro con el dato del evento enviando para su Actualizacion";
                        return(result);
                    }

                    nuevoEvento.NOMBRE          = ev.NOMBRE;
                    nuevoEvento.ESTADO_REGISTRO = ev.ESTADO_REGISTRO;
                    //nuevoEvento.USUARIO_MODIFICACION = Global.usuariologueado;
                    nuevoEvento.USUARIO_MODIFICACION = "MET01";
                    nuevoEvento.FECHA_MODIFICACION   = DateTime.Now;
                    db.SaveChanges();
                }
                result.codigo  = 0;
                result.mensaje = "Se ha actualizado correctamente el Evento: " + ev.NOMBRE;
                return(result);
            }
            catch (Exception ex)
            {
                result.codigo  = -1;
                result.mensaje = "Ocurrio una excepcion, Referencia: " + ex.ToString();
                result.error   = ex.ToString();
                return(result);
            }
        }
        public Mensaje <Iglesia> actualizarDatosIglesia()
        {
            Mensaje <Iglesia> result = new Mensaje <Iglesia>();

            result.codigo  = 1;
            result.mensaje = "Ocurrio un error en base de datos al Actualizar Datos de la Iglesia";
            result.data    = new Iglesia();

            try
            {
                using (var tr = new TransactionScope())
                {
                    using (var db = new EntitiesMetro())
                    {
                        var datoIglesia = (from i in db.MET01_IGLESIA
                                           where i.IGLESIA == this.idIglesia
                                           select i).SingleOrDefault();

                        var datoPastor = (from p in db.MET01_PASTOR
                                          where p.PASTOR == datoIglesia.PASTOR
                                          select p).SingleOrDefault();

                        var datoEncargado = (from e in db.MET01_ENCARGADO
                                             where e.ENCARGADO == datoIglesia.ENCARGADO
                                             select e).SingleOrDefault();

                        if (this.region != datoIglesia.REGION || this.nombre != datoIglesia.NOMBRE)
                        {
                            datoIglesia.REGION = this.region;
                            datoIglesia.NOMBRE = this.nombre.Trim().ToUpper();
                            datoIglesia.USUARIO_MODIFICACION = Global.usuario.ToUpper();
                            datoIglesia.FECHA_MODIFICACION   = DateTime.Now;
                            int res_i = db.SaveChanges();

                            if (res_i <= 0)
                            {
                                Transaction.Current.Rollback();
                                result.codigo  = -2;
                                result.mensaje = "No fue posible Actualizar la Region de la Iglesia";
                                return(result);
                            }
                        }

                        if (this.nombre_pastor.Trim().ToUpper() != datoPastor.NOMBRE.Trim().ToUpper())
                        {
                            datoPastor.NOMBRE = this.nombre_pastor.Trim().ToUpper();
                            datoPastor.USUARIO_MODIFICACION = Global.usuario.ToUpper();
                            datoPastor.FECHA_MODIFICACION   = DateTime.Now;
                            int res_p = db.SaveChanges();

                            if (res_p <= 0)
                            {
                                Transaction.Current.Rollback();
                                result.codigo  = -2;
                                result.mensaje = "No fue posible Actualizar la Informacion del Pastor";
                                return(result);
                            }
                        }

                        if (this.nombre_encargado.Trim().ToUpper() != datoEncargado.NOMBRE.Trim().ToUpper() ||
                            this.telefono_encargado.Trim() != datoEncargado.TELEFONO.Trim())
                        {
                            datoEncargado.NOMBRE               = this.nombre_encargado.Trim().ToUpper();
                            datoEncargado.TELEFONO             = this.telefono_encargado;
                            datoEncargado.USUARIO_MODIFICACION = Global.usuario.ToUpper();
                            datoEncargado.FECHA_MODIFICACION   = DateTime.Now;
                            int res_e = db.SaveChanges();

                            if (res_e <= 0)
                            {
                                Transaction.Current.Rollback();
                                result.codigo  = -2;
                                result.mensaje = "No fue posible Actualizar la Informacion del Encargado";
                                return(result);
                            }
                        }
                    }
                    tr.Complete();
                    result.codigo  = 0;
                    result.mensaje = "Se Actualizaron los datos Correctamente";
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public Mensaje <Iglesia> agregarNuevaIglesia()
        {
            Mensaje <Iglesia> result = new Mensaje <Iglesia>();

            result.codigo  = 1;
            result.mensaje = "Ocurrio un error en base de datos al tratar de agregar la Iglesia";
            result.data    = new Iglesia();

            try
            {
                using (var tr = new TransactionScope())
                {
                    using (var db = new EntitiesMetro())
                    {
                        var idp = db.MET01_PASTOR.Select(p => p.PASTOR).Max();
                        idp++;
                        MET01_PASTOR nuevoPastor = new MET01_PASTOR();
                        nuevoPastor.PASTOR           = idp;
                        nuevoPastor.NOMBRE           = this.nombre_pastor.ToUpper();
                        nuevoPastor.ESTADO_REGISTRO  = "A";
                        nuevoPastor.USUARIO_CREACION = Global.usuario;
                        nuevoPastor.FECHA_CREACION   = DateTime.Now;

                        db.MET01_PASTOR.Add(nuevoPastor);

                        int res_p = db.SaveChanges();

                        if (res_p <= 0)
                        {
                            Transaction.Current.Rollback();
                            result.codigo  = -2;
                            result.mensaje = "No fue posible registrar la Iglesia, ref: No pudo registrar datos del Pastor";
                            result.data    = new Iglesia();
                            return(result);
                        }

                        var ide = db.MET01_ENCARGADO.Select(p => p.ENCARGADO).Max();
                        ide++;
                        MET01_ENCARGADO nuevoEncargado = new MET01_ENCARGADO();
                        nuevoEncargado.ENCARGADO        = ide;
                        nuevoEncargado.NOMBRE           = this.nombre_encargado.ToUpper();
                        nuevoEncargado.TELEFONO         = this.telefono_encargado;
                        nuevoEncargado.ESTADO_REGISTRO  = "A";
                        nuevoEncargado.USUARIO_CREACION = Global.usuario;
                        nuevoEncargado.FECHA_CREACION   = DateTime.Now;

                        db.MET01_ENCARGADO.Add(nuevoEncargado);

                        int res_e = db.SaveChanges();

                        if (res_e <= 0)
                        {
                            Transaction.Current.Rollback();
                            result.codigo  = -2;
                            result.mensaje = "No fue posible registrar la Iglesia ref: No pudo registrar datos del Encargado";
                            result.data    = new Iglesia();
                            return(result);
                        }

                        var idi = db.MET01_IGLESIA.Select(iga => iga.IGLESIA).Max();
                        idi++;
                        MET01_IGLESIA nuevaIglesia = new MET01_IGLESIA();
                        nuevaIglesia.IGLESIA          = idi;
                        nuevaIglesia.NOMBRE           = this.nombre.ToUpper();
                        nuevaIglesia.REGION           = this.region;
                        nuevaIglesia.ENCARGADO        = ide;
                        nuevaIglesia.PASTOR           = idp;
                        nuevaIglesia.ESTADO_REGISTRO  = "A";
                        nuevaIglesia.USUARIO_CREACION = Global.usuario;
                        nuevaIglesia.FECHA_CREACION   = DateTime.Now;

                        db.MET01_IGLESIA.Add(nuevaIglesia);

                        int res_i = db.SaveChanges();

                        if (res_i <= 0)
                        {
                            Transaction.Current.Rollback();
                            result.codigo  = -2;
                            result.mensaje = "No fue posible registrar la Iglesia, ref: No pudo registrar datos de la Iglesia";
                            result.data    = new Iglesia();
                            return(result);
                        }
                    }
                    tr.Complete();
                    result.codigo  = 0;
                    result.mensaje = "Se registro la iglesia: " + this.nombre.ToUpper();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.codigo  = -1;
                result.mensaje = "Ocurrio una excepcion al guarda la Iglesia, ref: " + ex.ToString();
                result.error   = ex.ToString();
                return(result);
            }
        }