/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.ddns.grupotsergio;

import java.sql.*;
import java.util.ArrayList;

/**
 *
 * @author Edson
 */
public class cliforGS {
    public int chave = 0;
    public String cli = null;
    public String ctacontabilcli = null;
    public String forn = null;
    public String ctacontabilfor = null;
    public String esp = null;
    public String nome = null;
    public String nome_fantasia = null;
    public String endereco = null;
    public String numero = null;
    public String complemento = null;
    public String bairro = null;
    public String cidade = null;
    public String uf = null;
    public String cep = null;
    public String cxpostal = null;
    public String fone1 = null;
    public String fone2 = null;
    public String fone3 = null;
    public String fax = null;
    public String cnpj = null;
    public String ie = null;
    public String im = null;
    public String contato = null;
    public String representante = null;
    public String transportador = null;
    public String contribicms = null;
    public String infocoml = null;
    public String infobanc = null;
    public String outrasinfo = null;
    public String pais = null;
    public String email = null;
    public String homepage = null;
    public String ativa = null;
    public String auditoria = null;
    public int empresa_idempresa = 0;

    private static PreparedStatement stm = null;
    private static ResultSet rs = null;
    private static Statement stmt;

    public String getAuditoria() {
        return auditoria;
    }

    public void setAuditoria(String auditoria) {
        this.auditoria = auditoria;
    }

    public String getAtiva() {
        return ativa;
    }

    public void setAtiva(String ativa) {
        this.ativa = ativa;
    }

    public String getBairro() {
        return bairro;
    }

    public void setBairro(String bairro) {
        this.bairro = bairro;
    }

    public String getCep() {
        return cep;
    }

    public void setCep(String cep) {
        this.cep = cep;
    }

    public int getChave() {
        return chave;
    }

    public void setChave(int chave) {
        this.chave = chave;
    }

    public String getCli() {
        return cli;
    }

    public void setCli(String cli) {
        this.cli = cli;
    }

    public String getCnpj() {
        return cnpj;
    }

    public void setCnpj(String cnpj) {
        this.cnpj = cnpj;
    }

    public String getComplemento() {
        return complemento;
    }

    public void setComplemento(String complemento) {
        this.complemento = complemento;
    }

    public String getContato() {
        return contato;
    }

    public void setContato(String contato) {
        this.contato = contato;
    }

    public String getContribicms() {
        return contribicms;
    }

    public void setContribicms(String contribicms) {
        this.contribicms = contribicms;
    }

    public String getCtacontabilcli() {
        return ctacontabilcli;
    }

    public void setCtacontabilcli(String ctacontabilcli) {
        this.ctacontabilcli = ctacontabilcli;
    }

    public String getCtacontabilfor() {
        return ctacontabilfor;
    }

    public void setCtacontabilfor(String ctacontabilfor) {
        this.ctacontabilfor = ctacontabilfor;
    }

    public String getCxpostal() {
        return cxpostal;
    }

