Ir para o conteúdo

 Voltar a Fórum do For...
Tela cheia

Estado e Municipio

24 de Junho de 2013, 11:09 , por Desconhecido - | Ninguém seguindo este artigo por enquanto.
Visualizado 19 vezes

Bom dia!!

Pessoal estou tenha uma dúvida!

Peguei o exemplo dentro da base exe_CepField,e implementei ele dentro do meu formulario com a conexão com postgres, so que ele não grava dentro do meu formulario ele esta aparecendo todos os estado e municipio dentro do meu formulario cad_pessoas, eu sei que preciso adcionar dentro dao as classes, mas minha duvida é posso adcionar as classes dentro do form Tb_pessoasDAO.class e Tb_pessoasVO.class...

CAD_PESSOAS

<?php

$frm=new TForm( 'Cadastro de Membros', 430 );

$frm->addHiddenField( 'id' );

$pc=$frm->addPageControl( 'pc' ); 

$pc->addPage( 'Cadastro', true, true, 'abaCadastro' ); 

$frm->addSelectField('tipo','Tipo de Membro',false,'Obreiro,Membro,Pastor,Diacono,Auxiliar');

$frm->addTextField( 'nome', 'Nome:', 100, true, 80 );

$frm->addTextField( 'email', 'Email:', 30 );

$frm->addTextField( 'telefone', 'Telefone:', 30, false, null, null, false );

$frm->addSelectField('cod_uf','Estado:',false);

$frm->addSelectField('cod_municipio','Município:',null,null,false);

$frm->combinarSelects('cod_uf','cod_municipio','vw_municipios','cod_uf','cod_municipio','nom_municipio','-- Municípios --','0','Nenhum Município Encontrado');

$frm->addButton( 'Salvar', 'salvar', 'btnSalvar', null, null, true, false );

$frm->addButton( 'Limpar', 'limpar', 'btnLimpar', null, null, false, false );

$frm->addHtmlField( 'mensagem', '<br><center><b><span class="FonteVermelha">Campos em vermelho são de preenchimento obrigatório</span></b></center>' );

$pc->addPage( 'Listagem' );

$frm->addGroupField( 'gpPesquiar', 'Pesquisar Por:' )->setColumns( array

(

60,

150,

60,

100

));

$frm->addTextField( 'psq_nome', 'Nome:', 20, false, 20 );

$frm->addTextField( 'psq_modelo', 'Modelo:', 20, false, 20, null, false );

$frm->addButton( 'Pesquisar', 'pesquisar', 'btnPesquisar', null, null, false, false );

$frm->closeGroup();

$frm->addHtmlField( 'html_gride', 'Aqui será carregado o gride' );

$frm->processAction();

$where=null;

if ( $frm->get( 'psq_nome' ) || $frm->get( 'psq_modelo' ) )

{

$where=array();


if ( $frm->get( 'psq_nome' ) )

{

$where[ ] = "nome like '%" . trim( $frm->get( 'psq_nome' ) ) . "%'";

}


if ( $frm->get( 'psq_modelo' ) )

{

$where[ ] = "modelo like '%" . trim( $frm->get( 'psq_modelo' ) ) . "%'";

}


$where=implode( ' and ', $where );

}

$g=new TGrid( 'gd'                    

,             'Listagem de Pessoas'

,             Tb_pessoasDAO::selectAll( 'nome', $where ) 

,             null,

 null,

 'ID' );                                  

$frm->set( 'html_gride', $g ); // ou $frm->getField('gride')->add($g);

$frm->show();

?>

<script>


function myCallback(dataset)

{

console.log(jQuery("#cod_municipio_temp").val());

jQuery("#cod_uf").change();

}

</script> 

 TD_PESSOASVO.CLASS:

<?php

class Tb_pessoasVO

{

private $id = null;

private $tipo = null;

private $nome = null;

private $email = null;

private $telefone = null;

public function Tb_pessoasVO( $id=null, $tipo=null, $nome=null, $email=null, $telefone=null )

{

$this->setId( $id );

$this->setTipo( $tipo );

$this->setNome( $nome );

$this->setEmail( $email );

$this->setTelefone( $telefone );

}

//--------------------------------------------------------------------------------

function setId( $strNewValue = null )

{

$this->id = $strNewValue;

}

function getId()

{

return $this->id;

}

//--------------------------------------------------------------------------------

function setTipo( $strNewValue = null )

{

$this->tipo = $strNewValue;

}

function getTipo()

{

return $this->tipo;

}

//--------------------------------------------------------------------------------

function setNome( $strNewValue = null )

{

$this->nome = $strNewValue;

}

function getNome()

{

return $this->nome;

}

//--------------------------------------------------------------------------------

function setEmail( $strNewValue = null )

{

$this->email = $strNewValue;

}

function getEmail()

{

return $this->email;

}

//--------------------------------------------------------------------------------

function setTelefone( $strNewValue = null )

{

$this->telefone = $strNewValue;

}

function getTelefone()

{

return $this->telefone;

}

//--------------------------------------------------------------------------------

}

?> 

TD_PESSOASVO:

<?php

class Tb_pessoasDAO extends TPDOConnection

{

public function Tb_pessoasDAO()

{

}

//--------------------------------------------------------------------------------

public static function insert( Tb_pessoasVO $objVo )

{


// verificar se a tipo informada já existe

$res = self::executeSql("select id from tb_cadastro where nome = ?",$objVo->getnome());

if( res )

{

$objVo->setId($res['ID'][0]);

}


if( $objVo->getId() )

{

return self::update($objVo);

}

$values = array(  $objVo->getTipo()

, $objVo->getNome()

, $objVo->getEmail()

, $objVo->getTelefone()

);

return self::executeSql('insert into tb_cadastro(

tipo

,nome

,email

,telefone

) values (?,?,?,?)', $values );

}

//--------------------------------------------------------------------------------

public static function delete( $id )

{

$values = array($id);

return self::executeSql('delete from tb_cadastro where id = ?',$values);

}

//--------------------------------------------------------------------------------

public static function select( $id )

{

$values = array($id);

return self::executeSql('select

id

,tipo

,nome

,email

,telefone

from tb_cadastro where id = ?', $values );

}

//--------------------------------------------------------------------------------

public static function selectAll( $orderBy=null, $where=null )

{

return self::executeSql('select

id

,tipo

,nome

,email

,telefone

from tb_cadastro'.

( ($where)? ' where '.$where:'').

( ($orderBy) ? ' order by '.$orderBy:''));

}

//--------------------------------------------------------------------------------

public static function update ( Tb_pessoasVO $objVo )

{

$values = array( $objVo->getTipo()

,$objVo->getNome()

,$objVo->getEmail()

,$objVo->getTelefone()

,$objVo->getId() );

return self::executeSql('update tb_cadastro set

tipo = ?

,nome = ?

,email = ?

,telefone = ?

where id = ?',$values);

}

//--------------------------------------------------------------------------------

}

?> 

 

ME AJUDA!!! 

Autor: erick vinicius


Essa comunidade não possui posts nesse blog