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
No hay comentarios:
Publicar un comentario