Beispiel #1
0
        public int AddMatch(ScoreDetails sd)
        {
            string     sqlQuery = "Insert into Matches(GameID,Team1,Team2,MatchDate,MatchStatus) values(@Parm1,@Parm2,@Parm3,@Parm4,@Parm5); SELECT SCOPE_IDENTITY();";
            SqlCommand cmd      = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@Parm1", sd.GameID);
            cmd.Parameters.AddWithValue("@Parm2", sd.Team1ID);
            cmd.Parameters.AddWithValue("@Parm3", sd.Team2ID);
            cmd.Parameters.AddWithValue("@Parm4", sd.matchDate);
            cmd.Parameters.AddWithValue("@Parm5", 1);

            DataSet dtResult = new DataSet();

            cmd.CommandText = sqlQuery;
            cmd.Connection  = con;
            int matchID = 0;

            try
            {
                con.Open();
                matchID = Convert.ToInt32(cmd.ExecuteScalar());
                con.Close();
                return(matchID);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Beispiel #2
0
        public int AddScore(ScoreDetails sd, int MatchID)
        {
            string     sqlQuery = "Insert into Scores(MatchID,Team1Score,Team2Score) values(@Parm1,@Parm2,@Parm3); SELECT SCOPE_IDENTITY();";
            SqlCommand cmd      = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@Parm1", MatchID);
            cmd.Parameters.AddWithValue("@Parm2", sd.Team1Score);
            cmd.Parameters.AddWithValue("@Parm3", sd.Team2Score);

            DataSet dtResult = new DataSet();

            cmd.CommandText = sqlQuery;
            cmd.Connection  = con;
            int matchID = 0;

            try
            {
                con.Open();
                matchID = Convert.ToInt32(cmd.ExecuteScalar());
                con.Close();
                return(matchID);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Beispiel #3
0
        public bool AddMatchScore(ScoreDetails sd)
        {
            try
            {
                int matchID = AddMatch(sd);

                if (matchID > 0)
                {
                    AddScore(sd, matchID);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }