public bool UpdateList(PrayerDAO PD) { bool success = false; try { using (SqlConnection _connection = new SqlConnection(connectionstring)) { using (SqlCommand _command = new SqlCommand("sp_UpdateList", _connection)) { _command.CommandType = CommandType.StoredProcedure; _command.Parameters.AddWithValue("@ListID", PD.ListID); _command.Parameters.AddWithValue("@Firstname", PD.Firstname); _command.Parameters.AddWithValue("@Lastname", PD.Lastname); _command.Parameters.AddWithValue("@DateAdded", PD.DateAdded); _command.Parameters.AddWithValue("@Situation", PD.Situation); _command.Parameters.AddWithValue("@AddedBy", PD.AddedBy); _connection.Open(); _command.ExecuteNonQuery(); success = true; _connection.Close(); } } } catch (Exception error) { Errorlog Problem = new Errorlog(); Problem.LogError(error); } return(success); }
public PrayerDAO Map(Prayer _prayertomap) { PrayerDAO _prayertoview = new PrayerDAO(); _prayertoview.ListID = _prayertomap.ListID; _prayertoview.Firstname = _prayertomap.Firstname; _prayertoview.Lastname = _prayertomap.Lastname; _prayertoview.DateAdded = _prayertomap.DateAdded; _prayertoview.Situation = _prayertomap.Situation; _prayertoview.AddedBy = _prayertomap.AddedBy; _prayertoview.Username = _prayertomap.Username; return(_prayertoview); }
public List <PrayerDAO> GetPList() { //Create List Variables named plist. List <PrayerDAO> _Plist = new List <PrayerDAO>(); try { //connect to database. using (SqlConnection _connection = new SqlConnection(connectionstring)) { using (SqlCommand _command = new SqlCommand("sp_ViewList", _connection)) { _command.CommandType = CommandType.StoredProcedure; _connection.Open(); using (SqlDataReader _reader = _command.ExecuteReader()) { while (_reader.Read()) { DateTime datetime; PrayerDAO _prayertoList = new PrayerDAO(); _prayertoList.ListID = _reader.GetInt32(0); _prayertoList.Firstname = _reader.GetString(1); _prayertoList.Lastname = _reader.GetString(2); _prayertoList.DateAdded = _reader.GetDateTime(3); datetime = _prayertoList.DateAdded; string date = datetime.ToString("MM/dd/yyyy"); _prayertoList.date = date; _prayertoList.Situation = _reader.GetString(4); _prayertoList.AddedBy = _reader.GetInt32(5); _prayertoList.Username = _reader.GetString(6); _Plist.Add(_prayertoList); } } } } } catch (Exception error) { Errorlog Problem = new Errorlog(); Problem.LogError(error); } return(_Plist); }