private void inscrieButton_Click(object sender, EventArgs e) { try { int idCursa = Int32.Parse(idTextBox.Text); string nume = numeTextBox.Text; string echipa = echipaTextBox.Text; int capacMotor = Int32.Parse(categorieComboBox.SelectedItem.ToString()); Participant p = service.findParticipantByNumeSiEchipaSiCapacMotor(capacMotor, nume, echipa); Console.WriteLine(p.ToString()); Cursa c = service.findCursaByCapacMotor(capacMotor); Console.WriteLine(c.ToString()); c.Id = idCursa; Inscriere inscriere = new Inscriere(c, p); if (c.CapacMotor == capacMotor) { inscriereDbRepository.save(inscriere); cursaDbRepository.delete(idCursa); //sterg ca sa pot adauga noua cursa cu nrpers updatat c.NrPers = c.NrPers + 1; cursaDbRepository.save(c); //curseDataGridView.DataSource = service.findByCapacMotor(Int32.Parse(categorieComboBox.SelectedItem.ToString())); curseDataGridView.DataSource = service.getAllCurse(); } else { MessageBox.Show("Capacitatea motorului != categoria cursei"); } } catch (NullReferenceException ex) { MessageBox.Show("Selectati atat participantul cat si cursa pentru inscriere"); } catch (Exception ex) { MessageBox.Show("Participantul este deja inscris la cursa"); } }
public void inscriereParticipant(int capacMotor, string nume, string echipa) { InscriereDbRepository.save(new Inscriere(findCursaByCapacMotor(capacMotor), findParticipantByNumeSiEchipaSiCapacMotor(capacMotor, nume, echipa))); }