public Menu() { InitializeComponent(); labeltime.Text = DateTime.Now.ToShortDateString(); BindingSource bSource = new BindingSource(); DataTable table = GestionParticipations.GetDerniereCourse(2); bSource.DataSource = table; dataGridView1.DataSource = bSource; // empecher la modification du datagridview dataGridView1.ReadOnly = true; }
private void CourseComboBox_SelectedIndexChanged(object sender, EventArgs e) { int crs = 0; string crsSelect = CourseComboBox.Text; List <PPEV2BO.Course> listeCourse = new List <PPEV2BO.Course>(); listeCourse = GestionCourses.GetCourses(); foreach (PPEV2BO.Course Cou in listeCourse) { if (Cou.Nom == crsSelect) { crs = Cou.Id; label9.Text = Cou.AgeMin.ToString(); label11.Text = Cou.AgeMax.ToString(); //ON COMPTE LE NOMBRE DE CHEVAUX DANS LA COURSE List <PPEV2BO.Participe> listeParticipe = new List <PPEV2BO.Participe>(); listeParticipe = GestionParticipations.GetParticipations(); int indexDeComptage = 0; int nbrFinal = 0; foreach (PPEV2BO.Participe Participe in listeParticipe) { if (Participe.Course == Cou.Id) { // METTRE ICI LE COMPTEUR indexDeComptage = indexDeComptage + 1; } } nbrFinal = Cou.NbrMax - indexDeComptage; label6.Text = nbrFinal.ToString(); } } List <PPEV2BO.Cheval> uneListe = new List <PPEV2BO.Cheval>(); uneListe = GestionChevaux.GetChevauxDuneCourse(crs); dataGridView1.DataSource = uneListe; this.dataGridView1.Columns[0].Visible = false; this.dataGridView1.Columns[8].Visible = false; this.dataGridView1.Columns[9].Visible = false; }
private void comboBoxCou_SelectedIndexChanged(object sender, EventArgs e) { int crs = 0; string crsSelect = comboBoxCou.Text; List <PPEV2BO.Course> listeCourse = new List <PPEV2BO.Course>(); listeCourse = GestionCourses.GetCourses(); foreach (PPEV2BO.Course Cou in listeCourse) { if (Cou.Nom == crsSelect) { crs = Cou.Id; } } List <PPEV2BO.Cheval> uneListe = new List <PPEV2BO.Cheval>(); uneListe = GestionChevaux.GetChevauxDuneCourse(crs); dataGridViewResultat.DataSource = uneListe; comboBoxch1.Items.Clear(); comboBoxch2.Items.Clear(); comboBoxch3.Items.Clear(); comboBoxch4.Items.Clear(); comboBoxch5.Items.Clear(); foreach (PPEV2BO.Cheval Ch in uneListe) { comboBoxch1.Items.Add(Ch.Nom); comboBoxch1.MaxDropDownItems = uneListe.Count(); comboBoxch2.Items.Add(Ch.Nom); comboBoxch2.MaxDropDownItems = uneListe.Count(); comboBoxch3.Items.Add(Ch.Nom); comboBoxch3.MaxDropDownItems = uneListe.Count(); comboBoxch4.Items.Add(Ch.Nom); comboBoxch4.MaxDropDownItems = uneListe.Count(); comboBoxch5.Items.Add(Ch.Nom); comboBoxch5.MaxDropDownItems = uneListe.Count(); } this.dataGridViewResultat.Columns[0].Visible = false; this.dataGridViewResultat.Columns[8].Visible = false; this.dataGridViewResultat.Columns[9].Visible = false; List <PPEV2BO.Participe> uneListeParticipation = new List <PPEV2BO.Participe>(); uneListeParticipation = GestionParticipations.GetListeDuClassement(crs); foreach (PPEV2BO.Participe Participant in uneListeParticipation) { if (Participant.Clas == 1) { comboBoxch1.SelectedIndex = comboBoxch1.FindStringExact(GestionChevaux.GetUnChevaux(Participant.Cheval).Nom); } else if (Participant.Clas == 2) { comboBoxch2.SelectedIndex = comboBoxch2.FindStringExact(GestionChevaux.GetUnChevaux(Participant.Cheval).Nom); } else if (Participant.Clas == 3) { comboBoxch3.SelectedIndex = comboBoxch3.FindStringExact(GestionChevaux.GetUnChevaux(Participant.Cheval).Nom); } else if (Participant.Clas == 4) { comboBoxch4.SelectedIndex = comboBoxch4.FindStringExact(GestionChevaux.GetUnChevaux(Participant.Cheval).Nom); } else if (Participant.Clas == 5) { comboBoxch5.SelectedIndex = comboBoxch5.FindStringExact(GestionChevaux.GetUnChevaux(Participant.Cheval).Nom); } } }
private void btnajout_Click(object sender, EventArgs e) { if (MessageBox.Show("Etes vous sur de vouloir ajouter le cheval selectionné ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { string chvSelect = comboBox1.Text; string jckSelect = comboBox2.Text; // VERIF QUE LES CHAMPS NE SOIT PAS VIDE if (chvSelect == "" || jckSelect == "") { MessageBox.Show("Impossible ! Merci de bien vouloir remplir les champs Cheval et Jockey.", "Ajout", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // RECUPERATION DE l'ID DE LA COURSE ET DE LA DATE int crs = 0; string laDate = "x"; string crsSelect = CourseComboBox.Text; List <PPEV2BO.Course> listeCourse = new List <PPEV2BO.Course>(); listeCourse = GestionCourses.GetCourses(); foreach (PPEV2BO.Course Cou in listeCourse) { if (Cou.Nom == crsSelect) { crs = Cou.Id; laDate = Cou.Date.ToString(); } } // RECUPERATION DE L'ID DU CHEVAL int chv = 0; List <PPEV2BO.Cheval> listeChevaux = new List <PPEV2BO.Cheval>(); listeChevaux = GestionChevaux.GetChevaux(); foreach (PPEV2BO.Cheval Chv in listeChevaux) { if (Chv.Nom == chvSelect) { chv = Chv.Id; } } /// RECUPERATION DE L'ID DU JOCKEY int jck = 0; List <PPEV2BO.Jockey> listeJockey = new List <PPEV2BO.Jockey>(); listeJockey = GestionJockeys.GetJockeys(); foreach (PPEV2BO.Jockey Jck in listeJockey) { if (Jck.Nom == jckSelect) { jck = Jck.Id; } } // ----------------------------------------------------------- // VERIFICATION DE SAISIE !! LIKE A BOSS !!!!! // ----------------------------------------------------------- PPEV2BO.Cheval unCheval = GestionChevaux.GetUnChevaux(chv); PPEV2BO.Course uneCourse = GestionCourses.GetUneCourse(crs); if (unCheval.Age < uneCourse.AgeMin || unCheval.Age > uneCourse.AgeMax) { MessageBox.Show("Impossible ! Le Cheval séléctionné ne peux pas faire partie de cette course à cause de son age.", "Ajout", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (GestionChevaux.GetUnChevaux(chv).Sexe != GestionCourses.GetUneCourse(crs).Sexe&& GestionCourses.GetUneCourse(crs).Sexe != "X") { MessageBox.Show("Impossible ! Le Cheval séléctionné ne peux pas faire partie de cette course à cause de son sexe.", "Ajout", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } List <PPEV2BO.Cheval> uneListe = new List <PPEV2BO.Cheval>(); uneListe = GestionChevaux.GetChevauxDuneCourse(crs); dataGridView1.DataSource = uneListe; if (uneListe.Count() >= GestionCourses.GetUneCourse(crs).NbrMax) { MessageBox.Show("Impossible ! La course a atteint son maximum de chevaux.", "Ajout", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (PPEV2BO.Cheval unChevalTest in uneListe) { if (unChevalTest.Id == GestionChevaux.GetUnChevaux(chv).Id) { MessageBox.Show("Impossible ! Ce cheval est déja dans la liste.", "Ajout", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } List <PPEV2BO.Participe> uneListedeParticipation = new List <PPEV2BO.Participe>(); uneListedeParticipation = GestionParticipations.GetParticipations(); foreach (PPEV2BO.Participe uneParticipation in uneListedeParticipation) { if (uneParticipation.Jockey == GestionJockeys.GetUnJockey(jck).Id&& uneParticipation.Course == GestionCourses.GetUneCourse(crs).Id) { MessageBox.Show("Impossible ! Ce Jockey est déja dans a assigné à un Cheval de la liste.", "Ajout", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } // ------------------------------------------------------------- GestionParticipations.CreerParticipation(chv, crs, jck, 0); MessageBox.Show(comboBox1.Text + " a bien été ajouté", "Ajout", MessageBoxButtons.OK, MessageBoxIcon.Information); uneListe = GestionChevaux.GetChevauxDuneCourse(crs); dataGridView1.DataSource = uneListe; // REFRESH DU NOMBRES DE PLACES DISPO: listeCourse = GestionCourses.GetCourses(); foreach (PPEV2BO.Course Cou in listeCourse) { if (Cou.Nom == crsSelect) { crs = Cou.Id; //ON COMPTE LE NOMBRE DE CHEVAUX DANS LA COURSE List <PPEV2BO.Participe> listeParticipe = new List <PPEV2BO.Participe>(); listeParticipe = GestionParticipations.GetParticipations(); int indexDeComptage = 0; int nbrFinal = 0; foreach (PPEV2BO.Participe Participe in listeParticipe) { if (Participe.Course == Cou.Id) { // METTRE ICI LE COMPTEUR indexDeComptage = indexDeComptage + 1; } } nbrFinal = Cou.NbrMax - indexDeComptage; label6.Text = nbrFinal.ToString(); } } this.dataGridView1.Columns[0].Visible = false; this.dataGridView1.Columns[8].Visible = false; this.dataGridView1.Columns[9].Visible = false; } }
private void buttonValider_Click(object sender, EventArgs e) { if (MessageBox.Show("êtes vous sur de vouloir ajouter le cheval selectionné ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { // RECUPERATION DE LID DE LA COURSE int crs = 0; string crsSelect = comboBoxCou.Text; List <PPEV2BO.Course> listeCourse = new List <PPEV2BO.Course>(); listeCourse = GestionCourses.GetCourses(); foreach (PPEV2BO.Course Cou in listeCourse) { if (Cou.Nom == crsSelect) { crs = Cou.Id; } } // RECUPERATION DE L'ID DES CHEVAUX int chv1 = 0; int chv2 = 0; int chv3 = 0; int chv4 = 0; int chv5 = 0; string chvSelect1 = comboBoxch1.Text; string chvSelect2 = comboBoxch2.Text; string chvSelect3 = comboBoxch3.Text; string chvSelect4 = comboBoxch4.Text; string chvSelect5 = comboBoxch5.Text; List <PPEV2BO.Cheval> listeChevaux = new List <PPEV2BO.Cheval>(); listeChevaux = GestionChevaux.GetChevaux(); foreach (PPEV2BO.Cheval Chv in listeChevaux) { if (Chv.Nom == chvSelect1) { chv1 = Chv.Id; } else if (Chv.Nom == chvSelect2) { chv2 = Chv.Id; } else if (Chv.Nom == chvSelect3) { chv3 = Chv.Id; } else if (Chv.Nom == chvSelect4) { chv4 = Chv.Id; } else if (Chv.Nom == chvSelect5) { chv5 = Chv.Id; } } GestionParticipations.AssignerClassementCheval(chv1, crs, 1); GestionParticipations.AssignerClassementCheval(chv2, crs, 2); GestionParticipations.AssignerClassementCheval(chv3, crs, 3); GestionParticipations.AssignerClassementCheval(chv4, crs, 4); GestionParticipations.AssignerClassementCheval(chv5, crs, 5); MessageBox.Show("Le classement a bien été appliqué", "Ajout", MessageBoxButtons.OK, MessageBoxIcon.Information); } }