Beispiel #1
0
        static public ScoreCard copySc(LQModelLight.ScoreCard s)
        {
            ScoreCard sc = new ScoreCard();

            sc.dt         = s.dt;
            sc.equipe     = s.equipe;
            sc.packid     = s.pack;
            sc.pseudo     = s.pseudo.ToUpper();
            sc.rank       = s.rank;
            sc.ratio      = s.ratio;
            sc.tirs       = s.tirs;
            sc.LigneScore = new List <LigneScore>();
            foreach (LQModelLight.LigneScore ls in s.Up)
            {
                LigneScore l = new LigneScore(ls.equipe, ls.pseudo.ToUpper(), typeLigneScore.UP, ls.front, ls.back, ls.gun, ls.shoulder, sc);
                if (!sc.LigneScore.Contains(l))
                {
                    sc.LigneScore.Add(l);
                }
            }
            foreach (LQModelLight.LigneScore ls in s.Down)
            {
                LigneScore l = new LigneScore(ls.equipe, ls.pseudo.ToUpper(), typeLigneScore.DOWN, ls.front, ls.back, ls.gun, ls.shoulder, sc);
                if (!sc.LigneScore.Contains(l))
                {
                    sc.LigneScore.Add(l);
                }
            }
            return(sc);
        }
Beispiel #2
0
        public ScoreCard SaveScoreCard()
        {
            ScoreCard sc = new ScoreCard();

            if (cmdPseudo.SelectedItem == null || cmdEquipe.SelectedItem == null || string.IsNullOrEmpty(txtRatio.Text) || string.IsNullOrEmpty(txtNbTir.Text))
            {
                throw new Exception("Erreur, des données manquent, sauvegarde impossible");
            }
            sc.pseudo = ((string)cmdPseudo.SelectedValue).ToUpper();
            sc.equipe = ((string)cmdEquipe.SelectedValue).ToUpper();
            sc.ratio  = int.Parse(txtRatio.Text);
            sc.tirs   = int.Parse(txtNbTir.Text);
            sc.pack   = int.Parse(txtPack.Text);
            try {
                sc.dt = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
            }
            catch { }
            sc.score = 0;
            foreach (LigneScoreCtl lctl in pnlLignes.Children)
            {
                // on ignore les lignes vierges
                if (lctl.cmbEquipe.SelectedValue == null && lctl.cmbPlayer.SelectedValue == null)
                {
                    continue;
                }
                int front, back, gun, shoulder, score;
                front = gun = shoulder = back = score = 0;
                int frontPts, backPts, gunPts, shoulderPts;
                if (lctl.Mode == LigneScoreMode.IndivMinus)
                {
                    frontPts = -5;
                    backPts  = -4;
                    gunPts   = shoulderPts = -3;
                }
                else if (lctl.Mode == LigneScoreMode.IndivPlus)
                {
                    frontPts = backPts = gunPts = shoulderPts = 10;
                }
                else
                {
                    frontPts = backPts = gunPts = shoulderPts = 10;
                }
                if (lctl.txtFront.Text != "")
                {
                    front = int.Parse(lctl.txtFront.Text);
                }
                if (lctl.txtBack.Text != "")
                {
                    back = int.Parse(lctl.txtBack.Text);
                }
                if (lctl.txtGun.Text != "")
                {
                    gun = int.Parse(lctl.txtGun.Text);
                }
                if (lctl.txtShoulder.Text != "")
                {
                    shoulder = int.Parse(lctl.txtShoulder.Text);
                }
                score    += front * frontPts + back * backPts + gun * gunPts + shoulder * shoulderPts;
                sc.score += score;
                LigneScore l = new LigneScore(((string)lctl.cmbEquipe.SelectedValue).ToUpper(), ((string)lctl.cmbPlayer.SelectedValue).ToUpper(), front, back, gun, shoulder, score);
                if (lctl.Mode == LigneScoreMode.IndivPlus)
                {
                    sc.Up.Add(l);
                }
                else
                {
                    sc.Down.Add(l);
                }
            }
            if (sc.ratio > 20)
            {
                sc.score += 200;
            }
            else
            {
                sc.score += sc.ratio * 10;
            }
            if (txtScore.Text != "")
            {
                sc.score = int.Parse(txtScore.Text);
            }
            return(sc);
        }