Exemple #1
0
        public static List <Gastos> ObtenerGastos()
        {
            Gastos gastos;

            listagastos.Clear();

            using (SqlConnection con = new SqlConnection(SqlServer.CADENA_CONEXION))
            {
                con.Open();
                string     tectoCMD = "select * from Gastos";
                SqlCommand cmd      = new SqlCommand(tectoCMD, con);

                SqlDataReader elLectorDeDatos = cmd.ExecuteReader();

                while (elLectorDeDatos.Read())
                {
                    gastos                  = new Gastos();
                    gastos.ID_Gasto         = elLectorDeDatos.GetInt32(0);
                    gastos.ID_Reserva_Gasto = Reserva.ObtenerReserva(elLectorDeDatos.GetInt32(1));
                    gastos.Servicio         = (Servicios)elLectorDeDatos.GetInt32(2);
                    gastos.FechaGasto       = elLectorDeDatos.GetDateTime(3);
                    gastos.Cantidad         = Convert.ToString(elLectorDeDatos.GetInt32(4));
                    gastos.CostoTotalGasto  = Convert.ToDouble(elLectorDeDatos.GetDouble(5));

                    listagastos.Add(gastos);
                }
            }

            return(listagastos);
        }