jueves, 17 de marzo de 2022

Los mail de oulook no se pueden reenviar.

 cuando en el asunto poseen un caracter especial por ejemplo @#$ los correos no salen y no te muestra ningun correo de rebote, especialmente cuando se envian a gmail.

reenviar con otro nombre sin los caracteres. porque los ve como spam

viernes, 7 de enero de 2022

Exportar a Excel Varias Gridcontrol, vb.net

Imports DevExpress.XtraPrintingLinks

Imports DevExpress.XtraGrid

Imports DevExpress.XtraPrinting


  Private Sub cmdExcel_Click(sender As Object, e As EventArgs) Handles cmdExcel.Click

       Me.Cursor = Cursors.WaitCursor

      Try

        Using SFD As SaveFileDialog = GetExcelSaveFileDialog()

            If (SFD.ShowDialog(Me) = DialogResult.OK) Then

                    Dim ps As New PrintingSystem

                    Dim CompositeLink As New DevExpress.XtraPrintingLinks.CompositeLink

                    CompositeLink.PrintingSystem = ps

                    'con este metodo podemos exportar varias grillas mas no data grid view.

declaramos un vector y asignamos las grillas necesarias.

 Dim lgc() As DevExpress.XtraGrid.GridControl = {gc_ventas, gridVacia, gc_Stock, gridVacia, gc_0kmAsignado, gridVacia, gc_0kmS_Asignar, gridVacia, gc_TTVU}

                For i As Integer = 0 To lgc.Length - 1

                        Dim link As New PrintableComponentLink

                        link.Component = lgc(i)

                        CompositeLink.Links.Add(link)

                Next

                    CompositeLink.ExportToXls(SFD.FileName)

                End If

        End Using

        Me.Cursor = Cursors.Default


        Catch ex As Exception

            XtraMessageBox.Show("" & ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)

            Exit Sub

        End Try

martes, 8 de junio de 2021

Validar cuil Argentina, vb.net

 Private Sub te_cuil_Leave(sender As Object, e As EventArgs) Handles Txt_Cuil.Leave


        If Txt_Cuil.Text <> "" Then

            Dim a(11) As Integer, n As Single

            'cargo en la matriz de izquierda a derecha los numeros correspondientes

            'al cuit ingresado en text1.text sin los guiones suponiendo

            'que el cuit o cuil sea = 30-50052945-4


            a(1) = CInt(Mid(Txt_Cuil.Text, 1, 1)) '= 3

            a(2) = CInt(Mid(Txt_Cuil.Text, 2, 1)) '= 0

            a(3) = CInt(Mid(Txt_Cuil.Text, 4, 1)) '= 5

            a(4) = CInt(Mid(Txt_Cuil.Text, 5, 1)) '= 0

            a(5) = CInt(Mid(Txt_Cuil.Text, 6, 1)) '= 0

            a(6) = CInt(Mid(Txt_Cuil.Text, 7, 1)) '= 5

            a(7) = CInt(Mid(Txt_Cuil.Text, 8, 1)) '= 2

            a(8) = CInt(Mid(Txt_Cuil.Text, 9, 1)) '= 9

            a(9) = CInt(Mid(Txt_Cuil.Text, 10, 1)) '= 4

            a(10) = CInt(Mid(Txt_Cuil.Text, 11, 1)) '= 5

            a(11) = CInt(Mid(Txt_Cuil.Text, 13, 1)) '= 4


            'calculo el digito verificador

            n = (a(1) * 6) + (a(2) * 7) + (a(3) * 8) + (a(4) * 9) + (a(5) * 4) + (a(6) * 5) + (a(7) * 6) + (a(8) * 7) + (a(9) * 8) + (a(10) * 9)

            n = ((n / 11) - Int(n / 11)) * 11


            'el valor de n tiene que ser = a a(11) es decir 4 o el cuit esta mal

            If n = a(11) Then


            Else

                XtraMessageBox.Show("El cuil es incorrecto", "Error al ingresar el Cuil", MessageBoxButtons.OK, MessageBoxIcon.Error)

            End If

        Else

            XtraMessageBox.Show("Debe Ingresar el Cuil", "", MessageBoxButtons.OK, MessageBoxIcon.Error)

            Txt_Cuil.Focus()

        End If



    End Sub



