Пример #1
0
        private void RemoverMercadoFinanceiro()
        {
            Console.WriteLine("Insert Unique Code of Mercado Financeiro to REMOVE");
            int         cod  = Int32.Parse(Console.ReadLine());
            IEnumerable regs = from mer in dbContext.RegDiaMerFin
                               where mer.cod_un == cod
                               select mer;

            foreach (RegDiaMerFin reg in regs)
            {
                dbContext.RegDiaMerFin.Remove(reg);
            }
            MerFin merFin = (from mer in dbContext.MerFin
                             where mer.cod_un == cod
                             select mer).FirstOrDefault();

            if (merFin != null)
            {
                dbContext.MerFin.Remove(merFin);
                if (dbContext.SaveChanges() > 0)
                {
                    Console.WriteLine("SUCCESS");
                }
                else
                {
                    Console.WriteLine("UNSUCCESS");
                }
            }
            else
            {
                Console.WriteLine("No elements to be removed");
            }
        }
Пример #2
0
        private void InserirMercadoFinanceiro()
        {
            MerFin merFin = dbContext.MerFin.Create();

            Console.WriteLine("Insert Unique Code of Mercado Financeiro");
            merFin.cod_un = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Insert Name of Mercado Financeiro");
            merFin.nome = Console.ReadLine();
            Console.WriteLine("Insert Description of Mercado Financeiro");
            merFin.descrição = Console.ReadLine();
            dbContext.MerFin.Add(merFin);
            if (dbContext.SaveChanges() > 0)
            {
                Console.WriteLine("SUCCESS");
            }
            else
            {
                Console.WriteLine("UNSUCCESS");
            }
        }
Пример #3
0
        private void AtualizarMercadoFinanceiro()
        {
            Console.WriteLine("Insert Unique Code of Mercado Financeiro to Update");
            int    cod    = Int32.Parse(Console.ReadLine());
            MerFin merFin = (from mer in dbContext.MerFin
                             where mer.cod_un == cod
                             select mer).FirstOrDefault();

            if (merFin != null)
            {
                string src = "";
                Console.WriteLine("Do you want to update the name of Mercado Financeiro?(Y/N)");
                src = Console.ReadLine();
                if (src.ToUpper().Contains("Y"))
                {
                    Console.WriteLine("Insert the new name");
                    merFin.nome = Console.ReadLine();
                }
                Console.WriteLine("Do you want to update the description of Mercado Financeiro?(Y/N)");
                src = Console.ReadLine();
                if (src.ToUpper().Contains("Y"))
                {
                    Console.WriteLine("Insert the new description");
                    merFin.descrição = Console.ReadLine();
                }
                if (dbContext.SaveChanges() > 0)
                {
                    Console.WriteLine("SUCCESS");
                }
                else
                {
                    Console.WriteLine("UNSUCCESS");
                }
            }
            else
            {
                Console.WriteLine("Invalid Unique Code");
            }
        }