第十六周个人作业
PSP
计划
五天左右
需求分析
作为一个观众,我希望了解某一场比赛的比分,以便了解赛况
设计文档
设计复审:暂无
代码规范
Visual Studio 2010,Sql Server2008
具体设计
具体编码
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.Data.SqlClient;
using Model;
namespace 排球
{
public partial class Spectator : Form
{
public Spectator()
{
InitializeComponent();
}
private void Spectator_Load(object sender, EventArgs e)
{
groupBox1.Visible = false;
}
private void btnSelect_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(comboBox1.Text))
{
groupBox1.Visible = true;
//查询队伍
string sql = "select Team from Team where tName='%"+comboBox1.SelectedText+"%'";
SqlDataReader read = SqlHelper.ExecuteReader(sql,null);
if(read.Read())
{
int id = read.GetInt32(2);
//查询局分
string sql1 = "select * from JuFen where tId='%"+id+"%'";
SqlDataReader reader = SqlHelper.ExecuteReader(sql1, null);
if (reader.Read())
{
txtAfirst.Text = reader.GetString(2);
txtASec.Text = reader.GetString(2);
txtAThi.Text = reader.GetString(2);
txtAfou.Text = reader.GetString(2);
txtAfive.Text = reader.GetString(2);
txtBfirst.Text = reader.GetString(3);
txtBSec.Text = reader.GetString(3);
txtBThi.Text = reader.GetString(3);
txtBfou.Text = reader.GetString(3);
txtBfive.Text = reader.GetString(3);
}
}
}
else
{
MessageBox.Show("请输入要查询的比赛队伍!");
groupBox1.Visible = false;
}
}
private void labFirst_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
first a = new first();
a.Show();
}
private void comboBox1_TextChanged(object sender, EventArgs e)
{
//将查询到的关于输入队伍的比赛添加到comboBox1中
comboBox1.DroppedDown = true;
string sql = "select tName from Team where tName like '%"+comboBox1.Text.Trim()+"%'";
SqlDataReader read = SqlHelper.ExecuteReader(sql, null);
if (read.Read())
{
comboBox1.Items.Add(read.HasRows);
}
}
private void labSecond_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Two second = new Two();
second.Show();
}
}
}
代码复审
暂无
测试
由于数据库连接时临时出现问题,所以具体场分运行时出现了点问题
测试报告
查询时,comboBox的值添加时并不能准确添加
事后总结:
运行时还有部分错误,需要继续完善