排球计分员用户故事
计划
。估计项目总用时:7天
开发
。需求分析:作为一名现场计分员,我希望详细记录比赛现场比分增长情况,以便观众及运动员、教练员即及时掌握 比赛状况(每次比分形成一条记录)
。生成设计文档:活动图
。设计复审:通过
。代码规范:Visual Studio 2010
。具体设计:
。具体编码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
/// <summary>
///SqlHelper 的摘要说明
/// </summary>
public static class SqlHelper
{
//public SqlHelper()
//{
//
//TODO: 在此处添加构造函数逻辑
//
//private static readonly string constr = ConfigurationManager.ConnectionStrings["connectionStr"].ConnectionString;
private static readonly string constr = ConfigurationManager.ConnectionStrings["itcast"].ConnectionString;
public static int ExecuteNonQuery(string sql,params SqlParameter[] pms)
{
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(sql, con))
{
if (pms != null)
{
cmd.Parameters.AddRange(pms);
}
con.Open();
return cmd.ExecuteNonQuery();
}
}
}
public static object ExecuteScalar(string sql,params SqlParameter[] pms)
{
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(sql, con))
{
if (pms != null)
{
cmd.Parameters.AddRange(pms);
}
con.Open();
return cmd.ExecuteScalar();
}
}
}
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;
}
}
}
public static DataTable ExecuteDataTable(string sql, params SqlParameter[] pms)
{
DataTable dt = new DataTable();
using (SqlDataAdapter adapter = new SqlDataAdapter(sql, constr))
{
if (pms != null)
{
adapter.SelectCommand.Parameters.AddRange(pms);
}
adapter.Fill(dt);
}
return dt;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Model;
namespace sceneJiFenDAL
{
public class BeginDal
{
public int Insert(Fen fen)
{
string sql = "insert into Fen values(@TeamA,@ADeFen,@TeamAFenName,@TeamB,@BDeFen,@TeamBFenName)";
SqlParameter[] paras = new SqlParameter[]{
new SqlParameter("@TeamA",fen.TeamA),
new SqlParameter("@TeamAFenName",fen.TeamAFenName),
new SqlParameter("@TeamA",fen.TeamB),
new SqlParameter("@TeamAFenName",fen.TeamBFenName)
};
int count = SqlHelper.ExecuteNonQuery(sql,paras);
return count;
}
public List<Fen> SelectAllFen()
{
string sql = "select * from Fen";
List<Fen> fenlist = new List<Fen>();
using (SqlDataReader reader = SqlHelper.ExecuteReader(sql))
{
if(reader.HasRows)
{
while (reader.Read())
{
Fen fen = new Fen();
fen.TeamA = reader.GetString(1);
fen.ADeFen = reader.GetString(2);
fen.TeamAFenName = reader.GetString(3);
fen.TeamB = reader.GetString(4);
fen.BDeFen = reader.GetString(5);
fen.TeamBFenName = reader.GetString(6);
fenlist.Add(fen);
}
}
}
return fenlist;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using sceneJiFenDAL;
namespace sceneJiFenBLL
{
public class FenBLL
{
BeginDal dal = new BeginDal();
public bool Insert(Fen fen)
{
return dal.Insert(fen) > 0;
}
public List<Fen> GetAllFen()
{
return dal.SelectAllFen().Count > 0 ? dal.SelectAllFen() : null;
}
}
}
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 Model;
using sceneJiFenBLL;
namespace sceneJiFen
{
public partial class One : Form
{
public One()
{
InitializeComponent();
}
int Adefen=0;
int Bdefen = 0;
private FenBLL bll = new FenBLL();
private void button1_Click(object sender, EventArgs e)
{
Adefen++;
Fen fen=new Fen();
fen.TeamA=label1.Text;
fen.TeamB = label2.Text;
fen.ADeFen = Adefen.ToString();
if (radioBtn2.Checked == true)
{
fen.TeamAFenName = radioBtn2.Text;
}
if (radioButton2.Checked == true)
{
fen.TeamAFenName = radioButton2.Text;
}
if (radioButton3.Checked == true)
{
fen.TeamAFenName = radioButton3.Text;
}
if (radioButton14.Checked == true)
{
fen.TeamAFenName = radioButton14.Text;
}
if (radioButton6.Checked == true)
{
fen.TeamAFenName = radioButton6.Text;
}
if (radioButton5.Checked == true)
{
fen.TeamAFenName = radioButton5.Text;
}
if (radioButton4.Checked == true)
{
fen.TeamAFenName = radioButton4.Text;
}
if (radioButton13.Checked == true)
{
fen.TeamAFenName = radioButton13.Text;
}
//bool isOK = bll.Insert(fen);
//if(isOK)
//{
// MessageBox.Show("hhhhhh");
//}
}
private void button2_Click(object sender, EventArgs e)
{
Bdefen++;
Fen fen = new Fen();
fen.TeamA = label1.Text;
fen.TeamB = label2.Text;
fen.BDeFen = Bdefen.ToString();
if (radioButton12.Checked == true)
{
fen.TeamAFenName = radioButton12.Text;
}
if (radioButton11.Checked == true)
{
fen.TeamAFenName = radioButton11.Text;
}
if (radioButton10.Checked == true)
{
fen.TeamAFenName = radioButton10.Text;
}
if (radioButton9.Checked == true)
{
fen.TeamAFenName = radioButton9.Text;
}
if (radioButton8.Checked == true)
{
fen.TeamAFenName = radioButton8.Text;
}
if (radioButton7.Checked == true)
{
fen.TeamAFenName = radioButton7.Text;
}
}
private void One_Load(object sender, EventArgs e)
{
}
}
}
。代码复审:通过
。测试:通过
报告
。测试报告:尚未完善
。计算工作量:个人而言,工作量庞大
。事后总结,并提出过程改进计划:三层架构没有完全掌握,做这个用户故事有点难度