示例#1
0
 public void AddEmail(User s, string email, string pwd)
 {
     UserEmail ue = new UserEmail();
     ue.UserID = s.UserID;
     ue.Email = email;
     ue.Password = pwd;
 }
示例#2
0
        public void AddEmail(User s, string email, string pwd)
        {
            UserEmail ue = new UserEmail();

            ue.UserID   = s.UserID;
            ue.Email    = email;
            ue.Password = pwd;
        }
示例#3
0
        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);
                    }
                }
            }
        }
示例#4
0
        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);
                    }
                }
            }
        }
示例#5
0
 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;
             }
         }
     }
 }
示例#6
0
        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;
                    }
                }
            }
        }