Beispiel #1
0
        private void RestricaoRepresentante()
        {
            TccRepresentantes db = new TccRepresentantes();
            var representantes   = db.Alunos.Where(a => a.Representante == true).ToArray();

            if (representantes.Count() == 4)
            {
                label3.Visible       = false;
                rbSim.Visible        = false;
                radioButton2.Visible = false;
            }
        }
Beispiel #2
0
        private object Representante()
        {
            TccRepresentantes db = new TccRepresentantes();
            var representantes   = db.Alunos.Where(a => a.Representante == true).ToList();

            if (representantes == null)
            {
                return(null);
            }
            else
            {
                int x = 0;
                foreach (var item in representantes)
                {
                    if (x > 3)
                    {
                        break;
                    }

                    if (x == 0)
                    {
                        lblName1.Text = item.Aluno;
                    }

                    if (x == 1)
                    {
                        lblName2.Text = item.Aluno;
                    }

                    if (x == 2)
                    {
                        lblNome3.Text = item.Aluno;
                    }

                    if (x == 3)
                    {
                        lblName4.Text = item.Aluno;
                    }

                    x++;
                }

                /*
                 * lblName1.Text = representantes[0].Aluno;
                 * lblName2.Text = representantes[1].Aluno;
                 * lblNome3.Text = representantes[2].Aluno;
                 * lblName4.Text = representantes[3].Aluno;
                 */
                return(representantes);
            }
        }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            bool representante = false;

            if (rbSim.Checked)
            {
                representante = true;
            }
            else
            {
                representante = false;
            }

            TccRepresentantes db = new TccRepresentantes();

            Alunos aluno = new Alunos {
                Aluno = textBox1.Text, CGM = Convert.ToInt32(maskedTextBox1.Text), Representante = representante, Turma = comboBox1.Text
            };

            LoginUsuarios logUsu = new LoginUsuarios();

            logUsu.Usuario = textBox1.Text;
            logUsu.Senha   = maskedTextBox1.Text;


            if (representante)
            {
                Voto voto = new Voto {
                    candiato = Convert.ToInt32(maskedTextBox1.Text), Voto1 = 0, Alunos = aluno
                };
                db.Voto.Add(voto);
            }


            db.Alunos.Add(aluno);
            db.LoginUsuarios.Add(logUsu);

            db.SaveChanges();

            textBox1.Text        = "";
            maskedTextBox1.Text  = "";
            comboBox1.Text       = "";
            rbSim.Checked        = false;
            radioButton2.Checked = false;

            RestricaoRepresentante();
        }
Beispiel #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Confirma Voto?", "Voto",
                                MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string nomeRpresentate = string.Empty;

                if (radioButton1.Checked)
                {
                    nomeRpresentate = lblName1.Text;
                }
                if (radioButton2.Checked)
                {
                    nomeRpresentate = lblName2.Text;
                }
                if (radioButton3.Checked)
                {
                    nomeRpresentate = lblNome3.Text;
                }
                if (radioButton3.Checked)
                {
                    nomeRpresentate = lblName4.Text;
                }

                //grava voto no banco de dados
                TccRepresentantes db = new TccRepresentantes();

                Alunos aluno = db.Alunos.Where(a => a.Aluno == nomeRpresentate).FirstOrDefault();
                Voto   voto  = db.Voto.Where(v => v.Alunos.Aluno == nomeRpresentate).FirstOrDefault();

                /*voto.Voto1 = voto.Voto1 + 1;*/
                Voto novoVoto = new Voto()
                {
                    Alunos = aluno, Voto1 = 0, candiato = voto.candiato
                };
                db.Voto.Add(novoVoto);

                db.SaveChanges();

                Application.OpenForms["Form1"].Activate();
                Application.OpenForms["Form1"].Show();

                this.Hide();
                this.Dispose();
            }
        }
Beispiel #5
0
        private void btnAcessar_Click(object sender, EventArgs e)
        {
            TccRepresentantes db    = new TccRepresentantes();
            LoginUsuarios     login = db.LoginUsuarios.Where(a => a.Usuario == txtUsuario.Text && a.Senha == txtSenha.Text).FirstOrDefault();

            if (login == null)
            {
                MessageBox.Show("Usuário não existe", "Alerta", MessageBoxButtons.OK);
            }
            else if (login.Usuario == "Admin")
            {
                Registro Registro = new Registro();
                Registro.Show();
                this.Hide();
            }
            else
            {
                VotaRepresentante VotaRepresentante = new VotaRepresentante();
                VotaRepresentante.Show();
                this.Hide();
            }
        }
Beispiel #6
0
        public Registro()
        {
            InitializeComponent();


            AcessoDados       banco = new AcessoDados();
            TccRepresentantes db    = new TccRepresentantes();
            //banco.

            String sqlCmd = "select Nome from Turmas";


            SqlDataReader reader = (SqlDataReader)banco.ExecutarPersistência(CommandType.Text, sqlCmd, true);

            if (reader.HasRows)
            {
                foreach (DbDataRecord dr in reader)
                {
                    this.comboBox1.Items.Add(dr["Turmas.Nome"]);
                }
            }
        }