Exemple #1
0
        internal static int updatePlayer(clsPlayer player)
        {
            SqlCeCommand com1 = new SqlCeCommand("UPDATE tblPlayer SET playerFName=@p2, playerLName=@p3, DOB=@p4, countryId=@p5, battingHand=@p6, bowlingStyleId=@p7 WHERE playerID=@p1", connection.CON);

            com1.Parameters.AddWithValue("@p1", player.playerId);
            com1.Parameters.AddWithValue("@p2", player.fName);
            com1.Parameters.AddWithValue("@p3", player.lName);
            com1.Parameters.AddWithValue("@p4", player.dob);
            com1.Parameters.AddWithValue("@p5", clsCountry.getCountryCode(player.country));
            com1.Parameters.AddWithValue("@p6", player.battingHand);
            com1.Parameters.AddWithValue("@p7", clsBowlingStyle.getBowlingStyleCode(player.bowlingStyle));
            try
            {
                return(com1.ExecuteNonQuery());
            }
            catch (Exception e)
            {
                clsMessages.showMessage(clsMessages.msgType.error, e.Message);
            }
            return(0);
        }
Exemple #2
0
        internal static int addPlayer(clsPlayer player)
        {
            SqlCeCommand com = new SqlCeCommand("INSERT INTO tblPlayer VALUES(@p1,@p2,@p3, @p4, @p5, @p6, @p7)", connection.CON);

            com.Parameters.AddWithValue("@p1", player.playerId);
            com.Parameters.AddWithValue("@p2", player.fName);
            com.Parameters.AddWithValue("@p3", player.lName);
            com.Parameters.AddWithValue("@p4", player.dob);
            com.Parameters.AddWithValue("@p5", clsCountry.getCountryCode(player.country));
            com.Parameters.AddWithValue("@p6", player.battingHand);
            com.Parameters.AddWithValue("@p7", clsBowlingStyle.getBowlingStyleCode(player.bowlingStyle));
            try
            {
                return(com.ExecuteNonQuery());
            }
            catch (Exception e)
            {
                clsMessages.showMessage(clsMessages.msgType.error, e.Message);
            }
            return(0);
        }
Exemple #3
0
        internal static clsPlayer getPlayer(int playerId)
        {
            clsPlayer    player = new clsPlayer();
            SqlCeCommand com    = new SqlCeCommand("SELECT * FROM tblPlayer WHERE playerID=@P1", connection.CON);

            com.Parameters.AddWithValue("@p1", playerId);
            SqlCeDataAdapter ad = new SqlCeDataAdapter(com);
            DataSet          ds = new DataSet("tblPlayer");

            try
            {
                ad.Fill(ds, "tblPlayer");

                DataRow r = ds.Tables["tblPlayer"].Rows[0];

                player = new clsPlayer(Convert.ToInt32(r[0].ToString()), r[1].ToString(), r[2].ToString(), Convert.ToDateTime(r[3].ToString()), clsCountry.getCountryName(Convert.ToInt32(r[4].ToString())), Convert.ToChar(r[5].ToString()), clsBowlingStyle.getBowlingStyle(Convert.ToInt32(r[6].ToString())));
            }
            catch (Exception ex)
            {
                clsMessages.showMessage(clsMessages.msgType.error, ex.Message);
            }
            return(player);
        }