Exemplo n.º 1
0
 public User Register(string email, string firstname, string lastname, string username,
     string question1, string answer1, string question2, string answer2, string question3, string answer3)
 {
     Database db = new Database("Books");
     try
     {
         String Pass = ValidateEmail.GeneratePassword (3,3,3);
         db.Command.CommandType = CommandType.StoredProcedure;
         db.Command.CommandText = "tblUserREGISTER";
         db.Command.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = firstname;
         db.Command.Parameters.Add("@LastName", SqlDbType.VarChar).Value = lastname;
         db.Command.Parameters.Add("@UserName", SqlDbType.VarChar).Value = username;
         db.Command.Parameters.Add("@Password", SqlDbType.VarChar).Value = Pass;
         db.Command.Parameters.Add("@Email", SqlDbType.VarChar).Value = email;
         db.Command.Parameters.Add("@Question1", SqlDbType.VarChar).Value = question1;
         db.Command.Parameters.Add("@Answer1", SqlDbType.VarChar).Value = answer1;
         db.Command.Parameters.Add("@Question2", SqlDbType.VarChar).Value = question2;
         db.Command.Parameters.Add("@Answer2", SqlDbType.VarChar).Value = answer2;
         db.Command.Parameters.Add("@Question3", SqlDbType.VarChar).Value = question3;
         db.Command.Parameters.Add("@Answer3", SqlDbType.VarChar).Value = answer3;
         DataTable dt = db.ExecuteQuery();
         if (dt.Rows.Count == 1)
         {
             DataRow dr = dt.Rows[0];
             base.Initialize(dr);
             InitializeBusinessData(dr);
             Email e = new Email();
             e.To = email;
             e.Subject = "Your Password";
             e.Body = String.Format("Your password is {0}", dr["Password"].ToString());
             e.Send();
             return this;
         }
         else
         {
             return null;
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemplo n.º 2
0
 public Boolean Recover(string firstname,
                        string lastname,
                        string username,
                        string emailaddress)
 {
     Database db = new Database("student");
     try
     {
         db.Command.CommandType = CommandType.StoredProcedure;
         db.Command.CommandText = "tblStudentRecover";
         db.Command.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = firstname;
         db.Command.Parameters.Add("@LastName", SqlDbType.VarChar).Value = lastname;
         db.Command.Parameters.Add("@UserName", SqlDbType.VarChar).Value = username;
         DataTable dt = db.ExecuteQuery();
         if (dt.Rows.Count == 1)
         {
             DataRow dr = dt.Rows[0];
             Email email = new Email();
             email.Host = "smtp.gmail.com";
             email.Port = 587;
             email.Username = "******";
             email.Password = "******";
             email.To = emailaddress;
             email.From = "*****@*****.**";
             email.Subject = "Password Recovery";
             email.Body =
                 String.Format("Your password is {0}",
                 dr["password"].ToString());
             email.Send();
             return true;
         }
         else
             return false;
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemplo n.º 3
0
 public Boolean Recover(string email, string firstname, string lastname, string username, string answer)
 {
     Database db = new Database("Books");
     try
     {
         if (_Answers[_index] == answer)
         {
             db.Command.CommandType = CommandType.StoredProcedure;
             db.Command.CommandText = "tblUserRECOVER";
             db.Command.Parameters.Add("@Email", SqlDbType.VarChar).Value = email;
             DataTable dt = db.ExecuteQuery();
             if (dt.Rows.Count == 1)
             {
                 DataRow dr = dt.Rows[0];
                 Email e = new Email();
                 e.To = email;
                 e.Subject = "Password Recovery";
                 e.Body = String.Format("Your password is {0}", dr["password"].ToString());
                 e.Send();
                 return true;
             }
             else
             {
                 return false;
             }
         }
         else
         {
             return false;
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }