private void button2_Click(object sender, EventArgs e) { if (!LoginDuplo()) { return; } txtSenha1.Text = string.Empty; if (!Program.Pergunta("Tem certeza? Todos os votos serão perdidos")) { return; } ChapaDAO cd = new ChapaDAO(); cd.DeletarArquivo(); cd.ZerarBd(); }
private void Confirma() { if (lblPresidente.Text.Trim().Length == 0) { return; } int ret = new ChapaDAO().Votar(txtNumero.Text); if (ret < 1) { Program.telaMesario.Logger("FALHA AO REGISTRAR VOTO"); Corrige(); return; } Program.telaMesario.Logger("Voto computado com suceso"); Corrige(); boxRodape.Visible = false; picPresidente.Visible = false; picVicePresidente.Visible = false; picRelator.Visible = false; picViceRelator.Visible = false; lblSeuVotoPara.Visible = false; lblRepublica.Visible = false; lblIfpr.Visible = false; lblNumero.Visible = false; txtNumero.Visible = false; lblC.Visible = false; lblChapa.Visible = false; lblP.Visible = false; lblPresidente.Visible = false; lblVP.Visible = false; lblVicePresidente.Visible = false; lblR.Visible = false; lblRelator.Visible = false; lblVR.Visible = false; lblViceRelator.Visible = false; lblFim.Visible = true; }
private void Numero(string num) { if (lblPresidente.Text.Trim().Length != 0) { return; } txtNumero.Text = num; Chapa ch = new ChapaDAO().CarregarChapa(num); if (ch == null) { //VOTOU NULO ch = new Chapa(); ch.Nome = "NULO"; ch.Presidente = "NULO"; ch.VicePresidente = "NULO"; ch.Relator = "NULO"; ch.ViceRelator = "NULO"; ch.Numero = "N"; } MontarTela(ch); }
private void btnSalvar_Click(object sender, EventArgs e) { //Validação dos Dados string msg = ""; if (txtNome.Text.Trim().Length < 3) { msg += "Preencha o nome da chapa\n"; } if (txtPresidente.Text.Trim().Length < 3) { msg += "Prencha o nome do candidato a presidente\n"; } if (txtVicePresidente.Text.Trim().Length < 3) { msg += "Prencha o nome do candidato a vice presidente\n"; } if (txtRelator.Text.Trim().Length < 3) { msg += "Prencha o nome do candidato a relator\n"; } if (txtViceRelator.Text.Trim().Length < 3) { msg += "Prencha o nome do candidato a vice relator\n"; } if (txtFotoPresidente.Text.Trim().Length < 3) { msg += "Adicione a foto do candidato a presidente\n"; } if (txtFotoVicePresidente.Text.Trim().Length < 3) { msg += "Adicione a foto do candidato a vice presidente\n"; } if (txtFotoRelator.Text.Trim().Length < 3) { msg += "Adicione a foto do candidato a relator\n"; } if (txtFotoViceRelator.Text.Trim().Length < 3) { msg += "Adicione a foto do candidato a vice relator\n"; } if (msg != "") { Program.Alerta(msg); return; } //Se chegou a este ponto validou tudo certo //Constroi a entidade Chapa c = new Chapa(); c.Numero = txtNumero.Value.ToString().Trim(); c.Nome = txtNome.Text.Trim(); c.Presidente = txtPresidente.Text.Trim(); c.VicePresidente = txtVicePresidente.Text.Trim(); c.Relator = txtRelator.Text.Trim(); c.ViceRelator = txtViceRelator.Text.Trim(); //Prepara o buffer para caregar array de bytes FileStream fs; BinaryReader br; string FileName; //Foto do PRESIDENTE FileName = txtFotoPresidente.Text; fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); br = new BinaryReader(fs); c.FotoPresidente = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); //Foto do VICE-PRESIDENTE FileName = txtFotoVicePresidente.Text; fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); br = new BinaryReader(fs); c.FotoVicePresidente = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); //Foto do RELATOR FileName = txtFotoRelator.Text; fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); br = new BinaryReader(fs); c.FotoRelator = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); //Foto do VICE RELATOR FileName = txtFotoViceRelator.Text; fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); br = new BinaryReader(fs); c.FotoViceRelator = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); if (!Program.Pergunta("Os dados estão corretos?")) { return; } //Zera os votos da chapa recém-criada c.Votos = 0; int res = new ChapaDAO().Cadastrar(c); if (res == 0) { Program.Erro("Falha ao salvar"); } else { Program.Mensagem("Dados salvos com sucesso.\nPara votar nesta chapa use o número " + c.Numero); this.Close(); } }