博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
排球积分程序记分员
阅读量:5102 次
发布时间:2019-06-13

本文共 5407 字,大约阅读时间需要 18 分钟。

计划

        估计此程序需要1-2周

  • 开发
  • 需求分析

   用户故事:作为一个排球计分人员,我希望知道每场比赛队伍得分和积分情况,以便计分,让相关人员给每队进行排名。

  从分析用例故事可以知道完成此程序需要这两项任务:选择任务和查询队伍的比分和积分情况。

     .设计复审:

                    将编写的程序进行生成,进行设计复审。看看是否生成错误,如果错误进行修改。

     .代码规范:

                   利用VS对该程序进行代码规范。

代码如下:

using System;

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

namespace DAL
{
    public static  class SqlHelper
    {
       
        private static readonly string constr =
            ConfigurationManager.ConnectionStrings["MyPC"].ConnectionString;
       

       

        public static int ExecuteNonQuery(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.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 ExecuteReader(string sql, params SqlParameter[] pms)
        {
            SqlConnection con = new SqlConnection(constr);
            using (SqlCommand cmd = new SqlCommand(sql, con))
            {
                if (pms != null)
                {
                    cmd.Parameters.AddRange(pms);
                }

                try

                {
                    con.Open();
                    return cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                   
                }
                catch (Exception)
                {
                    con.Close();
                    con.Dispose();
                    throw; 
            }

        }

 

       

        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;
        }
    }
}

namespace Model

{
    public class Teams
    {
        public int ID { get; set; }
        public string TName { get; set; }
        public int WinCount { get; set; }
        public string FCount { get; set; }
        public string JiFen { get; set; }
        public string WinJuCount { get; set; }
        public string FJuCount { get; set; }
        public string _3to0 { get; set; }
        public string _3to1 { get; set; }
        public string _3to2 { get; set; }
        public string _2to3 { get; set; }
        public string _1to3 { get; set; }
        public string _0to3 { get; set; }
    }
}

namespace Model

{
    public class SingleBall
    {
        public int BallNum { get; set; }   
        public string GetTeam { get; set; }
        public int WinTeamScore { get; set; }  
        public int LoseTeamScore { get; set; }
        public int GetMemberNum { get; set; }
        public string HowGet { get; set; }
        public int LoseMemberNum { get; set; }
    }
}

 public class GameNotes

    {
        public int ID { get; set; }
        public string NameA { get; set; }
        public string NameB { get; set; }
        public DateTime Data { get; set; }
        public string R1 { get; set; }
        public string R2 { get; set; }
        public string R3 { get; set; }
        public string R4 { get; set; }
        public string R5 { get; set; }
        public string Place { get; set; }

    }

public class Members

    {
        public int ID { get; set; }
        public string MName { get; set; }
        public string TName { get; set; }
        public string Number { get; set; }
        public string Position { get; set; }
        public string Weight { get; set; }
        public string Height { get; set; }
        public int Age { get; set; }
        public string NickName { get; set; }
        public string Strength { get;set; }
    }

public class GameNotes

    {
        public int ID { get; set; }
        public string NameA { get; set; }
        public string NameB { get; set; }
        public DateTime Data { get; set; }
        public string R1 { get; set; }
        public string R2 { get; set; }
        public string R3 { get; set; }
        public string R4 { get; set; }
        public string R5 { get; set; }
        public string Place { get; set; }

    }

namespace DAL

{
    public class SingleBallDAL
    {
       
        public int InsertBallInfo(SingleBall sb)
        {
            string sql = "insert into SingleBall values"+
                "(@BallNum,@GetTeam,@WinTeamScore,@LoseTeamScore,@GetMemberNum,@HowGet,@LoseMemberNum)";
            SqlParameter[] pms = {
                                        new SqlParameter("@BallNum",sb.BallNum),
                                        new SqlParameter("@GetTeam",sb.GetTeam),
                                        new SqlParameter("@WinTeamScore",sb.WinTeamScore),
                                        new SqlParameter("@LoseTeamScore",sb.LoseTeamScore),
                                        new SqlParameter("@GetMemberNum",sb.GetMemberNum),
                                        new SqlParameter("@HowGet",sb.HowGet),
                                        new SqlParameter("@LoseMemberNum",sb.LoseMemberNum),
                                     };
            return SqlHelper.ExecuteNonQuery(sql, pms);
        }
    }
}

namespace VolleyballDal

{
   public class volleyDal
    {
       public DataTable SelectScore(string team)
       {
           string sql = "select * from VolleybalScore where Teams like '%"+team+"%'";
           DataTable dt = SqlHelper.ExecuteDataTable(sql);
           return dt;
       }
       public bool SelectScoreCount(string team)
       {
           string sql = "select count(*) from VolleybalScore where Teams like '%" + team + "%'";
           int count = (int)SqlHelper.ExecuteScalar(sql);
           return count>0;
         
       }
     
    }
}

namespace VolleyballBll

{
    public class volleyBll
    {
        private volleyDal dal = new volleyDal();
        public DataTable SelectScore(string team)
        {
            return dal.SelectScore(team);
        }
        public bool SelectScoreCount(string team)
        {
            return dal.SelectScoreCount(team);

        }

    }
}

namespace VolleyballDal

{
   public class volleyDal
    {
       public DataTable SelectScore(string team)
       {
           string sql = "select * from VolleybalScore where Teams like '%"+team+"%'";
           DataTable dt = SqlHelper.ExecuteDataTable(sql);
           return dt;
       }
       public bool SelectScoreCount(string team)
       {
           string sql = "select count(*) from VolleybalScore where Teams like '%" + team + "%'";
           int count = (int)SqlHelper.ExecuteScalar(sql);
           return count>0;
         
       }
     
    }
}

以上就是排球积分程序计分员的相关代码。

 

转载于:https://www.cnblogs.com/Apple0921/p/6568229.html

你可能感兴趣的文章
cmd批处理常用符号详解
查看>>
关于给构造函数传达参数方法
查看>>
mysql忘记密码时如何修改root用户密码
查看>>
STM32单片机使用注意事项
查看>>
在linux中出现there are stopped jobs 的解决方法
查看>>
获取浏览器版本信息
查看>>
SQLServer之删除视图
查看>>
js forEach跳出循环
查看>>
MyBatis---动态SQL
查看>>
快速创建一个 spring mvc 示例
查看>>
swing入门教程
查看>>
好莱坞十大导演排名及其代表作,你看过多少?
查看>>
JVM-class文件完全解析-类索引,父类索引和索引集合
查看>>
Loj #139
查看>>
StringBuffer是字符串缓冲区
查看>>
hihocoder1187 Divisors
查看>>
java入门
查看>>
Spring 整合 Redis
查看>>
Azure 托管镜像和非托管镜像对比
查看>>
SQLite3初探
查看>>