计划:估计这个任务需要一周时间
需求分析:作为一名排球教练助手,我需要了解每场每位队员的技术动作,每场比赛每位队员的得分情况,以便教练更好的了解到每位队员的发挥情况和特长。
设计文档:用户进入此界面可以查看队伍比赛成绩以及比赛结果。
设计复审:与同学一起审核
具体编码
namespace 排球
{
public partial class ZhouShou : Form
{
public ZhouShou()
{
InitializeComponent();
}
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
{
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;
}
}
private void ZhouShou_Load(object sender, EventArgs e)
{
groupBox1.Visible = true;
groupBox2.Visible = false;
}
int i = 0;
private void button1_Click(object sender, EventArgs e)
{
i++;
txtFen.Text = lblName.Text + button1.Text + " " + i;
//txtFirst.Text = label1.Text + ":" + button1.Text + " " + i;
}
int FQ = 0;
private void btnFaQiu_Click(object sender, EventArgs e)
{
FQ++;
txtFen.AppendText(lblName.Text+btnFaQiu.Text+" "+FQ);
//FQ++;
//txtZhuGong11.Text = lblZhuGong1.Text + btnFaQiu.Text + " " + FQ;
//txtZhuGong11.Text.Replace(FQ.ToString(), lblZhuGong1.Text + btnFaQiu.Text + " " + FQ);
//txtZhuGong11.AppendText(lblZhuGong1.Text + btnFaQiu.Text + " " + FQ);
}
int KQ=0;
private void btnKouQiu_Click(object sender, EventArgs e)
{
KQ++;
txtFen.AppendText(lblName.Text + btnKouQiu.Text + " " + KQ);
//txtZhuGong11.AppendText(lblZhuGong1.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)
{
//创建一个文件流,用以写入或者创建一个StreamWriter
FileStream fs = new FileStream("C:\\file.txt", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.Flush(); // 使用StreamWriter来往文件中写入内容
m_streamWriter.BaseStream.Seek(0, SeekOrigin.Begin);
// 把richTextBox1中的内容写入文件
m_streamWriter.Write(txtFen.Text);
//关闭此文件 m_streamWriter.Flush ( ) ;
m_streamWriter.Close();
MessageBox.Show("保存成功!");
groupBox2.Visible = false;
groupBox1.Visible = true;
}
测试
总结:程序运行过程中还有部分问题,有待完善,也没有运用三层架构。还需要再接再厉。