---------------------------------------------------------------------------------------------------------

  Public Shared Function NumeroCuit(ByVal numero As String) As Boolean

            Dim iSuma As Integer = 0

            Dim bValidado As Boolean = False

            numero = numero.Replace("-", "")

            If IsNumeric(numero) Then

                If CLng(numero) <= 0 Then Return False

                If numero.Length <> 11 Then

                    Return False

                Else

                    Dim inicio As Integer = CInt(numero.Substring(0, 2))

                    If inicio <> 20 And inicio <> 23 And inicio <> 24 And inicio <> 27 _

                        And inicio <> 30 And inicio <> 33 Then Return False

                    iSuma += CInt(numero.Substring(0, 1)) * 5

                    iSuma += CInt(numero.Substring(1, 1)) * 4

                    iSuma += CInt(numero.Substring(2, 1)) * 3

                    iSuma += CInt(numero.Substring(3, 1)) * 2

                    iSuma += CInt(numero.Substring(4, 1)) * 7

                    iSuma += CInt(numero.Substring(5, 1)) * 6

                    iSuma += CInt(numero.Substring(6, 1)) * 5

                    iSuma += CInt(numero.Substring(7, 1)) * 4

                    iSuma += CInt(numero.Substring(8, 1)) * 3

                    iSuma += CInt(numero.Substring(9, 1)) * 2

                    iSuma += CInt(numero.Substring(10, 1)) * 1

                End If


                If Math.Round(iSuma / 11, 0) = (iSuma / 11) Then

                    bValidado = True

                End If

            End If

            Return bValidado

        End Function

sábado, 22 de mayo de 2021

Error Code: 1267 Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_spanish_ci,IMPLICIT) for operation '='

 En el trabajo he tenido que modificar el modelo de una base de datos MySQL para un proyecto ya casi terminado (benditos lusers que no saben cómo hacen lo que hacen), por lo que creé un par de procedimientos almacenados. En mi equipo funcionaban perfectamente, pero al probarlo en otro no hacía más que mostrar el error:

ERROR 1267 (HY000): Illegal mix of collations (utf8_spanish_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='

El único punto del procedimiento donde podía ocurrir era en un where donde se comparaban dos longtext:

select id into errorid from errortecnico
where mensaje = errormensaje

Buscando y buscando encontré la inspiración en el blog de Pablo Viquez, un desarrollador de Costa Rica, con la única diferencia de que su problema ocurría con la codificación latin1.

La solución es convertir la parte del where que causa problemas a la collation (dentro de una codificación, la ordenación de caracteres) que nosotros usamos mediante la sentencia convert, que en mi caso quedaría tal que así:

select id into errorid from errortecnico where mensaje
CONVERT(errormensaje using utf8) collate utf8_spanish_ci

Con esto, MySQL convertirá automáticamente el dato que interpretaba como utf8_general_ci a utf8_spanish_ci.

tomado de: https://arklad.wordpress.com/2010/03/23/illegal-mix-of-collations-en-procedimiento-almacenado-de-mysql/

jueves, 6 de mayo de 2021

Buscar Procedimiento almacenado en mysql, comprobar si existe

 SELECT EXISTS(SELECT 1 FROM mysql.proc p WHERE db = 'db_name' AND name = 'stored_proc_name');

por lo que podría hacer:

IF NOT EXISTS(SELECT 1 FROM mysql.proc p WHERE db = 'db_name' AND name = 'stored_proc_name') THEN 
.... 
END IF; 

domingo, 11 de abril de 2021

TRIGGER mysql yog Ejemplo

 DELIMITER $$

Observacion: Quiero dispara un registro log en la tbl t_turno_log despues que en la tbl t_turnos de la bd turnos, se registre un nuevo turno.

USE `turnos`$$


DROP TRIGGER /*!50032 IF EXISTS */ `automatico`$$


CREATE

    /*!50017 DEFINER = 'root'@'localhost' */

    TRIGGER `automatico` AFTER INSERT ON `t_turno` 

    FOR EACH ROW BEGIN 

INSERT INTO `turnos`.`t_turno_log`(`codigo`,`descripcion`,`fecha`,`usuario`)

VALUES(NULL,'Se ingreso un nuevo turno.',CURRENT_TIMESTAMP,1);

    END;

$$


DELIMITER ;

jueves, 8 de octubre de 2020

Como ordenar los resultados de una consulta 1,2,5,6,3,4 con ORDER BY SQL SERVER. Otra forma de ordernar forzando los resultados con ORDER BY

 Se crea una tabla con dos campos donde el primero tenga el mismo orden de la consulta que quieres ordenar, y el segundo campo lo colocamos con el orden deseado

ejemplo: Script

necesitamos ordenar un resultado de la forma siguiente:

1,2,3,4,5,6,7,8,10,11,12,9

con el nueve al final de todo.

pasos 1

creamos la tabla que va forzar el orden


CREATE  TABLE ORDENADOR_EQUIVALENTE

(numero VARCHAR(10), 

 valor VARCHAR(10)

 )


insertamos los datos:


campo número esta ordenado y tiene los mismo de la consulta.

campo valor esta ordenado como vos queres y con letras.


 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '01','a')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '02','b')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '03','c')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '04','d')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '05','e')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '06','f')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '07','g')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '08','h')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '09','l')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '10','i')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '11','j')

 INSERT INTO ORDENADOR_EQUIVALENTE  VALUES( '12','k')

