예제 #1
0
 /**
  * <summary>
  * grava o valor de uma chave no registro do windows.
  * <para>
  * <paramref name="ListaCamposValores"/> - Contém um conjunto de chaves e valores que serão gravados no registro do windwos.
  * </para>
  * </summary>
  */
 public bool Gravar_ConteudoCampo(TipoChave TipoChave, string Chave, ref List <KeyValuePair <string, string> > ChavesAndValores)
 {
     try
     {
         if (TipoChave == TipoChave.LocalMachine)
         {
             RegistryKey CORAC = LocalMachine.OpenSubKey(Chave, true);
             foreach (KeyValuePair <string, string> Chaves in ChavesAndValores)
             {
                 CORAC.SetValue(Chaves.Key, Chaves.Value);
             }
             ChavesAndValores.Clear();
             return(true);
         }
         else
         {
             RegistryKey CORAC = Corrente_User.OpenSubKey(Chave, true);
             foreach (KeyValuePair <string, string> Chaves in ChavesAndValores)
             {
                 CORAC.SetValue(Chaves.Key, Chaves.Value);
             }
             ChavesAndValores.Clear();
             return(true);
         }
     }
     catch (Exception e)
     {
         TratadorErros(e, GetType().Name);
         return(false);
     }
 }
        public ActionResult Delete(string tipo, FormCollection collection)
        {
            TipoChave tipoChave = db.TipoChave.Find(tipo);

            db.TipoChave.Remove(tipoChave);
            db.SaveChanges();
            TempData["success"] = "Registro excluído com sucesso";
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "tipo, descricao, inativo")] TipoChave tipoChave)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tipoChave).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         TempData["success"] = "Registro editado com sucesso";
         return(RedirectToAction("Index"));
     }
     return(View());
 }
 public ActionResult Create([Bind(Include = "tipo, descricao, inativo")] TipoChave tipoChave)
 {
     if (ModelState.IsValid)
     {
         db.TipoChave.Add(tipoChave);
         db.SaveChanges();
         TempData["success"] = "Registro criado com sucesso";
         return(RedirectToAction("Index"));
     }
     return(View(tipoChave));
 }
예제 #5
0
        public int BuscaSeq(Lista l, TipoChave ch)
        {
            int i = 0;

            while (i < l.nroElem)
            {
                if (ch == l.A[i].chave)
                {
                    return(i);
                }
                i++;
            }
            return(-1);
        }
        // GET: TipoChave/Delete/5
        public ActionResult Delete(string tipo)
        {
            if (tipo == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TipoChave tipoChave = db.TipoChave.Find(tipo);

            if (tipoChave == null)
            {
                return(HttpNotFound());
            }
            return(View(tipoChave));
        }
예제 #7
0
        public int BuscaSeqSent(Lista l, TipoChave ch)
        {
            int i = 0;

            l.A[l.nroElem].chave = ch + 1;
            while (l.A[i].chave < ch)
            {
                i++;
            }

            if (i == l.nroElem || l.A[i].chave != ch)
            {
                return(-1);
            }
            else
            {
                return(i);
            }
        }
예제 #8
0
		/// <summary>
		/// Procura os dados desejados e mostra janela de resultados.
		/// </summary>
		/// <param name="tipo">Tipo de chave.</param>
		/// <param name="chave">Texto chave.</param>
		/// <returns>Pessoa escolhida ou nulo.</returns>
		private static Entidades.Pessoa.Pessoa Procurar(IWin32Window owner, TipoChave tipo, string chave)
		{
			List<Entidades.Pessoa.Pessoa> pessoas;

            using (Apresentação.Formulários.Aguarde aguarde =
                       new Apresentação.Formulários.Aguarde(
                       "Procurando no banco de dados.",
                       1,
                       "Procurando pessoas",
                       "Aguarde enquanto o sistema procura no banco de dados pelos dados fornecidos."))
            {
                aguarde.Abrir();

                switch (tipo)
                {
                    case TipoChave.Código:
                        ulong código = 0;
                        bool erro = false;

                        try
                        {
                            código = ulong.Parse(chave);
                        }
                        catch
                        {
                            erro = true;
                        }

                        if (erro)
                            pessoas = new List<Entidades.Pessoa.Pessoa> { };
                        else
                            pessoas = new List<Entidades.Pessoa.Pessoa> { Entidades.Pessoa.Pessoa.ObterPessoa(código) };
                        break;

                    case TipoChave.Nome:
                        pessoas = BuscaTextual.ObterPessoas(chave);
                        break;

                    case TipoChave.CPF:
                        pessoas = new List<Entidades.Pessoa.Pessoa>() { PessoaFísica.ObterPessoaPorCPF(chave) };
                        break;

                    case TipoChave.RG:
                        pessoas = PessoaFísica.ObterPessoasPorRG(chave);
                        break;

                    case TipoChave.CNPJ:
                        pessoas = PessoaJurídica.ObterPessoasPorCNPJ(chave);
                        break;

                    case TipoChave.Telefone:
                        pessoas = Entidades.Pessoa.Pessoa.ObterPessoasPorTelefone(chave);
                        break;

                    case TipoChave.Cidade:
                        pessoas = Entidades.Pessoa.Pessoa.ObterPessoasPorCidade(Localidade.ObterLocalidades(chave.Trim()));
                        break;

                    case TipoChave.Estado:
                        pessoas = Entidades.Pessoa.Pessoa.ObterPessoasPorEstado(Estado.ObterEstados(chave));
                        break;

                    default:
                        throw new NotSupportedException("Chave não suportada: " + Enum.GetName(typeof(TipoChave), tipo));
                }

                if (pessoas.Count == 0)
                {
                    aguarde.Close();
                    
                    const string msg = "Nenhuma pessoa foi encontrada com os dados fornecidos. ";
                    const string título = "Pesquisa de pessoa";

                    if (owner != null)
                        MessageBox.Show(
                            owner,
                            msg,
                            título,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation);
                    else
                        MessageBox.Show(
                            msg,
                            título,
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Exclamation);

                    return null;
                }
                else if (pessoas.Count == 1)
                    return pessoas[0];
                else
                {
                    aguarde.Passo("Preparando resultado.");

                    using (ProcurarPessoaResultados dlg = new ProcurarPessoaResultados(pessoas))
                    {
                        aguarde.Close();

                        if (dlg.ShowDialog(owner) == DialogResult.OK)
                        {
                            if (dlg.PessoaSelecionada is PessoaFísica)
                            {
                                Entidades.Pessoa.Pessoa pessoa;

                                Apresentação.Formulários.AguardeDB.Mostrar();

                                pessoa = Entidades.Pessoa.Pessoa.ObterPessoa(dlg.PessoaSelecionada.Código);

                                Apresentação.Formulários.AguardeDB.Fechar();

                                return pessoa;
                            }
                            else
                            {
                                return dlg.PessoaSelecionada;
                            }

                        }
                    }
                }
            }

			return null;
		}