计划
估计此程序需要1-2周
- 开发
- 需求分析
用户故事:作为一个排球计分人员,我希望知道每场比赛队伍得分和积分情况,以便计分,让相关人员给每队进行排名。
从分析用例故事可以知道完成此程序需要这两项任务:选择任务和查询队伍的比分和积分情况。
.设计复审:
将编写的程序进行生成,进行设计复审。看看是否生成错误,如果错误进行修改。
.代码规范:
利用VS对该程序进行代码规范。
代码如下:
namespace DAL
{
public static class SqlHelper
{
private static readonly string constr =
ConfigurationManager.ConnectionStrings["MyPC"].ConnectionString;
ExecuteNonQuery() 方法
ExecuteScalar() 方法
ExecuteReader() 方法
ExecuteDataTable() 方法
public static int ExecuteNonQuery(string sql, params SqlParameter[] pm
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;
namespace Model
{
public class Teams
{
public int ID { get; set; }
public string TName { get; set; }
public int WinCount { get; set; }
public string FCount { get; set; }
public string JiFen { get; set; }
public string WinJuCount { get; set; }
public string FJuCount { get; set; }
public string _3to0 { get; set; }
public string _3to1 { get; set; }
public string _3to2 { get; set; }
public string _2to3 { get; set; }
public string _1to3 { get; set; }
public string _0to3 { get; set; }
}
namespace Model
{
public class SingleBall
{
public int BallNum { get; set; }
public string GetTeam { get; set; }
public int WinTeamScore { get; set; }
public int LoseTeamScore { get; set; }
public int GetMemberNum { get; set; }
public string HowGet { get; set; }
public int LoseMemberNum { get; set; }
}
}using System.Text;
using System.Collections;
using System.Data.SqlClient;
using Model;
namespace DAL
{
public class SingleBallDAL
{
public int InsertBallInfo(SingleBall sb)
{
string sql = "insert into SingleBall values"+
"(@BallNum,@GetTeam,@WinTeamScore,@LoseTeamScore,@GetMemberNum,@HowGet,@LoseMemberNum)";
SqlParameter[] pms = {
new SqlParameter("@BallNum",sb.BallNum),
new SqlParameter("@GetTeam",sb.GetTeam),
new SqlParameter("@WinTeamScore",sb.WinTeamScore),
new SqlParameter("@LoseTeamScore",sb.LoseTeamScore),
new SqlParameter("@GetMemberNum",sb.GetMemberNum),
new SqlParameter("@HowGet",sb.HowGet),
new SqlParameter("@LoseMemberNum",sb.LoseMemberNum),
};
return SqlHelper.ExecuteNonQuery(sql, pms);
}
}
}
using Model;
using System.Data.SqlClient;
namespace DAL
{
public class MembersDAL
{
public int InsertMemberDal(Members m)
{
for (int i = 0; i < 1; i++)
{
string sqlIsRepeat = "select MName from Members where Number=" +
m.Number + " and TName=" + m.TName;
SqlDataReader reader = SqlHelper.ExecuteReader(
public List<string> GetTeamBName(string tname,string mname=null)
{
string sql = "select distinct TName from Members where TName not in(@tname)";
List<string> teamBList = null;
using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@tname",tname)))
{
if (reader.HasRows)
{
teamBList = new List<string>();
while (reader.Read())
{
teamBList.Add(reader[0].ToString());
}
}
}
return teamBList;
}
public List<string> GetTeamMembers(string tname, string mname = null)
{
string sql = "select MName from Members where TName='" + tname + "'";
List<string> teamBList = null;
using (SqlDataReader reader = SqlHelper.ExecuteReader(sql))
{
if (reader.HasRows)
{
teamBList = new List<string>();
while (reader.Read())
{
teamBList.Add(reader[0].ToString());
}
}
}
return teamBList;
}
}
}namespace BLL
{
public class SingleBallBll
{
SingleBallDAL sbdal = new SingleBallDAL();
public bool SuccessInsertSingleBall(SingleBall sb)
{
return sbdal.InsertBallInfo(sb) ==1;
}
}
}
namespace BLL
{
public class MembersBll
MembersDAL membersdal = new MembersDAL();
public bool InsertMembersBll(Members m)
{
return membersdal.InsertMemberDal(m) > 0;
}
public List<string> GetTeamBNameBll(string s)
{
List<string> teamBList = membersdal.GetTeamBName(s);
return teamBList;
}
public List<string> GetTeamMembers(string tname, string mname = null)
{
List<string> teamMemberList = membersdal.GetTeamMembers(tname,mname);
return teamMemberList;
}
}
}using System.Data;
using DAL;
namespace BLL
{
public class GetOtherDataBll
{
GetOtherDataDAL getdata = new GetOtherDataDAL();
public DataTable SelectInfoBll(string team, string member)
{
return getdata.SelectInfoDal(team,member);
}
}
}
namespace BLL
{
public class GetOtherDataBll
{
GetOtherDataDAL getdata = new GetOtherDataDAL();
public DataTable SelectInfoBll(string team, string member)
{
return getdata.SelectInfoDal(team,member);
}
}
}
.代码复审:30min
.测试(自测、修改代码、提交代码):40min
.报告
①测试报告:30min
②计算工作量:20min
③事后总结,并提出过程改进计划:2h