public FormCadastroCliente()
        {
            InitializeComponent();
            pessoa = new Pessoa();
            pessoaFisica = new PessoaFisica();
            pessoaJuridica = new PessoaJuridica();
            telefone = new Telefone();
            tipoTelefone = new TipoTelefone();
            endereco = new Endereco();
            cidade = new Cidade();
            uf = new UnidadeFederativa();
            tipoEndereco = new TipoEndereco();
            db = new ProjetoLojaEntities();
            this.pessoaData = new PessoaData(db);
            this.cidadeData = new CidadeData(db);
            this.enderecoData = new EnderecoData(db);
            this.pessoaFisicaData = new PessoaFisicaData(db);
            this.pessoaJuridicaData = new PessoaJuridicaData(db);
            this.telefoneData = new TelefoneData(db);
            this.tipoEnderecoData = new TipoEnderecoData(db);
            this.tipoPessoaData = new TipoPessoaData();
            this.tipoTelefoneData = new TipoTelefoneData(db);
            this.ufData = new UF_Data(db);

            tabDadosPessoais.Enabled = false;
            tabEndereco.Enabled = false;
            tabTelefone.Enabled = false;

            txtNomeFantasia.Enabled = false;
            txtRazaoSocial.Enabled = false;
            txtEmail.Enabled = false;
            txtRg.Enabled = false;
            txtCpf.Enabled = false;

            cbxTipoTelefone.DataSource = tipoTelefoneData.todosTiposTelefones();
            cbxTipoTelefone.DisplayMember = "descricao";
            cbxTipoTelefone.ValueMember = "idTipoTelefone";
            cbxUf.DataSource = ufData.todasUnidadesFederativas();
            cbxUf.DisplayMember = "nome";
            cbxUf.ValueMember = "UF";
            cbxCidade.DataSource = cidadeData.todasCidades();
            cbxCidade.DisplayMember = "nome";
            cbxCidade.ValueMember = "idCidade";
            cbxTipoEndereco.DataSource = tipoEnderecoData.todostipoenderecos();
            cbxTipoEndereco.DisplayMember = "descricao";
            cbxTipoEndereco.ValueMember = "idTipoEndereco";

            atualizarPesquisaClientes(pessoaData.todasPessoas());
            inicializar();
        }
Example #2
0
 public Endereco(int id, string nome, TipoEndereco tipo, int clienteId)
 {
     this.Id        = id;
     this.Nome      = nome;
     this.Tipo      = tipo;
     this.ClienteId = clienteId;
 }
Example #3
0
 public Endereco(int idEndereco, TipoEndereco tipo, string logradouro, string numero,
                 string complemento, string bairro, string municipio, string uf, string cep,
                 string telefone1, string telefone2, string email, bool igualCadastro, bool igualCobranca)
     : this(tipo, logradouro, numero, complemento, bairro, municipio, uf, cep, telefone1, telefone2, email, igualCadastro, igualCobranca)
 {
     IdEndereco = idEndereco;
 }
Example #4
0
 public ActionResult Edit(TipoEndereco te)
 {
     if (Roles.IsUserInRole(User.Identity.Name, "Administrador"))
     {
         string erro = null;
         if (te.idTipoEndereco == 0)
         {
             erro = teModel.adicionarTipoEndereco(te);
         }
         else
         {
             erro = teModel.editarTipoEndereco(te);
         }
         if (erro == null)
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewBag.Erro = erro;
             return(View(te));
         }
     }
     return(Redirect("/Shared/Restrito"));
 }
Example #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            TipoEndereco tipoEndereco = dao.Buscar(id);
            bool         valido       = dao.Deletar(tipoEndereco);

            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id)
        {
            TipoEndereco te = teModel.obterTipoEndereco(id);

            teModel.excluirTipoEndereco(te);
            return(RedirectToAction("Index"));
        }
Example #7
0
        public Endereco(string logradouro, string numero, CEP cep, Cidade cidade, TipoEndereco tipoEndereco)
        {
            if (string.IsNullOrWhiteSpace(logradouro))
            {
                throw new Excecao.ExcecaoParametroInvalido("Endereco.Logradouro");
            }

            if (string.IsNullOrWhiteSpace(numero))
            {
                throw new Excecao.ExcecaoParametroInvalido("Endereco.Numero");
            }

            if ((cep == null) || (string.IsNullOrEmpty(cep.Cep.Trim())))
            {
                throw new Excecao.ExcecaoParametroInvalido("Endereco.Cep");
            }

            if (cidade == null)
            {
                throw new Excecao.ExcecaoParametroInvalido("Endereco.Cidade");
            }

            this.Logradouro   = logradouro;
            this.Numero       = numero;
            this.Cep          = cep;
            this.Cidade       = cidade;
            this.TipoEndereco = tipoEndereco;
        }
Example #8
0
        public ReturnAction Save(TipoEnderecoModel model, Guid id)
        {
            ReturnAction retorno = new ReturnAction();

            var sit = db.TipoEndereco.AsNoTracking().Where(w => w.Id == model.Id);

            if (sit.Any())
            {
                retorno.Mensagens.Add("O indexador do item já está cadastrado.");
            }
            else
            {
                var obj = new TipoEndereco(id, model.Nome);

                if (!obj.EhValido())
                {
                    foreach (var item in obj.Get)
                    {
                        retorno.Mensagens.Add(item.Value);
                    }
                }
                else
                {
                    db.Entry(obj).State = EntityState.Added;
                    db.SaveChanges();
                }
            }

            return(retorno);
        }
Example #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            TipoEndereco tipoEndereco = db.TipoEndereco.Find(id);

            db.TipoEndereco.Remove(tipoEndereco);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public Endereco(string logradouro, string bairro, string numero, Cidade cidade, TipoEndereco tipo)
 {
     Logradouro = logradouro;
     Bairro     = bairro;
     Numero     = numero;
     Cidade     = cidade;
     Tipo       = tipo;
 }
Example #11
0
 public ActionResult Edit([Bind(Include = "TipoEnderecoID,Nome,rowguid,DataModificacao")] TipoEndereco tipoEndereco)
 {
     if (ModelState.IsValid)
     {
         bool valido = dao.Editar(tipoEndereco);
         return(RedirectToAction("Index"));
     }
     return(View(tipoEndereco));
 }
Example #12
0
 public Endereco(Guid id, TipoEndereco tipo, string tipoLogradouro, string logradouro, string numero, string complemento = "")
 {
     this.Id             = id;
     this.Tipo           = tipo;
     this.TipoLogradouro = tipoLogradouro;
     this.TipoLogradouro = logradouro;
     this.Numero         = numero;
     this.Complemento    = complemento;
 }
        public PartialViewResult Edit(int id)
        {
            TipoEndereco te = new TipoEndereco();

            if (id != 0)
            {
                te = teModel.obterTipoEndereco(id);
            }
            return(PartialView(te));
        }
Example #14
0
 public ActionResult Edit([Bind(Include = "TipoEnderecoID,Nome,rowguid,DataModificacao")] TipoEndereco tipoEndereco)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tipoEndereco).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tipoEndereco));
 }
Example #15
0
        public ActionResult Create([Bind(Include = "TipoEnderecoID,Nome")] TipoEndereco tipoEndereco)
        {
            if (ModelState.IsValid)
            {
                bool valido = dao.Criar(tipoEndereco);
                return(RedirectToAction("Index"));
            }

            return(View(tipoEndereco));
        }
Example #16
0
 public static String ObtemString(TipoEndereco tipo)
 {
     switch (tipo)
     {
         case TipoEndereco.Residencial: return "Residencial";
         case TipoEndereco.Comercial:   return "Comercial";
         case TipoEndereco.Cobranca:    return "Cobranca";
         default:  throw new ExcecaoParametroInvalido("Tipo");
     }
 }
Example #17
0
 public ActionResult Delete(int id)
 {
     if (Roles.IsUserInRole(User.Identity.Name, "Administrador"))
     {
         TipoEndereco te = teModel.obterTipoEndereco(id);
         teModel.excluirTipoEndereco(te);
         return(RedirectToAction("Index"));
     }
     return(Redirect("/Shared/Restrito"));
 }
Example #18
0
        public ActionResult Create([Bind(Include = "TipoEnderecoID,Nome,rowguid,DataModificacao")] TipoEndereco tipoEndereco)
        {
            if (ModelState.IsValid)
            {
                db.TipoEndereco.Add(tipoEndereco);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tipoEndereco));
        }
Example #19
0
        private static void criarTiposEnderecos()
        {
            var tipoEndereco = new TipoEndereco();

            tipoEndereco.Nome = "Residencial";
            tipoEndereco.Save();

            tipoEndereco      = new TipoEndereco();
            tipoEndereco.Nome = "Comercial";
            tipoEndereco.Save();
        }
Example #20
0
 public Endereco(TipoEndereco tipo, string cep, string uf, string cidade, string bairro,
                 string logradouro, string numero, string complemento)
 {
     Cep         = cep;
     Uf          = uf;
     Cidade      = cidade;
     Bairro      = bairro;
     Tipo        = tipo;
     Logradouro  = logradouro;
     Numero      = numero;
     Complemento = complemento;
 }
