zoukankan      html  css  js  c++  java
  • 排球积分程序

    流程如下

    任务:作为一个排球计分员,我需要知道每场比赛队伍的得分和积分情况,以便对队伍进行排名和反馈。

    计划:此程序需要2-3周

    设计文档

        由排球比赛用户故事的需求分析可知,此程序是用来统计各个队伍的比分和积分情况,每一次比分的改变,都要形成一条记录。

      计划复审

     目前在进行中

      代码规范

        根据Visual Studio 2010规范去写。

    具体代码如下

    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.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using VolleyballBll;
    using Moudel;

    namespace VolleyballUI
    {
    public partial class Index : System.Web.UI.Page
    {
    private TeamBll teamBll = new TeamBll();

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    BindDropDownList();
    }
    }

    protected void btnSaveName_Click(object sender, EventArgs e)
    {
    Team team = new Team();
    team.Name=TeamName.Text.Trim();
    if (teamBll.GetInsertTeamName(team))
    {
    Response.Redirect("Index.aspx");
    }
    else
    {
    Response.Write("<script>alert('失败')</script>");
    }
    }

    public void BindDropDownList()
    {
    DropDownListA.DataSource = teamBll.GetSelectAllTeams();
    DropDownListA.DataTextField = "Name";
    DropDownListA.DataValueField = "ID";
    DropDownListA.DataBind();
    DropDownListB.DataSource = teamBll.GetSelectAllTeams();
    DropDownListB.DataTextField = "Name";
    DropDownListB.DataValueField = "ID";
    DropDownListB.DataBind();
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
    if (DropDownListA.SelectedItem.Text == DropDownListB.SelectedItem.Text)
    {
    Response.Write("<script>alert('不能与己方队伍比赛!')</script>");
    }
    else
    {
    Response.Redirect("Main.aspx?TeamA=" + DropDownListA.SelectedItem.Text + "&TeamB=" + DropDownListB.SelectedItem.Text);
    }
    }

    protected void btnSelect_Click(object sender, EventArgs e)
    {
    if (DropDownListA.SelectedItem.Text == DropDownListB.SelectedItem.Text)
    {
    Response.Write("<script>alert('不能与己方队伍比赛!')</script>");
    }
    else
    {
    Response.Redirect("Select.aspx?TeamA=" + DropDownListA.SelectedItem.Text + "&TeamB=" + DropDownListB.SelectedItem.Text);
    }
    }
    }
    }

  • 相关阅读:
    ES 使用小结
    TruncateATable 清除一张表
    js 排序,去重
    读高性能JavaScript编程 第四章 Conditionals
    读高性能JavaScript编程 第四章 Duff's Device
    c# AOP 文章地址
    String、StringBuffer与StringBuilder之间区别
    批处理命令
    C#中的is和as操作符
    c# 入门
  • 原文地址:https://www.cnblogs.com/abc1/p/6568901.html
Copyright © 2011-2022 走看看