/// <summary> /// Metodo que agregra los usuarios a la base de datos /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAgregar_Click(object sender, EventArgs e) { try { IBLLSeguridad _BLLSeguridad = new BLLSeguridad(); Usuario oUsuario = new Usuario(); if (string.IsNullOrEmpty(txtNombreUsuario.Text)) { erpErrores.SetError(txtNombreUsuario, "Debe contener un valor"); return; } if (string.IsNullOrEmpty(txtContrasena.Text)) { erpErrores.SetError(txtContrasena, "Debe contener un valor"); return; } oUsuario = _BLLSeguridad.AgregarUsuario(FactoryUsuario.ConstruirUsuario(txtNombreUsuario.Text, txtContrasena.Text, cboTipoUsuario.SelectedItem.ToString())); CargarUsuarios(); } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Metodo que elimina el usuario seleccionado /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEliminar_Click(object sender, EventArgs e) { try { IBLLSeguridad _BLLSeguridad = new BLLSeguridad(); if (dgvUsuarios.SelectedRows.Count == 0) { erpErrores.SetError(dgvUsuarios, "Debe seleccionar un usuario"); return; } _BLLSeguridad.EliminarUsuario(dgvUsuarios.SelectedRows[0].Cells[1].Value.ToString(), dgvUsuarios.SelectedRows[0].Cells[0].Value.ToString()); CargarUsuarios(); } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal void GuardarPermisosUsuario(TextBox txtUsuario, DevExpress.XtraEditors.ListBoxControl lstPermisosAsignados) { #region GuardarPermisosUsuario seguridad.BorrarPermisosUsuarioBLL(txtUsuario.Text.ToUpper().Trim()); foreach (var permiso in lstPermisosAsignados.Items) { seguridad = new BLLSeguridad(); seguridad._permisoUsuario.PermisoID = Convert.ToDecimal(permiso.ToString().Split('-')[0]); seguridad._permisoUsuario.Usuario = txtUsuario.Text.Trim().ToUpper(); seguridad.GuardarPermisosUsuarioBLL(); } #endregion }
/// <summary> /// Metodo que verifica si el usuario es administrador /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEntrar_Click(object sender, EventArgs e) { try { erpErrores.Clear(); if (string.IsNullOrEmpty(txtUsuario.Text)) { erpErrores.SetError(txtUsuario, "No puede quedar vacío"); return; } if (string.IsNullOrEmpty(txtContrasenna.Text)) { erpErrores.SetError(txtContrasenna, "No puede quedar vacío"); return; } Usuario oUsuario = new Usuario(); IBLLSeguridad _BLLSeguridad = new BLLSeguridad(); oUsuario = _BLLSeguridad.SelectUsuarioXID(txtContrasenna.Text, txtUsuario.Text); if (oUsuario == null) { throw new Exception("El usuario no existe"); } else { if (oUsuario.TipoUsuario.Equals("Procesos") || oUsuario.TipoUsuario.Equals("Reporteador")) { throw new Exception("Solo los usuarios administradores pueden acceder a esta opción"); } else { DialogResult = DialogResult.OK; Close(); } } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); MessageBox.Show("Se produjo el siguiente error :" + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public LoginController() { validador = new Validador(); seguridad = new BLLSeguridad(); }
/// <summary> /// Metodo que carga los usuarios existentes en el data grid view /// </summary> public void CargarUsuarios() { IBLLSeguridad _BLLSeguridad = new BLLSeguridad(); dgvUsuarios.DataSource = _BLLSeguridad.ObtenerUsuarios(); }
public UsuarioController() { seguridad = new BLLSeguridad(); validador = new Validador(); }