码迷,mamicode.com
首页 > 其他好文 > 详细

排球计分

时间:2017-03-17 23:16:16      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:button   set   png   数据   name   uri   string   GridView   dial   

计划

  用半个月时间完成

开发

  需求分析  作为一名现场记分员,我希望详细记录比赛现场比分增长情况,以便观众及运动员、教练员及时掌握比赛状况。

  设计文档  某队员得分,对方失误得分,连胜积分,最终胜利。

 

 

技术分享

具体代码

{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int m = 1;

        SqlConnection con = new SqlConnection("server=刘志友; Initial Catalog=paiqiu; Integrated Security=true;");

        private void button1_Click(object sender, EventArgs e)
        {
            int a1 = int.Parse(txta1.Text);//没球分数
            int a2 = int.Parse(txta2.Text);
            int b1 = int.Parse(txtb1.Text);//每局分数
            int b2 = int.Parse(txtb2.Text);
            txtc1.Text = (int.Parse(txtc1.Text) + 1).ToString();//连胜几球
            txtc2.Text = "0";
            Form3 f = new Form3();
            f.ShowDialog();
            if (txta1.Text == "" && txta2.Text == "" && txtb1.Text == "" && txtb2.Text == "")
            {
                string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}局‘,‘{1}‘,‘{2}‘)", m, txtd1, txtd2);
                SqlCommand cmd = new SqlCommand(sql, con);
                con.Open();
                int count = cmd.ExecuteNonQuery();
                con.Close();
            }

            if (a1 < 9)
            {
                txta1.Text = 0 + (a1 + 1).ToString();
                string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}球‘,‘1‘,‘0‘)", (a1 + a2 + 1).ToString());
                SqlCommand cmd = new SqlCommand(sql, con);
                con.Open();
                int count = cmd.ExecuteNonQuery();
                con.Close();
            }
            else
            {
                if (m == 5)
                {
                    if (a1 >= 14 && a1 <= a2 || a1 < 14)
                    {
                        txta1.Text = (a1 + 1).ToString();
                        string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}球‘,‘1‘,‘0‘)", (a1 + a2 + 1).ToString());
                        SqlCommand cmd = new SqlCommand(sql, con);
                        con.Open();
                        int count = cmd.ExecuteNonQuery();
                        con.Close();
                    }
                    else
                    {
                        string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}球‘,‘1‘,‘0‘)", (a1 + a2 + 1).ToString());
                        SqlCommand cmd = new SqlCommand(sql, con);
                        con.Open();
                        int count = cmd.ExecuteNonQuery();
                        con.Close();
                        txtb1.Text = (b1 + 1).ToString();
                        txtjieju.Text += "" + m + "" + (a1 + 1).ToString() + ":" + txta2.Text + "\r" + "\n";
                    }
                }
                else
                {
                    if (a1 >= 24 && a1 <= a2 || a1 < 24)
                    {
                        txta1.Text = (a1 + 1).ToString();
                        string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}球‘,‘1‘,‘0‘)", (a1 + a2 + 1).ToString());
                        SqlCommand cmd = new SqlCommand(sql, con);
                        con.Open();
                        int count = cmd.ExecuteNonQuery();
                        con.Close();
                    }
                    else
                    {
                        string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}球‘,‘1‘,‘0‘)", (a1 + a2 + 1).ToString());
                        SqlCommand cmd = new SqlCommand(sql, con);
                        con.Open();
                        int count = cmd.ExecuteNonQuery();
                        con.Close();
                        txtb1.Text = (b1 + 1).ToString();
                        txtjieju.Text += "" + m + "" + (a1 + 1).ToString() + ":" + txta2.Text + "\r" + "\n";
                        txta1.Text = "00";
                        txta2.Text = "00";
                        txtm.Text = "" + (m + 1) + "";
                        m = m + 1;

                    }
                }

            }
            if (txtb1.Text == "3")
            {
                MessageBox.Show(txtd1.Text + "");
                txta1.Text = "00";
                txta2.Text = "00";
                txtb1.Text = "0";
                txtb2.Text = "0";
                m = 0;
                //txtjieju.Text += txtd1.Text + "胜";
                txtm.Text = "" + (m + 1) + "";
            }
        }

        private void txta1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            int a1 = int.Parse(txta1.Text);
            int a2 = int.Parse(txta2.Text);
            int b1 = int.Parse(txtb1.Text);
            int b2 = int.Parse(txtb2.Text);
            txtc2.Text = (int.Parse(txtc2.Text) + 1).ToString();//连胜几球
            txtc1.Text = "0";
            Form4 f = new Form4();
            f.ShowDialog();
            if (txta1.Text == "" && txta2.Text == "" && txtb1.Text == "" && txtb2.Text == "")
            {
                string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}局‘,‘{1}‘,‘{2}‘)", m, txtd1, txtd2);
                SqlCommand cmd = new SqlCommand(sql, con);
                con.Open();
                int count = cmd.ExecuteNonQuery();
                con.Close();
            }

            if (a2 < 9)
            {
                txta2.Text = 0 + (a2 + 1).ToString();
                string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}球‘,‘0‘,‘1‘)", (a1 + a2 + 1).ToString());
                SqlCommand cmd = new SqlCommand(sql, con);
                con.Open();
                int count = cmd.ExecuteNonQuery();
                con.Close();
            }
            else
            {
                if (m == 5)
                {
                    if (a2 >= 14 && a2 <= a1 || a2 < 14)
                    {
                        txta2.Text = (a2 + 1).ToString();
                        string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}球‘,‘0‘,‘1‘)", (a1 + a2 + 1).ToString());
                        SqlCommand cmd = new SqlCommand(sql, con);
                        con.Open();
                        int count = cmd.ExecuteNonQuery();
                        con.Close();
                    }
                    else
                    {

                        string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}球‘,‘0‘,‘1‘)", (a1 + a2 + 1).ToString());
                        SqlCommand cmd = new SqlCommand(sql, con);
                        con.Open();
                        int count = cmd.ExecuteNonQuery();
                        con.Close();
                        txtb2.Text = (b2 + 1).ToString();
                        txtjieju.Text += "" + m + "" + txta1.Text + ":" + (a2 + 1).ToString() + "\r" + "\n";
                        txta1.Text = "00";
                        txta2.Text = "00";
                    }
                }
                if (a2 >= 24 && a2 <= a1 || a2 < 24)
                {
                    txta2.Text = (a2 + 1).ToString();
                }
                else
                {
                    string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}球‘,‘0‘,‘1‘)", (a1 + a2 + 1).ToString());
                    SqlCommand cmd = new SqlCommand(sql, con);
                    con.Open();
                    int count = cmd.ExecuteNonQuery();
                    con.Close();
                    txtb2.Text = (b2 + 1).ToString();
                    txtjieju.Text += "" + m + "" + txta1.Text + ":" + (a2 + 1).ToString() + "\r" + "\n";
                    txta1.Text = "00";
                    txta2.Text = "00";
                    txtm.Text = "" + (m + 1) + "";
                    m = m + 1;
                }

            }
            if (txtb2.Text == "3")
            {
                MessageBox.Show(txtd2.Text + "");
                txta1.Text = "00";
                txta2.Text = "00";
                txtb1.Text = "0";
                txtb2.Text = "0";
                m = 0;
                txtm.Text = "" + (m + 1) + "";
            }
        }


        private void button4_Click(object sender, EventArgs e)
        {
            Form2 f = new Form2();
            f.ShowDialog();
        }

        private void button3_Click(object sender, EventArgs e)//重新开始
        {
            txta1.Text = "00";
            txta2.Text = "00";
            txtb1.Text = "0";
            txtb2.Text = "0";
            m = 0;
            txtm.Text = "" + (m + 1) + "";
            txtjieju.Text = "";
        }



        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void txtjieju_TextChanged(object sender, EventArgs e)
        {

        }
    }
}



