public void enviarMail() { var resultado = _mail.sendPass(1, "*****@*****.**", "Abd.1234", "002EC", "Elmer Chúc"); ////el resultado devuelto debe ser verdadero //con la comparacion de la siguiente frase "Credenciales Enviadas." Assert.IsTrue("Email enviado." == resultado); }
private void btnRst_Click(object sender, EventArgs e) { try { string pass = genPas.contrasena(); string usuario = txtUsuario.Text; MySqlConnection conn = new MySqlConnection(connString); conn.Open(); MySqlCommand command = conn.CreateCommand(); command = conn.CreateCommand(); command.CommandText = "UPDATE usuario SET password=AES_ENCRYPT(@password,'codActFij') where idUsu=@codUsu and usuario=@usuario"; command.Parameters.Add("@usuario", MySqlDbType.String).Value = usuario; command.Parameters.Add("@password", MySqlDbType.String).Value = pass; command.Parameters.Add("@codUsu", MySqlDbType.Int32).Value = Convert.ToInt32(txtCodUsu.Text); command.ExecuteNonQuery(); envMail send = new envMail(); send.sendPass(1, txtEmail.Text.Trim(), pass, usuario, txtNom.Text.Trim() + " " + txtApe.Text.Trim()); MessageBox.Show("Credenciales enviadas Exitosamente", "Registro Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } catch (Exception ex) { MessageBox.Show("Error" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void btnSave_Click(object sender, EventArgs e) { try { libGen libg = new libGen(); if (string.IsNullOrWhiteSpace(txtNom.Text)) { MessageBox.Show("Valor Inválido" + Environment.NewLine + "Nombre", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (string.IsNullOrWhiteSpace(txtNom.Text)) { MessageBox.Show("Valor Inválido" + Environment.NewLine + "Apellidos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (string.IsNullOrWhiteSpace(txtEmail.Text) || !libg.IsValidEmail(txtEmail.Text)) { MessageBox.Show("Valor Inválido" + Environment.NewLine + "Email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (string.IsNullOrWhiteSpace(txtCel.Text)) { MessageBox.Show("Valor Inválido" + Environment.NewLine + "Celular", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MySqlConnection conn = new MySqlConnection(connString); conn.Open(); MySqlCommand command = conn.CreateCommand(); command.CommandText = "SELECT * FROM usuario"; MySqlDataAdapter datos = new MySqlDataAdapter(command); DataTable dtUsu = new DataTable(); datos.Fill(dtUsu); int contUsu = dtUsu.Rows.Count; string codUsu = (contUsu + 1) + libg.genUsu(txtNom.Text.Trim() + " " + txtApe.Text.Trim()); string pass = genPas.contrasena(); command = conn.CreateCommand(); command.CommandText = "INSERT INTO usuario (nomUsu, apellido, email, dirUsu, celUsu, usuario, password, idRol, oficina_idOfi) " + "VALUES (@nom, @ape, @email, @dir, @cel, @usuario, AES_ENCRYPT(@password,'codActFij'), @idRol, @oficina)"; command.Parameters.Add("@nom", MySqlDbType.String).Value = txtNom.Text.Trim(); command.Parameters.Add("@ape", MySqlDbType.String).Value = txtApe.Text.Trim(); command.Parameters.Add("@dir", MySqlDbType.String).Value = txtDir.Text.Trim(); command.Parameters.Add("@email", MySqlDbType.String).Value = txtEmail.Text.Trim(); command.Parameters.Add("@cel", MySqlDbType.String).Value = txtCel.Text.Trim(); command.Parameters.Add("@usuario", MySqlDbType.String).Value = codUsu; command.Parameters.Add("@password", MySqlDbType.String).Value = pass; command.Parameters.Add("@idRol", MySqlDbType.Int32).Value = Convert.ToInt32(cbRol.SelectedValue); command.Parameters.Add("@oficina", MySqlDbType.Int32).Value = Convert.ToInt32(cbOfi.SelectedValue); command.ExecuteNonQuery(); envMail send = new envMail(); send.sendPass(1, txtEmail.Text.Trim(), pass, codUsu, txtNom.Text.Trim() + " " + txtApe.Text.Trim()); MessageBox.Show("Registro Ingresado Exitosamente", "Registro Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); conn.Close(); txtNom.Text = ""; txtApe.Text = ""; txtDir.Text = ""; txtEmail.Text = ""; txtCel.Text = ""; } } catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }