Example #1
0
 public ActionResult AddContributor(Contributors contributor)
 {
     SimchaFundManager manager = new SimchaFundManager(Properties.Settings.Default.ConStr);
     manager.AddContributor(new Contributors
     {
         FirstName = contributor.FirstName,
         LastName = contributor.LastName,
         PhoneNum = contributor.PhoneNum,
         AlwaysInclude = contributor.AlwaysInclude,
     });
     return Redirect("Contributors");
 }
Example #2
0
 public void AddContributor(Contributors newContributor)
 {
     using (SqlConnection connection = new SqlConnection(_connectionString))
         using (SqlCommand cmd = connection.CreateCommand())
         {
             cmd.CommandText = "INSERT INTO Contributor (FirstName,LastName, Date, AlwaysInclude, Cell) " +
                               "VALUES(@FirstName, @LastName, GetDate(), @AlwaysInclude, @Cell)";
             cmd.Parameters.AddWithValue("@FirstName", newContributor.FirstName);
             cmd.Parameters.AddWithValue("@LastName", newContributor.LastName);
             cmd.Parameters.AddWithValue("@AlwaysInclude", newContributor.AlwaysInclude);
             cmd.Parameters.AddWithValue("@Cell", newContributor.Cell);
             connection.Open();
             cmd.ExecuteNonQuery();
         }
 }
Example #3
0
        public void AddContributor(Contributors contributor)
        {
            var connection = new SqlConnection(_connectionString);
            var cmd        = connection.CreateCommand();

            connection.Open();
            cmd.CommandText = @"INSERT INTO Contributors (FirstName, LastName, Date, 
                                    AlwaysInclude) VALUES (@firstName, @lastName, 
                                    @date, @alwaysInclude) SELECT SCOPE_IDENTITY()";
            cmd.Parameters.AddWithValue("@firstName", contributor.FirstName);
            cmd.Parameters.AddWithValue("@lastName", contributor.LastName);
            cmd.Parameters.AddWithValue("@date", contributor.Date);
            cmd.Parameters.AddWithValue("@alwaysInclude", contributor.AlwaysInclude);
            contributor.Id = (int)cmd.ExecuteScalar();
        }
Example #4
0
        public void UpdateContributor(Contributors contributor)
        {
            var connection = new SqlConnection(_connectionString);
            var cmd        = connection.CreateCommand();

            connection.Open();
            cmd.CommandText = @"UPDATE Contributors SET FirstName = @firstName, 
                                    LastName = @lastName, Date = @date, 
                                    AlwaysInclude = @alwaysInclude WHERE Id = @id";
            cmd.Parameters.AddWithValue("@firstName", contributor.FirstName);
            cmd.Parameters.AddWithValue("@lastName", contributor.LastName);
            cmd.Parameters.AddWithValue("@date", contributor.Date);
            cmd.Parameters.AddWithValue("@alwaysInclude", contributor.AlwaysInclude);
            cmd.ExecuteNonQuery();
        }
        public int AddContributor(Contributors contibutor)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                SqlCommand command = connection.CreateCommand();
                command.CommandText = @"INSERT INTO Contributor (FirstName, LastName, PhoneNum, AlwaysInclude)
                                    VALUES (@firstName, @lastName, @phoneNum, @alwaysInclude) SELECT @@IDENTITY";
                command.Parameters.AddWithValue("@firstName", contibutor.FirstName);
                command.Parameters.AddWithValue("@lastName", contibutor.LastName);
                command.Parameters.AddWithValue("@phoneNum", contibutor.PhoneNum);
                command.Parameters.AddWithValue("@alwaysInclude", contibutor.AlwaysInclude);
                connection.Open();
                return (int)(decimal)command.ExecuteScalar();

            }
        }
Example #6
0
 public void Update(Contributors contributor)
 {
     using (SqlConnection connection = new SqlConnection(_connectionString))
         using (SqlCommand cmd = connection.CreateCommand())
         {
             cmd.CommandText = @"update Contributor Set FirstName = @FirstName, LastName = @LastName, Date = GetDate()," +
                               "AlwaysInclude = @AlwaysInclude, Cell = @Cell Where Id = @Id";
             cmd.Parameters.AddWithValue("@FirstName", contributor.FirstName);
             cmd.Parameters.AddWithValue("@LastName", contributor.LastName);
             cmd.Parameters.AddWithValue("@AlwaysInclude", contributor.AlwaysInclude);
             cmd.Parameters.AddWithValue("@Cell", contributor.Cell);
             cmd.Parameters.AddWithValue("@Id", contributor.Id);
             connection.Open();
             cmd.ExecuteNonQuery();
         }
 }