Example #21
0
    private void GetTipoEndereco(int idTipoEndereco)
    {
        dvSalvarTipoEndereco.Visible  = true;
        dvListarTipoEnderecos.Visible = false;

        var TipoEndereco = new TipoEndereco();

        TipoEndereco.IDTipoEndereco = idTipoEndereco;
        TipoEndereco.Get();

        txtId.Text   = TipoEndereco.IDTipoEndereco.ToString();
        txtNome.Text = TipoEndereco.Nome.ToString();
    }
Example #22
0
        public static String ObtemString(TipoEndereco tipo)
        {
            switch (tipo)
            {
            case TipoEndereco.Residencial: return("Residencial");

            case TipoEndereco.Comercial:   return("Comercial");

            case TipoEndereco.Cobranca:    return("Cobranca");

            default:  throw new ExcecaoParametroInvalido("Tipo");
            }
        }
Example #23
0
 protected void DeleteTipoEndereco(int idTipoEndereco)
 {
     try
     {
         var TipoEndereco = new TipoEndereco();
         TipoEndereco.IDTipoEndereco = idTipoEndereco;
         TipoEndereco.Delete();
         GetTipoEnderecos();
     }
     catch (Exception err)
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>");
     }
 }
Example #24
0
        // GET: TipoEnderecoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TipoEndereco tipoEndereco = db.TipoEndereco.Find(id);

            if (tipoEndereco == null)
            {
                return(HttpNotFound());
            }
            return(View(tipoEndereco));
        }
Example #25
0
        public FormCadastroCliente()
        {
            InitializeComponent();
            pessoa                  = new Pessoa();
            pessoaFisica            = new PessoaFisica();
            pessoaJuridica          = new PessoaJuridica();
            telefone                = new Telefone();
            tipoTelefone            = new TipoTelefone();
            endereco                = new Endereco();
            cidade                  = new Cidade();
            uf                      = new UnidadeFederativa();
            tipoEndereco            = new TipoEndereco();
            db                      = new ProjetoLojaEntities();
            this.pessoaData         = new PessoaData(db);
            this.cidadeData         = new CidadeData(db);
            this.enderecoData       = new EnderecoData(db);
            this.pessoaFisicaData   = new PessoaFisicaData(db);
            this.pessoaJuridicaData = new PessoaJuridicaData(db);
            this.telefoneData       = new TelefoneData(db);
            this.tipoEnderecoData   = new TipoEnderecoData(db);
            this.tipoPessoaData     = new TipoPessoaData();
            this.tipoTelefoneData   = new TipoTelefoneData(db);
            this.ufData             = new UF_Data(db);

            tabDadosPessoais.Enabled = false;
            tabEndereco.Enabled      = false;
            tabTelefone.Enabled      = false;

            txtNomeFantasia.Enabled = false;
            txtRazaoSocial.Enabled  = false;
            txtEmail.Enabled        = false;
            txtRg.Enabled           = false;
            txtCpf.Enabled          = false;

            cbxTipoTelefone.DataSource    = tipoTelefoneData.todosTiposTelefones();
            cbxTipoTelefone.DisplayMember = "descricao";
            cbxTipoTelefone.ValueMember   = "idTipoTelefone";
            cbxUf.DataSource              = ufData.todasUnidadesFederativas();
            cbxUf.DisplayMember           = "nome";
            cbxUf.ValueMember             = "UF";
            cbxCidade.DataSource          = cidadeData.todasCidades();
            cbxCidade.DisplayMember       = "nome";
            cbxCidade.ValueMember         = "idCidade";
            cbxTipoEndereco.DataSource    = tipoEnderecoData.todostipoenderecos();
            cbxTipoEndereco.DisplayMember = "descricao";
            cbxTipoEndereco.ValueMember   = "idTipoEndereco";

            atualizarPesquisaClientes(pessoaData.todasPessoas());
            inicializar();
        }
Example #26
0
        public void AlterarTipoEndereco(TipoEndereco tipoEndereco)
        {
            if (!modelState.IsValid)
            {
                return;
            }

            tipoEndereco.DataCadastro      = DateTime.Now;
            tipoEndereco.IdUsuarioCadastro = ((UsuarioBackOffice)HttpContext.Current.Session["user"]).Id;

            ResultValidation retorno = serviceTipoEndereco.Alterar(tipoEndereco);

            PreencherModelState(retorno);
        }
Example #27
0
 public string excluirTipoEndereco(TipoEndereco tipoendereco)
 {
     string erro = null;
     try
     {
         tipoenderecos.DeleteObject(tipoendereco);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
Example #28
0
        // GET: TipoEnderecos/Delete/5
        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TipoEndereco tipoEndereco = dao.Buscar(id);

            if (tipoEndereco == null)
            {
                return(HttpNotFound());
            }
            return(View(tipoEndereco));
        }
        public ActionResult addTipoEndereco(TipoEndereco tipoEndereco)
        {
            DAOTipoEndereco daoTipoEndereco = new DAOTipoEndereco();
            int             intChave        = daoTipoEndereco.AddRecord(tipoEndereco.descricao);

            if (intChave > 0)
            {
                return(Created("", intChave));
            }
            else
            {
                return(BadRequest());
            }
        }
        public string adicionarTipoEndereco(TipoEndereco t)
        {
            string erro = null;

            try
            {
                db.TipoEndereco.AddObject(t);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                erro = ex.Message;
            }
            return(erro);
        }
Example #31
0
        public string excluirTipoEndereco(TipoEndereco e)
        {
            string erro = null;

            try
            {
                db.TipoEndereco.DeleteObject(e);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                erro = ex.Message;
            }
            return(erro);
        }
Example #32
0
        public void TipoEndereco()
        {
            bool passouPorTodos = true;

            //Criar
            try
            {
                TipoEndereco obj = new TipoEndereco();
                obj.Nome            = "Testeabab";
                obj.DataModificacao = DateTime.Now;
                db.TipoEndereco.Add(obj);
                db.SaveChanges();
            }
            catch
            {
                passouPorTodos = false;
            }
            //Alterar
            try
            {
                TipoEndereco obj = new TipoEndereco();
                obj                 = db.TipoEndereco.FirstOrDefault(x => x.Nome == "Testeabab");
                obj.Nome            = "efefefef";
                obj.DataModificacao = DateTime.Now;
                db.Entry(obj).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch
            {
                passouPorTodos = false;
            }
            //Listar
            List <TipoEndereco> Listar = db.TipoEndereco.ToList();

            //Excluir
            try
            {
                TipoEndereco obj = new TipoEndereco();
                obj = db.TipoEndereco.FirstOrDefault(x => x.Nome == "efefefef");
                db.TipoEndereco.Remove(obj);
                db.SaveChanges();
            }
            catch
            {
                passouPorTodos = false;
            }
            Assert.AreEqual(true, passouPorTodos);
        } //2
Example #33
0
 public Endereco(Guid id, TipoEndereco tipoEndereco, string cep, string logradouro, int numero,
                 string complemento, string bairro, string cidade, string estado, bool principal,
                 string comprovanteBase64, Guid consultorId)
 {
     Id                = id;
     TipoEndereco      = tipoEndereco;
     Cep               = cep;
     Logradouro        = logradouro;
     Numero            = numero;
     Complemento       = complemento;
     Bairro            = bairro;
     Cidade            = cidade;
     Estado            = estado;
     Principal         = principal;
     ComprovanteBase64 = comprovanteBase64;
     ConsultorId       = consultorId;
 }
 public TipoEndereco Save(TipoEndereco entity)
 {
     using (var context = new RThomazDbEntities())
     {
         if (entity.TipoEnderecoId == 0)
         {
             entity.DataCriacao = DateTime.Now;
             context.TipoEndereco.AddObject(entity);
         }
         else
         {
             context.CreateObjectSet<TipoEndereco>().Attach(entity);
             context.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
         }
         context.SaveChanges();
     }
     return entity;
 }
Example #35
0
        public Endereco(string logradouro, string numero, CEP cep, Cidade cidade, TipoEndereco tipoEndereco)
        {
            if (string.IsNullOrWhiteSpace(logradouro))
                throw new Excecao.ExcecaoParametroInvalido("Endereco.Logradouro");

            if (string.IsNullOrWhiteSpace(numero))
                throw new Excecao.ExcecaoParametroInvalido("Endereco.Numero");

            if ((cep == null) || (string.IsNullOrEmpty(cep.Cep.Trim())))
                throw new Excecao.ExcecaoParametroInvalido("Endereco.Cep");

            if (cidade == null)
                throw new Excecao.ExcecaoParametroInvalido("Endereco.Cidade");

            this.Logradouro = logradouro;
            this.Numero = numero;
            this.Cep = cep;
            this.Cidade = cidade;
            this.TipoEndereco = tipoEndereco;
        }
Example #36
0
        public string editarTipoEndereco(TipoEndereco tipoendereco)
        {
            string erro = null;
            try
            {

                if (tipoendereco.EntityState == System.Data.EntityState.Detached)
                {
                    tipoenderecos.Attach(tipoendereco);
                }
                db.ObjectStateManager.ChangeObjectState(tipoendereco, System.Data.EntityState.Modified);

                db.SaveChanges();
            }
            catch (Exception ex)
            {
                erro = ex.Message;
            }
            return erro;
        }
 public ExcecaoEnderecoNaoPermitido(TipoPessoa tipoPessoa, TipoEndereco tipoEndereco)
     : base("Não é permitido adicionar " + NomeTipoEndereco.ObtemString(tipoEndereco) + "para pessoa " + NomeTipoPessoa.Obtem(tipoPessoa) + "!")
 {
 }