public void Inserir()
        {
            string query = "INSERT INTO PRODUTO VALUES('" +
                           descricao + "', " + isPA + ", " + tamanho + ", " +
                           preco + ");";

            bd.ExecutarComandoSQL(query);
        }
Beispiel #2
0
        public void Inserir()
        {
            string query = "INSERT INTO Fornecedor VALUES('" +
                           cnpj + "', '" + razao_social + "', '" + inscricao_estadual + "', '" +
                           inscricao_municipal + "', '" + endereco + "', '" + bairro + "', '" +
                           municipio + "', '" + uf + "', '" + pais + "', '" +
                           cep + "');";

            bd.ExecutarComandoSQL(query);
        }
Beispiel #3
0
 public void Inserir()
 {
     if (!Validacao.ExistPK("cnpj_cpf", "Cliente", cnpj_cpf))
     {
         string query = "INSERT INTO CLIENTE VALUES('" +
                        cnpj_cpf + "', '" + razao_social + "', '" + inscricao_estadual + "', '" +
                        inscricao_municipal + "', '" + endereco + "', '" + bairro + "', '" +
                        municipio + "', '" + uf + "', '" + pais + "', '" +
                        cep + "');";
         bd.ExecutarComandoSQL(query);
         MessageBox.Show("Cliente cadastrado!", "Sucesso");
     }
     else
     {
         MessageBox.Show("CNPJ/CPF já existente", "Erro");
     }
 }
        public void Inserir()
        {
            string    query     = "SELECT quantidade FROM ESTOQUE WHERE produto_id = " + produto_id + " AND locais_id = " + locais_id;
            DataTable tabelinha = bd.Tabela(query);

            if (tabelinha.Rows.Count == 0)
            {
                query = "INSERT INTO Estoque VALUES(" + locais_id + ", 1, " + produto_id + ", 'Disponível', " + quantidade + ")";
            }
            else
            {
                int x = bd.GetInt(query, 0);
                quantidade += x;
                query       = "UPDATE Estoque SET quantidade = " + quantidade + " WHERE produto_id = " + produto_id + " AND " +
                              "locais_id = " + locais_id;
            }
            bd.ExecutarComandoSQL(query);
        }
Beispiel #5
0
        public void Finalizar(string id)
        {
            string queryEstoque;

            if (new Estoque().TemRepetido(Int32.Parse(item_pedido_id)))
            {
                int qtd = bd.GetInt("SELECT quantidade FROM Estoque WHERE itens_pedido_id = " + item_pedido_id, 0);
                queryEstoque = "UPDATE Estoque SET quantidade = " + (quantidade + qtd) +
                               " WHERE itens_pedido_id = " + item_pedido_id;
            }
            else
            {
                queryEstoque = "INSERT INTO Estoque VALUES(" + local_id + ", " + item_pedido_id + ", " + produto_id +
                               ", 'Reservado', " + quantidade + ");";
            }
            string queryItemPedido = "UPDATE Itens_Pedido SET status = 'Atendido' WHERE id = " + item_pedido_id + ";";
            string query           = "UPDATE Ordem_producao SET status = 'Finalizada' WHERE id = " + id + ";";

            bd.ExecutarComandoSQL(queryEstoque + queryItemPedido + query);
        }
            public void Inserir()
            {
                string    query     = "SELECT quantidade FROM Itens_pedido WHERE produto_id = " + idProduto + " AND pedido_id = " + idPedido;
                DataTable tabelinha = bd.Tabela(query);

                if (tabelinha.Rows.Count == 0)
                {
                    if (QuantidadeNoEstoque(idProduto) == qtdProduto)
                    {
                        status = "Atendido";
                        query  = "INSERT INTO Itens_Pedido VALUES(" + idPedido + ", " + idProduto + ", " + qtdProduto + ", '" +
                                 status + "'); ";
                        string selectEstoque = "SELECT TOP 1 id, itens_pedido_id FROM Estoque " +
                                               "WHERE status = 'Disponível' AND produto_id = " + idProduto;
                        int    getIdEstoque = bd.GetInt(selectEstoque, 0);
                        string queryEstoque = "UPDATE Estoque SET status = 'Reservado', itens_pedido_id = " +
                                              GetMaxId() + " WHERE itens_pedido_id = " + bd.GetInt(selectEstoque, 1);
                        bd.ExecutarComandoSQL(query + queryEstoque);
                    }
                    else if (QuantidadeNoEstoque(idProduto) > qtdProduto)
                    {
                        status = "Atendido";
                        query  = "INSERT INTO Itens_Pedido VALUES(" + idPedido + ", " + idProduto + ", " + qtdProduto + ", '" +
                                 status + "'); ";
                        bd.ExecutarComandoSQL(query);

                        //Quebra o registro em 2
                        int    qtd           = QuantidadeNoEstoque(idProduto);
                        string selectEstoque = "SELECT TOP 1 id, itens_pedido_id FROM Estoque " +
                                               "WHERE status = 'Disponível' AND produto_id = " + idProduto;
                        int    getIdEstoque = bd.GetInt(selectEstoque, 0);
                        string queryEstoque = "UPDATE Estoque SET status = 'Reservado', quantidade = " +
                                              qtdProduto + ", itens_pedido_id = " + GetMaxId() + " WHERE id = " + getIdEstoque;
                        bd.ExecutarComandoSQL(queryEstoque);

                        int idLocal = bd.GetInt("SELECT locais_id FROM Estoque WHERE itens_pedido_id = " + GetMaxId(), 0);
                        queryEstoque = "INSERT INTO ESTOQUE VALUES(" + idLocal + ", " + bd.GetInt(selectEstoque, 1) +
                                       ", " + idProduto + ", 'Disponível', " + (qtd - qtdProduto) + ")";
                        bd.ExecutarComandoSQL(queryEstoque);
                    }
                    else
                    {
                        status = "Em produção";
                        query  = "INSERT INTO Itens_Pedido VALUES(" + idPedido + ", " + idProduto + ", " + qtdProduto + ", '" +
                                 status + "');";
                        bd.ExecutarComandoSQL(query);

                        string selectEstoque = "SELECT TOP 1 id, itens_pedido_id FROM Estoque " +
                                               "WHERE status = 'Disponível' AND produto_id = " + idProduto;
                        int    getIdEstoque = bd.GetInt(selectEstoque, 0);
                        string queryEstoque = "UPDATE Estoque SET status = 'Reservado'" +
                                              " WHERE itens_pedido_id = " + getIdEstoque;
                        string queryProducao = "INSERT INTO Ordem_producao VALUES(" + GetMaxId() + ", " +
                                               idProduto + ", 'Em produção'," + (qtdProduto - QuantidadeNoEstoque(idProduto)) + ");";
                        bd.ExecutarComandoSQL(queryEstoque + queryProducao);
                    }
                }
                else
                {
                    int id = bd.GetInt("SELECT id from Itens_pedido WHERE produto_id = " + idProduto + " AND " +
                                       "pedido_id = " + idPedido, 0);
                    int qtdInicial = bd.GetInt(query, 0);
                    int qtdFinal   = qtdProduto + qtdInicial;
                    if (QuantidadeNoEstoque(idProduto) >= qtdFinal)
                    {
                        status = "Atendido";
                    }
                    else
                    {
                        status = "Em produção"; bd.ExecutarComandoSQL("DELETE FROM Estoque WHERE itens_pedido_id = " + id);
                    }
                    query = "UPDATE Itens_Pedido SET quantidade = " + qtdFinal + ", status = '" + status +
                            "' WHERE produto_id = " + idProduto + " AND pedido_id = " + idPedido;

                    bd.ExecutarComandoSQL(query);
                    if (QuantidadeNoEstoque(idProduto) == qtdProduto)
                    {
                        string queryEstoque = "UPDATE Estoque SET status = 'Reservado', itens_pedido_id = " +
                                              id + " WHERE status = 'Disponível' AND produto_id = " + idProduto;
                        bd.ExecutarComandoSQL(query + queryEstoque);
                    }
                    else if (QuantidadeNoEstoque(idProduto) > qtdProduto)
                    {
                        //Quebra o registro em 2
                        string queryEstoque, selectLocais = "SELECT locais_id FROM Estoque WHERE " +
                                                            "itens_pedido_id = " + id;
                        int idLocal = bd.GetInt(selectLocais, 0);
                        if (new Estoque().TemRepetido(id))
                        {
                            int qtd = bd.GetInt("SELECT quantidade FROM Estoque WHERE itens_pedido_id = " + id, 0);
                            queryEstoque = "UPDATE Estoque SET quantidade = " + (qtdProduto + qtd) +
                                           " WHERE itens_pedido_id = " + id;
                        }
                        else
                        {
                            queryEstoque = "INSERT INTO Estoque VALUES(" + id + ", " +
                                           idProduto + ", 'Em produção'," + (qtdProduto - QuantidadeNoEstoque(idProduto)) + ");";
                        }
                        bd.ExecutarComandoSQL(queryEstoque);
                        queryEstoque = "UPDATE Estoque SET status = 'Reservado', quantidade = " +
                                       qtdProduto + ", itens_pedido_id = " + id + " WHERE status = 'Disponível' AND produto_id = " + idProduto;
                        bd.ExecutarComandoSQL(queryEstoque);
                    }
                    else
                    {
                        string queryProducao, queryEstoque = "UPDATE Estoque SET status = 'Reservado'" +
                                                             " WHERE status = 'Disponível' AND produto_id = " + idProduto + "; ";
                        if (new OrdemProducao().TemRepetido(id))
                        {
                            int qtd = bd.GetInt("SELECT quantidade FROM Ordem_producao WHERE itens_pedido_id = " + id, 0);
                            queryProducao = "UPDATE Ordem_producao SET quantidade = " + (qtdProduto + qtd) +
                                            ", status = 'Em produção' WHERE itens_pedido_id = " + id;
                        }
                        else
                        {
                            queryProducao = "INSERT INTO Ordem_producao VALUES(" + id + ", " +
                                            idProduto + ", 'Em produção'," + (qtdProduto - QuantidadeNoEstoque(idProduto)) + ");";
                        }
                        bd.ExecutarComandoSQL(queryEstoque + queryProducao);
                    }
                }
            }
Beispiel #7
0
        public void Inserir()
        {
            string query = "INSERT INTO Locais VALUES('" + descricao + "')";

            bd.ExecutarComandoSQL(query);
        }