博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第二小组作业
阅读量:5277 次
发布时间:2019-06-14

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

开发流程如下:

·项目计划

   完成这个项目需要的时间:7天

·项目开发

  ·需求分析:

    ·作为一名排球计分员,我希望在观看比赛过程中能实时记录并显示比赛双方的每一次的得分情况,以便于我能更好的去记录比赛得分,并将每一次得分实时的显示给观众(精确到每一次得分)。

  ·设计文档

    ·由排球比赛用户故事的需求分析可知,此程序是用来准确记录比赛双方的每一次得分情况,并及时显示给观众,且显示比赛的胜负结果的。

  ·计划复审

    ·正在进一步的商讨中。

  ·代码规范

    ·根据Visual Studio 2010规范去写。

  ·具体设计

    ·UML活动图:

  

    ·UML类图:

 

 

  ·具体编码

    ·部分代码如下

//Model

    public class TuanDui

    {
        public int ID { get; set; }
        public string Name { get; set; }
    }

    public class JiFen

    {
        public int Num { get; set; }
        public string NameA { get; set; }
        public string NameB { get; set; }
        public int JuNum { get; set; }
        public int JuFenA { get; set; }
        public int JuFenB { get; set; }
        public int ZongA { get; set; }
        public int ZongB { get; set; }
    }

 

