排球積分程序 (記分員)

計劃sql

        此程序須要1周(預計)spa

  • 開發
  • 需求分析

   用戶故事:做爲一個排球計分人員,我但願知道每場比賽隊伍得分和積分狀況,以便於計分給每隊按照得分進行排名進行選擇任務和查詢隊伍的比分和積分狀況。設計

  

     .設計複審:     將編寫的程序進行生成進行設計複審修改代碼。代碼規範

     .代碼規範:    利用VS對該程序進行代碼規範。開發

 

具體執行代碼以下:get

using System;cmd

using System.Collections.Generic;string

using System.Linq;it

using System.Text;io

using System.Data.SqlClient;

using System.Data;

using System.Configuration;

namespace DAL

{    

public static  class SqlHelper   

  {            

     private static readonly string constr =             ConfigurationManager.ConnectionStrings["MyPC"].ConnectionString;        

                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();      

           }        

     }    

  }

                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;   

      }   

  }

}

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

        public string _3to0{ get; set; }

        public string _3to1{ get; set; }  

       public string _3to2 { get; set; }   

      public string _2to3 { get; set; }    

     public string _1to3 { get; set; }    

     public string _0to3{ get; set; }

    }

}

namespace Model

{  

   public class SingleBall

    {   

      public int BallNum { get; set; } 

  

        public string GetTeam{ get; set; }  

  

     public int WinTeamScore{ get; set; }  

  

       public int LoseTeamScore{ get; set; }  

 

       public int GetMemberNum { get; set; }  

 

       public string HowGet { get; set; }   

      public int LoseMemberNum { get; set; }

    }

}

 public class GameNotes

    {    

     public int ID { get; set; }  

       public string NameA { get; set; }  

       public string NameB { get; set; }

        public DateTime Data { get; set; }

        public string R1 { get; set; }    

     public string R2 { get; set; }   

      public string R3 { get; set; }  

       public string R4 { get; set; }   

      public string R5 { get; set; }   

      public string Place { get; set; }

    }

public class Members

    {    

     public int ID { get; set; }  

       public string MName { get; set; }  

       public string TName { get; set; }  

       public string Number { get; set; }   

      public string Position { get; set; }  

       public string Weight { get; set; }  

       public string Height { get; set; }   

      public int Age { get; set; }   

      public string NickName { get; set; }   

      public string Strength { get;set; }

    }

public class GameNotes

    {    

     public int ID { get; set; }  

       public string NameA { get; set; }    

     public string NameB { get; set; }  

       public DateTime Data { get; set; }  

       public string R1 { get; set; }   

      public string R2 { get; set; }  

       public string R3 { get; set; }

        public string R4 { get; set; }   

      public string R5 { get; set; }   

      public string Place { get; set; }

    }

namespace DAL

{  

   public class SingleBallDAL

    {    

             public int InsertBallInfo(SingleBall sb)  

       {         

    string sql = "insert into SingleBall values"+                 "(@BallNum,@GetTeam,@WinTeamScore,@LoseTeamScore,@GetMemberNum,@HowGet,@LoseMemberNum)";    

         SqlParameter[] pms = {    

                                     new SqlParameter("@BallNum",sb.BallNum),   

                                      new SqlParameter("@GetTeam",sb.GetTeam),  

                                       new SqlParameter("@WinTeamScore",sb.WinTeamScore),   

                                      new SqlParameter("@LoseTeamScore",sb.LoseTeamScore),   

                                      new SqlParameter("@GetMemberNum",sb.GetMemberNum),     

                                    new SqlParameter("@HowGet",sb.HowGet),      

                                   new SqlParameter("@LoseMemberNum",sb.LoseMemberNum),  

                                   };   

          return SqlHelper.ExecuteNonQuery(sql, pms);  

       }   

  }

}

namespace VolleyballDal

{   

public class volleyDal

    {    

    public DataTable SelectScore(string team)  

      {    

        string sql = "select * from VolleybalScore where Teams like '%"+team+"%'";   

         DataTable dt = SqlHelper.ExecuteDataTable(sql);    

        return dt;   

     }   

     public bool SelectScoreCount(string team)  

      {  

          string sql = "select count(*) from VolleybalScore where Teams like '%" + team + "%'";    

        int count = (int)SqlHelper.ExecuteScalar(sql);    

        return count>0;   

               }    

       }

}

namespace VolleyballBll

{     public class volleyBll  

   {       

  private volleyDal dal = new volleyDal();

        public DataTable SelectScore(string team)  

       {    

         return dal.SelectScore(team);  

       }   

      public bool SelectScoreCount(string team)

        {    

         return dal.SelectScoreCount(team);

        }  

   }

}

namespace VolleyballDal

{

   public class volleyDal  

   {   

     public DataTable SelectScore(string team)  

      {

           string sql = "select * from VolleybalScore where Teams like '%"+team+"%'";

           DataTable dt = SqlHelper.ExecuteDataTable(sql);    

        return dt;  

      }   

     public bool SelectScoreCount(string team)  

      {   

         string sql = "select count(*) from VolleybalScore where Teams like '%" + team + "%'";

           int count = (int)SqlHelper.ExecuteScalar(sql);   

         return count>0;

                 }  

         }

}

以上就是排球積分程序計分員的相關代碼,可能會還須要改進,會再審查一下

相關文章
相關標籤/搜索