开发流程如下:
项目计划
完成这个项目需要的时间:5-7天
项目开发
需求分析:
作为一名排球赛事组织者,我希望能够根据比赛查询每场比赛的结果,以便于确定每支球队的比赛名次。
设计文档
由排球比赛用户故事的需求分析可知,此程序是用来统计各个队伍的比分和积分情况,并加以排名。
计划复审
目前在进行中
代码规范
根据Visual Studio 2010规范去写。
具体设计
URL活动图如下:
类图:
数据表:
界面设计:
代码(部分)如下:
namespace 排球计分程序
{
public partial class Form1 : Form
{
Action action = new Action();
public void INSERT()
{
Model M = new Model();
M.IDA = textBox1.Text.Trim().ToString();
M.IDB = textBox2.Text.Trim().ToString();
M.ONE = txtCount1.Text.Trim().Substring(4, 4);
M.TWO = txtCount2.Text.Trim().Substring(4, 4);
M.THREE = txtCount3.Text.Trim().Substring(4, 4);
if (txtCount4.Text =="")
{
M.FOUR = null;
}
else
{
M.FOUR = txtCount4.Text.Trim().Substring(4, 4);
}
if (txtCount5.Text =="")
{
M.FIVE= null;
}
else
{
M.FIVE = txtCount5.Text.Trim().Substring(4, 4);
}
M.SUM = txtH1.Text.ToString() + ":" + txtL1.Text.ToString();
M.Detail = sb.ToString();
action.InsertPK(M);
}
public Form1()
{
InitializeComponent();
}
int i = 1;
StringBuilder sb = new StringBuilder();
private void btnH_Click(object sender, EventArgs e)
{
int H = Convert.ToInt32(txtH.Text);
int L = Convert.ToInt32(txtL.Text);
int H1 = Convert.ToInt32(txtH1.Text);
int L1 = Convert.ToInt32(txtL1.Text);
txtH.Text = (H+1).ToString();
sb.AppendFormat("第{0}个球 {1}:{2}
",H+1,H+1,L);
if (H >= 24 && (H - L) > 0)
{
txtH1.Text = (Convert.ToInt32(txtH1.Text) + 1).ToString();
if((H1+L1)==0){
txtCount1.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 1)
{
txtCount2.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 2)
{
txtCount3.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 3)
{
txtCount4.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 4)
{
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
txtH.Text = "0";
txtL.Text = "0";
if (txtH1.Text == "3")
{
MessageBox.Show(textBox1.Text+"胜利");
INSERT();
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
}
}
if (H1 + L1 > 3)
{
if (H >= 14 && (H - L) > 1)
{
txtH1.Text = (Convert.ToInt32(txtH1.Text) + 1).ToString();
if ((H1 + L1) == 4)
{
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text + "
";
}
txtH.Text = "0";
txtL.Text = "0";
if (txtH1.Text == "3")
{
MessageBox.Show(textBox1.Text + "胜利");
INSERT();
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
i = 1;
}
}
}
}
private void btnL_Click(object sender, EventArgs e)
{
int H = Convert.ToInt32(txtH.Text);
int L = Convert.ToInt32(txtL.Text);
int H1 = Convert.ToInt32(txtH1.Text);
int L1 = Convert.ToInt32(txtL1.Text);
txtL.Text = (L+1).ToString();
sb.AppendFormat("第{0}个球 {1}:{2}
", L + 1, H, L+1);
if (L>= 24&&(L-H )>0)
{
txtL1.Text = (Convert.ToInt32(txtL1.Text) + 1).ToString();
if((H1+L1)==0){
txtCount1.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
} if ((H1 + L1) == 1)
{
txtCount2.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 2)
{
txtCount3.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 3)
{
txtCount4.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 4)
{
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
txtH.Text = "0";
txtL.Text = "0";
if (txtL1.Text=="3")
{
MessageBox.Show(textBox2.Text + "胜利");
INSERT();
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
}
}
if(H1+L1>3)
{
if (L >= 14 && (L - H) > 1)
{
txtL1.Text = (Convert.ToInt32(txtL1.Text) + 1).ToString();
if((H1+L1)==4){
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
txtH.Text = "0";
txtL.Text = "0";
if (txtL1.Text == "3")
{
MessageBox.Show(textBox2.Text + "胜利");
INSERT();
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
i = 1;
}
}
}
}
private void btnH1_Click(object sender, EventArgs e)
{
if (int.Parse(txtH.Text) > 0)
{
txtH.Text = (Convert.ToInt32(txtH.Text) - 1).ToString();
}
}
private void btnL1_Click(object sender, EventArgs e)
{
if (int.Parse(txtH.Text) > 0)
{
txtL.Text = (Convert.ToInt32(txtL.Text) - 1).ToString();
}
}
namespace 排球计分程序
{
public static class SqlHelper
{
private static readonly string strcon = ConfigurationManager.ConnectionStrings["rjgc"].ConnectionString;
public static int ExecuteNonQuery(string sql, params SqlParameter[] pms)
{//执行增删改的
using (SqlConnection con = new SqlConnection(strcon))
{
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(strcon))
{
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(strcon);
using (SqlCommand cmd = new SqlCommand(sql, con))
{
if (pms != null)
{
cmd.Parameters.AddRange(pms);
}
con.Open();
return cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
}
}
public static DataTable ExecuteDataTable(string sql, params SqlParameter[] pms)
{
DataTable dt = new DataTable();
using (SqlDataAdapter adapter = new SqlDataAdapter(sql, strcon))
{
if (pms != null)
{
adapter.SelectCommand.Parameters.AddRange(pms);
}
adapter.Fill(dt);
}
return dt;
namespace 排球计分程序
{
public partial class Detail : Form
{
Action action = new Action();
public int ID;
public Detail()
{
InitializeComponent();
}
public string SelectDetail()
{
string sql = "select Detail from ball where ID=@ID";
SqlParameter[] pms = { new SqlParameter("@ID", ID) };
string count = SqlHelper.ExecuteScalar(sql, pms).ToString();
return count;
}
private void Detail_Load(object sender, EventArgs e)
{
txtDetail.Text = SelectDetail();
}
}
}