private void CarregarDados()
        {
            ListaOcorrenciaTO listaOcorrenciaTO = new ListaOcorrenciaTO();

            listaOcorrenciaTO = OcorrenciaService.Listar();

            dgOcorrencia.DataSource = listaOcorrenciaTO.Lista;
            dgOcorrencia.Columns["Identificador"].Visible = false;
            dgOcorrencia.Columns["Valido"].Visible        = false;
            dgOcorrencia.Columns["Mensagem"].Visible      = false;
            dgOcorrencia.ReadOnly = true;

            ListaVisitanteTO listaVisitanteTO = new ListaVisitanteTO();

            listaVisitanteTO = VisitanteService.Listar();

            dgVisitantes.DataSource = listaVisitanteTO.Lista;
            dgVisitantes.Columns["Identificador"].Visible = false;
            dgVisitantes.Columns["Valido"].Visible        = false;
            dgVisitantes.Columns["Mensagem"].Visible      = false;
            dgVisitantes.ReadOnly = true;


            ListaDependenteTO listaDependentesTO = new ListaDependenteTO();

            listaDependentesTO = DependenteService.Listar();

            dgMorDependentes.DataSource = listaDependentesTO.Lista;
            dgMorDependentes.Columns["Identificador"].Visible = false;
            dgMorDependentes.Columns["Valido"].Visible        = false;
            dgMorDependentes.Columns["Mensagem"].Visible      = false;
            dgMorDependentes.ReadOnly = true;
        }
        private void btnSalvarDep_Click(object sender, EventArgs e)
        {
            string erro = String.Empty;

            if (!ValidarCampos(out erro))
            {
                MessageBox.Show(erro, "Atenção");
            }

            DependenteTO dependenteTO = new DependenteTO();

            dependenteTO.Nome           = txtNomeDep.Text;
            dependenteTO.RG             = txtRgDep.Text;
            dependenteTO.Telefone       = txtTelefoneDep.Text;
            dependenteTO.IdMorador      = Convert.ToInt32(txtMoradorResp);
            dependenteTO.GrauParentesco = Convert.ToString(cboGrauParentesco.Text);

            DependenteService.Criar(dependenteTO);

            if (!dependenteTO.Valido)
            {
                MessageBox.Show(dependenteTO.Mensagem, "Atenção");
                return;
            }

            this.Close();
        }
        private void CarregarDados()
        {
            ListaColaboradorTO listaColaboradorTO = new ListaColaboradorTO();

            listaColaboradorTO = ColaboradorService.Listar();

            dgPorteiroVisualizarColab.DataSource = listaColaboradorTO.Lista;
            dgPorteiroVisualizarColab.Columns["Identificador"].Visible = false;
            dgPorteiroVisualizarColab.Columns["Valido"].Visible        = false;
            dgPorteiroVisualizarColab.Columns["Mensagem"].Visible      = false;
            dgPorteiroVisualizarColab.ReadOnly = true;

            ListaDependenteTO listaDependenteTO = new ListaDependenteTO();

            listaDependenteTO = DependenteService.Listar();

            dgPorteiroDependentes.DataSource = listaDependenteTO.Lista;
            dgPorteiroDependentes.Columns["Identificador"].Visible = false;
            dgPorteiroDependentes.Columns["Valido"].Visible        = false;
            dgPorteiroDependentes.Columns["Mensagem"].Visible      = false;
            dgPorteiroDependentes.ReadOnly = true;

            ListaVisitanteTO listaVisitanteTO = new ListaVisitanteTO();

            listaVisitanteTO = VisitanteService.Listar();

            dgPorteiroVisualizarVisitante.DataSource = listaVisitanteTO.Lista;
            dgPorteiroVisualizarVisitante.Columns["Identificador"].Visible = false;
            dgPorteiroVisualizarVisitante.Columns["Valido"].Visible        = false;
            dgPorteiroVisualizarVisitante.Columns["Mensagem"].Visible      = false;
            dgPorteiroVisualizarVisitante.ReadOnly = true;
        }
        public ActionResult Details(int id)
        {
            _usuarioTO = (UsuarioTO)Session["UsuarioTO"];
            _moradorTO = (MoradorTO)Session["MoradorTO"];

            if (_usuarioTO != null)
            {
                _usuarioTO = (UsuarioTO)Session["UsuarioTO"];
                if (!_usuarioTO.Valido)
                {
                    return(RedirectToActionPermanent("Login", "Home"));
                }
            }
            else if (_moradorTO != null)
            {
                _moradorTO = (MoradorTO)Session["MoradorTO"];

                if (_moradorTO != null)
                {
                    _moradorTO = (MoradorTO)Session["MoradorTO"];
                    if (!_moradorTO.Valido)
                    {
                        return(RedirectToActionPermanent("Login", "Home"));
                    }
                }
            }
            else
            {
                return(RedirectToActionPermanent("Login", "Home"));
            }

            DependenteTO DependenteTO = new DependenteTO();

            try
            {
                DependenteTO = DependenteService.Obter(id);

                if (!DependenteTO.Valido)
                {
                    Session["Mensagem"] = DependenteTO.Mensagem;

                    return(RedirectToActionPermanent("Index"));
                }

                var DependenteVM = Mapper.Map <DependenteTO, DependenteVM>(DependenteTO);
                NomearVariaveis(DependenteVM, null);
                return(View(DependenteVM));
            }
            catch (Exception ex)
            {
                DependenteTO.Mensagem = $"Erro ao obter Dependente. Erro: {ex.Message}";
            }

            return(View());
        }
        public ActionResult Index()
        {
            _usuarioTO = (UsuarioTO)Session["UsuarioTO"];
            _moradorTO = (MoradorTO)Session["MoradorTO"];

            if (_usuarioTO != null)
            {
                _usuarioTO = (UsuarioTO)Session["UsuarioTO"];
                if (!_usuarioTO.Valido)
                {
                    return(RedirectToActionPermanent("Login", "Home"));
                }
            }
            else if (_moradorTO != null)
            {
                _moradorTO = (MoradorTO)Session["MoradorTO"];

                if (_moradorTO != null)
                {
                    _moradorTO = (MoradorTO)Session["MoradorTO"];
                    if (!_moradorTO.Valido)
                    {
                        return(RedirectToActionPermanent("Login", "Home"));
                    }
                }
            }
            else
            {
                return(RedirectToActionPermanent("Login", "Home"));
            }

            ListaDependenteTO listaDependente = new ListaDependenteTO();

            try
            {
                if (_moradorTO != null)
                {
                    listaDependente = DependenteService.ListarPorMorador(_moradorTO.Identificador);
                }
                else
                {
                    listaDependente = DependenteService.Listar();
                }

                var listaDependenteesVM = Mapper.Map <List <DependenteTO>, List <DependenteVM> >(listaDependente.Lista);
                NomearVariaveis(null, listaDependenteesVM);
                return(View(listaDependenteesVM));
            }
            catch (Exception ex)
            {
                listaDependente.Mensagem = $"Erro ao obter Dependentees. Erro: {ex.Message} ";
            }

            return(View());
        }
        public ActionResult Edit(int id)
        {
            _usuarioTO = (UsuarioTO)Session["UsuarioTO"];
            _moradorTO = (MoradorTO)Session["MoradorTO"];

            if (_usuarioTO != null)
            {
                _usuarioTO = (UsuarioTO)Session["UsuarioTO"];
                if (!_usuarioTO.Valido)
                {
                    return(RedirectToActionPermanent("Login", "Home"));
                }
                else if (_usuarioTO.IdGrupo == 3)
                {
                    return(RedirectToActionPermanent("Index"));
                }
            }
            else if (_moradorTO != null)
            {
                _moradorTO = (MoradorTO)Session["MoradorTO"];

                if (_moradorTO != null)
                {
                    _moradorTO = (MoradorTO)Session["MoradorTO"];
                    if (!_moradorTO.Valido)
                    {
                        return(RedirectToActionPermanent("Login", "Home"));
                    }
                }
            }
            else
            {
                return(RedirectToActionPermanent("Login", "Home"));
            }

            ViewBag.Morador = ListarMoradores();
            if (ModelState.IsValid)
            {
                var DependenteTO = DependenteService.Obter(id);

                if (!DependenteTO.Valido)
                {
                    Session["Mensagem"] = DependenteTO.Mensagem;
                    return(RedirectToAction("Index"));
                }

                var DependenteVM = Mapper.Map <DependenteTO, DependenteVM>(DependenteTO);
                NomearVariaveis(DependenteVM, null);
                return(View(DependenteVM));
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            if (ModelState.IsValid)
            {
                if (id > 0)
                {
                    var retorno = DependenteService.Remover(id);

                    Session["Mensagem"] = retorno.Mensagem;
                }
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Create(DependenteVM Dependente)
        {
            if (ModelState.IsValid)
            {
                var DependenteTO = Mapper.Map <DependenteVM, DependenteTO>(Dependente);

                DependenteService.Criar(DependenteTO);

                Session["Mensagem"] = DependenteTO.Mensagem;
                return(RedirectToAction("Index"));
            }

            return(View());
        }
Beispiel #9
0
        private void btnExcluirDependente_Click(object sender, EventArgs e)
        {
            int idDependente = Convert.ToInt32(lblExcluirCodigoDep.Text);

            RetornoTO retorno = new RetornoTO();

            retorno = DependenteService.Remover(idDependente);

            //Todo: Retornar mensagem se nao for valido
            if (!retorno.Valido)
            {
                MessageBox.Show(retorno.Mensagem);
            }

            this.Close();
        }
        public ActionResult Delete(int id)
        {
            _usuarioTO = (UsuarioTO)Session["UsuarioTO"];
            _moradorTO = (MoradorTO)Session["MoradorTO"];

            if (_usuarioTO != null)
            {
                _usuarioTO = (UsuarioTO)Session["UsuarioTO"];
                if (!_usuarioTO.Valido)
                {
                    return(RedirectToActionPermanent("Login", "Home"));
                }
                else if (_usuarioTO.IdGrupo == 3)
                {
                    return(RedirectToActionPermanent("Index"));
                }
            }
            else if (_moradorTO != null)
            {
                _moradorTO = (MoradorTO)Session["MoradorTO"];

                if (_moradorTO != null)
                {
                    _moradorTO = (MoradorTO)Session["MoradorTO"];
                    if (!_moradorTO.Valido)
                    {
                        return(RedirectToActionPermanent("Login", "Home"));
                    }
                }
            }
            else
            {
                return(RedirectToActionPermanent("Login", "Home"));
            }

            if (id > 0)
            {
                var DependenteTO = DependenteService.Obter(id);
                var DependenteVM = Mapper.Map <DependenteTO, DependenteVM>(DependenteTO);
                NomearVariaveis(DependenteVM, null);
                return(View(DependenteVM));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        private void btnSalvarEdicaoDep_Click(object sender, EventArgs e)
        {
            DependenteTO dependenteTO = new DependenteTO();

            dependenteTO.Nome          = txtEditarNomeDep.Text;
            dependenteTO.Identificador = Convert.ToInt32(lblEditarCodigoDep.Text);
            dependenteTO.RG            = txtEditarRgDep.Text;
            dependenteTO.Telefone      = txtEditarTelefoneDep.Text;
            dependenteTO.IdMorador     = Convert.ToInt32(txtEditarMoradorResp.Text);
            DependenteService.Atualizar(dependenteTO);

            if (!dependenteTO.Valido)
            {
                MessageBox.Show(dependenteTO.Mensagem);
            }

            this.Close();
        }
        private void PreencherCampos(int id)
        {
            DependenteTO dependenteTO = new DependenteTO();

            dependenteTO = DependenteService.Obter(id);

            if (!dependenteTO.Valido)
            {
                MessageBox.Show(dependenteTO.Mensagem, "Atenção");
                this.Close();
            }

            txtEditarNomeDep.Text                = dependenteTO.Nome;
            txtEditarRgDep.Text                  = dependenteTO.RG;
            txtEditarTelefoneDep.Text            = dependenteTO.Telefone;
            cboEditarGrauParentesco.SelectedItem = dependenteTO.GrauParentesco;
            txtEditarMoradorResp.Text            = Convert.ToString(dependenteTO.IdMorador);
            lblEditarCodigoDep.Text              = dependenteTO.Identificador.ToString();
        }
        public ActionResult Edit(DependenteVM DependenteVM)
        {
            if (ModelState.IsValid)
            {
                var DependenteTO = Mapper.Map <DependenteVM, DependenteTO>(DependenteVM);

                DependenteService.Atualizar(DependenteTO);

                if (!DependenteTO.Valido)
                {
                    Session["Mensagem"] = DependenteTO.Valido;
                    return(RedirectToAction("Index"));
                }

                DependenteVM = Mapper.Map <DependenteTO, DependenteVM>(DependenteTO);
            }

            return(RedirectToAction("Index"));
        }
Beispiel #14
0
        private void PreencherCampos(int id)
        {
            DependenteTO dependenteTO = new DependenteTO();

            dependenteTO = DependenteService.Obter(id);

            if (!dependenteTO.Valido)
            {
                //Todo: Exibir Mensagem e Fechar Form
                MessageBox.Show(dependenteTO.Mensagem);
                this.Close();
            }

            txtExcluirNomeDep.Text     = dependenteTO.Nome;
            txtExcluirRgDep.Text       = dependenteTO.RG;
            txtExcluirTelefoneDep.Text = dependenteTO.Telefone;
            txtExcluirGrauParent.Text  = dependenteTO.GrauParentesco;
            txtExcluirMoradorResp.Text = Convert.ToString(dependenteTO.IdMorador);
            lblExcluirCodigoDep.Text   = dependenteTO.Identificador.ToString();
        }
        private void CarregarDados()
        {
            ListaMoradorTO listaMoradoresTO = new ListaMoradorTO();

            listaMoradoresTO = MoradorService.Listar();

            dgMoradores.DataSource = listaMoradoresTO.Lista;
            dgMoradores.Columns["Identificador"].Visible = false;
            dgMoradores.Columns["Valido"].Visible        = false;
            dgMoradores.Columns["Mensagem"].Visible      = false;
            dgMoradores.ReadOnly = true;

            ListaContratoTO listaContratosTO = new ListaContratoTO();

            listaContratosTO = ContratoService.Listar();

            dgContratos.DataSource = listaContratosTO.Lista;
            dgContratos.Columns["Identificador"].Visible = false;
            dgContratos.Columns["Valido"].Visible        = false;
            dgContratos.Columns["Mensagem"].Visible      = false;
            dgContratos.ReadOnly = true;

            ListaDependenteTO listaDependentesTO = new ListaDependenteTO();

            listaDependentesTO = DependenteService.Listar();

            dgDependentes.DataSource = listaDependentesTO.Lista;
            dgDependentes.Columns["Identificador"].Visible = false;
            dgDependentes.Columns["Valido"].Visible        = false;
            dgDependentes.Columns["Mensagem"].Visible      = false;
            dgDependentes.ReadOnly = true;

            ListaEstacionamentoTO listaEstacionamentosTO = new ListaEstacionamentoTO();

            listaEstacionamentosTO = EstacionamentoService.Listar();

            ListaOcorrenciaTO listaOcorrenciasTO = new ListaOcorrenciaTO();

            listaOcorrenciasTO = OcorrenciaService.Listar();

            dgAdmOcorrencias.DataSource = listaOcorrenciasTO.Lista;
            dgAdmOcorrencias.Columns["Identificador"].Visible = false;
            dgAdmOcorrencias.Columns["Valido"].Visible        = false;
            dgAdmOcorrencias.Columns["Mensagem"].Visible      = false;
            dgAdmOcorrencias.ReadOnly = true;

            ListaReservaTO listaReservasTO = new ListaReservaTO();

            listaReservasTO = ReservaService.Listar();

            dgReservas.DataSource = listaReservasTO.Lista;
            dgReservas.Columns["Identificador"].Visible = false;
            dgReservas.Columns["Valido"].Visible        = false;
            dgReservas.Columns["Mensagem"].Visible      = false;
            dgReservas.ReadOnly = true;


            ListaAdvertenciaTO listaAdvertenciasTO = new ListaAdvertenciaTO();

            listaAdvertenciasTO = AdvertenciaService.Listar();
        }