Example #7
0
 public void AddContributor(Contributors contributor)
 {
     using (SqlConnection con = new SqlConnection(_connectionString))
         using (SqlCommand cmd = con.CreateCommand())
         {
             cmd.CommandText = "INSERT INTO Contributors(firstname, lastname, cellnumber, date, alwaysInclude) " +
                               "VALUES (@firstname, @lastname, @cell, @date, @alwaysInclude) SELECT SCOPE_IDENTITY()";
             cmd.Parameters.AddWithValue("@firstname", contributor.FirstName);
             cmd.Parameters.AddWithValue("@lastname", contributor.LastName);
             cmd.Parameters.AddWithValue("@cell", contributor.CellNumber);
             cmd.Parameters.AddWithValue("@date", contributor.Date);
             cmd.Parameters.AddWithValue("@alwaysInclude", contributor.AlwaysInclude);
             con.Open();
             contributor.Id = (int)(decimal)cmd.ExecuteScalar();
         }
 }
Example #8
0
 public void UpdateContributor(Contributors contributor)
 {
     using (var con = new SqlConnection(_connectionString))
         using (var cmd = con.CreateCommand())
         {
             cmd.CommandText = @"UPDATE Contributors SET Firstname = @firstname,
                             Lastname = @lastname, cellnumber = @cell, date = @date,
                             alwaysinclude = @alwaysinclude
                             where id = @id";
             cmd.Parameters.AddWithValue("@firstname", contributor.FirstName);
             cmd.Parameters.AddWithValue("@lastname", contributor.LastName);
             cmd.Parameters.AddWithValue("@cell", contributor.CellNumber);
             cmd.Parameters.AddWithValue("@date", contributor.Date);
             cmd.Parameters.AddWithValue("@alwaysinclude", contributor.AlwaysInclude);
             cmd.Parameters.AddWithValue("@id", contributor.Id);
             con.Open();
             cmd.ExecuteNonQuery();
         }
 }
Example #9
0
        public IEnumerable <Contributors> GetContributors()
        {
            var contributors = new List <Contributors>();
            var connection   = new SqlConnection(_connectionString);
            var cmd          = connection.CreateCommand();

            connection.Open();
            cmd.CommandText = "SELECT * FROM Contributors";
            var reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                var contributor = new Contributors();
                contributor.Id            = (int)reader["Id"];
                contributor.FirstName     = (string)reader["FirstName"];
                contributor.LastName      = (string)reader["LastName"];
                contributor.Date          = (DateTime)reader["Date"];
                contributor.AlwaysInclude = (bool)reader["AlwaysInclude"];
                contributor.Balance       = (int)reader["Balance"];
                contributors.Add(contributor);
            }
            return(contributors);
        }
Example #10
0
 public IEnumerable <Contributors> GetContributors()
 {
     using (var con = new SqlConnection(_connectionString))
         using (var cmd = con.CreateCommand())
         {
             cmd.CommandText = @"select * from Contributors";
             List <Contributors> list = new List <Contributors>();
             con.Open();
             SqlDataReader reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 Contributors c = new Contributors();
                 c.Id            = (int)reader["Id"];
                 c.FirstName     = (string)reader["FirstName"];
                 c.LastName      = (string)reader["LastName"];
                 c.CellNumber    = (string)reader["CellNumber"];
                 c.Date          = (DateTime)reader["Date"];
                 c.AlwaysInclude = (bool)reader["AlwaysInclude"];
                 c.Amount        = CurrentBalance(c.Id);
                 list.Add(c);
             }
             return(list);
         }
 }
Example #11
0
 public void UpdateContributor(Contributors contribtor)
 {
     using (SqlConnection connection = new SqlConnection(_connectionString))
     {
         SqlCommand command = connection.CreateCommand();
         command.CommandText = "update Contributor set FirstName = @firstName, LastName = @lastName, PhoneNum = @phoneNum, AlwaysInclude = @alwaysInclude  where id = @id";
         command.Parameters.AddWithValue("@firstName", contribtor.FirstName);
         command.Parameters.AddWithValue("@lastName", contribtor.LastName);
         command.Parameters.AddWithValue("@phoneNum", contribtor.PhoneNum);
         command.Parameters.AddWithValue("@alwaysInclude", contribtor.AlwaysInclude);
         command.Parameters.AddWithValue("@id", contribtor.Id);
         connection.Open();
         command.ExecuteNonQuery();
     }
 }
Example #12
0
 public ActionResult EditContributor(Contributors contributor)
 {
     SimchaFundManager manager = new SimchaFundManager(Properties.Settings.Default.ConStr);
     manager.UpdateContributor(contributor);
     return Redirect("Contributors");
 }