//volleyballDAL层

    public class volleyballDAL

    {

        public TuanDui SelectTuanDui()

        {
            string sql = "select * from tuandui";
            TuanDui td = null;
            using (SqlDataReader reader = SqlHelper.ExecuteReader(sql))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        td = new TuanDui();
                        td.ID = (int)reader["Id"];
                        td.Name = reader["Name"].ToString();
                    }
                }
            }
            return td;
        }

 

        public JiFen SelectJiFen()

        {
            string sql = "select * from JiFen";
            JiFen jf = null;
            using (SqlDataReader reader = SqlHelper.ExecuteReader(sql))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        jf = new JiFen();
                        jf.Num = (int)reader["Num"];
                        jf.NameA = reader["NameA"].ToString();
                        jf.NameB = reader["NameB"].ToString();
                        jf.JuNum = (int)reader["JuNum"];
                        jf.JuFenA = (int)reader["JuFenA"];
                        jf.JuFenB = (int)reader["JuFenA"];
                        jf.ZongA = (int)reader["ZongA"];
                        jf.ZongB = (int)reader["ZongB"];
                    }
                }
            }
            return jf ;

        } 

    }

  SqlHelper类

    public static class SqlHelper

    {
        //1.连接字符串
        private static readonly string constr = ConfigurationManager.ConnectionStrings["itcast"].ConnectionString;

        //4.执行返回多个值,多行

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

 

//volleyballBLL层

    public class volleyballBLL

    {
        private volleyballDAL dal = new volleyballDAL();

        public TuanDui GetSelectTuanDui()

        {
            return dal.SelectTuanDui();
        }

        public JiFen GetSelectJiFen()

        {
            return dal.SelectJiFen();
        }

    }

 

//volleyballUI层

    public partial class volleyball : System.Web.UI.Page

    {
        private JuFen jf = new JuFen();

        private volleyballDAL dal = new volleyballDAL();

        protected void Page_Load(object sender, EventArgs e)

        {
            if (!IsPostBack)
            {
               
            }
        }

        public void Add(string add)

        {
            jf.JuFenA = Convert.ToInt32(txtJuFenA.Text);
            jf.JuFenB = Convert.ToInt32(txtJuFenB.Text);
            jf.ZongA = Convert.ToInt32(txtZongA.Text);
            jf.ZongB = Convert.ToInt32(txtZongB.Text);
            jf.Num = jf.ZongA = jf.ZongB;
            if(add=="A1")
            {
                jf.JuFenA += 1;
                txtJuFenA.Text = jf.JuFenA.ToString();
                PanDuan();
            }
            else if(add=="B1")
            {
                jf.JuFenB += 1;
                txtJuFenB.Text=jf.JuFenB .ToString();
                PanDuan();
            }
        }

        public void Jian(string sub)

        {
            jf.JuFenA = Convert.ToInt32(txtJuFenA.Text);
            jf.JuFenB = Convert.ToInt32(txtJuFenB.Text);
            jf.ZongA = Convert.ToInt32(txtZongA.Text);
            jf.ZongB = Convert.ToInt32(txtZongB.Text);
            jf.Num = jf.ZongA +jf.ZongB;
            if(sub=="A2")
            {
                if (Convert.ToInt32(txtJuFenA.Text) == 0)
                {
                    jf.JuFenA =0;
                    txtJuFenA.Text = jf.JuFenA.ToString();
                }
                else
                {
                    jf.JuFenA -= 1;
                    txtJuFenA.Text = jf.JuFenA.ToString();
                }

            }

            else if(sub == "B2")
            {
                if (Convert.ToInt32(txtJuFenB.Text) == 0)
                {
                    jf.JuFenB = 0;
                    txtJuFenB.Text = jf.JuFenB.ToString();
                }
                else
                {
                    jf.JuFenB -= 1;
                    txtJuFenB.Text = jf.JuFenB.ToString();
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)

        {
            string add="A1";
            Add(add);
        }

        protected void Button3_Click(object sender, EventArgs e)

        {
            string sub = "A2";
            Jian(sub);
        }

        protected void Button2_Click(object sender, EventArgs e)

        {
            string add = "B1";
            Add(add);
        }

        protected void Button4_Click(object sender, EventArgs e)

        {
            string sub = "B2";
            Jian(sub);
        }

        public void PanDuan()

        {
            if (Convert.ToInt32(txtJuFenA.Text) == 25)
            {
                jf.ZongA += 1;
                txtZongA.Text = jf.ZongA.ToString();
                txtJuFenXianShi.Text += "第" + (jf.JuNum) + "局:" + Convert.ToInt32(txtJuFenA.Text) + ":" + Convert.ToInt32(txtJuFenB.Text) + "\r\n";
            }
            else if (Convert.ToInt32(txtJuFenB.Text) == 25)
            {
                jf.ZongB += 1;
                txtZongB.Text = jf.ZongB.ToString();
                txtJuFenXianShi.Text += "第" + (jf.JuNum) + "局:" + Convert.ToInt32(txtJuFenA.Text) + ":" + Convert.ToInt32(txtJuFenB.Text) + "\r\n";
            }
        }

    }

界面效果如下:

数据库中数据表结构如下:

转载于:https://www.cnblogs.com/shangguanlei/p/6219608.html

你可能感兴趣的文章
composer 报 zlib_decode(): data error
查看>>
hdu 3938 并查集
查看>>
《深入分析Java Web技术内幕》读书笔记之JVM内存管理
查看>>
python之GIL release (I/O open(file) socket time.sleep)
查看>>
软件开发与模型
查看>>
161017、SQL必备知识点
查看>>
kill新号专题
查看>>
MVC学习系列——Model验证扩展
查看>>
mysqladmin 修改和 初始化密码
查看>>
字符串
查看>>
vue2.x directive - 限制input只能输入正整数
查看>>
实现MyLinkedList类深入理解LinkedList
查看>>
自定义返回模型
查看>>
C#.NET 大型通用信息化系统集成快速开发平台 4.1 版本 - 客户端多网络支持
查看>>
HDU 4122
查看>>
Suite3.4.7和Keil u3自带fx2.h、fx2regs.h文件的异同
查看>>
打飞机游戏【来源于Crossin的编程教室 http://chuansong.me/account/crossincode 】
查看>>
[LeetCode] Merge Intervals
查看>>
【翻译自mos文章】当点击完 finishbutton后,dbca 或者dbua hang住
查看>>
Linux编程简介——gcc
查看>>