public static Candidato_DTO AtribuirImagem(int chapa)
 {
     try
     {
         Candidato_DTO obj    = new Candidato_DTO();
         string        script = "SELECT foto, Apelido FROM Candidato_Eleicao WHERE chapa = @Chapa";
         SqlCommand    cmd    = new SqlCommand(script, Conexao_DAL.Conexao());
         cmd.Parameters.AddWithValue("@Chapa", chapa);
         SqlDataReader dados = cmd.ExecuteReader();
         while (dados.Read())
         {
             if (dados.HasRows)
             {
                 obj.Foto    = (Byte[])(dados["foto"]);
                 obj.Apelido = dados["Apelido"].ToString();
             }
         }
         return(obj);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         if (Conexao_DAL.Conexao().State != ConnectionState.Closed)
         {
             Conexao_DAL.Conexao().Close();
         }
     }
 }
Example #2
0
        public static Candidato_DTO BuscarCPF(string CPF)
        {
            Candidato_DTO obj = new Candidato_DTO();

            try
            {
                string     script = "SELECT id_eleitores, nome, turma_cargo, modulo FROM Eleitor WHERE cpf = @CPF";
                SqlCommand cmd    = new SqlCommand(script, Conexao_DAL.Conexao());
                cmd.Parameters.AddWithValue("@CPF", CPF);
                SqlDataReader dados = cmd.ExecuteReader();
                while (dados.Read())
                {
                    obj.IdCandidato = Convert.ToInt32(dados["id_eleitores"]);
                    obj.Nome        = dados["nome"].ToString();
                    obj.Turma       = dados["turma_cargo"].ToString();
                    obj.Modulo      = dados["modulo"].ToString();
                }
                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (Conexao_DAL.Conexao().State != ConnectionState.Closed)
                {
                    Conexao_DAL.Conexao().Close();
                }
            }
        }
        public static string ValidarCandidato(string CPF, string data, string chapa, byte[] foto, string apelido)
        {
            Candidato_DTO obj = new Candidato_DTO();

            if (string.IsNullOrWhiteSpace(CPF))
            {
                throw new Exception("Campo CPF vazio!");
            }

            if (string.IsNullOrWhiteSpace(chapa))
            {
                throw new Exception("Campo Chapa vazio!");
            }

            if (string.IsNullOrWhiteSpace(apelido))
            {
                throw new Exception("Campo Apelido vazio!");
            }

            try
            {
                DateTime valor = Convert.ToDateTime(data);
                obj = CadCandidato_DAL.BuscarCPF(CPF);
                int id_C = obj.IdCandidato;
                int id_E;
                CadCandidato_DAL.RetornaData(out id_E);
                return(CadCandidato_DAL.CadastrarCand(id_C, id_E, chapa, foto, apelido));
            }

            catch (Exception ex)
            {
                throw new Exception("erro aqui" + ex.Message);
            }
        }
        public static Candidato_DTO AtribuirImagem(int chapa)
        {
            Candidato_DTO obj = new Candidato_DTO();

            obj = ValidarVoto_DAL.AtribuirImagem(chapa);

            return(obj);
        }
Example #5
0
        public void AtribuirImagem()
        {
            Candidato_DTO obj = new Candidato_DTO();
            Image         img;

            obj = ValidarVoto_BLL.AtribuirImagem(chapa);
            txtCandidato.Text = obj.Apelido;
            MessageBox.Show(obj.Apelido);
            MemoryStream mStream = new MemoryStream(obj.Foto);

            img           = Image.FromStream(mStream);
            ptbFoto.Image = img;
        }
Example #6
0
 private void button6_Click(object sender, EventArgs e)
 {
     try
     {
         string cpf = maskedTextBox2.Text;
         obj                 = CadCandidato_BLL.ValidaCPF(cpf);
         textBox3.Text       = obj.Nome;
         textBox2.Text       = obj.Turma;
         maskedTextBox1.Text = obj.Modulo;
         button1.Enabled     = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public static Candidato_DTO ValidaCPF(string cpf)
        {
            Candidato_DTO obj = new Candidato_DTO();

            if (string.IsNullOrWhiteSpace(cpf))
            {
                throw new Exception("Campo CPF vazio!");
            }
            try
            {
                obj = CadCandidato_DAL.BuscarCPF(cpf);
                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #8
0
 private void btn3_Click(object sender, EventArgs e)
 {
     if (txtNumero1.Text.Length == 0)
     {
         txtNumero1.Text = "3";
         txtNumero2.Focus();
     }
     else
     {
         txtNumero2.Text = "3";
         chapa           = Convert.ToInt32(txtNumero1.Text + txtNumero2.Text);
         MessageBox.Show("chapa: " + chapa);
         Candidato_DTO obj = new Candidato_DTO();
         Image         img;
         obj = ValidarVoto_BLL.AtribuirImagem(chapa);
         txtCandidato.Text = obj.Apelido;
         MessageBox.Show("chapa: " + obj.Foto);
         MemoryStream mStream = new MemoryStream(obj.Foto);
         img = Image.FromStream(mStream);
         //ptbFoto.Image = Image.img;
     }
 }