solo debemos relacionarla en el lugar presiso y que sea el campo numero el que se relacione 

ej.

 INNER JOIN ORDENADOR_EQUIVALENTE OE ON OE.numero = MAESTRA.IDESTADOHDR


y el campo valor el que ordene en la clausu: 

ej.

ORDER BY OE.valor ASC,HIS.TS desc

listo.




viernes, 18 de septiembre de 2020

crear tabla temporal y asignacion de registros / insertar registros desde una consulta SQL SERVER / insert records from a SQL SERVER query

 


----CREAMOS LA TABLA TEMPORAL

-- CREATE TABLE #temporal( IdPedidoDetalle BIGINT,IdPedido  bigint,IdArt  bigint,IdColor  bigint ,IdTalle  bigint,Cantidad  int,Precio  int,Ts  datetime)

-- INSERT INTO #temporal 

--SELECT IdPedidoDetalle, IdPedido, IdArt, IdColor, IdTalle, Cantidad, Precio, Ts FROM RDSAWSSQL.CATALOGO.dbo.SIGMA_CATALOGO_PEDIDO_DETALLES  AS scpd WITH (NOLOCK) WHERE SCPD.ts  BETWEEN @FDESDE AND @FHASTA

--------------------------------

--CREATE TABLE #temporal_cambio (IdPedidoDetalleCambio BIGINT,IdPedido  bigint,IdArt  bigint,IdColor  bigint ,IdTalle  bigint,Cantidad  int,Ts  datetime)

-- INSERT INTO #temporal_cambio 

--SELECT IdPedidoDetalleCambio,IdPedido,IdArt,IdColor,IdTalle,Cantidad,Ts FROM RDSAWSSQL.CATALOGO.dbo.SIGMA_CATALOGO_PEDIDO_DETALLES_CAMBIOS AS d WITH (NOLOCK) WHERE ts > @fdesde  

------

--CREATE TABLE #TEMPORAL_CABECERA

--       ( IdPedido bigint ,IdCliente  bigint ,IdToken  int,IdEstado  int,TipoCompra  varchar(100),QuienRetira  varchar(400),QuienRecibe varchar(400),Observaciones  varchar(400),CodigoEnvio  varchar(500),FechaAlta  datetime

--          ,Ts  datetime,NroFactura  varchar(200),Operacion  varchar(200),ObservacionesVendedor  varchar(max),EsResolucion  int,IdDireccion  bigint)

--INSERT into #TEMPORAL_CABECERA 

--SELECT IdPedido,IdCliente,IdToken,IdEstado,TipoCompra,QuienRetira,QuienRecibe,Observaciones,CodigoEnvio,FechaAlta,Ts,NroFactura,Operacion,ObservacionesVendedor,EsResolucion,IdDireccion

-- FROM RDSAWSSQL.CATALOGO.dbo.SIGMA_CATALOGO_PEDIDOS_CABECERA AS cb WITH (NOLOCK) WHERE cb.ts >  @FDESDE

-------

--CREATE TABLE #TEMPORAL_PEDIDO_HISTORICO (IdHistorial bigint,IdPedido  bigint,IdEstado  int,IdUsuario  int,Ts  datetime)

--INSERT INTO #TEMPORAL_PEDIDO_HISTORICO        

