Esempio n. 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;
 }
Esempio n. 2
0
 public User FindById(int id)
 {
     User s = null;
     string sql = string.Format("SELECT * FROM Users WHERE UserID = '{0}' ", id);
     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())
                     {
                         s = new User();
                         s.UserID = (int)reader["UserID"];
                         s.LoginName = reader["LoginName"].ToString();
                         s.EmailList = userEmailDAO.GetEmailList(s.UserID);
                     }
                     return s;
                 }
                 else
                     return s;
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine(ex.Message);
                 return s;
             }
         }
     }
 }
Esempio n. 3
0
        public User Login(string email, string pwd)
        {
            User user = null;

            string sql = string.Format("SELECT * FROM UserEmails WHERE Email = '{0}' and Password = '******' ", email, pwd);
            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())
                            {
                                user = new User();
                                user.UserID = (int)reader["UserID"];
                                user = userDAO.FindById(user.UserID);
                            }
                            return user;
                        }
                        else
                            return user;
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                        return user;
                    }
                }
            }
        }