zoukankan      html  css  js  c++  java
  • 排球计分程序

    一,设计
    估计这个任务需要两周的时间

    二,开发

    1,需求分析---》拆成任务,编写代码

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

     任务:1》作为现场记分员需要知道每场比赛每个队伍的计分情况;

    2,生成设计文档

     由排球用户故事的需求可知,这个程序用来统计各个队伍的比分与积分情况

    3,设计复审     2个小时

    4,代码规范      按照vs2010进行规范

    5,具体设计

              

    每一场比赛的每一局都会在哪个队进一个球之后加一分,

    那一队先达到25分,哪个队获胜,五局三胜

    6,(a)具体代码(编码)  三天

           (b)界面设计(截屏)

     

    编写代码

    链接数据库配置文件

    <configuration>
    <connectionStrings>
    <add name="connectionStr" connectionString="server=.;database=paiqiu;integrated security=true"/>
    </connectionStrings>
    <system.web>
    <compilation debug="true" targetFramework="4.0" />
    </system.web>

    </configuration>

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;

    namespace Lesson1DAL
    {
    class SqlHelper
    {
    private static readonly string constr = ConfigurationManager.ConnectionStrings["connectionStr"].ConnectionString;
    //执行增删改,左边路线
    public static int ExecutNonQuery(string sql, params SqlParameter[] pms)
    {
    using (SqlConnection con = new SqlConnection(constr))
    {
    using (SqlCommand cmd = new SqlCommand(sql, con))
    {
    //判断是否传递了sql参数
    if (pms != null)
    {
    //将参数添加到Parameters集合中
    cmd.Parameters.AddRange(pms);
    }
    con.Open();
    return cmd.ExecuteNonQuery();
    }
    }
    }
    //执行查询单个值,最左边路线
    public static object ExecuteScalar(string sql, params SqlParameter[] pms)
    {
    using (SqlConnection con = new SqlConnection(constr))
    {
    using (SqlCommand cmd = new SqlCommand(sql, con))
    {
    if (pms != null)
    {
    cmd.Parameters.AddRange(pms);
    }
    con.Open();
    return cmd.ExecuteScalar();
    }
    }
    }
    //执行查询多个值,中间路线
    public static SqlDataReader ExecuteReadr(string sql, params SqlParameter[] pms)
    {
    SqlConnection con = new SqlConnection(constr);
    using (SqlCommand cmd = new SqlCommand(sql, con))
    {
    if (pms != null)
    {
    cmd.Parameters.AddRange(pms);
    }
    con.Open();
    return cmd.ExecuteReader(CommandBehavior.CloseConnection);
    }
    }
    //执行返回一张表,右边路线
    public static DataTable ExecuteDataTable(string sql, params SqlParameter[] pms)
    {
    DataTable dt = new DataTable();
    using (SqlDataAdapter adapter = new SqlDataAdapter(sql, constr))
    {
    if (pms != null)
    {
    adapter.SelectCommand.Parameters.AddRange(pms);
    }
    adapter.Fill(dt);
    }
    return dt;
    }
    }
    }

    private void button1_Click(object sender, EventArgs e)
    {
    juci.Text=(int.Parse(juci.Text)+1).ToString();
    txtA.Text = "0";
    txtB.Text = "0";

    }

    private void label4_Click(object sender, EventArgs e)
    {
    if (int.Parse(txtA.Text) > int.Parse(txtB.Text))
    {
    bisai.Text = juci.Text + "局 " + "比赛得分: " + "A队" + ":" + "B队" + "=" + txtA.Text + ":" + txtB.Text + " " + "A队 " + "胜" + " B队";
    }
    else
    {
    bisai.Text =juci.Text + "局" + "比赛得分: " + "A队" + ":" + "B队" + "=" + txtA.Text + ":" + txtB.Text + " " + "A队 " + "败" + " B队";
    }

    if (int.Parse(txtA.Text) == int.Parse(txtB.Text))
    {
    bisai.Text = juci.Text + "局 " + "比赛得分: " + "A队" + ":" + "B队" + "=" + txtA.Text + ":" + txtB.Text + " " + "A队 " + "平局" + " B队";
    }
    }

    private void label1_Click(object sender, EventArgs e)
    {

    }

    private void button2_Click(object sender, EventArgs e)
    {
    if (int.Parse(txtA.Text) - 1 > 0)
    {
    txtA.Text = (int.Parse(txtA.Text) - 1).ToString();
    }

    }

    private void button3_Click(object sender, EventArgs e)
    {
    if (int.Parse(txtA.Text) - 1 > 0)
    {
    txtB.Text = (int.Parse(txtB.Text) - 1).ToString();
    }
    }

    private void btnA_Click(object sender, EventArgs e)
    {
    txtA.Text=(int.Parse(txtA.Text)+1).ToString();
    btnA.Enabled = true;

    }

    private void bunB_Click(object sender, EventArgs e)
    {
    txtB.Text=(int.Parse(txtB.Text)+1).ToString();
    bunB.Enabled = true;
    }

    private void bisai_TextChanged(object sender, EventArgs e)
    {

    }

    }

    private void texguojia1_TextChanged(object sender, EventArgs e)
    {
    button1.Text = txtguojia1.Text+"胜";

    }

    private void texguojia2_TextChanged(object sender, EventArgs e)
    {
    button2.Text = txtguojia2.Text+"胜";

    }

    总结:

    不是太会,运行结果没有出来!

     

  • 相关阅读:
    商务通服务器版LR_Data目录下相关配置文件
    Python入门神图
    你不知道的JavaScript-2.词法作用域
    你不知道的JavaScript-1.作用域是什么
    linux服务器对外打包处理
    C# Form 关闭按钮灰化
    Spread常用属性
    Spread 常用属性
    C#打开关闭窗体事件顺序
    sqlserver如何使用日期计算
  • 原文地址:https://www.cnblogs.com/ilff/p/6568911.html
Copyright © 2011-2022 走看看