예제 #1
0
        public bool AbreConexao()
        {
            try
            {
                conexao.Open();
                return(true);
            }
            catch (MySqlException ex)
            {
                {
                    switch (ex.ErrorCode)
                    {
                    case 0:
                        InformaDiag.Erro("Falha ao conectar no servidor de dados.");
                        break;

                    case 1045:
                        InformaDiag.Erro("A combinação de usuário e senha não existe. Tente novamente.");
                        break;

                    default:
                        InformaDiag.Erro("Erro" + ex.Code.ToString() + ex.Message);
                        break;
                    }
                }
                return(false);
            }
            catch (InvalidOperationException)
            {
                return(false);
            }
        }
예제 #2
0
        private void btnPesquisa_Click(object sender, EventArgs e)
        {
            string[] cs = txtCpf.Text.Split(".-".ToArray());
            string   c  = "";

            for (int i = 0; i < 4; i++)
            {
                c += cs[i];
            }
            regAtual = Servidor.ConverteObject(CRUD.SelecionarTabela("servidor", Servidor.Campos(), "CPF=" + c)).First();
            if (regAtual.Departamento == "")
            {
                InformaDiag.Erro("Nenhum registro encontrado!");
            }
            else
            {
                regAtual.p             = Pessoas_gen.ConverteObject(CRUD.SelecionarTabela("pessoa", Pessoas_gen.Campos(), "CPF=" + regAtual.p.cpf)).First();
                txtCpf.Text            = regAtual.p.cpf;
                txtNome.Text           = regAtual.p.nome;
                dtNascto.Value         = regAtual.p.dnasc;
                comboTipo.SelectedText = regAtual.p.tipoUsuario;
                comboSetor.Text        = regAtual.Departamento;
                novo = false;
            }
        }
예제 #3
0
 public bool FechaConexao()
 {
     try
     {
         conexao.Close();
         return(true);
     }
     catch (MySqlException ex)
     {
         InformaDiag.Erro(ex.Message);
         return(false);
     }
 }