第二次PSP

1、计划

    五天左右

2、需求分析

     作为一个排球教练的助手,我需要统计本队每名球员在球场各个技术动作的发挥情况,每个队员的技术习惯,以便教练员即时指导比赛,并作为以后球员训练的依据

3、生成设计文档

      输入本次比赛人员名单,然后根据比赛情况统计队员的技术动作、习惯,最后保存为txt文档

4、设计复审

        和同学讨教,最后精简了一点设计

5、代码规范

     Visual Studio 2010

6、具体设计

7、具体编码

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Management;

using System.IO;

 

namespace 排球

{

    public partial class ZhouShou : Form

    {

        public ZhouShou()

        {

            InitializeComponent();

        }            

        }

 

        private void ZhouShou_Load(object sender, EventArgs e)

        {

           //加载时首先显示输入队员名称的groupBox

            groupBox1.Visible = true;

            groupBox2.Visible = false;

        }

      //单击确定按钮时,隐藏输入界面,显示统计界面   

 private void btnOK_Click(object sender, EventArgs e)

        {

            string ZhuGong111 = txtZhuGong1.Text;

            string ZhuGong222 = txtZhuGong2.Text;

            string FuGong111 = txtFuGong1.Text;

            string FuGong222 = txtFuGong2.Text;

            string JieYing111 = txtJieYing.Text;

            string ErChuan111 = txtErChuan.Text;

            string ZiYouRen111 = txtZiYouRen.Text;

                //判断文本框是否都有输入队名,,如果其中一个文本框为空就提示错误信息

            if (string.IsNullOrEmpty(ZhuGong111)) { MessageBox.Show("请输入本场比赛的主攻手一"); }

            else if (string.IsNullOrEmpty(FuGong111)) { MessageBox.Show("请输入本场比赛的副攻手一"); }

            else if (string.IsNullOrEmpty(ZhuGong222)) { MessageBox.Show("请输入本场比赛的主攻手二"); }

            else if (string.IsNullOrEmpty(FuGong222)) { MessageBox.Show("请输入本场比赛的副攻手二"); }

            else if (string.IsNullOrEmpty(JieYing111)) { MessageBox.Show("请输入本场比赛的接应"); }

            else if (string.IsNullOrEmpty(ErChuan111)) { MessageBox.Show("请输入本场比赛的二传"); }

            else if (string.IsNullOrEmpty(ZiYouRen111)) { MessageBox.Show("请输入本场比赛的自由人"); }

            else

            {//如果都输入就显示groupBox2,隐藏groupBox1

                groupBox1.Visible = false;

                groupBox2.Visible = true;

                linkZhuGong1.Text = ZhuGong1.Text + txtZhuGong1.Text;

                linkFuGong1.Text=FuGong1.Text+txtFuGong1.Text;

                linkZhuGong2.Text = ZhuGong2.Text + txtZhuGong2.Text;

                linkFuGong2.Text = FuGong2.Text + txtFuGong2.Text;

                linkJieYing.Text = JieYing.Text + txtJieYing.Text;

                linkErChuan.Text = ErChuan.Text + txtErChuan.Text;

                linkZiYouRen.Text = ZiYouRen.Text + txtZiYouRen.Text;

            }

 //单击任一个linklabel时,label就显示为linklabel 的值,    

 private void linkFuGong1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            lblName.Text = linkFuGong1.Text;

        }

 

        private void linkZhuGong2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            lblName.Text = linkZhuGong2.Text;

        }

 

       private void linkZhuGong1_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)

        {

            lblName.Text = linkZhuGong1.Text;

        }

        private void linkFuGong2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            lblName.Text = linkFuGong2.Text;

        }

 

        private void linkJieYing_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            lblName.Text = linkJieYing.Text;

        }

 

        private void linkErChuan_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            lblName.Text = linkErChuan.Text;

        }

 

        private void linkZiYouRen_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

        {

            lblName.Text = linkZiYouRen.Text;

        }

//当单击相应的按钮时,就将所选队员名字和得分或失误次数添加到defen文本框内      

        int i = 0;

        private void button1_Click(object sender, EventArgs e)

        {

             i++;

             txtFen.AppendText = lblName.Text + button1.Text + " " + i;

        }

        int FQ = 0;

        private void btnFaQiu_Click(object sender, EventArgs e)

        {

            FQ++;

            txtFen.AppendText(lblName.Text+btnFaQiu.Text+" "+FQ);        }

        int KQ=0;

        private void btnKouQiu_Click(object sender, EventArgs e)

        {

            KQ++;

            txtFen.AppendText(lblName.Text + btnKouQiu.Text + " " + KQ);

        }

        int CW=0;

        private void btnChouWang_Click(object sender, EventArgs e)

        {

            CW++;

            txtFen.AppendText(lblName.Text + btnChouWang.Text + " " + CW);

        }

        int DQ = 0;

        private void btnDiaoQiu_Click(object sender, EventArgs e)

        {

            DQ++;

            txtFen.AppendText(lblName.Text + btnDiaoQiu.Text + " " + DQ);

        }

        int LWCJ = 0;

        private void btnLWChuJie_Click(object sender, EventArgs e)

        {

            LWCJ++;

            txtFen.AppendText(lblName.Text + btnLWChuJie.Text + " " + LWCJ);

        }

        int FQSW = 0;

        private void btnFaQiuShiWu_Click(object sender, EventArgs e)

        {

            FQSW++;

            txtFen.AppendText(lblName.Text + btnFaQiuShiWu.Text + " " + FQSW);

        }

        int KQCJ = 0;

        private void btnKouQiuChuJie_Click(object sender, EventArgs e)

        {

            KQCJ++;

            txtFen.AppendText(lblName.Text + btnKouQiuChuJie.Text + " " + KQCJ);

        }

//保存

        private void lastOK_Click(object sender, EventArgs e)

        {

            FileStream fs = new FileStream("C:\\file.txt", FileMode.OpenOrCreate, FileAccess.Write);

            StreamWriter m_streamWriter = new StreamWriter(fs);

            m_streamWriter.Flush();  

            m_streamWriter.BaseStream.Seek(0, SeekOrigin.Begin);

            m_streamWriter.Write(txtFen.Text);

            m_streamWriter.Close();

            MessageBox.Show("保存成功!");

            groupBox2.Visible = false;

            groupBox1.Visible = true;

        }

    }

}

 

8、代码复审
      功能基本实现,无错 

9、测试
       
文本框值为空时弹出对话框:

输入完毕点击确定后:

 

保存时:

 

 

10、测试报告
     能实现的功能基本已被实现

11、计算工作量
        比预算少了一天

12、事后总结 

   C#学的不是很好,很多东西还需要自己去扩展,比如,就目前而言,在输入队员名称时,需要限制文本框只能输入中文我还是无法实现

posted @ 2017-01-06 14:15  菜葉  阅读(180)  评论(0编辑  收藏  举报