コード例 #1
0
ファイル: Form3.cs プロジェクト: JoeG05/singlesLeague
        private void comboBoxWeek_SelectedIndexChanged(object sender, EventArgs e)
        {
            sql           s    = new sql();
            List <string> home = new List <string>();
            List <string> away = new List <string>();

            List <string> combo = new List <string>();


            string q = "SELECT Home FROM abschedule WHERE Week = '" + comboBoxWeek.Text + "'";

            home = s.Select(q, "Home");

            q    = "SELECT Away FROM abschedule WHERE Week ='" + comboBoxWeek.Text + "'";
            away = s.Select(q, "Away");



            for (int i = 0; i < home.Count; i++)
            {
                combo.Add(away[i] + " @ " + home[i]);
            }
            comboBoxMatch.DataSource = combo;

            labelMatch.Visible      = true;
            comboBoxMatch.Visible   = true;
            labelStart.Visible      = true;
            radioButtonAway.Visible = true;
            radioButtonHome.Visible = true;
            buttonGo.Visible        = true;
        }
コード例 #2
0
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            sql s = new sql();

            TextBox[] left        = { left1, left2, left3, left4, left5, left6, left7 };
            int       scoredTotal = 0;

            TextBox[] thrown      = { thrown1, thrown2, thrown3, thrown4, thrown5, thrown6, thrown7 };
            int       thrownTotal = 0;

            TextBox[] allstars      = { allstars1, allstars2, allstars3, allstars4, allstars5, allstars6, allstars7 };
            int       allstarsTotal = 0;

            int wins   = 0;
            int losses = 0;

            if (textBoxWeek.Text == "")
            {
                MessageBox.Show("Week required.");
                return;
            }

            int    week = Convert.ToInt32(textBoxWeek.Text);
            string name = comboBox1.Text;

            if (name == "")
            {
                MessageBox.Show("Player required.");
                return;
            }

            int j = 1;

            foreach (var x in left)
            {
                if (x.Text == "")
                {
                    MessageBox.Show("Required value missing in leg " + j);
                    return;
                }

                j++;
            }

            j = 1;
            foreach (var x in thrown)
            {
                if (x.Text == "")
                {
                    MessageBox.Show("Required value missing in leg " + j);
                    return;
                }
                j++;
            }

            for (int i = 0; i < 7; i++)
            {
                int scored = 501 - Convert.ToInt32(left[i].Text);
                scoredTotal += scored;

                thrownTotal += Convert.ToInt32(thrown[i].Text);

                if (allstars[i].Text != "")
                {
                    allstarsTotal += Convert.ToInt32(allstars[i].Text);
                }

                if (Convert.ToInt32(left[i].Text) == 0)
                {
                    wins++;
                }
            }
            losses = 7 - wins;

            string q = "INSERT INTO cdstats (Week, Name, W, L, scored, thrown, Allstars) VALUES ('" + week + "', '"
                       + name + "', '" + wins + "', '" + losses + "', '" + scoredTotal + "', '" + thrownTotal + "', '" + allstarsTotal + "')";

            s.Insert(q);


            this.Close();
        }
