• 排球记分员


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

            }

    代码不完善,下去得继续

  • 相关阅读:
    MyEclipse 快捷键(转载)
    Microsoft .NET Framework 2.0安装失败
    数据库管理方面的电子书下载地址汇总
    增强MyEclipse的代码自动提示功能 (转载)
    有关Eclipse的自动完成&代码整理(摘)
    使用NewtonSoft.JSON.dll来序列化和发序列化对象(转载)
    hMailServer配置默认域名
    arcgis中的 style和serverstyle(转载)
    python function learning
    整理的设计模式博文列表
  • 原文地址:https://www.cnblogs.com/wllwll/p/6568451.html
Copyright © 2020-2023  润新知