Exemple #1
0
        public bool ActualizarObervacionPorGasto(int gasto, string texto)
        {
            try
            {
                SigescoEntities context = new SigescoEntities();
                using (context)
                {
                    var query = (from a in context.GASTO
                                 where a.ID_GASTO == gasto
                                 select a).FirstOrDefault();

                    GASTO objeto = query;
                    if (texto == "")
                    {
                        objeto.OBSERVACION = null;
                        context.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        objeto.OBSERVACION = texto;
                        context.SaveChanges();
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #2
0
        public List <string> ObtenerGastosPorPagarPorVivienda(int vivienda, DateTime desde, DateTime hasta)
        {
            try
            {
                SigescoEntities context = new SigescoEntities();
                using (context)
                {
                    var query = (from a in context.GASTO
                                 where a.ID_VIVIENDA == vivienda &&
                                 a.FECHA_GASTO >= desde &&
                                 a.FECHA_GASTO <= hasta &&
                                 a.ESTADO == "NO PAGADO"
                                 orderby a.FECHA_GASTO ascending
                                 select a).ToList();

                    List <string> lista  = new List <string>();
                    List <GASTO>  _lista = query;
                    int           x      = query.Count();
                    for (int i = 0; i < x; i++)
                    {
                        GASTO obj = new GASTO();
                        obj = _lista[i];
                        string fecha = Convert.ToDateTime(obj.FECHA_GASTO).ToString("dd/MM/yyyy");
                        string fila  = obj.NOMBRE_GASTO + ";" + obj.DESCRIPCION + ";" + fecha + ";" + obj.MONTO_GASTO + ";" + obj.OBSERVACION + ";" + obj.ID_GASTO;
                        lista.Add(fila);
                    }

                    return(lista);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #3
0
        public List <string> GetGastoNoPagadoPorId(int gasto)
        {
            try
            {
                SigescoEntities context = new SigescoEntities();
                using (context)
                {
                    var query = (from a in context.GASTO
                                 where a.ID_GASTO == gasto &&
                                 a.ESTADO == "NO PAGADO"
                                 orderby a.FECHA_GASTO ascending
                                 select a).ToList();

                    List <string> lista  = new List <string>();
                    List <GASTO>  _lista = query;
                    int           x      = query.Count();
                    for (int i = 0; i < x; i++)
                    {
                        GASTO obj = new GASTO();
                        obj = _lista[i];
                        string fecha = Convert.ToDateTime(obj.FECHA_GASTO).ToString("dd/MM/yyyy");
                        string fila  = obj.ID_GASTO + ";" + obj.NOMBRE_GASTO + ";" + fecha + ";" + obj.MONTO_GASTO;
                        lista.Add(fila);
                    }

                    return(lista);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #4
0
        public List <string> GetGastosConObsPorVivienda(int vivienda, DateTime desde, DateTime hasta)
        {
            try
            {
                SigescoEntities context = new SigescoEntities();
                using (context)
                {
                    var query = (from a in context.GASTO
                                 where a.ID_VIVIENDA == vivienda &&
                                 a.FECHA_GASTO >= desde &&
                                 a.FECHA_GASTO <= hasta &&
                                 a.OBSERVACION != null
                                 orderby a.FECHA_GASTO ascending
                                 select a).ToList();

                    List <string> lista  = new List <string>();
                    List <GASTO>  _lista = query;
                    int           x      = query.Count();
                    for (int i = 0; i < x; i++)
                    {
                        GASTO obj = new GASTO();
                        obj = _lista[i];
                        string fila = obj.ID_GASTO + ";" + obj.NOMBRE_GASTO + ";" + obj.MONTO_GASTO;
                        lista.Add(fila);
                    }

                    return(lista);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #5
0
        public bool updateGastoPorID(GASTO gasto)
        {
            try
            {
                SigescoEntities context = new SigescoEntities();
                using (context)
                {
                    var query = (from a in context.GASTO
                                 where a.ID_GASTO == gasto.ID_GASTO
                                 select a).FirstOrDefault();

                    query.ID_TIPO_GASTO = gasto.ID_TIPO_GASTO;
                    query.MONTO_GASTO   = gasto.ID_VIVIENDA;
                    query.DESCRIPCION   = gasto.DESCRIPCION;
                    query.NOMBRE_GASTO  = gasto.NOMBRE_GASTO;
                    context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult IngresarMulta(FormCollection collection)
        {
            GastosDAL bd    = new GastosDAL();
            GASTO     multa = new GASTO();

            multa.NOMBRE_GASTO  = "Multa";
            multa.FECHA_GASTO   = DateTime.Now;
            multa.ID_TIPO_GASTO = 4;
            multa.ESTADO        = "NO PAGADO";
            multa.ID_VIVIENDA   = int.Parse(collection["Vivienda"].ToString());
            multa.DESCRIPCION   = collection["Descipcion"].ToString();
            multa.MONTO_GASTO   = int.Parse(collection["Monto"].ToString());
            var model = bd.IngresarNuevaMulta(multa);

            if (model)
            {
                var result = new { Success = true, Message = "Succes Message", model };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var result = new { Success = false, Message = "Error Message" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult CargarGatosMasivos(FormCollection collection)
        {
            GastosDAL    db          = new GastosDAL();
            List <GASTO> listaGasto  = new List <GASTO>();
            var          _arreglo    = collection["Array"].ToString();
            var          arreglo     = _arreglo.Split(',');
            var          nombre      = collection["Nombre"].ToString();
            var          descripcion = collection["Descripcion"].ToString();
            var          fecha       = Convert.ToDateTime(collection["Fecha"].ToString());
            var          tipo        = int.Parse(collection["Tipo"].ToString());
            var          monto       = int.Parse(collection["Monto"].ToString());
            int          ulti        = db.ultimo();
            int          x           = arreglo.Count();

            for (int i = 0; i < x; i++)
            {
                ulti = ulti + 1;
                GASTO gas = new GASTO();
                gas.ID_GASTO      = ulti;
                gas.ID_TIPO_GASTO = tipo;
                gas.ID_VIVIENDA   = int.Parse(arreglo[i]);
                gas.MONTO_GASTO   = monto;
                gas.NOMBRE_GASTO  = nombre;
                gas.DESCRIPCION   = descripcion;
                gas.FECHA_GASTO   = fecha;
                gas.ESTADO        = "NO PAGADO";
                listaGasto.Add(gas);
            }

            var model = db.InsertarGastoMasivo(listaGasto);

            if (model)
            {
                var result = new { Success = true, Message = "Succes Message", model };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var result = new { Success = false, Message = "Error Message" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #8
0
        public bool IngresarNuevaMulta(GASTO multa)
        {
            try
            {
                SigescoEntities context = new SigescoEntities();
                using (context)
                {
                    var query = (from a in context.GASTO
                                 orderby a.ID_GASTO descending
                                 select a.ID_GASTO).FirstOrDefault();

                    multa.ID_GASTO = query + 1;
                    context.GASTO.Add(multa);
                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #9
0
        public string getGastoPorID(int gasto)
        {
            try
            {
                SigescoEntities context = new SigescoEntities();
                using (context)
                {
                    var query = (from a in context.GASTO
                                 where a.ID_GASTO == gasto
                                 select a).FirstOrDefault();
                    GASTO  obj     = query;
                    string retorno = "";
                    string fecha   = Convert.ToDateTime(obj.FECHA_GASTO).ToString("dd/MM/yyyy");
                    retorno = obj.ID_GASTO + "{" + obj.NOMBRE_GASTO + "{" + obj.DESCRIPCION + "{" + obj.ID_TIPO_GASTO + "{" + obj.MONTO_GASTO;

                    return(retorno);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult UpdateGastoPorID(FormCollection collection)
        {
            GastosDAL bd         = new GastosDAL();
            GASTO     actualizar = new GASTO();

            actualizar.ID_GASTO      = int.Parse(collection["ID"].ToString());
            actualizar.NOMBRE_GASTO  = collection["Nombre"].ToString();
            actualizar.DESCRIPCION   = collection["Descripcion"].ToString();
            actualizar.ID_TIPO_GASTO = int.Parse(collection["Tipo"].ToString());
            actualizar.MONTO_GASTO   = int.Parse(collection["Monto"].ToString());
            var model = bd.updateGastoPorID(actualizar);

            if (model)
            {
                var result = new { Success = true, Message = "Succes Message", model };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var result = new { Success = false, Message = "Error Message" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }