public static int Insert(Telefones telefones)
    {
        int retorno = 0;

        try
        {
            IDbConnection objConnection;
            IDbCommand    objCommand;

            string sql = "insert into tel_telefone(tel_ddd, tel_num, emp_id) values(?tel_ddd, ?tel_num, ?emp_id); select last_insert_id();";

            objConnection = Mapped.Connection();
            objCommand    = Mapped.Command(sql, objConnection);

            objCommand.Parameters.Add(Mapped.Parameter("?tel_ddd", telefones.Tel_ddd));
            objCommand.Parameters.Add(Mapped.Parameter("?tel_num", telefones.Tel_num));

            //FK
            objCommand.Parameters.Add(Mapped.Parameter("?emp_id", telefones.Emp_id.Emp_id));

            retorno = Convert.ToInt32(objCommand.ExecuteScalar());
            objConnection.Close();
            objConnection.Dispose();
            objCommand.Dispose();
        }
        catch (Exception ex)
        {
            retorno = -2;
        }
        return(retorno);
    }
Example #2
0
        public void TelefoneFixo_ValidarTelefoneFixo_TelefoneFixoComMascaras()
        {
            var numero = "(11)5677-5967";
            var result = Telefones.ValidarTelefoneFixo(numero);

            Assert.NotEqual(result, numero);
        }
Example #3
0
        public void DefinirTelefones(string celular, string fixo)
        {
            var telefones = new Telefones(celular, fixo);

            this.DefinirCelularAgenciaUsuarioScopeEhValido(celular);
            Telefone = telefones;
        }
