private void button1_Click(object sender, EventArgs e) { if (this.textBoxID.Text != "" && this.textBoxID.Text != phi) { Handler h = new Handler(); Cls_Login login = h.Get <Cls_Login>(new Cls_Login(this.textBoxID.Text, null, null)); if (login != null) { this.SendEmail(login); } } else if (this.textBoxEmail.Text != "" && this.textBoxEmail.Text != phe) { Handler h = new Handler(); Cls_Login login = h.Get <Cls_Login>(new Cls_Login(null, this.textBoxEmail.Text, null)); if (login != null) { this.SendEmail(login); } } else { MessageBox.Show("Please enter login or email."); } }
private bool SendEmail(Cls_Login login) { try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(login.Email); mail.Subject = "SCE password reminder"; mail.Body = "You or someone requested password resend for your account\nYour Password is: " + login.Password; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("project.sce.12", "12345678Serg"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); MessageBox.Show("Your password has been sent to your email."); return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } }
public T Get <T>(T t) { if (t is Lecturer) { Lecturer lecturer = t as Lecturer; t = (T)(object)GetLecturer(lecturer); return(t); } else if (t is Classroom) { Classroom classroom = t as Classroom; t = (T)(object)GetClassroom(classroom); return(t); } else if (t is Cls_Login) { Cls_Login login = t as Cls_Login; t = (T)(object)GetCls_Login(login); return(t); } return(t); }
public Cls_Login GetCls_Login(Cls_Login toGeLogin) { DataBase db = DataBase.Instance; string where = toGeLogin.ID != null ? " WHERE (Id = '" + toGeLogin.ID + "')" : toGeLogin.Email != null ? " WHERE (Email = '" + toGeLogin.Email + "')" : ""; SqlCommand cmd = new SqlCommand ( "SELECT * from Login" + where, db.Con ); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string id = reader["Id"].ToString().Trim(); string email = reader["Email"].ToString().Trim(); string password = reader["Password"].ToString().Trim(); //... return(new Cls_Login(id, email, password)); } } return(null); }