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); }
private bool checkAdd() { bool correct = true; if (string.IsNullOrEmpty(txtUser.Text)) { correct = false; } if (string.IsNullOrEmpty(txtPassword.Text)) { correct = false; } if (string.IsNullOrEmpty(txtRepPass.Text)) { correct = false; } if (string.IsNullOrEmpty(cmbRol.Text)) { correct = false; } if (!txtPassword.Text.Equals(txtRepPass.Text)) { correct = false; } if (GestorUsers.existsUser(txtUser.Text)) { correct = false; } return(correct); }
public String updateSql() { String sql = "update usuario set password = '******', "; sql += "refrol = " + refRol; sql += " where upper(name) = '" + usuario + "'"; return(sql); }
public User(string nombre, string apellidos, string email, int telefono)//un nuevo usuario creado dede la interfaz, tiene un id automatico { this.gestor = new GestorUsers(); this.iduser = gestor.getLastId() + 1; this.nombre = nombre; this.apellidos = apellidos; this.email = email; this.telefono = telefono; this.photo = null; }
public void setContra(String contra) { if (contra.Equals("admin1234", StringComparison.OrdinalIgnoreCase)) { this.contra = (contra); } else { GestorUsers g = new GestorUsers(); this.contra = g.GetMD5V2(contra); } }
private void btnAddNew_Click(object sender, EventArgs e) { if (checkAdd()) { String sql = insertSql(); GestorUsers.insertUser(sql); clean(); } else { MessageBox.Show(errorDialog()); } }
private void btnAdd_Click(object sender, EventArgs e) { if (checkAdd()) { String sql = insertSql(); GestorUsers.insertUser(sql); //Console.WriteLine(GestorUsers.GetMD5(txtPassword.Text)); Dispose(); } else { MessageBox.Show(errorDialog()); } }
public ModUser(string usuario, string idioma) { this.usuario = usuario; oldPass = GestorUsers.getData("password", "usuario", "upper(name) = '" + usuario.ToUpper() + "'"); InitializeComponent(); lblUsuario.Text = usuario; initRole(" where deleted = 0"); this.idioma = idioma; if (this.idioma == "ESPAÑOL") { idioma_es(); this.Text = "Modificar Usuario"; } else if (this.idioma == "INGLES") { idioma_en(); this.Text = "Modify User"; } }
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 void btnDelete_Click(object sender, EventArgs e) { String usuario = dgvUsers.Rows[dgvUsers.CurrentRow.Index].Cells[0].Value.ToString(); if (this.idioma == "ESPAÑOL") { if (MessageBox.Show("¿Estas seguro de eliminar el usuario?", "Eliminar Usuario", MessageBoxButtons.YesNo) == DialogResult.Yes) { String sql = "update usuario set deleted=1 where upper(name) ='" + usuario.ToUpper() + "'"; GestorUsers.delUser(sql); initTable(" where us.deleted = 0"); } } else { if (MessageBox.Show("Do yo want to delete this user?", "Delete User", MessageBoxButtons.YesNo) == DialogResult.Yes) { String sql = "update usuario set deleted=1 where upper(name) ='" + usuario.ToUpper() + "'"; GestorUsers.delUser(sql); initTable(" where us.deleted = 0"); } } }
public User() { this.gestor = new GestorUsers(); }
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); } }
private void cmbRole_SelectedIndexChanged(object sender, EventArgs e) { refRol = Convert.ToInt16(GestorUsers.getData("idRol", "rol", "upper(name) = '" + cmbRol.SelectedItem.ToString().ToUpper() + "'")); }
private String errorDialog() { if (this.idioma == "ESPAÑOL") { String error = "Se han encontrado algunos errores: \n"; if (string.IsNullOrEmpty(txtUser.Text)) { error += "\t - El campo \"Usuario\" no puede estar vacio. \n"; } if (string.IsNullOrEmpty(txtPassword.Text)) { error += "\t - El campo \"Contraseña\" no puede estar vacio. \n"; } if (string.IsNullOrEmpty(txtRepPass.Text)) { error += "\t - El campo \"Rpetir contraseña\" no puede estar vacio. \n"; } if (string.IsNullOrEmpty(cmbRol.Text)) { error += "\t - El campo \"Rol\" no puede estar vacio. \n"; } if (GestorUsers.existsUser(txtUser.Text)) { error += "\t - Este usuario ya existe. \n"; } if (!txtPassword.Text.Equals(txtRepPass.Text)) { error += "\t - Las contraseñas no coinciden."; } return(error); } else { String error = "Some Errors have been found: \n"; if (string.IsNullOrEmpty(txtUser.Text)) { error += "\t - The field \"User\" can't be empty. \n"; } if (string.IsNullOrEmpty(txtPassword.Text)) { error += "\t - The field \"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.existsUser(txtUser.Text)) { error += "\t - This user already exists. \n"; } if (!txtPassword.Text.Equals(txtRepPass.Text)) { error += "\t - Passwords do not 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); }
public User() { g = new GestorUsers(); }