コード例 #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            bool estaValidado = ValidarFormulario();

            if (!estaValidado)
            {
                return;
            }

            UsuarioBe registro = new UsuarioBe();

            if (codigoUsuario.HasValue)
            {
                registro.CodigoUsuario = codigoUsuario.Value;
            }
            registro.Nombre         = txtNombre.Text.Trim();
            registro.Contraseña     = Seguridad.MD5Byte(txtContraseña.Text);
            registro.CodigoPersonal = codigoPersonal.Value;
            TreeNode[]      treeNodeArray       = tvwPerfil.Nodes.Cast <TreeNode>().ToArray();
            List <PerfilBe> listaPerfilMarcados = ListarPerfilesMarcados(treeNodeArray);

            registro.ListaPerfil = listaPerfilMarcados;

            bool seGuardoRegistro = usuarioBl.GuardarUsuario(registro);

            if (seGuardoRegistro)
            {
                DialogResult = MessageBox.Show("¡El registro se guardó correctamente!", "¡Bien hecho!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
            else
            {
                MessageBox.Show("¡Ocurrió un error! Contáctese con el administrador del sistema", "¡Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
ファイル: UsuarioBl.cs プロジェクト: RSEANCAS/bilecom
        public bool CambiarContrasena(int empresaId, int usuarioId, string contrasena, string modificadoPor)
        {
            bool seCambio = false;

            byte[] _contrasena = null;
            try
            {
                cn.Open();
                _contrasena = Seguridad.MD5Byte(contrasena);
                seCambio    = usuarioDa.CambiarContrasena(empresaId, usuarioId, _contrasena, modificadoPor, cn);
            }
            catch (Exception ex) { throw ex; }
            finally { if (cn.State == ConnectionState.Open)
                      {
                          cn.Close();
                      }
            }

            return(seCambio);
        }