--SELECT IdHistorial,IdPedido,IdEstado,IdUsuario,Ts FROM  RDSAWSSQL.CATALOGO.dbo.SIGMA_CATALOGO_PEDIDOS_ESTADOS_HISTORIAL AS D WHERE D.TS > '20200801'

------

viernes, 21 de agosto de 2020

Class Principal Gestion de Devolucion

 Public Class Principal

#Region "Declaraciones"

    Private LABASE As String

    Private SERVIDOR As String

    Private mDtResultado As New DataTable

    Private ConeccionExitosa As Boolean

    Private ResuBoolean As Boolean = False

    Private LogueoExitoso As Boolean

    Private AvisarAlSalir As Boolean

    Private sUsuario As String

    Private FrmGestiondeDevolucion As GestiondeDevolucion

    Private FrmAuditoria As AuditoriaCorreos

#End Region


#Region "Eventos"


    Private Sub Principal_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Try

            IniciarAplicacion()

            OperacionesControles()

        Catch ex As Exception

            GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: al intentar abrir la aplicación. " & vbCrLf & ex.Message.ToString).ShowDialog()

        End Try

    End Sub

#End Region


#Region "Funciones"


    Private Sub OperacionesControles()

        RegistroControles()

        EjecutarPermisos()

    End Sub

    Private Sub RegistroControles()

        ControlesPermisos.RegistrarControles(Me)

    End Sub


    Private Sub EjecutarPermisos()

        ControlesPermisos.DesactivarControlesAplicacion(Me)

        ControlesPermisos.ActivarControlesPorPefil(Me, My.Application.IDAPLICACION, My.Application.IDPERFIL)

        ControlesPermisos.ActivarControlesPorUsuario(Me, My.Application.IDAPLICACION, My.Application.IDUSUARIO)

    End Sub


    Private Sub IniciarAplicacion()

        InfoUsuario()

        InfoBD()

        ValidarVersiones(My.Application.IDAPLICACION)

        If ConectarUsuarioAAplicacionSinSeguridad(My.Application.IDUSUARIO, My.Application.IDAPLICACION, My.Computer.Name.ToString, My.Application.Info.Version.ToString) = False Then

            Me.Close()

        Else

            LogueoExitoso = True

        End If



    End Sub

    Private Function ConectarUsuarioAAplicacionSinSeguridad(ByVal unUsuario As Integer, ByVal unaAplicacion As Integer, ByVal unaPC As String,

                                         ByVal unaVersion As String) As Boolean

        mDtResultado = New DataTable

        ResuBoolean = False

        mDtResultado = AccesoBase.SetSP("SP_HERRAMIENTAS_SIGMA_CONECTAR_USUARIO_A_APLICACION_SIN_BLOQUEO").SetParam(unUsuario, unaAplicacion, unaPC, unaVersion)

        If mDtResultado IsNot Nothing Then

            ' 1 - INSERTO CORRECTAMENTE

            '-1 - FALLO EL INSERT

            ' 2 - HIZO EL UPDATE DEL ESTADO CORRECTAMENTE

            '-2 - FALLO EL UPDATE DEL ESTADO 

            Select Case mDtResultado.Rows(0).Item(0)

                Case 1

                    ResuBoolean = True

                Case -1

                    GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "Falló el ingreso del dato en la tabla 'HERRAMIENTAS_SIGMA_USUARIOS_CONECTADOS'").ShowDialog()

                Case 2

                    ResuBoolean = True

                Case -2

                    GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "Falló la actualización del dato en la tabla 'HERRAMIENTAS_SIGMA_USUARIOS_CONECTADOS'").ShowDialog()

            End Select

        Else

            ResuBoolean = False

        End If


        Return ResuBoolean

    End Function

    Private Sub ValidarVersiones(ByVal unIdAplicacion As Integer)

        Try

            mDtResultado = New DataTable

            mDtResultado = AccesoBase.SetSP("SP_MAESTRO_VERSIONES_LEER").SetParam(unIdAplicacion)

            If mDtResultado IsNot Nothing Then

                If mDtResultado.Rows(0).Item("VERSIONACTUAL") = My.Application.Info.Version.ToString Then

                    'Ok tiene la version actual

                Else

                    If mDtResultado.Rows(0).Item("VERSIONANTERIOR") = My.Application.Info.Version.ToString Then

                        'Tiene la versión anterior

                        If mDtResultado.Rows(0).Item("URGENTE") = 0 Then

                            'No es urgente

                        Else

                            'La actualización debe ser inmediatamente

                            GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Adveretencia, "Su versión está desactualizada, por favor salga del Sigma y vuelva a ingresar.").ShowDialog()


                            Application.ExitThread()

                        End If

                    Else

                        'Tiene una versión no registrada - mail a sistemas


                        'EnviarMail("desarrollo@mimo.com.ar", "Sigma - Versión no registrada", "URGENTE. La computadora " & My.Computer.Name & " (usuario " & My.Application.IDUSUARIO & ") posee una versión no registrada de la aplicación: " & My.Application.Info.AssemblyName & " (" & VVidaplic & "). version: " & My.Application.Info.Version.ToString)


                        GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Adveretencia, "Su versión no está registrada. Envío de email automático a Sistemas.").ShowDialog()

                        Application.ExitThread()

                    End If

                End If

            Else

                GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Adveretencia, "Ocurrio un error al validar la versión, se cerrará la aplicación. ").ShowDialog()

                Application.ExitThread()

            End If

        Catch ex As Exception

            GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Adveretencia, "Ocurrio un error al validar la versión, se cerrará la aplicación. " & vbCrLf & ex.Message.ToString).ShowDialog()

            Application.ExitThread()

        End Try

    End Sub

    Public Sub InfoBD()


        If AccesoBase.ObtenerBase <> "SIGMA" Then

            LABASE = " | Base: " & UCase(AccesoBase.ObtenerBase)

            SERVIDOR = " | Servidor: " & IIf(UCase(AccesoBase.ObtenerServidor) = "SR01SIG01" Or UCase(AccesoBase.ObtenerServidor) = "192.168.1.20", "PRODUCCIÓN", "TESTING")

        Else

            LABASE = ""

            'SERVIDOR = " | Servidor: " & UCase(objRemRN.ppServidor)

            SERVIDOR = " | Servidor: " & IIf(UCase(AccesoBase.ObtenerServidor) = "SR01SIG01" Or UCase(AccesoBase.ObtenerServidor) = "192.168.1.20", "PRODUCCIÓN", "TESTING")

        End If


        Me.Text = Me.Text & SERVIDOR & LABASE & " | Versión  " & My.Application.Info.Version.ToString


        ''Cargo la infro al supertip

        'Dim sTooltip2 As SuperToolTip = New SuperToolTip

        'Dim args As SuperToolTipSetupArgs = New SuperToolTipSetupArgs

        'args.Title.Text = "Mensaje del sistema"

        'args.Contents.Text = "Usted se encuentra en: " & vbCrLf & SERVIDOR & LABASE & vbCrLf & " | Versión  " & My.Application.Info.Version.ToString

        'args.Contents.Image = My.Resources.database_32x32

        ''args.Footer.Text = "Equipo de sistemas"

        'sTooltip2.Setup(args)


        '' Assign the created SuperToolTip to a BarItem.

        ''BarStaticItem_BASE.SuperTip = sTooltip2

    End Sub


    Private Sub InfoUsuario()

        sUsuario = ObtenerUsuarioLogueado(My.Application.IDUSUARIO)


    End Sub


    Private Function ObtenerUsuarioLogueado(ByVal idUsuario As Integer) As String

        mDtResultado = New DataTable

        mDtResultado = AccesoBase.SetSP("SP_ECOMMERCE_DEVOLUCION_OBTENER_USUARIO_LOGUEADO").SetParam(idUsuario)

        If mDtResultado IsNot Nothing Then

            Return mDtResultado.Rows(0).Item(0)

        Else

            Return Nothing

        End If

    End Function


    Private Sub BBI_Devoluciones_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBI_Devoluciones.ItemClick

        Try


            FrmGestiondeDevolucion = New GestiondeDevolucion

            FrmGestiondeDevolucion.Show()

        Catch ex As Exception

            GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: al intentar abrir 'Gestión de Devolucion'." & vbCrLf & ex.Message.ToString).ShowDialog()

        End Try

    End Sub


    Private Sub BBI_AuditoriaCorreo_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BBI_AuditoriaCorreo.ItemClick

        Try


            FrmAuditoria = New AuditoriaCorreos

            FrmAuditoria.Show()

        Catch ex As Exception

            GestorMensajes.MensajeDelSistema(MensajeSistema.TipoDeMensaje.Errores, "#ERROR: al intentar abrir 'Gestión Auditoria de Correos'." & vbCrLf & ex.Message.ToString).ShowDialog()

        End Try

    End Sub