    public void setCxpostal(String cxpostal) {
        this.cxpostal = cxpostal;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEndereco() {
        return endereco;
    }

    public void setEndereco(String endereco) {
        this.endereco = endereco;
    }

    public String getEsp() {
        return esp;
    }

    public void setEsp(String esp) {
        this.esp = esp;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getFone1() {
        return fone1;
    }

    public void setFone1(String fone1) {
        this.fone1 = fone1;
    }

    public String getFone2() {
        return fone2;
    }

    public void setFone2(String fone2) {
        this.fone2 = fone2;
    }

    public String getFone3() {
        return fone3;
    }

    public void setFone3(String fone3) {
        this.fone3 = fone3;
    }

    public String getForn() {
        return forn;
    }

    public void setForn(String forn) {
        this.forn = forn;
    }

    public String getHomepage() {
        return homepage;
    }

    public void setHomepage(String homepage) {
        this.homepage = homepage;
    }

    public String getIe() {
        return ie;
    }

    public void setIe(String ie) {
        this.ie = ie;
    }

    public String getIm() {
        return im;
    }

    public void setIm(String im) {
        this.im = im;
    }

    public String getInfobanc() {
        return infobanc;
    }

    public void setInfobanc(String infobanc) {
        this.infobanc = infobanc;
    }

    public String getInfocoml() {
        return infocoml;
    }

    public void setInfocoml(String infocoml) {
        this.infocoml = infocoml;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getNome_fantasia() {
        return nome_fantasia;
    }

    public void setNome_fantasia(String nome_fantasia) {
        this.nome_fantasia = nome_fantasia;
    }

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }

    public String getOutrasinfo() {
        return outrasinfo;
    }

    public void setOutrasinfo(String outrasinfo) {
        this.outrasinfo = outrasinfo;
    }

    public String getPais() {
        return pais;
    }

    public void setPais(String pais) {
        this.pais = pais;
    }

    public String getRepresentante() {
        return representante;
    }

    public void setRepresentante(String representante) {
        this.representante = representante;
    }

    public String getTransportador() {
        return transportador;
    }

    public void setTransportador(String transportador) {
        this.transportador = transportador;
    }

    public String getCidade() {
        return cidade;
    }

    public void setCidade(String cidade) {
        this.cidade = cidade;
    }

    public int getEmpresa_idempresa() {
        return empresa_idempresa;
    }

    public void setEmpresa_idempresa(int empresa_idempresa) {
        this.empresa_idempresa = empresa_idempresa;
    }

    public String getUf() {
        return uf;
    }

    public void setUf(String uf) {
        this.uf = uf;
    }


    public cliforGS(){
    }

    public static boolean inserirClifor (cliforGS clifor){
        try{
            stm = Conexao.conectar().prepareStatement("INSERT INTO clifor("
            + "idclifor, empresa_idempresa,cli,ctacontabilcli,"
            + "forn,ctacontabilfor,esp,nome,nome_fantasia,"
            + "endereco,numero,complemento,bairro,cidade,"
            + "uf,cep,cxpostal,fone1,fone2,fone3,fax,cnpj,"
            + "ie,im,contato,infocoml,infobanc,outrasinfo,"
            + "homepage,ativa)"
            + " VALUES (?,?,?,?,?,?,?,?,?,?"
                    + ",?,?,?,?,?,?,?,?,?,?"
                    + ",?,?,?,?,?,?,?,?,?,?)");
            stm.setInt(1, clifor.getChave());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setString(3, clifor.getCli());
            stm.setString(4, clifor.getCtacontabilcli());
            stm.setString(5, clifor.getForn());
            stm.setString(6, clifor.getCtacontabilfor());
            stm.setString(7, clifor.getEsp());
            stm.setString(8, clifor.getNome());
            stm.setString(9, clifor.getNome_fantasia());
            stm.setString(10, clifor.getEndereco());
            stm.setString(11, clifor.getNumero());
            stm.setString(12, clifor.getComplemento());
            stm.setString(13, clifor.getBairro());
            stm.setString(14, clifor.getCidade());
            stm.setString(15, clifor.getUf());
            stm.setString(16, clifor.getCep());
            stm.setString(17, clifor.getCxpostal());
            stm.setString(18, clifor.getFone1());
            stm.setString(19, clifor.getFone2());
            stm.setString(20, clifor.getFone3());
            stm.setString(21, clifor.getFax());
            stm.setString(22, clifor.getCnpj());
            stm.setString(23, clifor.getIe());
            stm.setString(24, clifor.getIm());
            stm.setString(25, clifor.getContato());
            stm.setString(26, clifor.getInfocoml());
            stm.setString(27, clifor.getInfobanc());
            stm.setString(28, clifor.getOutrasinfo());
            stm.setString(29, clifor.getHomepage());
            stm.setString(30, clifor.getAtiva());
            
            stm.executeUpdate();
            stm.close();
            return true;
        }catch(Exception e){
            System.out.println("Erro ao inserir");
            return false;
        }
    }

    public static boolean altCFcli (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "cli = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getCli());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFcccli (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "ctacontabilcli = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getCtacontabilcli());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFfor (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "forn = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getForn());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFccfor (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "ctacontabilfor = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(4, clifor.getCtacontabilfor());
            stm.setInt(31, clifor.getEmpresa_idempresa());
            stm.setInt(32, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFesp (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "esp = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getEsp());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFnome (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "nome = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getNome());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFnofan (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "nome_fantasia = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getNome_fantasia());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFend (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "endereco = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getEndereco());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFnro (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "numero = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getNumero());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFcompl (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "complemento = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getComplemento());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFbai (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "bairro = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getBairro());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFcid (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "cidade = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getCidade());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFuf (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "uf = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getUf());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFcep (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "cep = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getCep());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFcxp (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "cxpostal = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getCxpostal());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFfone1 (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "fone1 = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getFone1());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFfone2 (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "fone2 = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getFone2());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFfone3 (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "fone3 = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getFone3());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFfax (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "fax = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getFax());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFcnpj (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "cnpj = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getCnpj());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFie (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "ie = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getIe());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFim (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "im = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getIm());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFcontato (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "contato = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getContato());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFincoml (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "infocoml = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getInfocoml());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFinbanc (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "infobanc = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getInfobanc());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFoutin (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "outrasinfo = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getOutrasinfo());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFpais (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "pais = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getPais());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFemail (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "email = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getEmail());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFhpage (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "homepage = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getHomepage());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean altCFativa (cliforGS clifor){
        boolean testa = false;
        try{
            stm = Conexao.conectar().prepareStatement("UPDATE clifor SET "
                    + "ativa = ? "
                    + "WHERE empresa_idempresa = ? "
                    + "AND idclifor = ?");
            stm.setString(1, clifor.getAtiva());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            stm.setInt(3, clifor.getChave());

            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        }catch(Exception e){
            System.out.println("Erro ao alterar");
        }
        return testa;
    }

    public static boolean excluiClifor (cliforGS clifor){
        boolean testa = false;
        try {
            stm = Conexao.conectar().prepareStatement("delete from clifor "
            + "where idclifor = ? and empresa_idempresa = ?");
            stm.setInt(1, clifor.getChave());
            stm.setInt(2, clifor.getEmpresa_idempresa());
            int executeUpdate = stm.executeUpdate();

            if(executeUpdate > 0)
                testa = true;
            else
                testa = false;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return testa;
    }

    public void selClifor(String Id, String Ide) {
        try {
            cliforGS scid = null;
            stmt = Conexao.conectar().createStatement();
            rs = stmt.executeQuery("Select * From clifor Where "
            + "idclifor ='"+Id+"' and empresa_idempresa = '"+Ide+"'");
            if (rs.next()) {
                scid = new cliforGS();
                scid.setChave(rs.getInt("chave"));
                scid.setAtiva(rs.getString("ativa"));
                scid.setAuditoria(rs.getString("auditoria"));
                scid.setBairro(rs.getString("bairro"));
                scid.setCep(rs.getString("cep"));
                scid.setCidade(rs.getString("cidade"));
                scid.setCli(rs.getString("cli"));
                scid.setCnpj(rs.getString("cnpj"));
                scid.setComplemento(rs.getString("complemento"));
                scid.setContato(rs.getString("contato"));
                scid.setContribicms(rs.getString("contribicms"));
                scid.setCtacontabilcli(rs.getString("ctacontabilcli"));
                scid.setCtacontabilfor(rs.getString("ctacontabilfor"));
                scid.setCxpostal(rs.getString("cxpostal"));
                scid.setEmail(rs.getString("email"));
                scid.setEndereco(rs.getString("endereco"));
                scid.setEsp(rs.getString("esp"));
                scid.setFax(rs.getString("fax"));
                scid.setFone1(rs.getString("fone1"));
                scid.setFone2(rs.getString("fone2"));
                scid.setFone3(rs.getString("fone3"));
                scid.setForn(rs.getString("forn"));
                scid.setHomepage(rs.getString("homepage"));
                scid.setIe(rs.getString("ie"));
                scid.setIm(rs.getString("im"));
                scid.setInfobanc(rs.getString("infobanc"));
                scid.setInfocoml(rs.getString("infocoml"));
                scid.setNome(rs.getString("nome"));
                scid.setNome_fantasia(rs.getString("nome_fantasia"));
                scid.setNumero(rs.getString("numero"));
                scid.setOutrasinfo(rs.getString("outrasinfo"));
                scid.setPais(rs.getString("pais"));
                scid.setRepresentante(rs.getString("representante"));
                scid.setTransportador(rs.getString("transportador"));
                scid.setEmpresa_idempresa(rs.getInt("empresa_idempresa"));
            }
            rs.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void selCliforNome(String Id) {
        try {
            cliforGS scid = null;
            stmt = Conexao.conectar().createStatement();
            rs = stmt.executeQuery("Select * From clifor Where nome ='"+Id+"'");
            if (rs.next()) {
                scid = new cliforGS();
                scid.setChave(rs.getInt("chave"));
                scid.setAtiva(rs.getString("ativa"));
                scid.setAuditoria(rs.getString("auditoria"));
                scid.setBairro(rs.getString("bairro"));
                scid.setCep(rs.getString("cep"));
                scid.setCidade(rs.getString("cidade"));
                scid.setCli(rs.getString("cli"));
                scid.setCnpj(rs.getString("cnpj"));
                scid.setComplemento(rs.getString("complemento"));
                scid.setContato(rs.getString("contato"));
                scid.setContribicms(rs.getString("contribicms"));
                scid.setCtacontabilcli(rs.getString("ctacontabilcli"));
                scid.setCtacontabilfor(rs.getString("ctacontabilfor"));
                scid.setCxpostal(rs.getString("cxpostal"));
                scid.setEmail(rs.getString("email"));
                scid.setEndereco(rs.getString("endereco"));
                scid.setEsp(rs.getString("esp"));
                scid.setFax(rs.getString("fax"));
                scid.setFone1(rs.getString("fone1"));
                scid.setFone2(rs.getString("fone2"));
                scid.setFone3(rs.getString("fone3"));
                scid.setForn(rs.getString("forn"));
                scid.setHomepage(rs.getString("homepage"));
                scid.setIe(rs.getString("ie"));
                scid.setIm(rs.getString("im"));
                scid.setInfobanc(rs.getString("infobanc"));
                scid.setInfocoml(rs.getString("infocoml"));
                scid.setNome(rs.getString("nome"));
                scid.setNome_fantasia(rs.getString("nome_fantasia"));
                scid.setNumero(rs.getString("numero"));
                scid.setOutrasinfo(rs.getString("outrasinfo"));
                scid.setPais(rs.getString("pais"));
                scid.setRepresentante(rs.getString("representante"));
                scid.setTransportador(rs.getString("transportador"));
                scid.setEmpresa_idempresa(rs.getInt("empresa_idempresa"));
            }
            rs.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static int getAutoInc(String Id) {
        int Codigo = 0;
        try {
            PreparedStatement pstmt = Conexao.conectar().prepareStatement(
            "Select max(idclifor) From clifor "
            + "where empresa_idempresa = '"+Id+"'");
            ResultSet rss = pstmt.executeQuery();
            rss.next();
            Codigo = rss.getInt(1) + 1;
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        return Codigo;
    }

    public void listaClifor(String Id){
        try{
            stmt = Conexao.conectar().createStatement();
            rs = stmt.executeQuery("select * from clifor where "
                    + "empresa_idempresa = '"+Id+"' "
                    +"order by nome");
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public void listaCli(String Id){
        try{
            stmt = Conexao.conectar().createStatement();
            rs = stmt.executeQuery("select * from clifor c, empresa e where "
                    + "cli = 'S' and c.empresa_idempresa=e.idempresa and "
                    + "empresa_idempresa = '"+Id+"' "
                    +"order by nome");
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    
    public void listaForn(String Id){
        try{
            stmt = Conexao.conectar().createStatement();
            rs = stmt.executeQuery("select * from clifor where "
                    + "forn = 'S' and empresa_idempresa = '"+Id+"' "
                    +"order by nome");
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public ResultSet getResultado(){
        return rs;
    }

}

