private void gravarDuelo() { Modelo.SGCRPContexto contexto = new Modelo.SGCRPContexto(); Modelo.GoldMontaria goldMontaria1 = new Modelo.GoldMontaria(); Modelo.GoldMontaria goldMontaria2 = new Modelo.GoldMontaria(); Modelo.RoundGold roundGold = contexto.RoundGold.Find(rGoldID); int ord = roundGold.goldMontaria.Count == 0 ? 1 : roundGold.goldMontaria.Max(m => m.ord) + 1; goldMontaria1.ord = ord; goldMontaria1.goldTouroID = Convert.ToInt32(cmbTouro1.SelectedValue); goldMontaria1.roundGoldID = roundGold.id; atualizarGoldTouro(Convert.ToInt32(goldMontaria1.goldTouroID)); goldMontaria2.ord = ord; goldMontaria2.goldTouroID = Convert.ToInt32(cmbTouro2.SelectedValue); goldMontaria2.roundGoldID = roundGold.id; atualizarGoldTouro(Convert.ToInt32(goldMontaria2.goldTouroID)); if (roundGold.num == 1) { goldMontaria1.etapaCompetidorID = Convert.ToInt32(cmbCompetidor1.SelectedValue); goldMontaria1.recebeOrd = 0; goldMontaria2.etapaCompetidorID = Convert.ToInt32(cmbCompetidor2.SelectedValue); goldMontaria2.recebeOrd = 0; } else { goldMontaria1.etapaCompetidorID = null; goldMontaria1.recebeOrd = Convert.ToInt32(cmbCompetidor1.SelectedValue); goldMontaria2.etapaCompetidorID = null; goldMontaria2.recebeOrd = Convert.ToInt32(cmbCompetidor2.SelectedValue); } contexto.GoldMontaria.Add(goldMontaria1); contexto.GoldMontaria.Add(goldMontaria2); contexto.SaveChanges(); this.Close(); }
private void frmGoldNota_Load(object sender, EventArgs e) { Modelo.SGCRPContexto contexto = new Modelo.SGCRPContexto(); Modelo.GoldMontaria goldMontaria = contexto.GoldMontaria.Find(this.goldMontariaID); carregarMontaria(); controlesDinamico(goldMontaria.etapaCompetidor.etapa); }
private void removerNota(Modelo.GoldMontaria goldMontaria) { Modelo.SGCRPContexto contexto = new Modelo.SGCRPContexto(); List <Modelo.NotaGold> lstNotaGold = goldMontaria.notaGold.ToList(); for (int i = 0; i < lstNotaGold.Count; i++) { Modelo.NotaGold notaGold = contexto.NotaGold.Find(lstNotaGold[i].id); contexto.NotaGold.Remove(notaGold); } contexto.SaveChanges(); }
private void carregarMontaria() { Modelo.SGCRPContexto contexto = new Modelo.SGCRPContexto(); Modelo.GoldMontaria goldMontaria = contexto.GoldMontaria.Find(goldMontariaID); string tipo; if (goldMontaria.roundGold.tipo == 0) { tipo = goldMontaria.ord + "° DUELO - "; } else { tipo = goldMontaria.ord + "° MONTARIA - "; } lblTitulo.Text = tipo + goldMontaria.etapaCompetidor.apelidoCompetidor + " | " + goldMontaria.goldTouro.touro.nome; }
private void btnConfirmarNota_Click(object sender, EventArgs e) { Modelo.SGCRPContexto contexto = new Modelo.SGCRPContexto(); Modelo.GoldMontaria goldMontaria = contexto.GoldMontaria.Find(goldMontariaID); if (verificarCampos(goldMontaria.etapaCompetidor.etapa)) { if (goldMontaria.notaGold.Count > 0) { removerNota(goldMontaria); } atribuirNota(goldMontaria); this.Close(); } else { MessageBox.Show("É necessário atribuir a nota de todos os juízes.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void atribuirNota(Modelo.GoldMontaria goldMontaria) { Modelo.SGCRPContexto contexto = new Modelo.SGCRPContexto(); List <Modelo.Equipe> lstJuiz = goldMontaria.etapaCompetidor.etapa.equipe.Where(t => t.profissonal.tipoProfissonal.descricao.ToLower() == "juiz").ToList(); for (int i = 0; i < lstJuiz.Count; i++) { Modelo.NotaGold notaGold = new Modelo.NotaGold(); int juizID = lstJuiz[i].id; notaGold.juizID = juizID; TextBox txtNotaTouro = this.Controls.Find("txtNotaTouro" + lstJuiz[i].id, true).FirstOrDefault() as TextBox; notaGold.notaTouro = Convert.ToSingle(txtNotaTouro.Text); notaGold.goldMontariaID = goldMontaria.id; TextBox txtNotaCompetidor = this.Controls.Find("txtNotaCompetidor" + lstJuiz[i].id, true).FirstOrDefault() as TextBox; notaGold.notaCompetidor = Convert.ToSingle(txtNotaCompetidor.Text); contexto.NotaGold.Add(notaGold); } contexto.SaveChanges(); }