viernes, 31 de julio de 2020

Consultar Deposito Mayorista (Expresiones de combo box, control grid)

Public Class Consultar_Deposito_Mayorista

#Region "Declaraciones"
    Private ObjReqRN As New ReqRN
    Private _dtResu As New DataTable
    Public idcliente As Integer
    Private FBD_Exportar As New System.Windows.Forms.FolderBrowserDialog
    Private mDt As New DataTable
    Private _idUbicacion As Integer
#End Region

#Region "Funciones"

#End Region

    Private Sub CargarComboClientes(ByVal unUsuario As Integer)
        Dim dtResu As New DataTable
        ObjReqRN = New ReqRN

        GLUE_Cliente.Properties.DataSource = ObjReqRN.SP_PLUS_REQUERIMIENTOS_LISTAR_CLIENTE_X_USUARIO_COMBO_STOCK '(unUsuario)
        GLUE_Cliente.Properties.PopulateViewColumns()
        GLUE_Cliente.Properties.DisplayMember = "Cliente"
        GLUE_Cliente.Properties.ValueMember = "idcliente"
        GLUE_Cliente.Properties.View.Columns("idcliente").Visible = False

    End Sub
    Private Sub CargarComboClientesLocales()
        Dim dtResu As New DataTable
        ObjReqRN = New ReqRN

        GLUE_Cliente.Properties.DataSource = ObjReqRN.SP_PLUS_REQUERIMIENTOS_CLIENTES_STOCK_LISTADO_LOCALES '(unUsuario)
        GLUE_Cliente.Properties.PopulateViewColumns()
        GLUE_Cliente.Properties.DisplayMember = "Cliente"
        GLUE_Cliente.Properties.ValueMember = "idcliente"
        GLUE_Cliente.Properties.View.Columns("idcliente").Visible = False

    End Sub

    Private Sub Consultar_Deposito_Mayorista_Load(sender As Object, e As EventArgs) Handles Me.Load
        LimpiarCampos_Datos()
        'CargarComboClientes(My.Application.IDUSUARIO)
    End Sub
    Private Sub Cargar_Gcstock()
        ObjReqRN = New ReqRN
        Dim _dtResu = New DataTable
        Try
            idcliente = GLUE_Cliente.EditValue
            If idcliente <> 0 Then
                _dtResu = ObjReqRN.SP_PLUS_REQUERIMIENTOS_CLIENTES_STOCK_LEER_DEPOSITOS(idcliente)
                If Not IsNothing(_dtResu) Then
                    GcStockMayor.DataSource = _dtResu
                    Dim _ubicacion As String = _dtResu.Rows(0).Item(7)
                    Dim _subDeposito As String = _dtResu.Rows(0).Item(8)
                    Dim _Deposito As String = _dtResu.Rows(0).Item(9)
                    Dim _sede As String = _dtResu.Rows(0).Item(10)

                    CargaDatosLb(_ubicacion, _subDeposito, _Deposito, _sede)
                Else
                    GcStockMayor.DataSource = Nothing
                End If
            End If
        Catch ex As Exception
            MessageBox.Show("#ERROR D001" & ex.ToString, "Consultar Deposito", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
        End Try

    End Sub

    Private Sub RecuperaDatosConsulta()
        Try
            mDt = New DataTable
            idcliente = GLUE_Cliente.EditValue
            mDt = AccesoBase.SetSP("SP_PLUS_REQUERIMIENTOS_CLIENTES_STOCK_DATOS_CONSULTA").SetParam(idcliente, "RRL")
            If Not IsNothing(mDt) Then
                _idUbicacion = mDt.Rows(0).Item("UBICACION")
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub Cargar_Gcstock_Locales()
        RecuperaDatosConsulta()
        ObjReqRN = New ReqRN
        Dim _dtResu = New DataTable
        Try
            idcliente = GLUE_Cliente.EditValue.ToString
            If idcliente <> 0 Then
                '_dtResu = ObjReqRN.SP_PLUS_REQUERIMIENTOS_CLIENTES_STOCK_LEER_DEPOSITOS(idcliente, _idUbicacion)

                _dtResu = AccesoBase.SetSP("SP_PLUS_REQUERIMIENTOS_CLIENTES_STOCK_LEER_DEPOSITOS_LOCALES").SetParam(idcliente, _idUbicacion)
                'If Not IsNothing(mDtListadoArbol) Then

                If Not IsNothing(_dtResu) Then
                    GcStockMayor.DataSource = _dtResu
                    Dim _ubicacion As String = _dtResu.Rows(0).Item(7)
                    Dim _subDeposito As String = _dtResu.Rows(0).Item(8)
                    Dim _Deposito As String = _dtResu.Rows(0).Item(9)
                    Dim _sede As String = _dtResu.Rows(0).Item(10)

                    CargaDatosLb(_ubicacion, _subDeposito, _Deposito, _sede)
                Else
                    GcStockMayor.DataSource = Nothing
                End If
            End If
        Catch ex As Exception
            MessageBox.Show("#ERROR D001" & ex.ToString, "Consultar Deposito", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
        End Try

    End Sub

    Private Sub CargaDatosLb(ByVal ubicacion As String, ByVal subDeposito As String, ByVal Deposito As String, ByVal sede As String)
        LblDestinoSedeDato.Text = sede
        LblDestinoDepositoDato.Text = Deposito
        LblDestinoSubDepositoDato.Text = subDeposito
        LblDestinoUbicacionDato.Text = ubicacion
        Me.Refresh()
    End Sub


    Private Sub GLUE_Cliente_EditValueChanged(sender As Object, e As EventArgs) Handles GLUE_Cliente.EditValueChanged
        If RB_Mayor.Checked Then
            Cargar_Gcstock()
        Else
            Cargar_Gcstock_Locales()
        End If

    End Sub
    '****************** exportación *******************
    Private Sub Btn_ExportarExcel_Click(sender As Object, e As EventArgs) Handles Btn_ExportarExcel.Click
        FBD_Exportar = New System.Windows.Forms.FolderBrowserDialog
        Dim _valido As Boolean = True
        Try
            If (GLUE_Cliente.EditValue = 0 And GvDestino.RowCount = 0) Then
                MessageBox.Show("Algunos campos estan vacios, verifique de nuevo", "Exportar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
                Exit Sub
            End If
            If (GvDestino.RowCount = 0) Then
                If (MessageBox.Show("La tabla esta vacia, ¿Igual deseas Exportar?", "Exportar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)) = Windows.Forms.DialogResult.No Then
                    _valido = False
                End If
            Else
                If _valido = True Then
                    Dim Path As String = ""
                    If FBD_Exportar.ShowDialog() = Windows.Forms.DialogResult.OK Then
                        Path = FBD_Exportar.SelectedPath & "\Stock_Deposito_" & Trim(GLUE_Cliente.Text) & "_" & Date.Now.ToString("ddMMyyyy") & ".XLS"
                        GvDestino.ExportToXls(Path)
                        MessageBox.Show("Se exportó el archivo correctamente en la ruta seleccionada.", "Exportar", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
                    End If
                    LimpiarCampos_Datos()
                End If
            End If
            
        Catch ex As Exception
            MessageBox.Show("#ERROR D002: al intentar exportar archivo de excel." & vbCrLf & ex.Message, "Exportar", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
 
    Private Sub BTSalir_Click(sender As Object, e As EventArgs) Handles BTSalir.Click
        Me.Close()
    End Sub
    Private Sub LimpiarCampos_Datos()
        LblDestinoSedeDato.Text = ""
        LblDestinoDepositoDato.Text = ""
        LblDestinoSubDepositoDato.Text = ""
        LblDestinoUbicacionDato.Text = ""
        GcStockMayor.DataSource = Nothing
    End Sub

    Private Sub RB_Mayor_CheckedChanged(sender As Object, e As EventArgs) Handles RB_Mayor.CheckedChanged
        LimpiarCampos_Datos()
        CargarComboClientes(My.Application.IDUSUARIO)
    End Sub

    Private Sub RB_Locales_CheckedChanged(sender As Object, e As EventArgs) Handles RB_Locales.CheckedChanged
        LimpiarCampos_Datos()
        CargarComboClientesLocales()
    End Sub


End Class

jueves, 30 de julio de 2020

FUNCIONES DECLARADAS con Shared

Las funciones declaradas con Shared quieren decir que son definidas a nivel de clase no de instancia, por lo tanto la invocas directo con el nombre de la clase que la contenga, sin usar el "new"

por ejmeplo si tienes la clase

Public Class Prueba

  Public  Shared Function GetValor() As Int

      Return 10

  End Function

End Class

desde tu formulario lo usarias

TextBox1.Text = CStr(Prueba.GetValor())

o sea directamente nombre de la clase y nombre del metodo


Ejemplo de declaraciones de shared en la clase PermisosControles  del aplicativo seguridad plus.




Public Class ControlesPermisos

    Inherits DevExpress.XtraEditors.XtraForm


#Region "Declaraciones"


    Private Shared mDtListadoControles As New DataTable

    Private Shared WithEvents RibbonControl As DevExpress.XtraBars.Ribbon.RibbonControl

    Private Shared Solapas As DevExpress.XtraBars.Ribbon.RibbonPage

    Private Shared Grupo As DevExpress.XtraBars.Ribbon.RibbonPageGroup

    Private Shared Category As DevExpress.XtraBars.Ribbon.RibbonPageCategory

    Private Shared Boton As DevExpress.XtraBars.BarItemLink

    Private Shared ObjReqRN As New ReqRN


    Private Shared CotrolTab = New DevExpress.XtraTab.XtraTabControl

    Private Shared PageTab = New DevExpress.XtraTab.XtraTabPage

    'Private ColeccionTab = New DevExpress.XtraTab.XtraTabPageCollection

 

#End Region



#Region "Funciones"

    Public Shared Sub RegistrarCtrlMenues(ByRef unForm As Form)


        Dim Pagina As DevExpress.XtraBars.Ribbon.RibbonPage

        Dim Grupo As DevExpress.XtraBars.Ribbon.RibbonPageGroup

        Dim CntGrupo As Integer = 0

        Dim Boton As DevExpress.XtraBars.BarItemLink

        Dim CntBoton As Integer = 0

        Dim DT_Pagina, DT_Boton As New DataTable

        Dim idAplicacion As Integer = My.Application.IDAPLICACION



        Dim _descripcion As String

        Dim _descripcionUNO As String

        For Each Pagina In Principal.RBMenu.Pages

            ObjReqRN = New ReqRN

            'DT_Pagina =

            ObjReqRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(idAplicacion, Pagina.Name.ToString, Pagina.Name.ToString)

            For Each Grupo In Pagina.Groups

                _descripcionUNO = Pagina.Name + "/" + Grupo.Name

                ObjReqRN = New ReqRN

                ObjReqRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(idAplicacion, Grupo.Name.ToString, _descripcionUNO)

                For Each Boton In Grupo.ItemLinks

                    _descripcion = Pagina.Name + "/" + Grupo.Name + "/" + Boton.Item.Name ' REGISTRA LOS GRUPOS TAMBIEN

                    ' _descripcion = Pagina.Name + "/" + Boton.Item.Name ' AQUI NO REGISTRA LOS GRUPOPS SOLO LOS BOTONES

                    ObjReqRN = New ReqRN

                    ObjReqRN.SP_HERRAMIENTAS_SIGMA_SEGURIDAD_INGRESAR_CONTROL_POR_APLICACION(idAplicacion, Boton.Item.Name.ToString, _descripcion)

                Next 'Links

            Next 'Grupo

        Next 'Pagina


    End Sub




miércoles, 29 de julio de 2020

Ejecutar un formulario dentro de otro formulario Padre vb.net

El formulario donde haras el codigo que acontinuacion te muestro es el padre o donde va reposar el otro formulario cuando lo ejecutes, y el que estamos definiendo como instancia, es el hijo.


 If mostrar Then
            Me.fHojaDeRutaLista = New FormHojaDeRutaLista
            Me.fHojaDeRutaLista.MdiParent = Me
            Me.fHojaDeRutaLista.Show()
End If

La palabra (Me) nos dice que el formulario hijo se ejecutara aqui.

la instancia del formulario hijo:

            Me.fHojaDeRutaLista.Show()


Configurar controlgrid (grilla, filtros dentro de la grilla) vb.net









Se debe seleccionar primero la opcion  (option view show group panel option)





Una vez seleccionada la opcion que muestra el campo en la pantalla anterior te permite , seleccionar una columna, para mover al lugar del filtros para colocar dentro de la grilla un filtro o una pestaña que te clasifica los estados en este caso.


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...