Ejemplo n.º 1
0
        public static bool novoCliente(String nome, String rua, String cidade, String estado)
        {
            try
            {
                GeFatEntities db = new GeFatEntities();

                //List<Clientes> lista = db.Clientes.ToList();
                Clientes c;
                c = new Clientes
                {
                    Nome = nome
                };

                db.Clientes.Add(c);
                int       id       = c.ClienteID;
                Endereços endereco = new Endereços
                {
                    ClienteID = c.ClienteID,
                    Rua       = rua,
                    Cidade    = cidade,
                    Estado    = estado,
                    Clientes  = c
                };
                pnEndereço.novoEndereco(endereco);


                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public static bool gerarPedidos(int mes)
        {
            Pedidos        p;
            DetalhesPedido produto;
            int            nprod;
            Produtos       prod;
            int            atual;

            try
            {
                GeFatEntities   db    = new GeFatEntities();
                List <Produtos> prods = db.Produtos.ToList();
                List <Clientes> clis  = db.Clientes.ToList();

                foreach (var cli in clis)
                {
                    for (int pedPorCli = numeroRd(130, 170); pedPorCli > 0; pedPorCli--)
                    {
                        p = new Pedidos
                        {
                            Clientes = db.Clientes.Find(cli.ClienteID),
                            Data     = new DateTime(2017, mes, numeroRd(1, 28))
                        };
                        db.Pedidos.Add(p);
                        nprod = numeroRd(1, 19);
                        //List<int> num = ListaRd(1, prods.Count, nprod);
                        while (nprod > 0)
                        {
                            int num = numeroRd(1, prods.Count);
                            if (db.DetalhesPedido.Find(p.NroPedido, num) == null)
                            {
                                prod    = db.Produtos.Find(num);
                                produto = new DetalhesPedido
                                {
                                    Pedidos  = p,
                                    Produtos = prod,
                                    Qtde     = numeroRd(1, 5),
                                    Preco    = prod.Preco
                                };
                                nprod--;
                                db.DetalhesPedido.Add(produto);
                            }
                        }
                        db.SaveChanges();
                    }
                }


                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
 public static List <Clientes> listar()
 {
     try
     {
         GeFatEntities db = new GeFatEntities();
         return(db.Clientes.ToList());
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 4
0
 public static Clientes pesquisar(String nome)
 {
     try
     {
         GeFatEntities db = new GeFatEntities();
         return(db.Clientes.Find(nome));
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 5
0
        public static bool novoEndereco(Endereços endereco)
        {
            try
            {
                GeFatEntities db = new GeFatEntities();
                db.Endereços.Add(endereco);
                db.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        public static bool novoProduto(Produtos prod)
        {
            try
            {
                GeFatEntities db = new GeFatEntities();
                db.Produtos.Add(prod);
                db.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 7
0
 public static List <String> listarNomes()
 {
     try
     {
         GeFatEntities   db       = new GeFatEntities();
         List <Clientes> clientes = db.Clientes.ToList();
         List <String>   nomes    = new List <String>();
         foreach (Clientes cliente in clientes)
         {
             nomes.Add(cliente.Nome);
         }
         return(nomes);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 8
0
        public static List <DateTime?> datasFaturadas()
        {
            try
            {
                GeFatEntities db = new GeFatEntities();

                int              atual       = db.CoreData.ToList().Max(c => c.Vers);
                CoreData         dadosAtutal = db.CoreData.Find(atual);
                List <DateTime?> datas       = new List <DateTime?>();
                datas.Add(dadosAtutal.FatIni);
                datas.Add(dadosAtutal.FatFim);
                return(datas);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 9
0
        public static bool faturar(DateTime inicio, DateTime fim)
        {
            try
            {
                GeFatEntities db = new GeFatEntities();


                if (db.CoreData.ToList().Count == 0)
                {
                    registrarVersao(1);
                }
                int      atual     = db.CoreData.Max(core => core.Vers);
                CoreData coreAtual = db.CoreData.Find(atual);
                if (coreAtual.FatIni == null)
                {
                    coreAtual.FatIni = inicio;
                }
                else
                {
                    if (coreAtual.FatIni > inicio)
                    {
                        coreAtual.FatIni = inicio;
                    }
                }
                if (coreAtual.FatFim == null)
                {
                    coreAtual.FatFim = fim;
                }
                else
                {
                    if (coreAtual.FatFim < fim)
                    {
                        coreAtual.FatFim = fim;
                    }
                }
                db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 10
0
        public static bool novoEndereco(int clientID, String rua, String cidade, String estado)
        {
            try
            {
                GeFatEntities db       = new GeFatEntities();
                Endereços     endereco = new Endereços
                {
                    ClienteID = clientID,
                    Rua       = rua,
                    Cidade    = cidade,
                    Estado    = estado
                };
                db.Endereços.Add(endereco);
                db.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 11
0
        public static bool registrarVersao(int versao)
        {
            try
            {
                GeFatEntities db = new GeFatEntities();


                CoreData core;
                core = new CoreData
                {
                    Vers = versao
                };

                db.CoreData.Add(core);
                db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 12
0
 public pnFaturamento(DateTime inicio, DateTime fim)
 {
     try
     {
         GeFatEntities db = new GeFatEntities();
         clientes     = new List <Clientes>();
         this.pedidos = db.Pedidos.Where(pedido => pedido.Data >= inicio).Where(pedido => pedido.Data <= fim).ToList();
         List <Clientes> clientesTemp = db.Pedidos.Where(pedido => pedido.Data >= inicio).Where(pedido => pedido.Data <= fim).Join(db.Clientes, t => t.ClienteID, g => g.ClienteID, (t, g) => g).ToList();
         List <int>      ids          = new List <int>();
         foreach (Clientes cliente in clientesTemp)
         {
             if (!ids.Contains(cliente.ClienteID))
             {
                 ids.Add(cliente.ClienteID);
                 clientes.Add(cliente);
             }
         }
         pnCoreData.faturar(inicio, fim);
     }
     catch (Exception)
     {
         throw;
     }
 }