コード例 #3
0
ファイル: scoreBoard.cs プロジェクト: JoeG05/singlesLeague
        public void endMatch()
        {
            System.IO.StreamWriter logA = new System.IO.StreamWriter(@"log-" + a.player + "(" + a.week + ").txt");
            System.IO.StreamWriter logH = new System.IO.StreamWriter(@"log-" + h.player + "(" + h.week + ").txt");

            for (int i = 1; i < 12; i++)
            {
                a.totalDarts  += a.darts[i];
                a.totalScored += a.scored[i];
                h.totalDarts  += h.darts[i];
                h.totalScored += h.scored[i];
                if (a.darts[i] < a.bestleg)
                {
                    a.bestleg = a.darts[i];
                }
                if (h.darts[i] < h.bestleg)
                {
                    h.bestleg = h.darts[i];
                }
                if (a.takeout[i] > a.highout)
                {
                    a.highout = a.takeout[i];
                }
                if (h.takeout[i] > h.highout)
                {
                    h.highout = h.takeout[i];
                }
            }

            logA.WriteLine(a.week);
            logA.WriteLine("{0} vs {1}", a.player, a.opponent);
            logA.WriteLine("{0} - {1}", a.w, a.l);
            logA.WriteLine("First 9: {0}", a.first9 / 3);
            logA.WriteLine("Allstars: {0}", a.allstars);
            logA.WriteLine("<30: {0}", a.thirty);
            logA.WriteLine("80+: {0}", a.eighty);
            logA.WriteLine("95+: {0}", a.ninety5);
            logA.WriteLine("140+: {0}", a.ton40);
            logA.WriteLine("180: {0}", a.ton80);
            if (a.outthrown == 0)
            {
                logA.WriteLine("0%");
            }
            else
            {
                logA.WriteLine("{0}%", a.outhit / a.outthrown * 100.0);
            }
            logA.WriteLine(a.totalScored);
            logA.WriteLine(a.totalDarts);
            logA.WriteLine("Avg: {0}", (a.totalScored / a.totalDarts) * 3.0);
            logA.WriteLine("Best Leg: {0}", a.bestleg);
            logA.WriteLine("High Out: {0}", a.highout);

            logH.WriteLine(a.week);
            logH.WriteLine("{0} vs {1}", h.player, h.opponent);
            logH.WriteLine("{0} - {1}", h.w, h.l);
            logH.WriteLine("First 9: {0}", h.first9 / 3);
            logH.WriteLine("Allstars: {0}", h.allstars);
            logH.WriteLine("<30: {0}", h.thirty);
            logH.WriteLine("80+: {0}", h.eighty);
            logH.WriteLine("95+: {0}", h.ninety5);
            logH.WriteLine("140+: {0}", h.ton40);
            logH.WriteLine("180: {0}", h.ton80);
            if (h.outthrown == 0)
            {
                logH.WriteLine("0%");
            }
            else
            {
                logH.WriteLine("{0}%", h.outhit / h.outthrown * 100.0);
            }
            logH.WriteLine(h.totalScored);
            logH.WriteLine(h.totalDarts);
            logH.WriteLine("Avg: {0}", (h.totalScored / h.totalDarts) * 3.0);
            logH.WriteLine("Best Leg: {0}", h.bestleg);
            logH.WriteLine("High Out: {0}", h.highout);

            logA.Close();
            logH.Close();

            sql    s = new sql();
            string q;

            q = string.Format(
                "INSERT INTO abstats (week, player, opponent, w, l, first9, allstars, " +
                "thirty, eighty, ninety5, ton40, ton80, outthrown, outhit, highout, " +
                "bestleg, darts1, darts2, darts3, darts4, darts5, darts6, darts7, " +
                "darts8, darts9, darts10, darts11, dartstotal, scored1, scored2, scored3, scored4, " +
                "scored5, scored6, scored7, scored8, scored9, scored10, scored11, scoredtotal, user) VALUES " +
                "('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', " +
                "'{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', " +
                "'{20}', '{21}', '{22}', '{23}', '{24}', '{25}', '{26}', '{27}', '{28}', '{29}', " +
                "'{30}', '{31}', '{32}', '{33}', '{34}', '{35}', '{36}', '{37}', '{38}', '{39}', '{40}')",
                a.week, a.player, a.opponent, a.w, a.l, a.first9, a.allstars, a.thirty, a.eighty, a.ninety5,
                a.ton40, a.ton80, a.outthrown, a.outhit, a.highout, a.bestleg,
                a.darts[1], a.darts[2], a.darts[3], a.darts[4], a.darts[5], a.darts[6],
                a.darts[7], a.darts[8], a.darts[9], a.darts[10], a.darts[11], a.totalDarts, a.scored[1],
                a.scored[2], a.scored[3], a.scored[4], a.scored[5], a.scored[6], a.scored[7],
                a.scored[8], a.scored[9], a.scored[10], a.scored[11], a.totalScored, a.user);
            s.Insert(q);

            string z;

            z = string.Format(
                "INSERT INTO abstats (week, player, opponent, w, l, first9, allstars, " +
                "thirty, eighty, ninety5, ton40, ton80, outthrown, outhit, highout, " +
                "bestleg, darts1, darts2, darts3, darts4, darts5, darts6, darts7, " +
                "darts8, darts9, darts10, darts11, dartstotal, scored1, scored2, scored3, scored4, " +
                "scored5, scored6, scored7, scored8, scored9, scored10, scored11, scoredtotal, user) VALUES " +
                "('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', " +
                "'{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', " +
                "'{20}', '{21}', '{22}', '{23}', '{24}', '{25}', '{26}', '{27}', '{28}', '{29}', " +
                "'{30}', '{31}', '{32}', '{33}', '{34}', '{35}', '{36}', '{37}', '{38}', '{39}', '{40}')",
                h.week, h.player, h.opponent, h.w, h.l, h.first9, h.allstars, h.thirty, h.eighty, h.ninety5,
                h.ton40, h.ton80, h.outthrown, h.outhit, h.highout, h.bestleg,
                h.darts[1], h.darts[2], h.darts[3], h.darts[4], h.darts[5], h.darts[6],
                h.darts[7], h.darts[8], h.darts[9], h.darts[10], h.darts[11], h.totalDarts, h.scored[1],
                h.scored[2], h.scored[3], h.scored[4], h.scored[5], h.scored[6], h.scored[7],
                h.scored[8], h.scored[9], h.scored[10], h.scored[11], h.totalScored, h.user
                );
            s.Insert(z);

            MessageBox.Show("Ending");
            this.Close();
        }