Ejemplo n.º 1
0
        public void AddContribution(Contribution c)
        {
            SqlConnection connection = new SqlConnection(_connectionstring);
            SqlCommand    command    = connection.CreateCommand();

            command.CommandText = @"INSERT INTO Contributions(Contributorid,Amount,Date)
                                    VALUES(@contributorid,@amount,@date); SELECT @@Identity";
            command.Parameters.AddWithValue("@contributorid", c.Contributorid);
            command.Parameters.AddWithValue("@amount", c.Amount);
            command.Parameters.AddWithValue("@date", c.Date);
            connection.Open();
            c.id = (int)(decimal)command.ExecuteScalar();
        }
Ejemplo n.º 2
0
        public IEnumerable <Contribution> GetAllContributions()
        {
            SqlConnection connection = new SqlConnection(_connectionstring);
            SqlCommand    command    = connection.CreateCommand();

            command.CommandText = "SELECT * FROM Contributions";
            connection.Open();
            SqlDataReader       reader        = command.ExecuteReader();
            List <Contribution> contributions = new List <Contribution>();

            while (reader.Read())
            {
                Contribution contribution = new Contribution
                {
                    id            = (int)reader["id"],
                    Contributorid = (int)reader["ContributorId"],
                    Amount        = (Decimal)reader["Amount"],
                    Date          = (DateTime)reader["Date"],
                };
                contributions.Add(contribution);
            }
            return(contributions);
        }
Ejemplo n.º 3
0
        public IEnumerable <Contribution> GetContributionsForid(int id)
        {
            SqlConnection connection = new SqlConnection(_connectionstring);
            SqlCommand    command    = connection.CreateCommand();

            command.CommandText = "SELECT Amount, Date FROM Contributions Where contributorid = @id";
            command.Parameters.AddWithValue("@id", id);
            connection.Open();
            List <Contribution> contribution = new List <Contribution>();
            SqlDataReader       reader       = command.ExecuteReader();

            while (reader.Read())
            {
                Contribution c = new Contribution
                {
                    Amount = (Decimal)reader["Amount"],
                    Date   = (DateTime)reader["Date"],
                };
                contribution.Add(c);
            }
            command.CommandText = @"select sc.Amount, s.Date from SimchaContributions sc
                                    Join Simchas s 
                                    on sc.simchaid=s.id
                                    where sc.contributorid=@id";
            while (reader.Read())
            {
                Contribution c2 = new Contribution
                {
                    Amount = (Decimal)reader["Amount"],
                    Date   = (DateTime)reader["Date"],
                };
                contribution.Add(c2);
            }

            return(contribution);
        }