public Configuracao()
        {
            data.bd_postgres sql = new data.bd_postgres();
            sql.localdb();
            sql.AbrirConexao();
            sql.Comando             = new Npgsql.NpgsqlCommand();
            sql.Comando.CommandText = "select * from configuracao";
            IDataReader dr = sql.RetornaDados_v2();

            Boolean x = true;

            while (dr.Read())
            {
                x = false;
            }

            if (x)
            {
                sql.FechaConexao();
                sql.Comando.CommandText = "insert into configuracao(validar_ncm) values(true)";
                sql.AbrirConexao();
                sql.ExecutaComando_v2();
                sql.FechaConexao();
            }
        }
 public void atualiza(Entidade_Configuracao item)
 {
     data.bd_postgres sql = new data.bd_postgres();
     sql.localdb();
     sql.AbrirConexao();
     sql.Comando             = new Npgsql.NpgsqlCommand();
     sql.Comando.CommandText = "update configuracao set validar_ncm = " + item.valida_ncm;
     sql.ExecutaComando_v2();
     sql.FechaConexao();
 }
Beispiel #3
0
 public void fecha_venda(Entidade_Vendas item)
 {
     data.bd_postgres sql = new data.bd_postgres();
     sql.localdb();
     sql.AbrirConexao();
     sql.Comando             = new Npgsql.NpgsqlCommand();
     sql.Comando.CommandText = "update vendas set status = " + Status_venda.fechado.GetHashCode() + " , data = current_timestamp, xml = '" + item.xml + "' where id = " + item.id + " ";
     sql.ExecutaComando_v2();
     sql.FechaConexao();
 }
Beispiel #4
0
        public void abrir_caixa(Entidade_Caixa item)
        {
            Boolean x = false;

            data.bd_postgres sql = new data.bd_postgres();
            sql.localdb();
            sql.AbrirConexao();
            sql.Comando             = new Npgsql.NpgsqlCommand();
            sql.Comando.CommandText = "INSERT INTO caixa(usuario, data_abertura, valor_abertura) VALUES (@usuario,current_timestamp, @valor_abertura);";
            sql.Comando.Parameters.AddWithValue("@usuario", item.usuario);
            sql.Comando.Parameters.AddWithValue("@valor_abertura", item.valor_abertura);
            sql.ExecutaComando_v2();

            sql.FechaConexao();

            //return item;
        }
Beispiel #5
0
        public void salva(Entidade_Produto item)
        {
            data.bd_postgres sql = new data.bd_postgres();
            sql.localdb();
            sql.Comando = new Npgsql.NpgsqlCommand();

            StringBuilder sb = new StringBuilder();

            if (item.id > 0)
            {
                sb.AppendLine("update produto set fornecedor=@fornecedor,nome=@nome,ean=@ean,valor_compra=@valor_compra,valor_venda=@valor_venda");
                sb.AppendLine(",valor_atacado=@valor_atacado,margem=@margem,margem_atacado=@margem_atacado,cfop=@cfop,ncm=@ncm,estoque=@estoque,estoque_minimo=@estoque_minimo");
                sb.AppendLine(",estoque_maximo=@estoque_maximo where id = @id");

                sql.Comando.Parameters.AddWithValue("@id", item.id);
                sql.Comando.Parameters.AddWithValue("@fornecedor", item.fornecedor);
                sql.Comando.Parameters.AddWithValue("@nome", item.nome_produto);
                sql.Comando.Parameters.AddWithValue("@ean", item.ean);
                sql.Comando.Parameters.AddWithValue("@valor_compra", item.valor_compra);
                sql.Comando.Parameters.AddWithValue("@valor_venda", item.valor_venda);
                sql.Comando.Parameters.AddWithValue("@valor_atacado", item.valor_venda_atacado);
                sql.Comando.Parameters.AddWithValue("@margem", item.valor_venda_margem);
                sql.Comando.Parameters.AddWithValue("@margem_atacado", item.valor_venda_atacado_margem);
                sql.Comando.Parameters.AddWithValue("@cfop", item.cfop);
                sql.Comando.Parameters.AddWithValue("@ncm", item.ncm);
                sql.Comando.Parameters.AddWithValue("@estoque", item.estoque_inicial);
                sql.Comando.Parameters.AddWithValue("@estoque_minimo", item.estoque_minimo);
                sql.Comando.Parameters.AddWithValue("@estoque_maximo", item.estoque_maximo);
            }
            else
            {
                //Salva

                //INSERT INTO produto(
                //        id, nome, empresa, fornecedor, ean, tipo_produto, valor_compra,
                //        venda, status, ncm, cfop, estoque, estoque_minimo, estoque_maximo,
                //        sat_cfop, sat_ncm)
                //VALUES (?, ?, ?, ?, ?, ?, ?,
                //        ?, ?, ?, ?, ?, ?, ?,
                //        ?, ?);

                sb.AppendLine("INSERT INTO produto(fornecedor,nome,ean,valor_compra,valor_venda,valor_atacado,margem,margem_atacado,cfop,ncm,estoque,estoque_minimo,estoque_maximo)");
                sb.AppendLine("VALUES (@fornecedor,@nome,@ean,@valor_compra,@valor_venda,@valor_atacado,@margem,@margem_atacado,@cfop,@ncm,@estoque,@estoque_minimo,@estoque_maximo)");

                sql.Comando.Parameters.AddWithValue("@fornecedor", item.fornecedor);
                sql.Comando.Parameters.AddWithValue("@nome", item.nome_produto);
                sql.Comando.Parameters.AddWithValue("@ean", item.ean);
                sql.Comando.Parameters.AddWithValue("@valor_compra", item.valor_compra);
                sql.Comando.Parameters.AddWithValue("@valor_venda", item.valor_venda);
                sql.Comando.Parameters.AddWithValue("@valor_atacado", item.valor_venda_atacado);
                sql.Comando.Parameters.AddWithValue("@margem", item.valor_venda_margem);
                sql.Comando.Parameters.AddWithValue("@margem_atacado", item.valor_venda_atacado_margem);
                sql.Comando.Parameters.AddWithValue("@cfop", item.cfop);
                sql.Comando.Parameters.AddWithValue("@ncm", item.ncm);
                sql.Comando.Parameters.AddWithValue("@estoque", item.estoque_inicial);
                sql.Comando.Parameters.AddWithValue("@estoque_minimo", item.estoque_minimo);
                sql.Comando.Parameters.AddWithValue("@estoque_maximo", item.estoque_maximo);
            }

            sql.Comando.CommandText = sb.ToString();
            sql.AbrirConexao();
            sql.ExecutaComando_v2();
            sql.FechaConexao();
        }