Esempio n. 1
0
        public void DonateToSimcha(DonateToSimcha simcha)
        {
            SqlConnection connection = new SqlConnection(_connectionstring);
            SqlCommand    command    = connection.CreateCommand();

            command.CommandText = "DELETE from SimchaContributions where @simchaid = simchaid" + "INSERT INTO SimchaContribution VALUES(@simchaid,@contributorid, @amount)";
            command.Parameters.AddWithValue("@simchaid", simcha.Simchaid);
            command.Parameters.AddWithValue("@contributorid", simcha.Contributorid);
            command.Parameters.AddWithValue("@amount", simcha.Amount);
            connection.Open();
            command.ExecuteNonQuery();
        }
Esempio n. 2
0
        public IEnumerable <DonateToSimcha> GetAllSimchaDonations(int simchaid)
        {
            SqlConnection connection = new SqlConnection(_connectionstring);
            SqlCommand    command    = connection.CreateCommand();

            command.CommandText = "SELECT * FROM SimchaContribution where simchaid = @simchaid";
            command.Parameters.AddWithValue("@simchaid", simchaid);
            connection.Open();
            List <DonateToSimcha> donors = new List <DonateToSimcha>();
            SqlDataReader         reader = command.ExecuteReader();

            while (reader.Read())
            {
                DonateToSimcha simcha = new DonateToSimcha
                {
                    Simchaid      = (int)reader["simchaid"],
                    Contributorid = (int)reader["contributorid"],
                    Amount        = (Decimal)reader["Amount"]
                };
                donors.Add(simcha);
            }
            return(donors);
        }