private bool checkUpdate() { bool correct = true; if (string.IsNullOrEmpty(txtOldPass.Text)) { correct = false; } if (string.IsNullOrEmpty(txtNewPass.Text)) { correct = false; } if (string.IsNullOrEmpty(txtRepPass.Text)) { correct = false; } if (string.IsNullOrEmpty(cmbRol.Text)) { correct = false; } if (!txtNewPass.Text.Equals(txtRepPass.Text)) { correct = false; } if (!oldPass.Equals(GestorUsers.GetMD5(txtOldPass.Text))) { correct = false; } return(correct); }
public String updateSql() { String sql = "update usuario set password = '******', "; sql += "refrol = " + refRol; sql += " where upper(name) = '" + usuario + "'"; return(sql); }
private void btnChange_Click(object sender, EventArgs e) { if (MessageBox.Show("Do yo want to update this user's info?", "Update User", MessageBoxButtons.YesNo) == DialogResult.Yes) { Console.WriteLine(refRol); Console.WriteLine(usuario); Console.WriteLine(oldPass); Console.WriteLine(GestorUsers.GetMD5(txtOldPass.Text.ToString())); if (checkUpdate()) { String sql = updateSql(); GestorUsers.setData(sql); Dispose(); } else { MessageBox.Show(errorDialog()); } } }
private String errorDialog() { if (this.idioma == "ESPAÑOL") { String error = "Se han encontrado algunos errores: \n"; if (string.IsNullOrEmpty(txtOldPass.Text)) { error += "\t - El campo \"Contraseña actual\" no puede estar vacio. \n"; } if (string.IsNullOrEmpty(txtNewPass.Text)) { error += "\t - El campo \"Nueva contraseña\" no puede estar vacio. \n"; } if (string.IsNullOrEmpty(txtRepPass.Text)) { error += "\t - El campo \"Repetir contraseña\" no puede estar vacio. \n"; } if (string.IsNullOrEmpty(cmbRol.Text)) { error += "\t - El campo \"Rol\" no puede estar vacio. \n"; } if (!GestorUsers.GetMD5(txtOldPass.Text).Equals(oldPass)) { error += "\t - La contraseña actual es incorrecta. \n"; } if (!txtNewPass.Text.Equals(txtRepPass)) { error += "\t - Las contraseñas no coinciden"; } return(error); } else { String error = "Some Errors have been found: \n"; if (string.IsNullOrEmpty(txtOldPass.Text)) { error += "\t - The field \"Old Password\" can't be empty. \n"; } if (string.IsNullOrEmpty(txtNewPass.Text)) { error += "\t - The field \"New Password\" can't be empty. \n"; } if (string.IsNullOrEmpty(txtRepPass.Text)) { error += "\t - The field \"Repeat Password\" can't be empty. \n"; } if (string.IsNullOrEmpty(cmbRol.Text)) { error += "\t - The field \"Role\" can't be empty. \n"; } if (!GestorUsers.GetMD5(txtOldPass.Text).Equals(oldPass)) { error += "\t - The old password is wrong. \n"; } if (!txtNewPass.Text.Equals(txtRepPass)) { error += "\t - New passwords don't match"; } return(error); } }
public String insertSql() { String sql = "insert into usuario values (null,'" + txtUser.Text.ToUpper() + "','" + GestorUsers.GetMD5(txtPassword.Text) + "',"; sql += "0," + refRol + ")"; return(sql); }