public List <Financas> pesquisaFluxosTipoDataPeriodo(String tipo, DateTime data1, DateTime data2)
        {
            List <Financas> lista = new List <Financas>();

            try
            {
                this.cmd = new MySqlCommand(SELECT_FLUXO_TIPO_DATA_PERIODO, this.conn);

                this.cmd.Parameters.Add(new MySqlParameter("@tipo", tipo));
                this.cmd.Parameters.Add(new MySqlParameter("@data1", data1));
                this.cmd.Parameters.Add(new MySqlParameter("@data2", data2));

                this.conn.Open();
                this.dtReader = this.cmd.ExecuteReader();

                if (this.dtReader.HasRows)
                {
                    while (this.dtReader.Read())
                    {
                        lista.Add(populaFinanca(this.dtReader));
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao carregar Dados");
            }
            finally
            {
                this.dtReader.Close();
                ConnectDAO.CloseConnection(this.conn);
            }

            return(lista);
        }
Esempio n. 2
0
        public List <PedidoPesquisa> ultimosPedidosPendentes()
        {
            List <PedidoPesquisa> pedidos = new List <PedidoPesquisa>();

            try
            {
                this.command = new MySqlCommand(SELECT_PEDIDOS_PENDENTES, this.conn);

                this.conn.Open();
                this.dataReader = this.command.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        pedidos.Add(populaPedidoPesquisa(this.dataReader));
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Carregar Dados");
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
                this.dataReader.Close();
            }

            return(pedidos);
        }
Esempio n. 3
0
        public void atualizarCliente(Cliente cliente)
        {
            try
            {
                this.command = new MySqlCommand(UPDATE_CLIENTE, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@nome", cliente.Nome));
                this.command.Parameters.Add(new MySqlParameter("@telefone", cliente.Telefone));
                this.command.Parameters.Add(new MySqlParameter("@celular", cliente.Celular));
                this.command.Parameters.Add(new MySqlParameter("@instagram", cliente.Instagram));
                this.command.Parameters.Add(new MySqlParameter("@email", cliente.Email));

                this.command.Parameters.Add(new MySqlParameter("@id", cliente.Id));

                this.conn.Open();
                this.command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Atualizar Cliente");
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 4
0
        public List <Cliente> pesquisaClientesDesativados()
        {
            List <Cliente> clientes = new List <Cliente>();

            try
            {
                this.command = new MySqlCommand(SELECT_CLIENTES_DESATIVO, this.conn);

                this.conn.Open();
                this.dataReader = this.command.ExecuteReader();

                while (this.dataReader.Read())
                {
                    Cliente cliente = populaCliente(this.dataReader);
                    clientes.Add(cliente);
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Pesquisar Clientes Deletados");
            }
            finally
            {
                this.dataReader.Close();
                ConnectDAO.CloseConnection(this.conn);
            }

            return(clientes);
        }
Esempio n. 5
0
        public Produto pesquisaProdutosId(int id)
        {
            Produto produto = new Produto();

            try
            {
                this.cmd = new MySqlCommand(SELECT_PRODUTO_ID, this.conn);
                this.cmd.Parameters.Add(new MySqlParameter("@id", id));

                this.conn.Open();
                this.dataReader = this.cmd.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        produto = publicarProduto(this.dataReader);
                    }
                }
                else
                {
                    throw new Exception("Id não Cadastrado");
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erro ao Carregar Dados" + e.Message);
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }

            return(produto);
        }
Esempio n. 6
0
        public List <Pedido> pesquisaPedidoData(DateTime data, DateTime data2)
        {
            List <Pedido> lista = new List <Pedido>();

            try
            {
                this.command = new MySqlCommand(SELECT_PEDIDO_DATA, this.conn);
                this.command.Parameters.Add(new MySqlParameter("@data", data));
                this.command.Parameters.Add(new MySqlParameter("@data2", data2));


                this.conn.Open();
                this.dataReader = this.command.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        lista.Add(populaPedido(this.dataReader));
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao carregar Dados");
            }
            finally
            {
                this.dataReader.Close();
                ConnectDAO.CloseConnection(this.conn);
            }

            return(lista);
        }
Esempio n. 7
0
        public List <Produto> pesquisaProdutosDesativados()
        {
            List <Produto> lista = new List <Produto>();

            try
            {
                this.cmd = new MySqlCommand(SELECT_PRODUTO_DESATIVADO, this.conn);

                this.conn.Open();

                this.dataReader = cmd.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        Produto produto = publicarProduto(this.dataReader);
                        lista.Add(produto);
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Listar Produtos Deletados");
            }
            finally
            {
                this.dataReader.Close();
                ConnectDAO.CloseConnection(conn);
            }

            return(lista);
        }
Esempio n. 8
0
        public void atualizarEndereco(Pedido pedido)
        {
            try
            {
                this.command = new MySqlCommand(UPDATE_ENDERECO, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@log", pedido.Logradouro));
                this.command.Parameters.Add(new MySqlParameter("@num", pedido.Numero));
                this.command.Parameters.Add(new MySqlParameter("@bairro", pedido.Bairro));
                this.command.Parameters.Add(new MySqlParameter("@cep", pedido.Cep));
                this.command.Parameters.Add(new MySqlParameter("@compl", pedido.Complemento));
                this.command.Parameters.Add(new MySqlParameter("@cid", pedido.Cidade));
                this.command.Parameters.Add(new MySqlParameter("@uf", pedido.Uf));
                this.command.Parameters.Add(new MySqlParameter("@id", pedido.Id_endereco));

                if (this.conn.State != System.Data.ConnectionState.Open)
                {
                    this.conn.Open();
                }

                this.command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 9
0
        public void inserirProduto(ProdutoPesquisa produto, int idPedido)
        {
            try
            {
                this.command = new MySqlCommand(INSERT_PRODUTO, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@id_produto", produto.Id));
                this.command.Parameters.Add(new MySqlParameter("@id_pedido", idPedido));
                this.command.Parameters.Add(new MySqlParameter("@qtd", produto.Quantidade));
                this.command.Parameters.Add(new MySqlParameter("@obs", produto.Observacao));

                if (this.conn.State != System.Data.ConnectionState.Open)
                {
                    this.conn.Open();
                }

                this.command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 10
0
        public void inserirPedido(Pedido pedido, List <ProdutoPesquisa> produtos)
        {
            try
            {
                int idPedido = 0;

                this.command = new MySqlCommand(INSERT_PEDIDO, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@tipo", pedido.Tipo_pedido));
                this.command.Parameters.Add(new MySqlParameter("@situacao", pedido.Situacao_pedido));
                this.command.Parameters.Add(new MySqlParameter("@tipo_pag", pedido.Tipo_pagamento));
                this.command.Parameters.Add(new MySqlParameter("@data_pag", pedido.Data_pagamento));
                this.command.Parameters.Add(new MySqlParameter("@valor", pedido.Valor_total));
                this.command.Parameters.Add(new MySqlParameter("@data_ent", pedido.Data_entrega));
                this.command.Parameters.Add(new MySqlParameter("@hora_ent", pedido.Hora_entrega));
                this.command.Parameters.Add(new MySqlParameter("@id_cliente", pedido.Id_cliente));

                this.conn.Open();
                this.command.ExecuteNonQuery();

                this.command = new MySqlCommand(SELECT_LAST_ID, this.conn);

                this.dataReader = this.command.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        idPedido = int.Parse(this.dataReader["id"].ToString());
                    }

                    this.dataReader.Close();
                }
                else
                {
                    throw new Exception("Erro ao Carregar Dados");
                }

                if (pedido.Tipo_pedido == "Entrega")
                {
                    inserirEndereco(pedido, idPedido);
                }

                foreach (ProdutoPesquisa p in produtos)
                {
                    inserirProduto(p, idPedido);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 11
0
        public List <Produto> pesquisaProdutosDesativadosFiltro(string filtro)
        {
            List <Produto> lista = new List <Produto>();

            try
            {
                int    num;
                string select = SELECT_PRODUTO_DESATIVO_FILTRO;

                if (!int.TryParse(filtro, out num))
                {
                    filtro += "%";
                    select += " nome LIKE @nome";
                }
                else
                {
                    select += " id = @id";
                }

                this.cmd = new MySqlCommand(select, this.conn);
                this.cmd.Parameters.Add(new MySqlParameter("@nome", filtro));

                this.conn.Open();
                this.cmd.ExecuteNonQuery();
                this.dataReader = this.cmd.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        Produto dado = publicarProduto(this.dataReader);
                        lista.Add(dado);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                this.dataReader.Close();
                ConnectDAO.CloseConnection(conn);
            }

            return(lista);
        }
Esempio n. 12
0
        public List <PedidoPesquisa> pesquisaPedidosFiltro(String filtro)
        {
            List <PedidoPesquisa> pedidos = new List <PedidoPesquisa>();

            try
            {
                int    num;
                string select = SELECT_PEDIDO_FILTRO;

                if (!int.TryParse(filtro, out num))
                {
                    select += " nome LIKE @filtro OR situacao_pedido LIKE @filtro2 ORDER BY data_entrega DESC";
                    filtro += "%";
                }
                else
                {
                    select += " p.id = @filtro ORDER BY data_entrega DESC";
                }

                this.command = new MySqlCommand(select, this.conn);
                this.command.Parameters.Add(new MySqlParameter("@filtro", filtro));
                this.command.Parameters.Add(new MySqlParameter("@filtro2", filtro));

                this.conn.Open();
                this.dataReader = this.command.ExecuteReader();

                while (this.dataReader.Read())
                {
                    pedidos.Add(populaPedidoPesquisa(this.dataReader));
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                this.dataReader.Close();
                ConnectDAO.CloseConnection(this.conn);
            }

            return(pedidos);
        }
Esempio n. 13
0
        public void desativarProduto(int id)
        {
            try
            {
                this.cmd = new MySqlCommand(DESATIVE_PRODUTO, this.conn);
                this.cmd.Parameters.Add(new MySqlParameter("@id", id));

                this.conn.Open();
                this.cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 14
0
        public void reativarCliente(int id)
        {
            try
            {
                this.command = new MySqlCommand(REATIVA_CLIENTE, this.conn);
                this.command.Parameters.Add(new MySqlParameter("@id", id));

                this.conn.Open();
                this.command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
        public void deletarFluxo(int id)
        {
            try
            {
                this.cmd = new MySqlCommand(DELETE_FLUXO, this.conn);
                this.cmd.Parameters.Add(new MySqlParameter("@id", id));

                this.conn.Open();
                this.cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 16
0
        public List <Cliente> pesquisaClientesDesativadosFiltro(String filtro)
        {
            List <Cliente> clientes = new List <Cliente>();

            try
            {
                int    num;
                string select = SELECT_CLIENTES_DESATIVO_FILTRO;

                if (!int.TryParse(filtro, out num))
                {
                    select += " nome LIKE @filtro";
                    filtro += "%";
                }
                else
                {
                    select += " id = @filtro";
                }

                this.command = new MySqlCommand(select, this.conn);
                this.command.Parameters.Add(new MySqlParameter("@filtro", filtro));

                this.conn.Open();
                this.dataReader = this.command.ExecuteReader();

                while (this.dataReader.Read())
                {
                    Cliente cliente = populaCliente(this.dataReader);
                    clientes.Add(cliente);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                this.dataReader.Close();
                ConnectDAO.CloseConnection(this.conn);
            }

            return(clientes);
        }
Esempio n. 17
0
        public void deletarEndereco(int idPedido)
        {
            try
            {
                this.command = new MySqlCommand(DELETE_ENDERECO, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@pedido_id", idPedido));

                this.conn.Open();
                this.command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 18
0
        public void atualizarProduto(Produto produto)
        {
            try
            {
                this.cmd = new MySqlCommand(UPDATE_PRODUTO, this.conn);
                this.cmd.Parameters.Add(new MySqlParameter("@nome", produto.Nome));
                this.cmd.Parameters.Add(new MySqlParameter("@preco", produto.Preco));
                this.cmd.Parameters.Add(new MySqlParameter("@descricao", produto.Descricao));

                this.conn.Open();
                this.cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Atualizar Produto");
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 19
0
        public void atualizarSituacao(String situacao, int id)
        {
            try
            {
                this.command = new MySqlCommand(UPDATE_SITUACAO, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@situacao", situacao));
                this.command.Parameters.Add(new MySqlParameter("@id", id));

                this.conn.Open();
                this.command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 20
0
        public List <ProdutoPesquisa> pesquisaProdutoMaisVendidoData(DateTime data, DateTime data2)
        {
            List <ProdutoPesquisa> lista = new List <ProdutoPesquisa>();

            try
            {
                this.command = new MySqlCommand(SELECT_PRODUTO_MAIS_VENDIDO, this.conn);
                this.command.Parameters.Add(new MySqlParameter("@data1", data));
                this.command.Parameters.Add(new MySqlParameter("@data2", data2));

                this.conn.Open();
                this.dataReader = this.command.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        ProdutoPesquisa p = new ProdutoPesquisa()
                        {
                            Id         = int.Parse(dataReader["id"].ToString()),
                            Nome       = dataReader["nome"].ToString(),
                            Quantidade = int.Parse(dataReader["qtd"].ToString())
                        };

                        lista.Add(p);
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao carregar Dados");
            }
            finally
            {
                this.dataReader.Close();
                ConnectDAO.CloseConnection(this.conn);
            }

            return(lista);
        }
Esempio n. 21
0
        public void atualizarPedido(Pedido pedido, List <ProdutoPesquisa> produtos)
        {
            try
            {
                this.command = new MySqlCommand(UPDATE_PEDIDO, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@tipo", pedido.Tipo_pedido));
                this.command.Parameters.Add(new MySqlParameter("@situacao", pedido.Situacao_pedido));
                this.command.Parameters.Add(new MySqlParameter("@tipo_pag", pedido.Tipo_pagamento));
                this.command.Parameters.Add(new MySqlParameter("@data_pag", pedido.Data_pagamento));
                this.command.Parameters.Add(new MySqlParameter("@valor", pedido.Valor_total));
                this.command.Parameters.Add(new MySqlParameter("@data_ent", pedido.Data_entrega));
                this.command.Parameters.Add(new MySqlParameter("@hora_ent", pedido.Hora_entrega));
                this.command.Parameters.Add(new MySqlParameter("@id", pedido.Id_pedido));

                this.conn.Open();
                this.command.ExecuteNonQuery();

                if (pedido.Tipo_pedido == "Entrega")
                {
                    atualizarEndereco(pedido);
                }

                deletarProduto(pedido.Id_pedido);

                foreach (ProdutoPesquisa p in produtos)
                {
                    inserirProduto(p, pedido.Id_pedido);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
Esempio n. 22
0
        public Cliente pesquisaClienteId(int id)
        {
            Cliente cliente = new Cliente();

            try
            {
                this.command = new MySqlCommand(SELECT_CLIENTE_ID, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@id", id));

                this.conn.Open();
                this.dataReader = this.command.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        cliente = populaCliente(this.dataReader);
                    }
                }
                else
                {
                    throw new Exception("Id não Cadastrado");
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Carregar Dados");
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
                this.dataReader.Close();
            }

            return(cliente);
        }
Esempio n. 23
0
        public List <ProdutoPesquisa> pesquisaProduto(int id)
        {
            List <ProdutoPesquisa> produtos = new List <ProdutoPesquisa>();

            try
            {
                this.command = new MySqlCommand(SELECT_PRODUTO, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@id", id));

                this.conn.Open();
                this.dataReader = this.command.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        produtos.Add(populaProduto(this.dataReader));
                    }
                }
                else
                {
                    throw new Exception("Id não Cadastrado");
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Carregar Dados");
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
                this.dataReader.Close();
            }

            return(produtos);
        }
Esempio n. 24
0
        public Pedido pesquisaEnderecoId(int id)
        {
            Pedido pedido = new Pedido();

            try
            {
                this.command = new MySqlCommand(SELECT_ENDERECO_ID, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@id", id));

                this.conn.Open();
                this.dataReader = this.command.ExecuteReader();

                if (this.dataReader.HasRows)
                {
                    while (this.dataReader.Read())
                    {
                        pedido = populaEndereco(this.dataReader);
                    }
                }
                else
                {
                    throw new Exception("Id não Cadastrado");
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Carregar Dados");
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
                this.dataReader.Close();
            }

            return(pedido);
        }
        public void atualizarFluxo(Financas financas)
        {
            try
            {
                this.cmd = new MySqlCommand(UPDATE_FLUXO, this.conn);

                this.cmd.Parameters.Add(new MySqlParameter("@titulo", financas.Titulo));
                this.cmd.Parameters.Add(new MySqlParameter("@valor", financas.Valor));
                this.cmd.Parameters.Add(new MySqlParameter("@descricao", financas.Descricao));
                this.cmd.Parameters.Add(new MySqlParameter("@data_lancamento", financas.Data_lancamento));
                this.cmd.Parameters.Add(new MySqlParameter("@tipo_fluxo", financas.Tipo_fluxo));

                this.conn.Open();
                this.cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Atualizar Atividade");
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
        public Financas pesquisaFinancasId(int id)
        {
            Financas financas = new Financas();

            try
            {
                this.cmd = new MySqlCommand(SELECT_FLUXO_ID, this.conn);

                this.cmd.Parameters.Add(new MySqlParameter("@id", id));

                this.conn.Open();
                this.dtReader = this.cmd.ExecuteReader();

                if (this.dtReader.HasRows)
                {
                    while (this.dtReader.Read())
                    {
                        financas = populaFinanca(this.dtReader);
                    }
                }
                else
                {
                    throw new Exception("Id Não Cadastrado");
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao Carregar Dados");
            }
            finally
            {
                ConnectDAO.CloseConnection(conn);
            }

            return(financas);
        }
Esempio n. 27
0
        public void deletarProduto(int idPedido)
        {
            try
            {
                this.command = new MySqlCommand(DELETE_PRODUTO, this.conn);

                this.command.Parameters.Add(new MySqlParameter("@pedido_id", idPedido));

                if (this.conn.State != System.Data.ConnectionState.Open)
                {
                    this.conn.Open();
                }

                this.command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ConnectDAO.CloseConnection(this.conn);
            }
        }
 public FinancasDAO()
 {
     this.conn = ConnectDAO.GetConnection();
 }
Esempio n. 29
0
 public ProdutoDAO()
 {
     this.conn = ConnectDAO.GetConnection();
 }
Esempio n. 30
0
 public ClienteDAO()
 {
     this.conn = ConnectDAO.GetConnection();
 }