Ejemplo n.º 1
0
        private void ExecuteCommandGetCPF(object obj)
        {
            try
            {
                if (Viabilidade.Requerente.Inscricao == string.Empty)
                {
                    return;
                }

                string identificador = new mMascaras().Remove(Viabilidade.Requerente.Inscricao);

                Requerente.Clear();

                switch (identificador.Length)
                {
                case 11:
                    ClientePF(new mData().ExistPessoaFisica(identificador));
                    break;

                case 14:
                    ClientePJ(new mData().ExistPessoaJuridica(identificador));
                    break;
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
        }
Ejemplo n.º 2
0
        public AppResultado CadastrarRequerente(RequerenteDTO req)
        {
            var res = new AppResultado();

            try
            {
                var r = new Requerente
                {
                    IdRequerente        = Guid.NewGuid(),
                    IdMunicipio         = req.IdMunicipio,
                    Nome                = req.Nome,
                    PessoaContacto      = req.PessoaDeContacto,
                    TelefoneAlternativo = req.TelefoneAlternativo,
                    TelefonePrimario    = req.TelefonePrimario,
                    Email               = req.Email,
                    ObjetoSocial        = req.ObjetoSocial,
                    CNES                = req.CNES,
                    IBGE                = req.IBGE,
                    UF = req.UF
                };

                db.Requerente.Add(r);
                db.SaveChanges();

                res.Good("Cadastro realizado com sucesso.");
            }
            catch (Exception)
            {
                res.Bad("Erro ao cadastrar requerente.");
            }


            return(res);
        }
        public async Task <IActionResult> PutRequerente(int id, Requerente requerente)
        {
            if (id != requerente.Id)
            {
                return(BadRequest());
            }

            _context.Entry(requerente).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RequerenteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
 public void Clear()
 {
     Indice    = 0;
     Protocolo = string.Empty;
     Requerente.Clear();
     Logradouro     = string.Empty;
     Numero         = string.Empty;
     Complemento    = string.Empty;
     CEP            = string.Empty;
     Bairro         = string.Empty;
     Municipio      = string.Empty;
     UF             = string.Empty;
     CTM            = string.Empty;
     Atividades     = string.Empty;
     Data           = DateTime.Now;
     DataParecer    = DateTime.Now;
     DataRetorno    = DateTime.Now;
     RetornoCliente = false;
     Perecer        = 0;
     TextoEmail     = string.Empty;
     SendMail       = false;
     Motivo         = string.Empty;
     Operador       = string.Empty;
     SemRetorno     = false;
     Ativo          = true;
 }
        public async Task <ActionResult <Requerente> > PostRequerente(Requerente requerente)
        {
            _context.Requerente.Add(requerente);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRequerente", new { id = requerente.Id }, requerente));
        }
Ejemplo n.º 6
0
 private void NovaViabilidade()
 {
     Viabilidade.Data  = DateTime.Now;
     EstudoViabilidade = Protocolo();
     Viabilidade.Clear();
     GetCNAE = string.Empty;
     ListaAtividades.Clear();
     Requerente.Clear();
     Viabilidade.Operador = Account.Logged.Identificador;
 }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("ID,Nome,Telemovel,Email,Responsavel")] Requerente requerente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(requerente);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, Id = requerente.ID }));
            }
            return(PartialView("PartialViews/_CreateForm", requerente));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Delete(string id)
        {
            Requerente requerente = null;

            try
            {
                requerente = await _context.Requerentes.Include(s => s.Servicos).Where(s => s.ID.Equals(id)).FirstOrDefaultAsync();
            }
            catch (Exception e)
            {
                await _logger.LogError(
                    descricao : "Erro ao encontrar Requerente.",
                    classe : "RequerentesController",
                    metodo : "Delete",
                    erro : e.Message
                    );

                return(Json(new { success = false }));
            }

            try
            {
                // Apenas deixa apagar o serviço caso este não tenha galerias associadas
                if (requerente != null && requerente.Servicos.Count() == 0)
                {
                    _context.Remove(requerente);
                    await _context.SaveChangesAsync();
                }
                else
                {
                    return(Json(new { success = false, hasServicos = true }));
                }
            }
            catch (Exception e)
            {
                await _logger.LogError(
                    descricao : "Erro ao eliminar o Requerente.",
                    classe : "RequerentesController",
                    metodo : "Delete",
                    erro : e.Message
                    );

                return(Json(new { success = false }));
            }

            // Feeback ao utilizador - Vai ser redirecionado para o Index
            TempData["Feedback"] = "Requerente removido com sucesso.";
            return(Json(new { success = true }));
        }
