private void RecuperareParola_FormClosing(object sender, FormClosingEventArgs e) { this.Hide(); Autentificare frm = new Autentificare(); frm.txtNumeUtilizator.Text = ""; frm.txtParola.Text = ""; frm.txtNumeUtilizator.Focus(); frm.Show(); }
private void SchimbaParola_FormClosing(object sender, FormClosingEventArgs e) { this.Hide(); Autentificare frm = new Autentificare(); frm.txtNumeUtilizator.Text = ""; frm.txtParola.Text = ""; frm.ProgressBar1.Visible = false; frm.txtNumeUtilizator.Focus(); frm.Show(); }
private void Button1_Click(object sender, EventArgs e) { if (txtEmail.Text == "") { MessageBox.Show("Enter your email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Focus(); return; } try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; DataSet ds = new DataSet(); SqlConnection con = new SqlConnection(cs); con.Open(); SqlCommand cmd = new SqlCommand("SELECT User_Password FROM Registration Where Email = '" + txtEmail.Text + "'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); con.Close(); if (ds.Tables[0].Rows.Count > 0) { MailMessage Msg = new MailMessage(); // Sender e-mail address. Msg.From = new MailAddress("*****@*****.**"); // Recipient e-mail address. Msg.To.Add(txtEmail.Text); Msg.Subject = "Your Password Details"; Msg.Body = "Your Password: "******"user_Password"]) + ""; Msg.IsBodyHtml = true; // your remote SMTP server IP. SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "abcd"); smtp.EnableSsl = true; smtp.Send(Msg); MessageBox.Show(("Password Successfully sent " + ("\r\n" + "Please check your mail")), "Thank you", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); Autentificare LoginForm1 = new Autentificare(); LoginForm1.Show(); LoginForm1.txtNumeUtilizator.Text = ""; LoginForm1.txtParola.Text = ""; LoginForm1.ProgressBar1.Visible = false; LoginForm1.txtNumeUtilizator.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Button1_Click(object sender, EventArgs e) { try { int RowsAffected = 0; if ((txtNumeUtilizator.Text.Trim().Length == 0)) { MessageBox.Show("Please enter user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumeUtilizator.Focus(); return; } if ((txtParolaVeche.Text.Trim().Length == 0)) { MessageBox.Show("Please enter old password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtParolaVeche.Focus(); return; } if ((txtParolaNoua.Text.Trim().Length == 0)) { MessageBox.Show("Please enter new password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtParolaNoua.Focus(); return; } if ((txtConfirmaParola.Text.Trim().Length == 0)) { MessageBox.Show("Please confirm new password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtConfirmaParola.Focus(); return; } if ((txtParolaNoua.TextLength < 5)) { MessageBox.Show("The New Password Should be of Atleast 5 Characters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtParolaNoua.Text = ""; txtConfirmaParola.Text = ""; txtParolaNoua.Focus(); return; } else if ((txtParolaNoua.Text != txtConfirmaParola.Text)) { MessageBox.Show("Password do not match", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtParolaNoua.Text = ""; txtParolaVeche.Text = ""; txtConfirmaParola.Text = ""; txtParolaVeche.Focus(); return; } else if ((txtParolaVeche.Text == txtParolaNoua.Text)) { MessageBox.Show("Password is same..Re-enter new password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtParolaNoua.Text = ""; txtConfirmaParola.Text = ""; txtParolaNoua.Focus(); return; } con = new SqlConnection(cs.DBConn); con.Open(); string co = "Update Inregistrare set Parola = '" + txtParolaNoua.Text + "'where UserName='******' and Password = '******'"; cmd = new SqlCommand(co); cmd.Connection = con; RowsAffected = cmd.ExecuteNonQuery(); if ((RowsAffected > 0)) { MessageBox.Show("Schimbat cu succes", "Parola", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); txtNumeUtilizator.Text = ""; txtParolaNoua.Text = ""; txtParolaVeche.Text = ""; txtConfirmaParola.Text = ""; Autentificare LoginForm1 = new Autentificare(); LoginForm1.Show(); LoginForm1.txtNumeUtilizator.Text = ""; LoginForm1.txtParola.Text = ""; LoginForm1.ProgressBar1.Visible = false; LoginForm1.txtNumeUtilizator.Focus(); } else { MessageBox.Show("Nume utilizator sau parola gresite", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumeUtilizator.Text = ""; txtParolaNoua.Text = ""; txtParolaVeche.Text = ""; txtConfirmaParola.Text = ""; txtNumeUtilizator.Focus(); } if ((con.State == ConnectionState.Open)) { con.Close(); } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error); } }