1.计划:

做这个任务大概需要七天。

2.需求分析:

作为一名现场记分员,我希望详细记录比赛现场比分增长情况,以便观众及运动员、教练员及时掌握比赛状况。
3.生成设计文档:

 

 

  .设计复审:

                    将编写的程序进行生成,进行设计复审。看看是否生成错误,如果错误进行修改。

     .代码规范:

                   利用VS对该程序进行代码规范。

 

 代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

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; }
    }
}

 

namespace DAL
{

 public static class SqlHelper
        {
            private static readonly string constr = ConfigurationManager.ConnectionStrings["itcast"].ConnectionString;
           
            public static int ExecuteNonQuery(string sql, params SqlParameter[] pms)
            {
               
                using (SqlConnection conn = new SqlConnection(constr))
                {
                    
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                       
                        if (pms != null)
                        {
                            
                            cmd.Parameters.AddRange(pms);
                        }
                        conn.Open();
                        return cmd.ExecuteNonQuery();
                    }
                }
            }
            
            public static object ExecuteScalar(string sql, params SqlParameter[] pms)
            {
                using (SqlConnection conn = new SqlConnection(constr))
                {
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        if (pms != null)
                        {
                            cmd.Parameters.AddRange(pms);
                        }
                        conn.Open();
                        return cmd.ExecuteScalar();
                    }
                }
            }
            public static SqlDataReader ExecuteReader(string sql, params SqlParameter[] pms)
            {
                SqlConnection conn = new SqlConnection(constr);
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    if (pms != null)
                    {
                        cmd.Parameters.AddRange(pms);
                    }
                    try
                    {
                        conn.Open();
                        return cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                    }
                    catch (Exception)
                    {
                        conn.Close();
                        conn.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;
            }

        }

代码不完善,下去得继续

posted on 2017-03-17 21:33  如果巴黎不快乐  阅读(213)  评论(0编辑  收藏  举报