예제 #1
0
        public static void SalvarFilial(Filial filial)
        {
            SqlConnection  conexao = null;
            SqlTransaction tx      = null;

            try
            {
                conexao = FabricaConexao.GetConnection();
                tx      = conexao.BeginTransaction();

                FilialDAO filialDAO = new FilialDAO(conexao, tx);
                filialDAO.salvarFilial(filial);
                filialDAO.salvarFilialBarbearia(filial);

                TelefoneDAO telefoneDAO = new TelefoneDAO(conexao, tx);
                telefoneDAO.salvarTelefone(filial.Telefone);
                filialDAO.salvarFilialTelefone(filial);

                tx.Commit();
            }
            catch (Exception ex)
            {
                tx.Rollback();
                throw ex;
            }
            finally
            {
                FabricaConexao.CloseConnection(conexao);
            }
        }
        public ActionResult ListarTelefone()
        {
            TelefoneDAO      dao       = new TelefoneDAO();
            IList <Telefone> telefones = dao.Lista();

            return(View(telefones));
        }
예제 #3
0
        internal static void AtualizarFilial(Filial filial)
        {
            SqlConnection  conexao = null;
            SqlTransaction tx      = null;

            try
            {
                conexao = FabricaConexao.GetConnection();
                tx      = conexao.BeginTransaction();

                FilialDAO filialDAO = new FilialDAO(conexao, tx);
                filialDAO.atualizarFilial(filial);

                BarbeariaDAO barbeariaDAO = new BarbeariaDAO(conexao, tx);
                barbeariaDAO.atualizarBarbeariaDaFilial(filial);

                TelefoneDAO telefoneDAO = new TelefoneDAO(conexao, tx);
                telefoneDAO.atualizarTelefoneDaFilial(filial);

                tx.Commit();
            }
            catch (Exception ex)
            {
                tx.Rollback();
                throw ex;
            }
            finally
            {
                FabricaConexao.CloseConnection(conexao);
            }
        }
 public ActionResult CadastrarTelefone(Telefone telefone)
 {
     if (TelefoneDAO.CadastrarTelefone(telefone))
     {
         return(RedirectToAction("Index", "Telefone"));
     }
     ModelState.AddModelError("", "Erro ao cadastrar telefone!");
     return(View(telefone));
 }
        public ActionResult Adiciona(Telefone telefone)
        {
            if (ModelState.IsValid)
            {
                TelefoneDAO dao = new TelefoneDAO();
                dao.Adiciona(telefone);
            }

            return(RedirectToAction("Menu", "Telefone"));
        }
        public ActionResult GravarAlteracao(Telefone telefone)
        {
            TelefoneDAO dao          = new TelefoneDAO();
            Telefone    novoTelefone = dao.BuscaPorId(telefone.Id);

            novoTelefone.NomeContato = telefone.NomeContato;
            novoTelefone.NomeId      = telefone.NomeId;
            novoTelefone.Numero      = telefone.Numero;

            dao.Atualiza(novoTelefone);

            return(RedirectToAction("Menu", "Telefone"));
        }
        public ActionResult AlterarTelefone(int id)
        {
            using (var contexto = new AgendaContext())
            {
                TelefoneDAO dao = new TelefoneDAO();
                ViewBag.Telefone = dao.BuscaPorId(id);

                NomeDAO      nomeDao = new NomeDAO();
                IList <Nome> nomes   = nomeDao.Lista();
                ViewBag.Nomes = nomes;
            }

            return(View());
        }
예제 #8
0
        public bool Excluir(Funcionario fun)
        {
            EnderecoDAO endDAO = new EnderecoDAO();

            endDAO.Excluir(fun.Id);

            TelefoneDAO telDAO = new TelefoneDAO();

            telDAO.Excluir(fun.Id);

            FuncionarioDAO funDAO = new FuncionarioDAO();

            funDAO.Excluir(fun.Id);

            return(true);
        }
        public ActionResult AlterarTelefone(Telefone telefoneAlterado)
        {
            Telefone telefoneOriginal = TelefoneDAO.BuscarTelefonePorID(telefoneAlterado.IdTelefone);

            telefoneOriginal.Tipo   = telefoneAlterado.Tipo;
            telefoneOriginal.Numero = telefoneAlterado.Numero;

            if (TelefoneDAO.AlterarTelefone(telefoneOriginal))
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Erro ao alterar telefone!");
                return(View(telefoneOriginal));
            }
        }
예제 #10
0
        public bool Gravar(Responsavel resp, Aluno alu, Telefone telObrigatorio, Telefone telOpcional, Telefone telTrabalho)
        {
            ResponsavelDAO respDAO = new ResponsavelDAO();
            TelefoneDAO    telDAO  = new TelefoneDAO();

            if (resp.Id == 0)
            {
                respDAO.Inserir(resp, alu);

                telObrigatorio.Pessoa = resp;
                telDAO.Inserir(telObrigatorio);

                telOpcional.Pessoa = resp;
                telDAO.Inserir(telOpcional);

                telTrabalho.Pessoa = resp;
                telDAO.Inserir(telTrabalho);
            }


            return(true);
        }
예제 #11
0
        public bool Gravar(Funcionario fun, Telefone telefone1, Telefone telefone2)
        {
            FuncionarioDAO funDAO = new FuncionarioDAO();
            TelefoneDAO    telDAO = new TelefoneDAO();

            if (fun.Id == 0)
            {
                funDAO.Inserir(fun);
                telefone1.Pessoa = fun;
                telDAO.Inserir(telefone1);
                telefone2.Pessoa = fun;
                telDAO.Inserir(telefone2);
            }
            else
            {
                funDAO.Alterar(fun);
                telefone1.Pessoa = fun;
                telDAO.Alterar(telefone1);
                telefone2.Pessoa = fun;
                telDAO.Alterar(telefone2);
            }

            return(true);
        }
 public ActionResult AlterarTelefone(int id)
 {
     return(View(TelefoneDAO.BuscarTelefonePorID(id)));
 }
 public ActionResult RemoverTelefone(int id)
 {
     TelefoneDAO.ExcluirTelefone(TelefoneDAO.BuscarTelefonePorID(id));
     return(RedirectToAction("Index", "Telefone"));
 }
 // GET: Telefone
 public ActionResult Index()
 {
     ViewBag.Data = DateTime.Now;
     return(View(TelefoneDAO.ListarTodos()));
 }