Ejemplo n.º 1
0
        public void AddSimcha(Simcha s)
        {
            SqlConnection connection = new SqlConnection(_connectionstring);
            SqlCommand    command    = connection.CreateCommand();

            command.CommandText = @"INSERT INTO simchas(Name,Date)
                                    VALUES(@name,@date); SELECT @@Identity";
            command.Parameters.AddWithValue("@name", s.Name);
            command.Parameters.AddWithValue("@date", s.Date);
            connection.Open();

            s.Id = (int)(decimal)command.ExecuteScalar();
        }
Ejemplo n.º 2
0
        public IEnumerable <Simcha> GetAllSimchas()
        {
            SqlConnection connection = new SqlConnection(_connectionstring);
            SqlCommand    command    = connection.CreateCommand();

            command.CommandText = "SELECT * FROM Simchas";
            connection.Open();
            SqlDataReader reader  = command.ExecuteReader();
            List <Simcha> simchas = new List <Simcha>();

            while (reader.Read())
            {
                Simcha s = new Simcha();

                s.Id      = (int)reader["Id"];
                s.Name    = (string)reader["Name"];
                s.Date    = (DateTime)reader["Date"];
                s.Count   = GetContributorCount(s.Id);
                s.Balance = GetBalanceForSimcha(s.Id);
                simchas.Add(s);
            }
            return(simchas);
        }