Пример #1
0
        public void ExecuteEnt()
        {
            int           Nif;
            DateTime      min, max;
            string        tipo;
            List <string> prms = new List <string>();

            prms = InfoGetter(prms);

            try
            {
                Nif  = Convert.ToInt32(prms[0]);
                min  = Convert.ToDateTime(prms[1]);
                max  = Convert.ToDateTime(prms[2]);
                tipo = prms[3];
            }
            catch (FormatException)
            {
                Console.WriteLine("Alguns parametros estavam errados.");
                return;
            }

            int montante;

            using (var ctx = new SoAventuraEntities())
            {
                montante = ctx.Database.ExecuteSqlCommand("return select SUM(montante) from dbo.Fatura, dbo." + tipo +
                                                          " where NIF = {0} and data_pagamento< {1} and data_pagamento> {2} and dbo.Fatura.Id_Evento=dbo." + tipo + ".Id_Evento", Nif, max, min);

                ctx.SaveChanges();
            }
            Console.WriteLine("Montante:{0}", montante);
        }
Пример #2
0
        public void ExecuteEnt()
        {
            int        ano;
            List <int> prms = new List <int>();

            prms = InfoGetter(prms);

            try
            {
                ano = prms[0];
            }
            catch (FormatException)
            {
                Console.WriteLine("Alguns parametros estavam errados.");
                return;
            }


            using (var ctx = new SoAventuraEntities())
            {
                ctx.Database.ExecuteSqlCommand("delete from  dbo.Fatura where ano = {0} " +
                                               "delete from  dbo.Subscrição where ano = {0} " +
                                               "delete from  dbo.trail where ano = {0} " +
                                               "delete from  dbo.ciclismo where ano = {0} " +
                                               "delete from  dbo.escalada where ano = {0} " +
                                               "delete from  dbo.canoagem where ano = {0} " +
                                               "delete from  dbo.Evento_Desportivo where ano = {0} ", ano);
                ctx.SaveChanges();
            }
            Console.WriteLine("Eventos apagados com sucesso !");
        }
Пример #3
0
        public void ExecuteEnt()
        {
            int        intervalo;
            List <int> prms = new List <int>();

            prms = InfoGetter(prms);

            try
            {
                intervalo = prms[0];
            }
            catch (FormatException)
            {
                Console.WriteLine("Alguns parametros estavam errados.");
                return;
            }
            using (var ctx = new SoAventuraEntities())
            {
                try
                {
                    ctx.EnviarMailIntervalo(intervalo);
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.InnerException.Message);
                    return;
                }
            }

            Console.WriteLine("Emails Enviados.");
        }
Пример #4
0
        public void ExecuteEnt()
        {
            using (var ctx = new SoAventuraEntities())
            {
                try
                {
                    ctx.VerificarEstados();
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.InnerException.Message);
                    return;
                }
            }

            Console.WriteLine("Estados atualizados!");
        }
Пример #5
0
        public void ExecuteEnt()
        {
            int        ano, MONTANTEMINIMO, MONTANTEMAXIMO;
            List <int> prms = new List <int>();

            prms = InfoGetter(prms);

            try
            {
                ano            = prms[0];
                MONTANTEMINIMO = prms[1];
                MONTANTEMAXIMO = prms[2];
            }
            catch (FormatException)
            {
                Console.WriteLine("Alguns parametros estavam errados.");
                return;
            }

            using (var ctx = new SoAventuraEntities())
            {
                try
                {
                    var CanceledEvents = ctx.FaturasPorAno(ano, MONTANTEMINIMO, MONTANTEMAXIMO).ToList();
                    ctx.SaveChanges();

                    var colunas = typeof(EventosDisponiveis_Result).GetProperties().Select(prop => prop.Name).ToList();

                    TablePrinter.PrintTable(colunas);

                    CanceledEvents.ForEach(eq => Console.WriteLine(eq.Id_Evento + " - " + eq.ano + " - " + eq.NIF + " - " + eq.montante));

                    Console.WriteLine("Listagem dos eventos Disponiveis.");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.InnerException.Message);
                    return;
                }
            }
        }
Пример #6
0
        public void ExecuteEnt()
        {
            DateTime      inicio, fim;
            List <string> prms = new List <string>();

            prms = InfoGetter(prms);

            try
            {
                inicio = Convert.ToDateTime(prms[0]);
                fim    = Convert.ToDateTime(prms[1]);
            }
            catch (FormatException)
            {
                Console.WriteLine("Alguns parametros estavam errados.");
                return;
            }

            using (var ctx = new SoAventuraEntities())
            {
                try
                {
                    var CanceledEvents = ctx.EventosDisponiveis(inicio, fim).ToList();
                    ctx.SaveChanges();

                    var colunas = typeof(EventosDisponiveis_Result).GetProperties().Select(prop => prop.Name).ToList();

                    TablePrinter.PrintTable(colunas);

                    CanceledEvents.ForEach(eq => Console.WriteLine(eq.Id_Evento + " - " + eq.ano));

                    Console.WriteLine("Listagem dos eventos Disponiveis.");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.InnerException.Message);
                    return;
                }
            }
        }
Пример #7
0
        public void ExecuteEnt()
        {
            int        IDevento, ano, Nif, montante;
            List <int> prms = new List <int>();

            prms = InfoGetter(prms);

            try
            {
                IDevento = prms[0];
                ano      = prms[1];
                montante = prms[2];
                Nif      = prms[3];
            }
            catch (FormatException)
            {
                Console.WriteLine("Alguns parametros estavam errados.");
                return;
            }

            var Fac_ID = new ObjectParameter("Id_Factura", typeof(Int32));

            using (var ctx = new SoAventuraEntities())
            {
                try
                {
                    ctx.PagarSubscricao(IDevento, ano, Fac_ID, montante, Nif);
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.InnerException.Message);
                    return;
                }
            }

            Console.WriteLine("Subscrição paga com sucesso com o id {0}", (int)Fac_ID.Value);
        }
Пример #8
0
        public void ExecuteEnt()
        {
            int        IDevento, ano, Nif;
            List <int> prms = new List <int>();

            prms = InfoGetter(prms);

            try
            {
                IDevento = prms[0];
                ano      = prms[1];
                Nif      = prms[2];
            }
            catch (FormatException)
            {
                Console.WriteLine("Alguns parametros estavam errados.");
                return;
            }


            using (var ctx = new SoAventuraEntities())
            {
                try
                {
                    ctx.SubscreverClienteEvento(IDevento, ano, Nif);
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.InnerException.Message);
                    return;
                }
            }

            Console.WriteLine("Subscrição efectuada com sucesso !");
        }