zoukankan      html  css  js  c++  java
  • 排球计分程序(现场记分员)

    1.计划

    估计需要两周

    2.需求分析

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

    3.设计文档

    当用户进入程序时,可以看到以往队员的分数,和得分类型双击表格。

    4.具体代码

    public static class SqlHelper
        {

            //1.连接字符串
            private static readonly string constr = ConfigurationManager.ConnectionStrings["player"].ConnectionString;

            //2.执行增删改的
            public static int ExecuteNonQuery(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.ExecuteNonQuery();
                    }
                }
            }

            //3.执行返回单个值的
            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();
                    }
                }
            }

            //4.执行返回SqlDataReader
            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;
            }


    代码测试:

    添加功能和删除功能能用

    总结:

    勤加练习

  • 相关阅读:
    ScrollView 实现循环轮播
    UINavigationController和UITabBarController合用
    iOS开发网络篇—网络编程基础
    iOS开发网络篇—搭建本地服务器
    iOS开发网络篇—HTTP协议
    iOS开发网络篇—GET请求和POST请求
    UIView
    iOS准备程序
    iOS小程序-混合计算器
    IOS入门-计算机小程序
  • 原文地址:https://www.cnblogs.com/zxcv5678/p/6568456.html
Copyright © 2011-2022 走看看