Example #4
0
        public void Celular_ValidarCelular_CelularFormatoIncorreto()
        {
            var numero = "1197633788";
            var result = Telefones.ValidarCelular(numero);

            Assert.False(result);
        }
    protected void carregaDados()
    {
        Empresas id = (Empresas)Session["emp_empresa"];

        Telefones tel   = new Telefones();
        DataSet   dsTel = TelefonesDB.SelectTel(id.Emp_id);

        tel.Tel_ddd = Convert.ToString(dsTel.Tables[0].Rows[0]["tel_ddd"]);
        tel.Tel_num = Convert.ToString(dsTel.Tables[0].Rows[0]["tel_num"]);

        tel.Emp_id        = new Empresas();
        tel.Emp_id.Emp_id = Convert.ToInt32(dsTel.Tables[0].Rows[0]["emp_id"]);


        DataSet ds = EmpresasDB.SelectID(id.Emp_id);

        tel.Emp_id.Emp_nome_fantasia   = Convert.ToString(ds.Tables[0].Rows[0]["emp_nome_fantasia"]);
        tel.Emp_id.Emp_senha           = Convert.ToString(ds.Tables[0].Rows[0]["emp_senha"]);
        tel.Emp_id.Emp_email           = Convert.ToString(ds.Tables[0].Rows[0]["emp_email"]);
        tel.Emp_id.Emp_razao_social    = Convert.ToString(ds.Tables[0].Rows[0]["emp_razao_social"]);
        tel.Emp_id.Emp_cnpj            = Convert.ToString(ds.Tables[0].Rows[0]["emp_cnpj"]);
        tel.Emp_id.Emp_foto_url        = Convert.ToString(ds.Tables[0].Rows[0]["emp_foto_url"]);
        tel.Emp_id.Emp_numero_endereco = Convert.ToString(ds.Tables[0].Rows[0]["emp_numero_endereco"]);


        textDDD.Text          = tel.Tel_ddd.ToString();
        textTelefone.Text     = tel.Tel_num.ToString();
        textNomeFantasia.Text = tel.Emp_id.Emp_nome_fantasia.ToString();
        textEmail2.Text       = tel.Emp_id.Emp_email.ToString();
        textSocial.Text       = tel.Emp_id.Emp_razao_social.ToString();
        textCNPJ.Text         = tel.Emp_id.Emp_cnpj.ToString();
    }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            errorProvider1.SetError(txtTelefone, "");
            if (txtTelefone.Text.Replace("_", "").Replace("(", "").Replace(")", "").Replace("-", "").Trim().Length < 10)
            {
                errorProvider1.SetError(txtTelefone, "Telefone inválido.");
                return;
            }
            if (!string.IsNullOrEmpty(txtEmail.Text) && !Funcoes.validarEmail(txtEmail, errorProvider1))
            {
                return;
            }
            if (!string.IsNullOrEmpty(txtSite.Text) && !Funcoes.validarURL(txtSite, errorProvider1))
            {
                return;
            }
            try
            {
                TelefonesRepository repositorioTelefone = new TelefonesRepository();
                Telefones           telefoneModel       = new Telefones();

                telefoneModel.email       = txtEmail.Text.Trim();
                telefoneModel.id_contatos = Convert.ToInt32(cbxContatos.SelectedValue);
                telefoneModel.site        = txtSite.Text.Trim();
                telefoneModel.telefone    = txtTelefone.Text.Trim();
                telefoneModel.tipo        = cbxTipo.Text;
                repositorioTelefone.Inserir(telefoneModel);
                Limpar();
                MessageBox.Show("Registro cadastro com sucesso!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao cadastrar telefone: " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 private void button2_Click(object sender, EventArgs e)
 {
     if (dgvContatos.RowCount > 0)
     {
         if (MessageBox.Show("Deseja realmente excluir?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
             == System.Windows.Forms.DialogResult.Yes)
         {
             int       codigo        = Convert.ToInt32(dgvContatos.CurrentRow.Cells[0].Value.ToString());
             Telefones telefoneModel = repositorioTelefones.RetornarPorId(codigo);
             try
             {
                 repositorioTelefones.Excluir(telefoneModel);
                 MessageBox.Show("Registro excluído com sucesso!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 button1_Click(sender, e);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Erro ao excluir: " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("Não há registro(s) para excluir!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Example #8
0
        public ActionResult Edit(Telefones objeto)
        {
            try
            {
                Telefones.TransactionInstance.Save(objeto);

                return RedirectToAction("Index", new { displayMessage = MENSAGEM_ALTERACAO });
            }
            catch (ApplicationException ex)
            {
                string[] campos = ex.Message.Split(',');
                ModelState.AddModelError(string.Empty, MENSAGEM_CAMPOS_OBRIGATORIOS);
                foreach (string campo in campos)
                {
                    ModelState[campo].Errors.Add(ex);
                }

                return View(objeto);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);

                return View(objeto);
            }
        }
Example #9
0
        // GET: Telefones/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Telefones telefones = db.Telefone.Find(id);

            if (telefones == null)
            {
                return(HttpNotFound());
            }

            ViewBag.IdClassificacaoFK = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Casa", Value = "1"
                },
                new SelectListItem {
                    Text = "Trabalho", Value = "2"
                },
                new SelectListItem {
                    Text = "Outro", Value = "3"
                }
            };

            return(View(telefones));
        }
Example #10
0
        public void Telefone_Formato_Correto()
        {
            telefone = new Telefones(1, "1156775967", "976337887");
            var tel = new TelefoneValidoSpecification();

            Assert.True(tel.IsSatisfiedBy(telefone));
        }
Example #11
0
        public void TelefoneFixo_ValidarTelefoneFixo_TelefoneFixoFormatoCorreto()
        {
            var numero = "1156775967";
            var result = Telefones.ValidarTelefoneFixo(numero);

            Assert.Equal(result, numero);
        }
    public static int Update(Telefones tel)
    {
        int retorno = 0;

        try
        {
            IDbConnection objConnection;
            IDbCommand    objCommand;

            string sql = "update tel_telefone set tel_ddd = ?tel_ddd, tel_num = ?tel_num where emp_id = ?emp_id;";
            objConnection = Mapped.Connection();
            objCommand    = Mapped.Command(sql, objConnection);

            objCommand.Parameters.Add(Mapped.Parameter("?tel_ddd", tel.Tel_ddd));
            objCommand.Parameters.Add(Mapped.Parameter("?tel_num", tel.Tel_num));
            objCommand.Parameters.Add(Mapped.Parameter("?emp_id", tel.Emp_id.Emp_id));

            objCommand.ExecuteNonQuery();

            objConnection.Close();
            objConnection.Dispose();
            objCommand.Dispose();
        }
        catch (Exception ex)
        {
            retorno = -2;
        }
        return(retorno);
    }
Example #13
0
 public static bool DefinirCelularAgenciaUsuarioScopeEhValido(this AgenciaUsuario agenciausuario, string celular)
 {
     return(AssertionConcern.IsSatisfiedBy
            (
                AssertionConcern.AssertNotNullOrEmpty(celular, "O celular é obrigatório"),
                AssertionConcern.AssertTrue(Telefones.ValidarCelular(celular), "Celular em formato inválido")
            ));
 }
        public IActionResult Create()
        {
            var telefones = new Telefones();

            CarregaTipoTelefone();

            return(View(telefones));
        }
Example #15
0
 public void AddTelefone(string tel)
 {
     if (Telefones == null)
     {
         Telefones = new List <string>();
     }
     Telefones.Add(tel);
 }
Example #16
0
        public void Celular_ValidarCelular_CelularComMascaras()
        {
            var numero     = "(11)97633-7887";
            var semmascara = "11976337887";
            var result     = Telefones.RetornarCelular(numero);

            Assert.Equal(result, semmascara);
        }
Example #17
0
        // GET: Telefones/Delete/5
        public ActionResult Delete(int?id)
        {
            Telefones telefones = db.Telefone.Find(id);

            db.Telefone.Remove(telefones);
            db.SaveChanges();
            return(RedirectToAction("Edit", "Contatos", new { id = telefones.IdContato, idTelefone = telefones.IdTelefone }));
        }
Example #18
0
 public Endereco(string logradouro, string numero, string complemento,
                 string cidade, string uf, Telefones telefone)
 {
     this.logradouro  = logradouro;
     this.numero      = numero;
     this.complemento = complemento;
     this.cidade      = cidade;
     this.uf          = uf;
     this.telefone    = telefone;
 }
Example #19
0
 public Endereco(string logradouro, string numero, string complemento, 
     string cidade, string uf, Telefones telefone)
 {
     this.logradouro = logradouro;
     this.numero = numero;
     this.complemento = complemento;
     this.cidade = cidade;
     this.uf = uf;
     this.telefone = telefone;
 }
        public IActionResult Create(Telefones telefones)
        {
            if (ModelState.IsValid)
            {
                _contexto.Telefones.Add(telefones);
                _contexto.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(telefones));
        }
        public IActionResult Delete(Telefones _telefones)
        {
            var telefones = _contexto.Telefones.Find(_telefones.Id);

            if (telefones != null)
            {
                _contexto.Telefones.Remove(telefones);
                _contexto.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(telefones));
        }
 public IActionResult Edit(Telefones telefones)
 {
     if (ModelState.IsValid)
     {
         _contexto.Telefones.Update(telefones);
         _contexto.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(telefones));
     }
 }
Example #23
0
        // GET: Telefones/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Telefones telefones = db.Telefone.Find(id);

            if (telefones == null)
            {
                return(HttpNotFound());
            }
            return(View(telefones));
        }
Example #24
0
        private void ConsultaInsereClassificacao(Telefones telefones)
        {
            Classificacoes classificacaoAux = db.Classificacao.Where(x => x.IdClassificacao == telefones.IdClassificacaoFK).FirstOrDefault();

            if (classificacaoAux == null)
            {
                classificacaoAux = new Classificacoes();
                classificacaoAux.IdClassificacao   = telefones.IdClassificacaoFK;
                classificacaoAux.NomeClassificacao = telefones.IdClassificacaoFK == 1 ? "Casa" : telefones.IdClassificacaoFK == 2 ? "Trabalho" : "Outro";

                db.Classificacao.Add(classificacaoAux);
                db.SaveChanges();
            }
        }
Example #25
0
        public ActionResult Edit([Bind(Include = "IdTelefone,IdContato,NumeroTelefone,IdClassificacaoFK")] Telefones telefones)
        {
            if (ModelState.IsValid)
            {
                ConsultaInsereClassificacao(telefones);

                db.Entry(telefones).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Edit", "Contatos", new { id = telefones.IdContato, idTelefone = telefones.IdTelefone }));
            }

            ViewBag.IdClassificacaoFK = new SelectList(db.Classificacao, "IdClassificacao", "NomeClassificacao", telefones.IdClassificacaoFK);
            return(View(telefones));
        }
Example #26
0
        public TelefoneCadastroValidator(Telefones telefone)
        {
            var telefoneFormato = new TelefoneValidoSpecification();
            var celularFormato  = new CelularValidoSpecification();

            if (!telefoneFormato.IsSatisfiedBy(telefone))
            {
                telefone.validateResult.notifications.Add(new Notification(1, "O Telefone deve ter entre 10 e 11 caracteres.", DateTime.Now));
            }

            if (!celularFormato.IsSatisfiedBy(telefone))
            {
                telefone.validateResult.notifications.Add(new Notification(1, "O Telefone deve ter entre 10 e 11 caracteres.", DateTime.Now));
            }
        }
Example #27
0
        // GET: Contatos/Create
        public ActionResult Create(int?idTelefone, int?idEmail, int?idEndereco)
        {
            List <Telefones> listTelefonesSession = new List <Telefones>();
            List <Emails>    listEmailsSession    = new List <Emails>();
            string           enderecoLogradouro   = string.Empty;

            if (idTelefone != null)
            {
                listTelefonesSession = (List <Telefones>) this.Session["ListTelefones"] == null ? new List <Telefones>() : (List <Telefones>) this.Session["ListTelefones"];

                Telefones telefones = db.Telefone.Find(idTelefone);

                listTelefonesSession.Add(telefones);

                this.Session.Add("ListTelefones", listTelefonesSession);
            }

            if (idEmail != null)
            {
                listEmailsSession = (List <Emails>) this.Session["ListEmails"] == null ? new List <Emails>() : (List <Emails>) this.Session["ListEmails"];

                Emails emails = db.Email.Find(idEmail);

                listEmailsSession.Add(emails);

                this.Session.Add("ListEmails", listEmailsSession);
            }

            idEndereco = idEndereco == null ? (int?)this.Session["Endereco"] : idEndereco;

            if (idEndereco != null)
            {
                this.Session.Add("Endereco", idEndereco);

                Enderecos endereco = new Enderecos();
                endereco           = db.Endereco.Where(x => x.IdEndereco == idEndereco).FirstOrDefault();
                enderecoLogradouro = endereco.Logradouro;
            }

            listTelefonesSession = (List <Telefones>) this.Session["ListTelefones"] == null ? listTelefonesSession : (List <Telefones>) this.Session["ListTelefones"];
            listEmailsSession    = (List <Emails>) this.Session["ListEmails"] == null ? listEmailsSession : (List <Emails>) this.Session["ListEmails"];

            ViewBag.IdTelefone = new SelectList(listTelefonesSession, "IdTelefone", "NumeroTelefone");
            ViewBag.IdEmail    = new SelectList(listEmailsSession, "IdEmail", "Email");
            ViewBag.Logradouro = enderecoLogradouro;

            return(View());
        }
Example #28
0
        public bool AdicionarTelefone(Telefone telefone)
        {
            if (Telefones.Any(x => x.Equals(telefone)))
            {
                return(false);
            }

            if (telefone.TelefonePadrao)
            {
                MudarTelefonePadrao();
            }

            Telefones.Add(telefone);

            return(true);
        }
    protected void btnAtualizar_Click(object sender, EventArgs e)
    {
        Empresas id = (Empresas)Session["emp_empresa"];

        Telefones tel   = new Telefones();
        DataSet   dsTel = TelefonesDB.SelectTel(id.Emp_id);

        tel.Tel_ddd = Convert.ToString(dsTel.Tables[0].Rows[0]["tel_ddd"]);
        tel.Tel_num = Convert.ToString(dsTel.Tables[0].Rows[0]["tel_num"]);

        tel.Emp_id        = new Empresas();
        tel.Emp_id.Emp_id = Convert.ToInt32(dsTel.Tables[0].Rows[0]["emp_id"]);


        DataSet ds = EmpresasDB.SelectID(id.Emp_id);

        tel.Emp_id.Emp_nome_fantasia   = Convert.ToString(ds.Tables[0].Rows[0]["emp_nome_fantasia"]);
        tel.Emp_id.Emp_senha           = Convert.ToString(ds.Tables[0].Rows[0]["emp_senha"]);
        tel.Emp_id.Emp_email           = Convert.ToString(ds.Tables[0].Rows[0]["emp_email"]);
        tel.Emp_id.Emp_razao_social    = Convert.ToString(ds.Tables[0].Rows[0]["emp_razao_social"]);
        tel.Emp_id.Emp_cnpj            = Convert.ToString(ds.Tables[0].Rows[0]["emp_cnpj"]);
        tel.Emp_id.Emp_foto_url        = Convert.ToString(ds.Tables[0].Rows[0]["emp_foto_url"]);
        tel.Emp_id.Emp_numero_endereco = Convert.ToString(ds.Tables[0].Rows[0]["emp_numero_endereco"]);


        tel.Tel_ddd = textDDD.Text;
        tel.Tel_num = textTelefone.Text;
        tel.Emp_id.Emp_nome_fantasia = textNomeFantasia.Text;
        tel.Emp_id.Emp_email         = textEmail2.Text;
        tel.Emp_id.Emp_razao_social  = textSocial.Text;
        tel.Emp_id.Emp_cnpj          = textCNPJ.Text;


        switch (EmpresasDB.Update(tel.Emp_id) & TelefonesDB.Update(tel))
        {
        case 0:
            ltl.Text = "<p class='text-success'>atualizado com sucesso </p>";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#myModal').modal('show');</script>", false);

            break;

        case -2:
            ltl.Text = "<p class='text-success'>Erro no cadastro</p>";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#myModal').modal('show');</script>", false);
            break;
        }
    }
 public Pessoa(int id, string nomeCompleto, int cpf, int sus, int idade, int rg, Filiacao filiacao, Genero genero, DateTime dataNascimento, Local local, TipoSanguineo tipoSanguineo, Telefones telefones, float altura, int peso, string observacao)
 {
     this.id             = id;
     this.nomeCompleto   = nomeCompleto;
     this.cpf            = cpf;
     this.sus            = sus;
     this.idade          = idade;
     this.rg             = rg;
     this.filiacao       = filiacao;
     this.genero         = genero;
     this.dataNascimento = dataNascimento;
     this.local          = local;
     this.tipoSanguineo  = tipoSanguineo;
     this.telefones      = telefones;
     this.altura         = altura;
     this.peso           = peso;
     this.observacao     = observacao;
 }
Example #31
0
        public ActionResult Create([Bind(Include = "IdTelefone,IdContato,NumeroTelefone,IdClassificacaoFK")] Telefones telefones, string ed)
        {
            if (ModelState.IsValid)
            {
                ConsultaInsereClassificacao(telefones);

                telefones.IdContato = string.IsNullOrEmpty(ed) ? null : (int?)this.Session["IdContatoEditTel"];
                db.Telefone.Add(telefones);
                db.SaveChanges();

                string pagina = string.IsNullOrEmpty(ed) ? "Create" : "Edit";

                return(RedirectToAction(pagina, "Contatos", new { id = telefones.IdContato, idTelefone = telefones.IdTelefone }));
            }

            ViewBag.IdClassificacaoFK = new SelectList(db.Classificacao, "IdClassificacao", "NomeClassificacao", telefones.IdClassificacaoFK);
            return(View(telefones));
        }
        public static AspNetUsers ViewModelEditToEntity(UsuarioViewModelEdit user)
        {
            var _user = new AspNetUsers()
            {
                Id       = user.Id,
                UserName = user.UserName,
                Email    = user.Email
            };
            var _usuario = new Usuario()
            {
                IdUser = user.Id,
            };

            var id        = Convert.ToInt32(user.Id);
            var _telefone = new Telefones(id, user.Telefone, user.Celular);

            _usuario.Telefones.Add(_telefone);
            _user.Usuario.Add(_usuario);

            return(_user);
        }
Example #33
0
        public ActionResult Remove(Telefones objeto)
        {
            Telefones.TransactionInstance.Remove(objeto);

            return RedirectToAction("Index", new { displayMessage = MENSAGEM_EXCLUSAO });
        }