Ejemplo n.º 9
0
    protected void btnSalvar_Click(object sender, EventArgs e)
    {
        FunMod funCod = (FunMod)Session["funcionario"];

        string setor = funCod.Funcionario.Setor.Set_nome;

        Processo           pro = new Processo();
        Requerente         req = new Requerente();
        Status             sta = new Status();
        ModeloRequerimento mrq = new ModeloRequerimento();

        if (dpRequerimento.SelectedIndex != 0 && ddlRequerente.SelectedIndex != 0)
        {
            pro.Pro_numeroProcesso         = txbNumero.Text;
            pro.Pro_dataPedido             = txbDataPedido.Text;
            pro.Cod_fun                    = funCod.Funcionario.Pessoa.Pes_cod;
            pro.Pro_ativo                  = "Ativo";
            pro.Requerente                 = req;
            pro.Status                     = sta;
            pro.ModeloRequerimento         = mrq;
            pro.ModeloRequerimento.Mrq_cod = Convert.ToInt32(dpRequerimento.SelectedValue);
            pro.Requerente.Req_cod         = Convert.ToInt32(ddlRequerente.SelectedValue);
            pro.Status.Sta_cod             = 3;

            string retorno = ProcessoDB.Insert(pro, setor);

            if (retorno != "Erro ao chamar procedure")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>sucess();</script>", false);
                CarregaNumProcesso();
                dpRequerimento.SelectedIndex = 0;
                ddlRequerente.SelectedIndex  = 0;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>error();</script>", false);
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>warning();</script>", false);
        }
    }
Ejemplo n.º 10
0
    public static Requerente Select(int req_cod)
    {
        Requerente req = null;

        try
        {
            IDbConnection objConexao;
            IDbCommand    objComando;
            IDataReader   objReader;
            objConexao = Mapped.Connection();

            string sql = "select * from req_requerente where req_cod = ?req_cod;";

            objComando = Mapped.Command(sql, objConexao);
            objComando.Parameters.Add(Mapped.Parameter("?req_cod", req_cod));
            objReader = objComando.ExecuteReader();

            int pessoa = 0;


            while (objReader.Read())
            {
                req         = new Requerente();
                req.Req_cod = Convert.ToInt32(objReader["req_cod"]);


                pessoa = Convert.ToInt32(objReader["pes_cod"]);
            }

            objConexao.Close();
            objComando.Dispose();
            objConexao.Dispose();
            req.Pessoa = PessoaDB.Select(pessoa);


            return(req);
        }
        catch
        {
            return(req = null);
        }
    }
