Esempio n. 1
0
 private void FEndereco_Cadastro_Shown(object sender, EventArgs e)
 {
     try
     {
         if (Modo == Modo.Cadastrar)
         {
             Endereco = new TB_REL_ENDERECO();
         }
         else if (Modo == Modo.Alterar)
         {
             teID_ENDERECO.Text = Endereco.ID_ENDERECO.ToString();
             teCEP.Text         = Endereco.CEP.Validar();
             teNM_RUA.Text      = Endereco.NM_RUA.Validar();
             teNM_BAIRRO.Text   = Endereco.NM_BAIRRO.Validar();
             teNR.Text          = Endereco.NR.Validar();
             beID_CIDADE.Text   = Endereco.ID_CIDADE.Padrao().ToString();
             beID_CIDADE_Leave(null, null);
             beID_PAIS.Text = Endereco.ID_PAIS.Padrao().ToString();
             beID_PAIS_Leave(null, null);
             meDS_COMPLEMENTO.Text = Endereco.DS_COMPLEMENTO.Validar();
         }
     }
     catch (Exception excessao)
     {
         excessao.Validar();
     }
 }
Esempio n. 2
0
        public void Gravar(TB_REL_ENDERECO endereco, ref int posicaoTransacao)
        {
            try
            {
                Conexao.Iniciar(ref posicaoTransacao);


                var existente = Conexao.BancoDados.TB_REL_ENDERECOs.FirstOrDefault(a => a.ID_ENDERECO == endereco.ID_ENDERECO);
                if (existente == null)
                {
                    endereco.ID_ENDERECO = (Conexao.BancoDados.TB_REL_ENDERECOs.Any() ? Conexao.BancoDados.TB_REL_ENDERECOs.Max(a => a.ID_ENDERECO) : 0) + 1;
                    Conexao.BancoDados.TB_REL_ENDERECOs.InsertOnSubmit(endereco);
                }
                else
                {
                    existente.ID_CIDADE            = endereco.ID_CIDADE;
                    existente.ID_PAIS              = endereco.ID_PAIS;
                    existente.ID_UNIDADEFEDERATIVA = endereco.ID_UNIDADEFEDERATIVA;
                    existente.NM_BAIRRO            = endereco.NM_BAIRRO;
                    existente.NR             = endereco.NR;
                    existente.DS_COMPLEMENTO = endereco.DS_COMPLEMENTO;
                    existente.CEP            = endereco.CEP;
                    existente.NM_RUA         = endereco.NM_RUA;
                }

                Conexao.Enviar();

                Conexao.Finalizar(ref posicaoTransacao);
            }
            catch (Exception excessao)
            {
                Conexao.Voltar(ref posicaoTransacao);
                throw excessao;
            }
        }
Esempio n. 3
0
        public void Deletar(TB_REL_ENDERECO endereco, ref int posicaoTransacao)
        {
            try
            {
                Conexao.Iniciar(ref posicaoTransacao);

                var existente = Conexao.BancoDados.TB_REL_ENDERECOs.FirstOrDefault(a => a.ID_ENDERECO == endereco.ID_ENDERECO);
                if (existente != null)
                {
                    Conexao.BancoDados.TB_REL_ENDERECOs.DeleteOnSubmit(endereco);
                }

                Conexao.Enviar();

                Conexao.Finalizar(ref posicaoTransacao);
            }
            catch (Exception excessao)
            {
                Conexao.Voltar(ref posicaoTransacao);
                throw excessao;
            }
        }