个人作业

题目:排球比赛计分程序

 

项目进程总结:

计划  
估计要用多长时间 3d
开发  
需求分析 1h
生成设计文档 1h
设计复审  40min
代码规范 20min
具体设计 40min
具体编码 2h
代码复审 1h
测试 50min
测试报告 10min
计算工作量 25min
总结

40min

 

 采用三层架构方式做

 比赛分数结果显示如下:

部分程序代码如下:

 

<connectionStrings>
<add name="paiqiu" connectionString="server=.; database=paiqiu; integrated security=true;"/>
</connectionStrings>

 

private static readonly string constr = ConfigurationManager.ConnectionStrings["paiqiu"].ConnectionString;
//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;
}
}
}

 

//UI层
private void Form1_Load(object sender, EventArgs e)
{
//将查询到的数据加载到控件中,显示在页面中
txtNameA.Text = pq.NameA;
txtNameB.Text = pq.NameB;
txtFenShuA.Text = pq.FenShuA;
txtFenShuB.Text = pq.FenShuB;
txtOneA.Text = pq.OneA;
txtOneB.Text = pq.OneB;
txtTwoA.Text = pq.TwoA;
txtTwoB.Text = pq.TwoB;
txtThreeA.Text = pq.ThreeA;
txtThreeB.Text = pq.ThreeB;
txtFourA.Text = pq.FourA;
txtFourB.Text = pq.FourB;
txtFiveA.Text = pq.FiveA;
txtFiveB.Text = pq.FiveB;
txtJieGuo.Text = pq.JieGuo;
}

 

//Model层
public class paiqiu
{
public int ID { get; set; }
public string NameA { get; set; }
public string NameB { get; set; }
public int FenShuA { get; set; }
public int FenShuB { get; set; }
public int OneA { get; set; }
public int OneB { get; set; }
public int TwoA { get; set; }
public int TwoB { get; set; }
public int ThreeA { get; set; }
public int ThreeA { get; set; }
public int FourB { get; set; }
public int FourA { get; set; }
public int FiveB { get; set; }
public int FiveB { get; set; }
public string JieGuo { get; set; }
}

 

//Dal层
public paiqiu Selectpaiqiu(int Id)
{
string sql = "select * from Student where ID=@ID";
paiqiu pq = null;
using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@ID", Id)))
{
if (reader.HasRows)
{
if (reader.Read())
{
//在数据库中查询相对应的数据
pq = new paiqiu();
pq.ID = (int)reader["Id"];
pq.NameA = reader["NameA"].ToString();
pq.NameB = reader["NameB"].ToString();
pq.FenShuA = (int)reader["FenShuA"];
pq.FenShuB = (int)reader["FenShuB"];
pq.OneA = (int)reader["OneA"];
pq.OneB = (int)reader["OneB"];
pq.TwoA = (int)reader["TwoA"];
pq.TwoB = (int)reader["TwoB"];
pq.ThreeA = (int)reader["ThreeA"];
pq.ThreeB = (int)reader["ThreeB"];
pq.FourA = (int)reader["FourA"];
pq.FourB = (int)reader["FourB"];
pq.FiveA = (int)reader["FiveA"];
pq.FiveB = (int)reader["FiveB"];
pq.JieGuo = reader["JieGuo"].ToString();
}
}

}
return pq;
}

//BLL层
public paiqiu GetSelectpaiqiu(int Id)
{
return Selectpaiqiu(Id);
}

 

posted @ 2016-12-18 21:06  闫中磊  阅读(152)  评论(1编辑  收藏  举报