#End Region


End Class

lunes, 3 de agosto de 2020

ControlesPermisos MENU ITEM


Public Class ControlesPermisos
#Region "DECLARACION"

    Private Shared Menu As System.Windows.Forms.ToolStripMenuItem
    Private Shared SubMenu As System.Windows.Forms.ToolStripDropDownItem
    Private Shared submenu_ As System.Windows.Forms.ToolStripItem
    Public Shared mDtListadoControles = New DataTable
    Private Shared objPedidosRN = New VMPedidosRN.PedidosRN

#End Region

#Region "FUNCIONES"


    Public Shared Sub RegistrarControles(ByRef unform As Form) ' esta registra los controles de la aplicacion seguridad plues nada mas
        Dim nombreControl As String
        Dim descripcionControl As String = "testing-Seguridad"
        Dim descripcionControlRibbon As String = "testing-Ribbon"
        Try
            objPedidosRN = New VMPedidosRN.PedidosRN
            objPedidosRN.InicializarBase()

            'objAdmVentas_RN = New AdmVentas_RN.AdmVentas_RN
            'objAdmVentas_RN.InicializarBase()
            'Solapas = New DevExpress.XtraBars.Ribbon.RibbonPage
            'Grupo = New DevExpress.XtraBars.Ribbon.RibbonPageGroup
            'Category = New DevExpress.XtraBars.Ribbon.RibbonPageCategory
            'Dim sol As String = Category.Name

            Dim Ctrl As Control
            For i As Integer = 0 To unform.Controls.Count - 1
                Ctrl = unform.Controls.Item(i)
                If Ctrl.Name <> "" Then
                    If TypeOf (Ctrl) Is System.Windows.Forms.Control Then 'TypeOf (Ctrl) Is System.Windows.Forms.Form Or
                        nombreControl = Ctrl.Name
                        RegistroItems(Ctrl, unform)
                    Else
                        nombreControl = Ctrl.Name
                        objPedidosRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(My.Application.IDAPLICACION, nombreControl, descripcionControl)
                    End If
                End If

            Next
        Catch ex As Exception
            MessageBox.Show("" + ex.ToString)
        End Try
    End Sub


    'registro automatico de los controles ingresados al menu
    Public Shared Sub RegistroItems(ByRef unControl As System.Windows.Forms.Control, ByRef unform As Form)
        Dim Menu As System.Windows.Forms.ToolStripMenuItem
        Dim SubMenu As System.Windows.Forms.ToolStripDropDownItem
        Dim submenu_ As System.Windows.Forms.ToolStripItem
        Dim I, H As Integer
        Dim NombreControl, DescripcionControl As String
        Try
            For Each Menu In unform.MainMenuStrip.Items
                NombreControl = Menu.Name
                DescripcionControl = Menu.Text
                If DescripcionControl = "" Then
                    DescripcionControl = Menu.Name
                Else
                    DescripcionControl = Menu.Text
                End If

                objPedidosRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(My.Application.IDAPLICACION, NombreControl, DescripcionControl)
                For I = 0 To Menu.DropDownItems.Count - 1
                    If Menu.DropDownItems.Item(I).GetType().FullName = "System.Windows.Forms.ToolStripMenuItem" Then '---->Menu
                        SubMenu = Menu.DropDownItems.Item(I) '--->opciones del menu
                        NombreControl = SubMenu.Name
                        DescripcionControl = SubMenu.Text
                        If DescripcionControl = "" Then
                            DescripcionControl = Menu.Name + " / " + SubMenu.Name
                        Else
                            DescripcionControl = Menu.Text + " / " + SubMenu.Text
                        End If

                        objPedidosRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(My.Application.IDAPLICACION, NombreControl, DescripcionControl)
                        For H = 0 To SubMenu.DropDownItems.Count - 1
                            If SubMenu.DropDownItems.Item(H).GetType().FullName = "System.Windows.Forms.ToolStripMenuItem" Then '---->Menu
                                submenu_ = SubMenu.DropDownItems.Item(H) '--->opciones del menu
                                NombreControl = submenu_.Name
                                DescripcionControl = submenu_.Text
                                If DescripcionControl = "" Then
                                    DescripcionControl = Menu.Name + " / " + SubMenu.Name + " / " + submenu_.Name '"OpcMenu,Sin Definir"
                                Else
                                    DescripcionControl = Menu.Text + " / " + SubMenu.Text + " / " + submenu_.Text '"OpcMenu,Sin Definir"
                                End If
                                objPedidosRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(My.Application.IDAPLICACION, NombreControl, DescripcionControl)
                            End If
                        Next
                    End If
                Next
            Next
        Catch ex As Exception
            MessageBox.Show("#ERROR RC002, No se pudo realizar el registro de los controles: " + ex.ToString)
        End Try

    End Sub


    Public Shared Sub DesactivarControlesAplicacion(ByRef unForm As Form) 'se desactivan incialmente los controles para poder controlarlos
        Dim Menu As System.Windows.Forms.ToolStripMenuItem
        Dim SubMenu As System.Windows.Forms.ToolStripDropDownItem
        Dim submenu_ As System.Windows.Forms.ToolStripItem
        Dim I, H As Integer
        Dim NombreControl As String

        Try
            For Each Menu In unForm.MainMenuStrip.Items
                NombreControl = Menu.Name
                Menu.Enabled = False
                Menu.Visible = False
                For I = 0 To Menu.DropDownItems.Count - 1
                    If Menu.DropDownItems.Item(I).GetType().FullName = "System.Windows.Forms.ToolStripMenuItem" Then '---->Menu
                        SubMenu = Menu.DropDownItems.Item(I) '--->opciones del menu
                        NombreControl = SubMenu.Name
                        SubMenu.Enabled = False
                        SubMenu.Visible = False
                        For H = 0 To SubMenu.DropDownItems.Count - 1
                            If SubMenu.DropDownItems.Item(H).GetType().FullName = "System.Windows.Forms.ToolStripMenuItem" Then '---->Menu
                                submenu_ = SubMenu.DropDownItems.Item(H) '--->opciones del menu
                                NombreControl = submenu_.Name
                                submenu_.Enabled = False
                                submenu_.Visible = False
                            End If
                        Next
                    End If
                Next
            Next
        Catch ex As Exception
            MessageBox.Show("#ERROR DC1002, No se pudieron desactivar los controles: " + ex.ToString)
        End Try

    End Sub
    Public Shared Sub ActivarControlesPorPefil(ByRef unForm As Form, ByVal unIdAplicacion As Integer, ByVal unIdPerfil As Integer)
        Dim Menu As System.Windows.Forms.ToolStripMenuItem
        Dim SubMenu As System.Windows.Forms.ToolStripDropDownItem
        Dim submenu_ As System.Windows.Forms.ToolStripItem
        Dim I, H As Integer
        Dim NombreControl As String
        Try

            '    ''2) Obtengo el listado de los controles habilitados POR PERFIL desde el sistema de seguridad
            Dim mDtListadoControles = New DataTable

            objPedidosRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LISTADO_CONTROLES_POR_PERFIL(My.Application.IDAPLICACION, My.Application.IDPERFIL)
            mDtListadoControles = objPedidosRN.Tabla
            If Not IsNothing(mDtListadoControles) Then

                For Each Menu In unForm.MainMenuStrip.Items
                    NombreControl = Menu.Name
                    'Menu.Enabled = False                    
                    ActivarControlPorSeguridad(Menu, mDtListadoControles)
                    For I = 0 To Menu.DropDownItems.Count - 1
                        If Menu.DropDownItems.Item(I).GetType().FullName = "System.Windows.Forms.ToolStripMenuItem" Then '---->Menu
                            SubMenu = Menu.DropDownItems.Item(I) '--->opciones del menu
                            NombreControl = SubMenu.Name                           
                            'SubMenu.Enabled = False
                            ActivarControlPorSeguridad(SubMenu, mDtListadoControles)
                            For H = 0 To SubMenu.DropDownItems.Count - 1
                                If SubMenu.DropDownItems.Item(H).GetType().FullName = "System.Windows.Forms.ToolStripMenuItem" Then '---->Menu
                                    submenu_ = SubMenu.DropDownItems.Item(H) '--->opciones del menu
                                    NombreControl = submenu_.Name
                                    ActivarControlPorSeguridad(submenu_, mDtListadoControles)
                                End If
                            Next
                        End If

                    Next
                Next
            End If
        Catch ex As Exception
            MessageBox.Show("#ERROR RC002, No se pudo realizar el activación de los controles: " + ex.ToString)
        End Try

    End Sub
    Public Shared Sub ActivarControlesPorUsuario(ByRef unForm As Form, ByVal unIdAplicacion As Integer, ByVal unIdPerfil As Integer)
        Dim Menu As System.Windows.Forms.ToolStripMenuItem
        Dim SubMenu As System.Windows.Forms.ToolStripDropDownItem
        Dim submenu_ As System.Windows.Forms.ToolStripItem
        Dim I, H As Integer
        Dim NombreControl As String
        Try

            ''2) Obtengo el listado de los controles habilitados POR USUARIO desde el sistema de seguridad
            Dim mDtListadoControlesUSu = New DataTable
            objPedidosRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_LISTADO_CONTROLES_POR_USUARIO(My.Application.IDAPLICACION, My.Application.IDUSUARIO)
            mDtListadoControlesUSu = objPedidosRN.Tabla

            If Not IsNothing(mDtListadoControlesUSu) Then
                For Each Menu In unForm.MainMenuStrip.Items
                    NombreControl = Menu.Name
                    'Menu.Enabled = False
                    ActivarControlPorSeguridad(Menu, mDtListadoControlesUSu)
                    For I = 0 To Menu.DropDownItems.Count - 1
                        If Menu.DropDownItems.Item(I).GetType().FullName = "System.Windows.Forms.ToolStripMenuItem" Then '---->Menu
                            SubMenu = Menu.DropDownItems.Item(I) '--->opciones del menu
                            NombreControl = SubMenu.Name
                            ' SubMenu.Enabled = False
                            ActivarControlPorSeguridad(SubMenu, mDtListadoControlesUSu)
                            For H = 0 To SubMenu.DropDownItems.Count - 1
                                If SubMenu.DropDownItems.Item(H).GetType().FullName = "System.Windows.Forms.ToolStripMenuItem" Then '---->Menu
                                    submenu_ = SubMenu.DropDownItems.Item(H) '--->opciones del menu
                                    NombreControl = submenu_.Name
                                    ActivarControlPorSeguridad(submenu_, mDtListadoControlesUSu)
                                End If
                            Next
                        End If
                    Next
                Next
            End If
        Catch ex As Exception
            MessageBox.Show("#ERROR AC0034, No se pudo realizar la activación de los controles por usuario: " + ex.ToString)
        End Try
    End Sub


    Public Shared Sub ActivarControlPorSeguridad(ByVal NControl As ToolStripMenuItem, ByRef mdtListadocontroles1 As DataTable)

        For i As Integer = 0 To mdtListadocontroles1.Rows.Count - 1
            If NControl.Name = mdtListadocontroles1.Rows(i).Item("NOMBRECONTROL") Then
                NControl.Visible = mdtListadocontroles1.Rows(i).Item("VISIBLE")
                NControl.Enabled = mdtListadocontroles1.Rows(i).Item("ACTIVO")
                Exit For
            End If
        Next
    End Sub
    Public Shared Sub ActivarControlPorSeguridad(ByVal NControl As ToolStripDropDownItem, ByRef mdtListadocontroles1 As DataTable)

        For i As Integer = 0 To mdtListadocontroles1.Rows.Count - 1
            If NControl.Name = mdtListadocontroles1.Rows(i).Item("NOMBRECONTROL") Then
                NControl.Visible = mdtListadocontroles1.Rows(i).Item("VISIBLE")
                NControl.Enabled = mdtListadocontroles1.Rows(i).Item("ACTIVO")
                Exit For
            End If
        Next
    End Sub


    Public Shared Sub ActivarControlPorSeguridad(ByVal NControl As ToolStripItem, ByRef mdtListadocontroles1 As DataTable)
        For i As Integer = 0 To mdtListadocontroles1.Rows.Count - 1
            If NControl.Name = mdtListadocontroles1.Rows(i).Item("NOMBRECONTROL") Then
                NControl.Visible = mdtListadocontroles1.Rows(i).Item("VISIBLE")
                NControl.Enabled = mdtListadocontroles1.Rows(i).Item("ACTIVO")
                Exit For
            End If
        Next
    End Sub

#End Region

End Class

Los mail de oulook no se pueden reenviar.

 cuando en el asunto poseen un caracter especial por ejemplo @#$ los correos no salen y no te muestra ningun correo de rebote, especialmente...