Ejemplo n.º 11
0
        private void ClientePJ(mPJ_Ext obj)
        {
            try
            {
                string identificador = new mMascaras().Remove(Viabilidade.Requerente.Inscricao);


                if (obj == null)
                {
                    if (MessageBox.Show("CLIENTE " + Viabilidade.Requerente.Inscricao + " não encontrado! Cadastrá-lo agora?", "Sim.Alerta!", MessageBoxButton.YesNo, MessageBoxImage.Asterisk) == MessageBoxResult.Yes)
                    {
                        //NavigationCommands.GoToPage.Execute(new Uri("pAddPJe.xaml", UriKind.RelativeOrAbsolute), null);
                        GlobalNavigation.Navegar = new Uri("/Sim.Sec.Desenvolvimento;component/Shared/View/Empresa/pView.xaml", UriKind.Relative);
                        AreaTransferencia.CNPJ   = Viabilidade.Requerente.Inscricao;
                    }

                    return;
                }

                Requerente.Add(new mCliente()
                {
                    Inscricao = new mMascaras().CNPJ(obj.CNPJ),
                    NomeRazao = obj.RazaoSocial,
                    Telefones = obj.Telefones,
                    Email     = obj.Email
                });

                Viabilidade.Requerente.Inscricao = new mMascaras().CNPJ(obj.CNPJ);
                Viabilidade.Requerente.NomeRazao = obj.RazaoSocial;
                Viabilidade.Requerente.Telefones = obj.Telefones;
                Viabilidade.Requerente.Email     = obj.Email;

                //Corpo = Visibility.Visible;
                //Cabecalho = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 12
0
        private void ClientePF(mPF_Ext obj)
        {
            try
            {
                string identificador = new mMascaras().Remove(Viabilidade.Requerente.Inscricao);


                if (obj == null)
                {
                    if (MessageBox.Show("CLIENTE " + Viabilidade.Requerente.Inscricao + " não encontrado! Cadastrá-lo agora?", "Sim.Alerta!", MessageBoxButton.YesNo, MessageBoxImage.Asterisk) == MessageBoxResult.Yes)
                    {
                        GlobalNavigation.Navegar = new Uri("/Sim.Modulo.Empreendedor;component/View/pAddPF.xaml", UriKind.Relative);
                        //NavigationCommands.GoToPage.Execute(new Uri("/Sim.Modulo.Empreendedor;component/View/pAddPFe.xaml", UriKind.Relative), null);
                        AreaTransferencia.CPF = Viabilidade.Requerente.Inscricao;
                    }

                    return;
                }

                Requerente.Add(new mCliente()
                {
                    Inscricao = new mMascaras().CPF(obj.CPF),
                    NomeRazao = obj.Nome,
                    Telefones = obj.Telefones,
                    Email     = obj.Email
                });

                Viabilidade.Requerente.Inscricao = new mMascaras().CPF(obj.CPF);
                Viabilidade.Requerente.NomeRazao = obj.Nome;
                Viabilidade.Requerente.Telefones = obj.Telefones;
                Viabilidade.Requerente.Email     = obj.Email;

                //Corpo = Visibility.Visible;
                //Cabecalho = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> Edit(string id, [Bind("ID,Nome,Telemovel,Email,Responsavel")] Requerente requerente)
        {
            if (!id.Equals(requerente.ID))
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(requerente);
                    await _context.SaveChangesAsync();

                    return(Json(new { success = true }));
                }
                catch (DbUpdateConcurrencyException e)
                {
                    if (!RequerentesExists(requerente.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        await _logger.LogError(
                            descricao : "Erro ao guardar na BD.",
                            classe : "RequerentesController",
                            metodo : "Edit",
                            erro : e.Message
                            );
                    }
                }
            }

            return(PartialView("PartialViews/_EditForm", requerente));
        }
Ejemplo n.º 14
0
    protected void btnSalvarJur_ServerClick(object sender, EventArgs e)
    {
        FunMod funCod = (FunMod)Session["funcionario"];

        if (txbNomeJur.Text != "" && txbDataNascJur.Text != "" && txbSiglaJur.Text != "" && txbRazaoSocialJur.Text != "" && txbCnpjJur.Text != "" && ddlEstadoJur.SelectedIndex != 0 && txbCepJur.Text != "" && txbCidadeJur.Text != "" && txbBairroJur.Text != "" && txbRuaJur.Text != "" && txbNumeroJur.Text != "" && txbComplementoJur.Text != "")
        {
            string[] listaContato = Request.Form.GetValues("lbTabelaJur");


            if (listaContato != null)
            {
                Requerente req = new Requerente();
                Pessoa     pes = new Pessoa();
                req.Pessoa = pes;

                req.Pessoa.Cod_fun            = funCod.Funcionario.Pessoa.Pes_cod;
                req.Cod_fun                   = funCod.Funcionario.Pessoa.Pes_cod;
                req.Pessoa.Pes_tipo           = "Juridica";
                req.Pessoa.Pes_ativo          = "Ativo";
                req.Pessoa.Pes_nome           = txbNomeJur.Text;
                req.Pessoa.Pes_sobrenome      = null;
                req.Pessoa.Pes_razaoSocial    = txbRazaoSocialJur.Text;
                req.Pessoa.Pes_dataNascimento = txbDataNascJur.Text;
                req.Pessoa.Pes_sexo           = null;
                req.Pessoa.Pes_cnpj           = txbCnpjJur.Text;
                req.Pessoa.Pes_sigla          = txbSiglaJur.Text;

                string contatos = "";
                for (int i = 0; i < listaContato.Length; i++)
                {
                    contatos += "(0, '" + listaContato[i].Split('|')[0] + "', '" + listaContato[i].Split('|')[1] + "', 'pes_con', " + funCod.Funcionario.Pessoa.Pes_cod + "),";
                }
                contatos = contatos.Substring(0, contatos.Length - 1);

                req.Pessoa.Pes_cep         = txbCepJur.Text;
                req.Pessoa.Pes_estado      = ddlEstadoJur.SelectedValue;
                req.Pessoa.Pes_cidade      = txbCidadeJur.Text;
                req.Pessoa.Pes_bairro      = txbBairroJur.Text;
                req.Pessoa.Pes_rua         = txbRuaJur.Text;
                req.Pessoa.Pes_numero      = txbNumeroJur.Text;
                req.Pessoa.Pes_complemento = txbComplementoJur.Text;

                string retorno = RequerenteDB.Insert(req, contatos);

                if (retorno != "Erro ao chamar procedure")
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>sucess();</script>", false);
                    txbNomeJur.Text                 = "";
                    txbDataNascJur.Text             = "";
                    txbSiglaJur.Text                = "";
                    txbRazaoSocialJur.Text          = "";
                    txbCnpjJur.Text                 = "";
                    ddlTipoContatoJur.SelectedIndex = 0;
                    txbCepJur.Text             = "";
                    ddlEstadoJur.SelectedIndex = 0;
                    txbCidadeJur.Text          = "";
                    txbBairroJur.Text          = "";
                    txbRuaJur.Text             = "";
                    txbNumeroJur.Text          = "";
                    txbComplementoJur.Text     = "";
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>error();</script>", false);
                    ddlTipoContatoJur.SelectedIndex = 0;
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>warning1();</script>", false);
                ddlTipoContatoJur.SelectedIndex = 0;
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>warning();</script>", false);
            ddlTipoContatoJur.SelectedIndex = 0;
        }
    }
Ejemplo n.º 15
0
    public static string Insert(Requerente req, string listaContato)
    {
        string retorno = ""; // 0 = OK / -2 = Erro

        try
        {
            IDbConnection objConexao;
            IDbCommand    objCommand;

            string sql = "call CadastroRequerente(?pes_nome, ?pes_sobrenome, ?pes_dataNascimento, ?pes_rua, ?pes_numero, ?pes_complemento, ?pes_bairro, ?pes_cep, " +
                         "?pes_cidade, ?pes_estado, ?pes_rg, ?pes_cpf, ?pes_sexo, ?pes_cnpj, ?pes_sigla, ?pes_razaoSocial, ?pes_tipo, ?pes_ativo, ?pes_fun, ?req_fun, ?listaContato); ";

            objConexao = Mapped.Connection();
            objCommand = Mapped.Command(sql, objConexao);
            objCommand.Parameters.Add(Mapped.Parameter("?pes_nome", req.Pessoa.Pes_nome));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_sobrenome", req.Pessoa.Pes_sobrenome));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_dataNascimento", req.Pessoa.Pes_dataNascimento));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_rua", req.Pessoa.Pes_rua));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_numero", req.Pessoa.Pes_numero));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_complemento", req.Pessoa.Pes_complemento));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_bairro", req.Pessoa.Pes_bairro));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_cep", req.Pessoa.Pes_cep));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_cidade", req.Pessoa.Pes_cidade));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_estado", req.Pessoa.Pes_estado));
            if (req.Pessoa.Pes_rg != null)
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_rg", req.Pessoa.Pes_rg));
            }
            else
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_rg", null));
            }
            if (req.Pessoa.Pes_cpf != null)
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_cpf", req.Pessoa.Pes_cpf));
            }
            else
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_cpf", null));
            }
            objCommand.Parameters.Add(Mapped.Parameter("?pes_sexo", req.Pessoa.Pes_sexo));
            if (req.Pessoa.Pes_cnpj != null)
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_cnpj", req.Pessoa.Pes_cnpj));
            }
            else
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_cnpj", null));
            }
            if (req.Pessoa.Pes_sigla != null)
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_sigla", req.Pessoa.Pes_sigla));
            }
            else
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_sigla", null));
            }
            if (req.Pessoa.Pes_razaoSocial != null)
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_razaoSocial", req.Pessoa.Pes_razaoSocial));
            }
            else
            {
                objCommand.Parameters.Add(Mapped.Parameter("?pes_razaoSocial", null));
            }
            objCommand.Parameters.Add(Mapped.Parameter("?pes_tipo", req.Pessoa.Pes_tipo));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_ativo", req.Pessoa.Pes_ativo));
            objCommand.Parameters.Add(Mapped.Parameter("?pes_fun", req.Pessoa.Cod_fun));
            objCommand.Parameters.Add(Mapped.Parameter("?req_fun", req.Cod_fun));
            objCommand.Parameters.Add(Mapped.Parameter("?listaContato", listaContato));
            //objCommand.ExecuteNonQuery();
            retorno = objCommand.ExecuteScalar().ToString();
            objConexao.Close();
            objCommand.Dispose();
            objConexao.Dispose();
        }
        catch (Exception e)
        {
            retorno = "Erro ao chamar procedure";
        }
        return(retorno);
    }