首页 > 代码库 > 记分员计分程序
记分员计分程序
开发流程如下:
·项目计划
完成这个项目需要的时间:3~5天
·项目开发
·需求分析
.用户故事:
·作为一名现场记分员,我希望详细记录比赛现场比分增长情况,以便观众及运动员、教练员及时掌握比赛状况。(满意条件:每一次比分的改变,都要形成一条记录)。
·生成设计文档
·由排球比赛用户故事的需求分析可知,此程序是用来统计各个队伍的总比分和队伍中每个球员的详细得分情况的,并针对每一次比分的改变,都要形成一条记录。
·计划复审
·正在进一步的商讨中。
·代码规范
·根据Visual Studio 2010规范去写。
·具体设计
·URL活动图如下:
·URL活动图如下:
·具体编码
//SqlHelper类
public static class SqlHelper
{
//1.连接字符串
private static readonly string constr = ConfigurationManager.ConnectionStrings["itcast"].ConnectionString;
//2.执行增删改
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();
}
}
}
//3.执行返回单个值(查)
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();
}
}
}
//4.执行返回多个值,多行
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;
}
}
}
//5.执行返回一张表
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;
}
}
//Model实体模型
public class TuanDui
{
public int ID { get; set; }
public string Name { get; set; }
}
public class JiFen
{
public int Num { get; set; }
public string NameA { get; set; }
public string NameB { get; set; }
public int JuNum { get; set; }
public int JuFenA { get; set; }
public int JuFenB { get; set; }
public int ZongA { get; set; }
public int ZongB { get; set; }
}
//volleyballDAL层
public class volleyballDAL
{
public TuanDui SelectTuanDui()
{
string sql = "select * from tuandui";
TuanDui td = null;
using (SqlDataReader reader = SqlHelper.ExecuteReader(sql))
{
if (reader.HasRows)
{
while (reader.Read())
{
td = new TuanDui();
td.ID = (int)reader["Id"];
td.Name = reader["Name"].ToString();
}
}
}
return td;
}
public JiFen SelectJiFen()
{
string sql = "select * from JiFen";
JiFen jf = null;
using (SqlDataReader reader = SqlHelper.ExecuteReader(sql))
{
if (reader.HasRows)
{
while (reader.Read())
{
jf = new JiFen();
jf.Num = (int)reader["Num"];
jf.NameA = reader["NameA"].ToString();
jf.NameB = reader["NameB"].ToString();
jf.JuNum = (int)reader["JuNum"];
jf.JuFenA = (int)reader["JuFenA"];
jf.JuFenB = (int)reader["JuFenA"];
jf.ZongA = (int)reader["ZongA"];
jf.ZongB = (int)reader["ZongB"];
}
}
}
return jf ;
}
}
//volleyballBLL层
public class volleyballBLL
{
private volleyballDAL dal = new volleyballDAL();
public TuanDui GetSelectTuanDui()
{
return dal.SelectTuanDui();
}
public JiFen GetSelectJiFen()
{
return dal.SelectJiFen();
}
}
//volleyballUI层
public partial class volleyball : System.Web.UI.Page
{
private JuFen jf = new JuFen();
private volleyballDAL dal = new volleyballDAL();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
public void Add(string add)
{
jf.JuFenA = Convert.ToInt32(txtJuFenA.Text);
jf.JuFenB = Convert.ToInt32(txtJuFenB.Text);
jf.ZongA = Convert.ToInt32(txtZongA.Text);
jf.ZongB = Convert.ToInt32(txtZongB.Text);
jf.Num = jf.ZongA = jf.ZongB;
if(add=="A1")
{
jf.JuFenA += 1;
txtJuFenA.Text = jf.JuFenA.ToString();
PanDuan();
}
else if(add=="B1")
{
jf.JuFenB += 1;
txtJuFenB.Text=jf.JuFenB .ToString();
PanDuan();
}
}
public void Jian(string sub)
{
jf.JuFenA = Convert.ToInt32(txtJuFenA.Text);
jf.JuFenB = Convert.ToInt32(txtJuFenB.Text);
jf.ZongA = Convert.ToInt32(txtZongA.Text);
jf.ZongB = Convert.ToInt32(txtZongB.Text);
jf.Num = jf.ZongA +jf.ZongB;
if(sub=="A2")
{
if (Convert.ToInt32(txtJuFenA.Text) == 0)
{
jf.JuFenA =0;
txtJuFenA.Text = jf.JuFenA.ToString();
}
else
{
jf.JuFenA -= 1;
txtJuFenA.Text = jf.JuFenA.ToString();
}
}
else if(sub == "B2")
{
if (Convert.ToInt32(txtJuFenB.Text) == 0)
{
jf.JuFenB = 0;
txtJuFenB.Text = jf.JuFenB.ToString();
}
else
{
jf.JuFenB -= 1;
txtJuFenB.Text = jf.JuFenB.ToString();
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string add="A1";
Add(add);
}
protected void Button3_Click(object sender, EventArgs e)
{
string sub = "A2";
Jian(sub);
}
protected void Button2_Click(object sender, EventArgs e)
{
string add = "B1";
Add(add);
}
protected void Button4_Click(object sender, EventArgs e)
{
string sub = "B2";
Jian(sub);
}
.界面显示
·代码复审
.正在进一步复审中。
·测试
.准备放在下一步中进行。
.报告
.测试报告
.测试结束后再写。
.计算工作量
.事后总结,并提出过程改进计划
.整个项目费时费力费心血,但收获不少.会进一步改进此程序,争取做到更加完善.
记分员计分程序