namespace 排球计分
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“paiqiuDataSet.jifen”中。您可以根据需要移动或删除它。
            this.jifenTableAdapter.Fill(this.paiqiuDataSet.jifen);
            // TODO: 这行代码将数据加载到表“pqjfDataSet.baiqiu”中。您可以根据需要移动或删除它。
           // this.baiqiuTableAdapter.Fill(this.pqjfDataSet.baiqiu);

            DAta();
        }
        private void DAta(string sql = "select * from jifen")
        {
            SqlConnection con = new SqlConnection("server=刘志友; Initial Catalog=paiqiu; Integrated Security=true;");
            SqlDataAdapter ad = new SqlDataAdapter(sql, con);
            DataSet ds = new DataSet();
            con.Open();
            ad.Fill(ds);
            con.Close();
            dataGridView1.DataSource = ds.Tables[0];
        }


        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}


namespace 排球计分
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }
            SqlConnection con = new SqlConnection("server=刘志友; Initial Catalog=paiqiu; Integrated Security=true;");
            Form1 f = new Form1();
        private void but1_Click(object sender, EventArgs e)
            {
               // string sql = string.Format("insert into jifen (dijiqiu,Dname1,Dname2) values (‘第{0}局‘,‘{1}‘,‘{2}‘)", m, txtd1, txtd2);
            string sql = string.Format("insert into jifen (name1) values (‘{0}‘)",1 );
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
        }

        private void but2_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 2);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but3_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 3);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but4_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 4);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but5_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 5);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but6_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 6);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but7_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 7);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but8_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 8);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but9_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 9);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but10_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 10);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but11_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 11);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void but12_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", 12);
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }

        private void butt_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into jifen (name) values (‘{0}‘)", "对方失误得分");
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            int count = cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
            this.Close();
        }
    }
}

运行后

技术分享技术分享

出现了一些问题 还在解决中 。

 

排球计分

标签:button   set   png   数据   name   uri   string   GridView   dial   

原文地址:http://www.cnblogs.com/liu-26/p/6569064.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!