Exemplo n.º 1
0
        public JsonResult EliminarSubCate(SubCategorias_Model Objeto)
        {
            try
            {
                var db = new mmsEntities();
                var Modelo_Modificar = db.combo_sub_categoria.FirstOrDefault(x => x.id == Objeto.Id && x.Activo);
                Modelo_Modificar.Activo = false;
                var Modifico_Ingresos = db.ingresos.Where(i => i.Id_Entidad == ID_Entidad && i.Activo && i.Id_SubCategoria == Objeto.Id).ToList();
                Modifico_Ingresos.ForEach(x => x.Activo = false);
                var res = db.SaveChanges();
                if (res > 0)
                {
                    return(Json(ResultadoJson.ResultadoCorrecto("Sub Categoría Eliminado con exito")));
                }
                else
                {
                    return(Json(ResultadoJson.ResultadoInCorrecto("Error al Eliminar la Sub Categoría")));
                }
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 2
0
        public JsonResult ModificarSubCate(SubCategorias_Model modelo)
        {
            try
            {
                var db = new mmsEntities();
                var Modelo_Modificar = db.combo_sub_categoria.FirstOrDefault(x => x.id == modelo.Id && x.Activo);
                Modelo_Modificar.Id_Categoria = modelo.Categoria.Id;
                Modelo_Modificar.Nombre       = modelo.Nombre;

                var Modifico_Ingresos = db.ingresos.Where(i => i.Id_Entidad == ID_Entidad && i.Activo && i.Id_SubCategoria == modelo.Id).ToList();
                var TipoCate          = db.combo_tipo.FirstOrDefault(x => x.Nombre == modelo.Categoria.Tipo);
                foreach (var item in Modifico_Ingresos)
                {
                    item.Id_Categoria    = modelo.Categoria.Id;
                    item.Id_SubCategoria = modelo.Id;
                    item.Id_Tipo         = TipoCate.id;
                }

                var res = db.SaveChanges();
                if (res > 0)
                {
                    return(Json(ResultadoJson.ResultadoCorrecto("Sub Categoría Modificada con exito")));
                }
                else
                {
                    return(Json(ResultadoJson.ResultadoInCorrecto("Error al Modificar la Categoría")));
                }
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 3
0
        public JsonResult GuardarEgreso(EgresosMensuales_Model Objeto)
        {
            try
            {
                var db = new mmsEntities();
                if (Objeto.Id == 0)
                {
                    //Guardamos
                    var resultado = new MMS_DLL.egresos_mensuales
                    {
                        Fecha_Insert      = DateTime.Now,
                        Fecha_Vencimiento = Objeto.FechaVencimiento,
                        Id_Entidad        = ID_Entidad,
                        Id_SubCategoria   = Objeto.Nombre.Id,
                        Detalle           = Objeto.Detalle != null ? Objeto.Detalle : "-",
                        Precio            = Objeto.Precio,
                        Pagado            = Objeto.Pagado,
                        Recordatorio      = Objeto.Recordatorio,
                        Activo            = true
                    };
                    db.egresos_mensuales.Add(resultado);
                    var resu = db.SaveChanges();
                    if (resu > 0)
                    {
                        return(Json(ResultadoJson <EgresosMensuales_Model> .ResultadoCorrecto("El Egreso fue guardado con Exito")));
                    }
                    else
                    {
                        return(Json(ResultadoJson <EgresosMensuales_Model> .ResultadoInCorrecto("Error al guardar el Egreso")));
                    }
                }

                else
                {
                    //Modificamos.
                    var IdEgreso = db.egresos_mensuales.FirstOrDefault(x => x.Activo && x.Id_Entidad == ID_Entidad && x.id == Objeto.Id);
                    IdEgreso.Id_SubCategoria   = Objeto.Nombre.Id;
                    IdEgreso.Fecha_Vencimiento = Objeto.FechaVencimiento;
                    IdEgreso.Precio            = Objeto.Precio;
                    IdEgreso.Pagado            = Objeto.Pagado;
                    IdEgreso.Recordatorio      = Objeto.Recordatorio;
                    IdEgreso.Detalle           = Objeto.Detalle != null ? Objeto.Detalle : "-";
                    var res = db.SaveChanges();
                    if (res > 0)
                    {
                        return(Json(ResultadoJson <EgresosMensuales_Model> .ResultadoCorrecto("El Egreso fue modificado con exito")));
                    }
                    else
                    {
                        return(Json(ResultadoJson <EgresosMensuales_Model> .ResultadoInCorrecto("Error al modificar el Egreso")));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 4
0
        public JsonResult Recordatorio_Alarmas()
        {
            try
            {
                var db            = new mmsEntities();
                var listaIngresos = db.ingesos_mensuales.Where(x => x.Activo && x.Recordatorio.Value && x.Id_Entidad == ID_Entidad && x.Fecha_Vencimiento.Value.Day == DateTime.Now.Day && x.Fecha_Vencimiento.Value.Month == DateTime.Now.Month && x.Fecha_Vencimiento.Value.Year == DateTime.Now.Year).Select(p => new Recordatorios_Model
                {
                    FechaVencimiento = p.Fecha_Vencimiento.Value,
                    Nombre           = p.combo_sub_categoria.Nombre,
                    Observacion      = p.Detalle,
                    Tipo             = "COBRAR"
                }).ToList();
                var listaEgresos = db.egresos_mensuales.Where(x => x.Activo && x.Recordatorio.Value && x.Id_Entidad == ID_Entidad && x.Fecha_Vencimiento.Value.Day == DateTime.Now.Day && x.Fecha_Vencimiento.Value.Month == DateTime.Now.Month && x.Fecha_Vencimiento.Value.Year == DateTime.Now.Year).Select(p => new Recordatorios_Model
                {
                    FechaVencimiento = p.Fecha_Vencimiento.Value,
                    Nombre           = p.combo_sub_categoria.Nombre,
                    Observacion      = p.Detalle,
                    Tipo             = "PAGAR"
                }).ToList();
                var lista = listaIngresos.Concat(listaEgresos).ToList();
                return(Json(ResultadoJson <Recordatorios_Model> .ResultadoCorrecto(lista)));
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 5
0
        public JsonResult Grafico_Area()
        {
            try
            {
                var db        = new mmsEntities();
                var lista     = db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Activo).GroupBy(x => x.Fecha.Year).ToList();
                var resultado = new List <Morris_Area>();
                var dato      = new Morris_Area
                {
                    element = "morris-area-chart",
                    data    = lista.Select(p => new Datos_Area
                    {
                        Anio    = p.Key.ToString(),
                        Ingreso = p.Where(r => r.Id_Tipo == 1).Sum(r => Math.Round(r.Precio.Value)),
                        Egreso  = p.Where(r => r.Id_Tipo == 2).Sum(r => Math.Round(r.Precio.Value)),
                    }).ToList(),
                    xkey      = "Anio",
                    ykeys     = { { "Ingreso" }, { "Egreso" }, { "Total_Area" } },
                    labels    = { "Ingreso", "Egreso", "Total" },
                    hideHover = "auto",
                    pointSize = 2,
                    resize    = true
                };

                resultado.Add(dato);
                return(Json(ResultadoJson <Morris_Area> .ResultadoCorrecto(resultado)));
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson <Morris_Area> .ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 6
0
        public JsonResult ObtenerListado_SubCate()
        {
            try
            {
                var db        = new mmsEntities();
                var lista     = db.combo_sub_categoria.Where(x => x.Id_Entidad == ID_Entidad && x.Activo).OrderBy(p => p.Nombre).ToList();
                var resultado = new List <SubCategorias_Model>();
                foreach (var item in lista)
                {
                    resultado.Add(new SubCategorias_Model
                    {
                        Id        = item.id,
                        Categoria = new Combo_Categorias()
                        {
                            Id     = item.combo_categoria != null ? item.combo_categoria.id : 0,
                            Nombre = item.combo_categoria != null ? item.combo_categoria.Nombre : null,
                            Tipo   = item.combo_categoria != null ? item.combo_categoria.combo_tipo.Nombre : null
                        },
                        Nombre = item.Nombre,
                        Fecha  = item.Fecha_Proceso.Value
                    });
                }
                return(Json(ResultadoJson <SubCategorias_Model> .ResultadoCorrecto(resultado)));
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson <SubCategorias_Model> .ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 7
0
        public JsonResult Grafico_Donut(Busqueda_Model modelo)
        {
            try
            {
                var db    = new mmsEntities();
                var lista = db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Fecha >= modelo.Fecha_Desde.Date && x.Fecha <= modelo.Fecha_Hasta.Date && x.Activo).ToList()
                            .Where(x => (modelo.Cate == null || x.Id_Categoria == modelo.Cate.Id) &&
                                   (modelo.Tipo == null || x.Id_Tipo == modelo.Tipo.id) &&
                                   (modelo.SubCate == null || x.Id_SubCategoria == modelo.SubCate.Id)).OrderByDescending(p => p.id).ToList();

                var GraficoCate = lista.Where(p => (modelo.Cate == null || p.Id_Categoria == modelo.Cate.Id) && (modelo.SubCate == null || p.Id_SubCategoria == modelo.SubCate.Id)).GroupBy(x => x.combo_sub_categoria.Nombre).ToList();
                var resultado   = new List <Morris_Donut>();
                var dato        = new Morris_Donut
                {
                    element = "morris-donut-chart",
                    data    = GraficoCate.Select(p => new Datos_Donut {
                        label = p.Key, value = p.Sum(q => Math.Round(q.Precio.Value))
                    }).ToList(),
                    resize = true
                };
                resultado.Add(dato);
                return(Json(ResultadoJson <Morris_Donut> .ResultadoCorrecto(resultado)));
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson <Morris_Donut> .ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 8
0
        public JsonResult ObtenerMes()
        {
            try
            {
                var db        = new mmsEntities();
                var lista     = db.combo_mes.OrderBy(x => x.idmes).ToList();
                var resultado = new List <CierreMes.ComboMeses>();
                foreach (var item in lista)
                {
                    resultado.Add(new CierreMes.ComboMeses
                    {
                        Id     = item.idmes,
                        Nombre = item.meses
                    });
                }

                return(Json(ResultadoJson <CierreMes.ComboMeses> .ResultadoCorrecto(resultado)));
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson <CierreMes_Model> .ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 9
0
        public JsonResult ObtenerSubCategorias()
        {
            try
            {
                var db        = new mmsEntities();
                var lista     = db.combo_sub_categoria.Where(x => x.Id_Entidad == ID_Entidad && x.Activo).ToList();
                var resultado = new List <Sub_Categorias_Mensuales>();

                foreach (var item in lista)
                {
                    var Tipo = db.combo_tipo.FirstOrDefault(x => x.id == item.combo_categoria.Id_Tipo);
                    resultado.Add(new Sub_Categorias_Mensuales
                    {
                        Id        = item.id,
                        Nombre    = item.Nombre,
                        Categoria = new Combo_Categorias()
                        {
                            Id = item.combo_categoria.id, Nombre = item.combo_categoria.Nombre
                        },
                        Tipo = new Combo_Tipo()
                        {
                            id = Tipo.id, Nombre = Tipo.Nombre
                        },
                    });
                }
                return(Json(ResultadoJson <Sub_Categorias_Mensuales> .ResultadoCorrecto(resultado)));
            }

            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 10
0
        public JsonResult ObtenerListado(int pagina, int cant)
        {
            try
            {
                var db        = new mmsEntities();
                var lista     = db.cierre_mes.Where(x => x.Id_Entidad == ID_Entidad && x.Activo).OrderBy(p => p.Anio.Trim()).OrderByDescending(x => x.id).ToList();
                var grafico   = lista.GroupBy(x => x.Anio).ToList();
                var resultado = new List <CierreMes_Model>();
                foreach (var item in lista)
                // long Id_Mes = db.combo_mes.FirstOrDefault(x => x.meses == item.Mes).idmes;
                {
                    resultado.Add(new CierreMes_Model
                    {
                        Id  = item.id,
                        Mes = new ComboMeses()
                        {
                            Id     = db.combo_mes.FirstOrDefault(x => x.meses == item.Mes).idmes,
                            Nombre = item.Mes
                        },
                        Anio    = item.Anio,
                        Monto   = item.Monto.Value,
                        Detalle = item.Detalle,
                        Activo  = true,
                        Fecha   = item.Fecha_Proceso.Value,
                        Grafico = new Reportes_Model()
                        {
                            MBar = new Morris_Bar()
                            {
                                element = "morris-bar-chart",
                                data    = grafico.Select(p => new Datos {
                                    Nombre = p.Key, Total = p.Sum(q => q.Monto.Value)
                                }).ToList(),
                                xkey      = "Nombre",
                                ykeys     = { { "Total" } },
                                hideHover = "auto",
                                resize    = true,
                                labels    = { "Total" }
                            }
                        }
                    });
                }

                //
                //  return Json(ResultadoJson<Home_Model>.ResultadoCorrecto(res, resultado.Count));
                var total = resultado.Count;
                var res   = resultado.Skip((pagina - 1) * cant).Take(cant).ToList();
                return(Json(ResultadoJson <CierreMes_Model> .ResultadoCorrecto(res, total)));
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson <CierreMes_Model> .ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 11
0
        //combo Sub_Categorias
        public JsonResult ObtenerSubCategorias()
        {
            var db    = new mmsEntities();
            var lista = db.combo_sub_categoria.Where(x => x.Id_Entidad == ID_Entidad && x.Activo).Select(x => new Combo_Sub_Categorias
            {
                Id     = x.id,
                Nombre = x.Nombre,
                Tipo   = x.combo_categoria.Nombre
            }).OrderBy(p => p.Nombre).ToList();

            return(Json(ResultadoJson <Combo_Sub_Categorias> .ResultadoCorrecto(lista)));
        }
Exemplo n.º 12
0
        public JsonResult ListadoIngreso()
        {
            try
            {
                var db      = new mmsEntities();
                var Español = new System.Globalization.CultureInfo("es-ES");
                var Num_Mes = DateTime.Now.Month - 1;
                if (Num_Mes == 0)
                {
                    Num_Mes = DateTime.Now.Month;
                }
                var NombreMes = Español.DateTimeFormat.GetMonthName(Num_Mes).ToUpper();

                var listaIngreso = db.ingesos_mensuales.Where(x => x.Id_Entidad == ID_Entidad && x.Activo).OrderBy(p => p.combo_sub_categoria.Nombre).ToList();
                var resultado    = new List <IngresosMensuales_Model>();
                foreach (var item in listaIngreso)
                {
                    //var Tipo = db.combo_tipo.FirstOrDefault(x => x.id == item.combo_sub_categoria.combo_categoria.Id_Tipo);
                    resultado.Add(new IngresosMensuales_Model
                    {
                        Id     = item.id,
                        Nombre = new Sub_Categorias_Mensuales()
                        {
                            Id = item.combo_sub_categoria.id, Nombre = item.combo_sub_categoria.Nombre
                        },
                        Categoria = new Combo_Categorias()
                        {
                            Id = item.combo_sub_categoria.combo_categoria.id, Nombre = item.combo_sub_categoria.combo_categoria.Nombre
                        },
                        Tipo = new Combo_Tipo()
                        {
                            id = item.combo_sub_categoria.combo_categoria.combo_tipo.id, Nombre = item.combo_sub_categoria.combo_categoria.combo_tipo.Nombre
                        },
                        Detalle          = item.Detalle,
                        FechaVencimiento = item.Fecha_Vencimiento.Value,
                        Precio           = item.Precio.Value,
                        Pagado           = item.Pagado.Value,
                        Activo           = item.Activo,
                        Recordatorio     = item.Recordatorio.Value,
                        Num_MesAnterior  = NombreMes
                    });
                }
                return(Json(ResultadoJson <IngresosMensuales_Model> .ResultadoCorrecto(resultado)));
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 13
0
        public JsonResult EstadoPagado(Estado_Pagado_Model Objeto)
        {
            try
            {
                var db        = new mmsEntities();
                var existente = db.ingresos.FirstOrDefault(p => p.Activo && p.Observación == Objeto.Observacion && p.Precio == Objeto.Precio && p.Fecha.Day == Objeto.Fecha.Day && p.Fecha.Month == Objeto.Fecha.Month && p.Fecha.Year == Objeto.Fecha.Year);
                if (existente != null)
                {
                    return(Json(ResultadoJson.ResultadoInCorrecto("El Registro Ingresado ya existe")));
                }

                // Guardamos.
                var objeto_modelo = new MMS_DLL.ingresos
                {
                    Id_Tipo         = Objeto.Tipo.id,
                    Id_Categoria    = Objeto.Categoria.Id,
                    Id_Entidad      = ID_Entidad,
                    Id_SubCategoria = Objeto.Nombre.Id,
                    Observación     = Objeto.Observacion != null ? Objeto.Observacion : "-",
                    Precio          = Objeto.Precio,
                    Id_Forma_Pago   = Objeto.Forma_Pago.Id,
                    Fecha           = Objeto.Fecha,

                    Activo = true
                };
                db.ingresos.Add(objeto_modelo);

                //Pasamos en Estado Pagado el IngresoMensual.
                var IngresoMensual = db.ingesos_mensuales.FirstOrDefault(x => x.Id_Entidad == ID_Entidad && x.Activo && x.id == Objeto.Id);
                IngresoMensual.Pagado = true;
                var res = db.SaveChanges();
                if (res > 0)
                {
                    return(Json(ResultadoJson <Home_Model> .ResultadoCorrecto("Guardado con Exito")));
                }
                else
                {
                    return(Json(ResultadoJson <Home_Model> .ResultadoInCorrecto("Error al Igresar el Registro")));
                }
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson <Home_Model> .ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 14
0
        public JsonResult Forma_Pago()
        {
            try
            {
                var db    = new mmsEntities();
                var lista = db.combo_forma_pago.Select(x => new Combo_Tipo
                {
                    id     = x.id,
                    Nombre = x.Nombre
                }).OrderBy(p => p.id).ToList();

                return(Json(ResultadoJson <Combo_Tipo> .ResultadoCorrecto(lista)));
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 15
0
        /////// EGRESOS ///////////

        public JsonResult Obtener_ListadoEgreso()
        {
            try
            {
                var db        = new mmsEntities();
                var Lista     = db.egresos_mensuales.Where(x => x.Id_Entidad == ID_Entidad && x.Activo).OrderBy(p => p.combo_sub_categoria.Nombre).ToList();
                var resultado = new List <EgresosMensuales_Model>();
                foreach (var item in Lista)
                {
                    resultado.Add(new EgresosMensuales_Model
                    {
                        Id     = item.id,
                        Nombre = new Sub_Categorias_Mensuales()
                        {
                            Id = item.combo_sub_categoria.id, Nombre = item.combo_sub_categoria.Nombre
                        },
                        Categoria = new Combo_Categorias()
                        {
                            Id = item.combo_sub_categoria.combo_categoria.id, Nombre = item.combo_sub_categoria.combo_categoria.Nombre
                        },
                        Tipo = new Combo_Tipo()
                        {
                            id = item.combo_sub_categoria.combo_categoria.combo_tipo.id, Nombre = item.combo_sub_categoria.combo_categoria.combo_tipo.Nombre
                        },
                        Detalle          = item.Detalle,
                        FechaVencimiento = item.Fecha_Vencimiento.Value,
                        Precio           = item.Precio.Value,
                        Pagado           = item.Pagado.Value,
                        Activo           = item.Activo,
                        Recordatorio     = item.Recordatorio.Value
                    });
                }
                return(Json(ResultadoJson <EgresosMensuales_Model> .ResultadoCorrecto(resultado)));
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 16
0
 public JsonResult Eliminar(int Id)
 {
     try
     {
         var db   = new mmsEntities();
         var dato = db.ingresos.FirstOrDefault(x => x.id == Id && x.Activo);
         dato.Activo = false;
         var res = db.SaveChanges();
         if (res > 0)
         {
             return(Json(ResultadoJson.ResultadoCorrecto("Eliminado con Exito")));
         }
         else
         {
             return(Json(ResultadoJson.ResultadoInCorrecto("Error al Eliminar el Registro")));
         }
     }
     catch (Exception ex)
     {
         Json(ResultadoJson.ResultadoInCorrecto(ex.Message));
         throw;
     }
 }
Exemplo n.º 17
0
        public JsonResult GuardarSubCate(int Id_Cate, string Nombre)
        {
            try
            {
                var db     = new mmsEntities();
                var Existe = db.combo_sub_categoria.FirstOrDefault(x => x.Id_Entidad == ID_Entidad && x.Activo && x.Id_Categoria == Id_Cate && x.Nombre.ToLower() == Nombre.ToLower());
                if (Existe != null)
                {
                    return(Json(ResultadoJson.ResultadoInCorrecto("La Sub Categoría ya existe")));
                }
                var Resultado = new MMS_DLL.combo_sub_categoria
                {
                    Id_Categoria  = Id_Cate,
                    Activo        = true,
                    Pagado        = true,
                    Fecha_Proceso = DateTime.Now,
                    Id_Entidad    = ID_Entidad,
                    Nombre        = Nombre
                };
                db.combo_sub_categoria.Add(Resultado);
                var res = db.SaveChanges();
                if (res > 0)
                {
                    return(Json(ResultadoJson.ResultadoCorrecto("La Sub Categoría fue guardada con exito")));
                }
                else
                {
                    return(Json(ResultadoJson.ResultadoInCorrecto("Error al Guardar el Registro")));
                }
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 18
0
        public JsonResult GuardarCategoria(string Nombre, int id_Tipo)
        {
            try
            {
                var db     = new mmsEntities();
                var existe = db.combo_categoria.FirstOrDefault(x => x.Id_Entidad == ID_Entidad && x.Activo && x.Nombre.ToLower() == Nombre.ToLower() && x.Id_Tipo == id_Tipo);
                if (existe != null)
                {
                    return(Json(ResultadoJson.ResultadoInCorrecto("El Registro Ingresado ya existe")));
                }

                var ObjetoGuardar = new MMS_DLL.combo_categoria
                {
                    Nombre        = Nombre,
                    Id_Tipo       = id_Tipo,
                    Id_Entidad    = ID_Entidad,
                    Fecha_Proceso = DateTime.Now,
                    Activo        = true
                };
                db.combo_categoria.Add(ObjetoGuardar);
                var res = db.SaveChanges();
                if (res > 0)
                {
                    return(Json(ResultadoJson <Categorias_Model> .ResultadoCorrecto("Guardado con Exito")));
                }
                else
                {
                    return(Json(ResultadoJson <Categorias_Model> .ResultadoInCorrecto("Error al Guardar el Registro")));
                }
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 19
0
        public JsonResult EliminarMensual_Egreso(EgresosMensuales_Model Objeto)
        {
            try
            {
                var db             = new mmsEntities();
                var ObjetoEliminar = db.egresos_mensuales.FirstOrDefault(x => x.id == Objeto.Id && x.Id_Entidad == ID_Entidad);
                ObjetoEliminar.Activo = false;
                var res = db.SaveChanges();
                if (res > 0)
                {
                    return(Json(ResultadoJson <EgresosMensuales_Model> .ResultadoCorrecto("El Egreso fue eliminado con exito")));
                }
                else
                {
                    return(Json(ResultadoJson <EgresosMensuales_Model> .ResultadoInCorrecto("Error al eliminar el Egreso")));
                }
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 20
0
        public JsonResult BuscarListado(BuscarListado_Model Objeto)
        {
            try
            {
                var db = new mmsEntities();
                if (Objeto.IdsSubCate == null)
                {
                    Objeto.IdsSubCate = new List <int>();
                }
                var lista = db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Activo && x.combo_tipo.id == Objeto.Tipo.id && x.Fecha.Year == Objeto.Anio && Objeto.IdsSubCate.Contains(x.Id_SubCategoria.Value)).GroupBy(p => new { p.Fecha.Month, p.combo_sub_categoria }).ToList();

                var lista_2 = lista.Select(p => new { Mes = p.Key.Month, IdSubCategoria = p.Key.combo_sub_categoria.id, SubCategoria = p.Key.combo_sub_categoria.Nombre, Precio = p.Sum(q => q.Precio.Value) });

                //var Grafico = lista.GroupBy(x => x.combo_sub_categoria.Nombre).ToList();
                var resultado = new List <DatosxMes_BuscarListado_Model>();
                var meses     = lista_2.Select(p => p.Mes).Distinct();

                foreach (var mes in meses)
                {
                    var dato = new DatosxMes_BuscarListado_Model();


                    var Español = new System.Globalization.CultureInfo("es-ES");
                    var Num_Mes = Convert.ToInt32(mes.ToString());
                    if (Num_Mes == 0)
                    {
                        Num_Mes = 1;
                    }
                    var NombreMes = Español.DateTimeFormat.GetMonthName(Num_Mes).ToUpper();
                    dato.Mes = NombreMes;

                    var datosGrilla = lista_2.Where(p => p.Mes == mes)
                                      .Select(p => new BuscarListado_Model
                    {
                        SubCate = new Combo_Sub_Categorias()
                        {
                            Id     = p.IdSubCategoria,
                            Nombre = p.SubCategoria
                        },
                        Monto = p.Precio,
                    });

                    dato.Datos.AddRange(datosGrilla);
                    dato.Total   = datosGrilla.Sum(q => q.Monto);
                    dato.Grafico = datosGrilla.Select(p => new Datos_Donut
                    {
                        label = p.SubCate.Nombre,
                        value = p.Monto
                    }).ToList();

                    resultado.Add(dato);
                }

                var res = Json(ResultadoJson <DatosxMes_BuscarListado_Model> .ResultadoCorrecto(resultado));
                res.MaxJsonLength = int.MaxValue;
                return(res);
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson.ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 21
0
        public JsonResult GuardarCierreMes(CierreMes_Model Objeto)
        {
            try
            {
                var db     = new mmsEntities();
                var Existe = db.cierre_mes.FirstOrDefault(x => x.Anio == Objeto.Anio && x.Id_Entidad == ID_Entidad && x.Mes == Objeto.Mes.Nombre && x.Activo);
                if (Existe != null && Objeto.Id == 0)
                {
                    return(Json(ResultadoJson.ResultadoInCorrecto("El Registro Ingresado ya existe")));
                }

                if (Objeto.Id == 0)
                {
                    var GuardarObjeto = new MMS_DLL.cierre_mes
                    {
                        Anio          = Objeto.Anio,
                        Mes           = Objeto.Mes.Nombre,
                        Id_Entidad    = ID_Entidad,
                        Monto         = Objeto.Monto,
                        Detalle       = Objeto.Detalle != null ? Objeto.Detalle : "-",
                        Activo        = true,
                        Fecha_Proceso = DateTime.Now
                    };

                    db.cierre_mes.Add(GuardarObjeto);
                    var res = db.SaveChanges();
                    if (res > 0)
                    {
                        return(Json(ResultadoJson <CierreMes_Model> .ResultadoCorrecto("Guardado con Exito")));
                    }
                    else
                    {
                        return(Json(ResultadoJson <CierreMes_Model> .ResultadoInCorrecto("Error al Igresar el Registro")));
                    }
                }
                else
                {
                    //Modificamos.
                    var ModificarObjeto = db.cierre_mes.FirstOrDefault(x => x.id == Objeto.Id && x.Activo);
                    ModificarObjeto.Anio          = Objeto.Anio;
                    ModificarObjeto.Mes           = Objeto.Mes.Nombre;
                    ModificarObjeto.Monto         = Objeto.Monto;
                    ModificarObjeto.Detalle       = Objeto.Detalle;
                    ModificarObjeto.Fecha_Proceso = DateTime.Now;
                    var res = db.SaveChanges();
                    if (res > 0)
                    {
                        return(Json(ResultadoJson <CierreMes_Model> .ResultadoCorrecto("Modificado con Exito")));
                    }
                    else
                    {
                        return(Json(ResultadoJson <CierreMes_Model> .ResultadoInCorrecto("Error al Modificar el Registro")));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson <CierreMes_Model> .ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 22
0
        public JsonResult BusquedaGeneral(Busqueda_Model modelo)
        {
            try
            {
                var db          = new mmsEntities();
                var lista       = new List <ingresos>();
                var Reporte_Bar = new List <ingresos>();
                if (modelo.detallado)
                {
                    lista = db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Fecha >= modelo.Fecha_Desde.Date && x.Fecha <= modelo.Fecha_Hasta.Date && x.Activo).ToList()
                            .Where(x => (modelo.Cate == null || x.Id_Categoria == modelo.Cate.Id) &&
                                   (modelo.Tipo == null || x.Id_Tipo == modelo.Tipo.id) &&
                                   (modelo.SubCate == null || x.Id_SubCategoria == modelo.SubCate.Id)).OrderByDescending(p => p.id).ToList();

                    //lista = lista.Where(x => );
                    //  lista = db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.combo_categoria.Nombre.ToString() == modelo.Cate.Nombre.ToString() && x.combo_tipo.Nombre.ToString() == modelo.Tipo.Nombre.ToString() && x.combo_sub_categoria.Nombre.ToString() == modelo.SubCate.Nombre.ToString()
                    // && x.Fecha >= modelo.Fecha_Desde.Date && x.Fecha <= modelo.Fecha_Hasta.Date && x.Activo).OrderByDescending(p => p.id).ToList();
                }
                else
                {
                    lista = db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Fecha >= modelo.Fecha_Desde.Date && x.Fecha <= modelo.Fecha_Hasta.Date && x.Activo).OrderByDescending(p => p.id).ToList();
                }


                var resultado = new List <Home_Model>();

                foreach (var item in lista)
                {
                    var grafico = lista.GroupBy(x => x.combo_categoria.Nombre).ToList();
                    resultado.Add(new Home_Model

                    {
                        Id   = item.id,
                        Cate = new Combo_Categorias()
                        {
                            Id     = item.combo_categoria.id != null ? item.combo_categoria.id : 0,
                            Nombre = item.combo_categoria.Nombre != null ? item.combo_categoria.Nombre : null
                        },
                        SubCate = new Combo_Sub_Categorias()
                        {
                            Id     = item.combo_sub_categoria.id != null ? item.combo_sub_categoria.id : 0,
                            Nombre = item.combo_sub_categoria.Nombre != null ? item.combo_sub_categoria.Nombre : null
                        },

                        Observacion = item.Observación,
                        Tipo        = new Combo_Tipo()
                        {
                            id = item.combo_tipo.id, Nombre = item.combo_tipo.Nombre
                        },
                        Forma_Pago = new Combo_FormaPago()
                        {
                            Id = item.combo_forma_pago.id, Nombre = item.combo_forma_pago.Nombre
                        },
                        Precio = item.Precio.Value,
                        Fecha  = item.Fecha,

                        Grafico = new Reportes_Model()
                        {
                            MBar = new Morris_Bar()
                            {
                                element = "morris-bar-chart",
                                data    = grafico.Select(p => new Datos {
                                    Nombre = p.Key, Total = p.Sum(q => Math.Round(q.Precio.Value))
                                }).ToList(),
                                xkey      = "Nombre",
                                ykeys     = { { "Total" } },
                                hideHover = "auto",
                                resize    = true,
                                labels    = { "Total" }
                            }
                        }
                    });
                }

                var res = Json(ResultadoJson <Home_Model> .ResultadoCorrecto(resultado));
                res.MaxJsonLength = int.MaxValue;
                return(res);
            }

            catch (Exception ex)
            {
                return(Json(ResultadoJson <Home_Model> .ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 23
0
        public JsonResult Guardar(Home_Model modelo)
        {
            try
            {
                var db = new mmsEntities();

                //var existente = db.ingresos.FirstOrDefault(p => p.id != modelo.Id && p.Id_Categoria == modelo.Cate.Id && p.Id_SubCategoria == modelo.SubCate.Id && p.Observación == modelo.Observacion && p.Precio == modelo.Precio);
                //if (existente != null)
                //{
                //    return Json(ResultadoJson.ResultadoInCorrecto("El Registro Ingresado ya existe"));
                //}

                if (modelo.Id == 0)
                {
                    // Guardamos.
                    var objeto_modelo = new MMS_DLL.ingresos
                    {
                        Id_Tipo                                             = modelo.Tipo.id,
                        Id_Categoria                                        = modelo.Cate.Id,
                        Id_Entidad                                          = ID_Entidad,
                        Id_SubCategoria                                     = modelo.SubCate.Id,
                        Observación                                         = modelo.Observacion != null?modelo.Observacion.ToUpper() : "-",
                                                              Precio        = modelo.Precio,
                                                              Id_Forma_Pago = modelo.Forma_Pago.Id,
                                                              Fecha         = modelo.Fecha,
                                                              Activo        = true
                    };
                    db.ingresos.Add(objeto_modelo);
                    var res = db.SaveChanges();
                    if (res > 0)
                    {
                        return(Json(ResultadoJson <Home_Model> .ResultadoCorrecto("Guardado con Exito")));
                    }
                    else
                    {
                        return(Json(ResultadoJson <Home_Model> .ResultadoInCorrecto("Error al Igresar el Registro")));
                    }
                }
                else
                {
                    //Modificamos.

                    var Modelo_modificar = db.ingresos.FirstOrDefault(x => x.id == modelo.Id && x.Activo);
                    Modelo_modificar.Id_Tipo         = modelo.Tipo.id;
                    Modelo_modificar.Id_Categoria    = modelo.Cate.Id;
                    Modelo_modificar.Id_SubCategoria = modelo.SubCate.Id;
                    Modelo_modificar.Precio          = modelo.Precio;
                    Modelo_modificar.Fecha           = modelo.Fecha;
                    Modelo_modificar.Id_Forma_Pago   = modelo.Forma_Pago.Id;
                    Modelo_modificar.Observación     = modelo.Observacion.ToUpper();
                    var res = db.SaveChanges();
                    if (res > 0)
                    {
                        return(Json(ResultadoJson <Home_Model> .ResultadoCorrecto("Modificado con Exito")));
                    }
                    else
                    {
                        return(Json(ResultadoJson <Home_Model> .ResultadoInCorrecto("Error al Modificar el Registro")));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(ResultadoJson <Home_Model> .ResultadoInCorrecto(ex.Message)));

                throw;
            }
        }
Exemplo n.º 24
0
        // para cuando tenemos que hacer un paginador.
        //public JsonResult ObtenerListado(int pagina)
        public JsonResult ObtenerListado(int periodo)
        {
            var db           = new mmsEntities();
            var lista        = new List <ingresos>();
            var AnioCurso    = DateTime.Now.Year;
            var AnioAnterior = DateTime.Now.Year - 1;
            var MesCurso     = DateTime.Now.Month;

            //if (periodo == 1)
            //{
            //    //Mes en Curso
            //    lista = db.ingresos.Where(x => x.Id_Entidad == ID_Entidad  && x.Activo && x.Fecha.Month == MesCurso && x.Fecha.Year == AnioCurso).OrderByDescending(p => p.id).ToList();
            //}
            //else if (periodo == 2)
            //{
            //    //Año en Curso
            //    lista = db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Activo && x.Fecha.Year == AnioCurso).OrderByDescending(p => p.id).ToList();
            //}

            //else
            //{
            //    lista = db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Activo).OrderByDescending(p => p.id).ToList();
            //}

            lista = periodo == 1 ? db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Activo && x.Fecha.Month == MesCurso && x.Fecha.Year == AnioCurso).OrderByDescending(p => p.id).ToList()
                : periodo == 2 ? db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Activo && x.Fecha.Year == AnioCurso).OrderByDescending(p => p.id).ToList()
                                : periodo == 3 ? db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Activo && x.Fecha.Year == AnioAnterior).OrderByDescending(p => p.id).ToList()
                            : db.ingresos.Where(x => x.Id_Entidad == ID_Entidad && x.Activo).OrderByDescending(p => p.id).ToList();

            var resultado = new List <Home_Model>();

            foreach (var item in lista)
            {
                var grafico = lista.GroupBy(x => x.combo_categoria.Nombre).ToList();
                resultado.Add(new Home_Model
                {
                    Id   = item.id,
                    Cate = new Combo_Categorias()
                    {
                        Id     = item.Id_Categoria != null ? item.Id_Categoria.Value : 0,
                        Nombre = item.combo_categoria.Nombre != null ? item.combo_categoria.Nombre : null,
                        Tipo   = item.combo_categoria.combo_tipo.Nombre
                    },
                    SubCate = new Combo_Sub_Categorias()
                    {
                        Id     = item.combo_sub_categoria != null ? item.combo_sub_categoria.id : 0,
                        Nombre = item.combo_sub_categoria.Nombre != null ? item.combo_sub_categoria.Nombre : null
                    },
                    Observacion = item.Observación,
                    Tipo        = new Combo_Tipo()
                    {
                        id = item.combo_tipo.id, Nombre = item.combo_tipo.Nombre
                    },
                    Forma_Pago = new Combo_FormaPago()
                    {
                        Id = item.combo_forma_pago.id, Nombre = item.combo_forma_pago.Nombre
                    },
                    Precio = item.Precio.Value,
                    Fecha  = item.Fecha,

                    Grafico = new Reportes_Model()
                    {
                        MBar = new Morris_Bar()
                        {
                            element = "morris-bar-chart",
                            data    = grafico.Select(p => new Datos {
                                Nombre = p.Key, Total = p.Sum(q => q.Precio.Value)
                            }).ToList(),
                            xkey      = "Nombre",
                            ykeys     = { { "Total" } },
                            hideHover = "auto",
                            resize    = true,
                            labels    = { "Total" }
                        }
                    }
                });
            }
            // para cuando tenemos que hacer un paginador.
            //  var res = resultado.Skip((pagina - 1) * 5).Take(5).ToList();
            //  return Json(ResultadoJson<Home_Model>.ResultadoCorrecto(res, resultado.Count));
            var res = Json(ResultadoJson <Home_Model> .ResultadoCorrecto(resultado));

            res.MaxJsonLength = int.MaxValue;
            return(res);
        }