計劃:估計這個任務需要一周時間
需求分析:作為一名排球教練助手,我需要了解每場每位隊員的技術動作,每場比賽每位隊員的得分情況,以便教練更好的了解到每位隊員的發揮情況和特長。
設計文檔:用戶進入此界面可以查看隊伍比賽成績以及比賽結果。
設計復審:與同學一起審核
具體編碼
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;
}
測試
總結:程序運行過程中還有部分問題,有待完善,也沒有運用三層架構。還需要再接再厲。
?