首页 > 代码库 > 排球计分
排球计分
计划
用半个月时间完成
开发
需求分析 作为一名现场记分员,我希望详细记录比赛现场比分增长情况,以便观众及运动员、教练员及时掌握比赛状况。
设计文档 某队员得分,对方失误得分,连胜积分,最终胜利。
具体代码
{ 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(); } } }
运行后
出现了一些问题 还在解决中 。
排球计分
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。