public void AddEmail(User s, string email, string pwd) { UserEmail ue = new UserEmail(); ue.UserID = s.UserID; ue.Email = email; ue.Password = pwd; }
public List <UserEmail> GetEmailList(int userID) { List <UserEmail> list = new List <UserEmail>(); string sql = string.Format("SELECT * FROM UserEmails WHERE UserID = '{0}' ", userID); using (Connection cn = new Connection()) { using (SqlCommand cmd = new SqlCommand()) { try { cmd.Connection = cn.SqlConnection; cmd.CommandText = sql; int recordsAffected = cmd.ExecuteNonQuery(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { UserEmail ue = new UserEmail(); ue.UserID = (int)reader["UserID"]; ue.UserEmailID = (int)reader["UserEmailID"]; ue.Email = reader["Email"].ToString(); ue.Password = reader["Password"].ToString(); list.Add(ue); } return(list); } else { return(list); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(list); } } } }
public bool Insert(UserEmail userEmail) { string sql = string.Format("INSERT INTO UserEmails(UserID, Email, Password) VALUES ('{0}', '{1}', '{2}') ", userEmail.UserID, userEmail.Email, userEmail.Password); using (Connection cn = new Connection()) { using (SqlCommand cmd = new SqlCommand()) { try { cmd.Connection = cn.SqlConnection; cmd.CommandText = sql; int recordsAffected = cmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(false); } } } }
public bool Insert(UserEmail userEmail) { string sql = string.Format("INSERT INTO UserEmails(UserID, Email, Password) VALUES ('{0}', '{1}', '{2}') ", userEmail.UserID, userEmail.Email, userEmail.Password); using (Connection cn = new Connection()) { using (SqlCommand cmd = new SqlCommand()) { try { cmd.Connection = cn.SqlConnection; cmd.CommandText = sql; int recordsAffected = cmd.ExecuteNonQuery(); return true; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return false; } } } }
public List<UserEmail> GetEmailList(int userID) { List<UserEmail> list = new List<UserEmail>(); string sql = string.Format("SELECT * FROM UserEmails WHERE UserID = '{0}' ", userID); using (Connection cn = new Connection()) { using (SqlCommand cmd = new SqlCommand()) { try { cmd.Connection = cn.SqlConnection; cmd.CommandText = sql; int recordsAffected = cmd.ExecuteNonQuery(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { UserEmail ue = new UserEmail(); ue.UserID = (int)reader["UserID"]; ue.UserEmailID = (int)reader["UserEmailID"]; ue.Email = reader["Email"].ToString(); ue.Password = reader["Password"].ToString(); list.Add(ue); } return list; } else return list; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return list; } } } }