Esempio n. 1
0
        private void btnCreer_Click(object sender, EventArgs e)
        {
            try {
                CtrlConfiguration cc      = new CtrlConfiguration(connexion);
                string            equipe1 = cbEquipe1.Text;
                string            equipe2 = cbEquipe2.Text;
                string            duree   = dtpMitemps.Value.ToString("HH:mm:ss");
                string            partie  = cc.Create(equipe1, equipe2, duree);
                ViewCoursMatch    vcm     = new ViewCoursMatch(connexion, partie, duree, "1", equipe1, equipe2);
                vcm.Show();

                if (this.partie != null)
                {
                    Model.ProchainePartieDAO ppdao   = new Model.ProchainePartieDAO(connexion);
                    Model.PartieDAO          ptdao   = new Model.PartieDAO(connexion);
                    Model.Partie             encours = ptdao.Select("WHERE id='" + partie + "'").First();
                    this.partie.Partie = encours;

                    ppdao.Update(this.partie.ToUpdate(), "WHERE id='" + this.partie.Id + "'");
                }
            } catch (Exception ex) {
                throw ex;
                //throw new Exception("Etape : " + etape);
                //System.Windows.Forms.MessageBox.Show(ex.Message + ":" + ex.StackTrace);
            }
        }
Esempio n. 2
0
        private void Suite()
        {
            try {
                int             mt    = int.Parse(mitemps);
                Model.PartieDAO ptdao = new Model.PartieDAO(connexion);
                if ((mt % 2) == 0)
                {
                    if (true)   // SI IL Y A PAS D'EGALITE

                    {
                        Model.Partie pt = ptdao.Select("WHERE id = '" + this.partie + "'").First();
                        pt.Fini = 1;
                        ptdao.Update(pt.ToUpdate(), "WHERE id='" + pt.Id + "'");
                        string datePartie = pt.DatePartie.ToString("yyyy-MM-dd HH:mm:ss");

                        Ctrl.RestClient client = new RestClient();
                        String          json   = "{ \"id\": \"" + pt.Id + "\" }";
                        client.Post("http://localhost:51549/api/Departager", json);

                        ViewMatchStat vms = new ViewMatchStat(connexion, datePartie, equipe2, equipe1);
                        vms.Show();
                    }
                    else
                    {
                        ViewCoursMatch vcm = new ViewCoursMatch(connexion, partie, duree, (mt + 1) + "", equipe1, equipe2);
                        vcm.Show();
                    }
                }
                else
                {
                    DialogResult result = MessageBox.Show("Continuer avec le prochain mi-temps ?", "Confirmation", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        ViewCoursMatch vcm = new ViewCoursMatch(connexion, partie, duree, (mt + 1) + "", equipe2, equipe1);
                        vcm.Show();
                    }
                    else if (result == DialogResult.No)
                    {
                        Model.Partie pt = ptdao.Select("WHERE id = '" + this.partie + "'").First();
                        pt.Fini = 1;
                        ptdao.Update(pt.ToUpdate(), "WHERE id='" + pt.Id + "'");
                        string datePartie = pt.DatePartie.ToString("yyyy-MM-dd HH:mm:ss");

                        Ctrl.RestClient client = new RestClient();
                        String          json   = "{ \"id\": \"" + pt.Id + "\" }";
                        client.Post("http://localhost:51549/api/Departager", json);

                        ViewMatchStat vms = new ViewMatchStat(connexion, datePartie, equipe1, equipe2);
                        vms.Show();
                    }
                    else
                    {
                        throw new Exception("Une erreur inconnue !");
                    }
                }
            } catch (Exception ex) {
                throw ex;
                //System.Windows.Forms.MessageBox.Show(ex.StackTrace);
            }
        }