Excel de productos y modificacion en grids para inventario fisco
This commit is contained in:
@@ -3,6 +3,7 @@ Option Explicit On
|
||||
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports GemBox.Spreadsheet
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class Inventarios_InventarioFisicoDetalle
|
||||
@@ -49,6 +50,7 @@ Partial Class Inventarios_InventarioFisicoDetalle
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
@@ -153,7 +155,14 @@ Partial Class Inventarios_InventarioFisicoDetalle
|
||||
CveAlmacenesStr.AppendFormat("{0},", dr("CveAlmacen"))
|
||||
Next
|
||||
End If
|
||||
LblAlmacenes.Text = str.ToString
|
||||
If str.ToString.Length > 500 Then
|
||||
LblAlmacenes.Text = str.ToString.Substring(0, 500)
|
||||
LblAlmacenes.ToolTip = str.ToString
|
||||
Else
|
||||
LblAlmacenes.Text = str.ToString
|
||||
End If
|
||||
str.Clear()
|
||||
|
||||
CveAlmacenes = CveAlmacenesStr.ToString.Substring(0, CveAlmacenesStr.Length - 1)
|
||||
End If
|
||||
|
||||
@@ -165,12 +174,24 @@ Partial Class Inventarios_InventarioFisicoDetalle
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
||||
str.AppendFormat("{0},", dr("Clasificacion"))
|
||||
Next
|
||||
LblClasif.Text = str.ToString
|
||||
If str.ToString.Length > 500 Then
|
||||
LblClasif.Text = str.ToString.Substring(0, 29)
|
||||
LblClasif.ToolTip = str.ToString
|
||||
Else
|
||||
LblClasif.Text = str.ToString
|
||||
End If
|
||||
str.Clear()
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows
|
||||
str.AppendFormat("{0},", dr("Clasificacion"))
|
||||
Next
|
||||
LblClasificacionesExcluidas.Text = str.ToString
|
||||
Next
|
||||
If str.ToString.Length > 500 Then
|
||||
LblClasificacionesExcluidas.Text = str.ToString.Substring(0, 500)
|
||||
LblClasificacionesExcluidas.ToolTip = str.ToString
|
||||
Else
|
||||
LblClasificacionesExcluidas.Text = str.ToString
|
||||
End If
|
||||
str.Clear()
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
@@ -182,13 +203,26 @@ Partial Class Inventarios_InventarioFisicoDetalle
|
||||
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
||||
str.AppendFormat("{0},", dr("CodigoPS"))
|
||||
Next
|
||||
LblProductos.Text = str.ToString
|
||||
Next
|
||||
If str.ToString.Length > 500 Then
|
||||
LblProductos.Text = str.ToString.Substring(0, 500)
|
||||
LblProductos.ToolTip = str.ToString
|
||||
|
||||
Else
|
||||
LblProductos.Text = str.ToString
|
||||
End If
|
||||
str.Clear()
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows
|
||||
str.AppendFormat("{0},", dr("CodigoPS"))
|
||||
Next
|
||||
LblProductosExcluidos.Text = str.ToString
|
||||
Next
|
||||
If str.ToString.Length > 500 Then
|
||||
LblProductosExcluidos.Text = str.ToString.Substring(0, 500)
|
||||
LblProductosExcluidos.ToolTip = str.ToString
|
||||
Else
|
||||
LblProductosExcluidos.Text = str.ToString
|
||||
End If
|
||||
str.Clear()
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
@@ -200,8 +234,13 @@ Partial Class Inventarios_InventarioFisicoDetalle
|
||||
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
||||
str.AppendFormat("{0},", dr("RazonSocial"))
|
||||
Next
|
||||
LblProveedores.Text = str.ToString
|
||||
Next
|
||||
If str.ToString.Length > 500 Then
|
||||
LblProveedores.Text = str.ToString.Substring(0, 500)
|
||||
LblProveedores.ToolTip = str.ToString
|
||||
Else
|
||||
LblProveedores.Text = str.ToString
|
||||
End If
|
||||
str.Clear()
|
||||
End If
|
||||
|
||||
@@ -566,7 +605,6 @@ Partial Class Inventarios_InventarioFisicoDetalle
|
||||
Private Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
|
||||
Impimir(Formato:="EXCEL")
|
||||
End Sub
|
||||
|
||||
Protected Sub Impimir(Optional Formato As String = "PDF", Optional Agrupar As Boolean = False)
|
||||
Dim DtDatos As New DataTable
|
||||
Dim ObjInventario As New ClsInventarios()
|
||||
@@ -607,6 +645,86 @@ Partial Class Inventarios_InventarioFisicoDetalle
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub LnkExcelUniverso_Click(sender As Object, e As EventArgs) Handles LnkExcelUniverso.Click
|
||||
Dim IncluyePS, ExcluyePS, IncluyeClasificacion, ExcluyeClasificacion, IncluyeProveedor As New StringBuilder
|
||||
Dim ObjInventario As New ClsInventarios
|
||||
|
||||
If ObjInventario.GetInventarioFisicoDetallesClasificacion(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
||||
Dim dt As DataTable = ObjInventario.DtResultados
|
||||
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
||||
IncluyeClasificacion.AppendFormat("{0},", dr("CveClasificacion"))
|
||||
Next
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows
|
||||
ExcluyeClasificacion.AppendFormat("{0},", dr("CveClasificacion"))
|
||||
Next
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If ObjInventario.GetInventarioFisicoDetallesProductosServicios(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
||||
Dim dt As DataTable = ObjInventario.DtResultados
|
||||
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
||||
IncluyePS.AppendFormat("{0},", dr("CvePS"))
|
||||
Next
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 0").Rows
|
||||
ExcluyePS.AppendFormat("{0},", dr("CvePS"))
|
||||
Next
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If ObjInventario.GetInventarioFisicoDetallesProveedores(CveInventarioFisico, UsuarioActual.CveEmpresa) Then
|
||||
Dim dt As DataTable = ObjInventario.DtResultados
|
||||
Dim str As New StringBuilder
|
||||
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
||||
For Each dr As DataRow In dt.FiltraParametros("Incluye = 1").Rows
|
||||
IncluyeProveedor.AppendFormat("{0},", dr("CveProveedor"))
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
Dim dtPS As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa)
|
||||
If IncluyePS.ToString <> "" Then
|
||||
dtPS = dtPS.FiltraParametros(String.Format("CvePS IN ({0})", IncluyePS.ToString.TrimEnd(",")))
|
||||
End If
|
||||
If ExcluyePS.ToString <> "" Then
|
||||
dtPS = dtPS.FiltraParametros(String.Format("CvePS NOT IN ({0})", ExcluyePS.ToString.TrimEnd(",")))
|
||||
End If
|
||||
If IncluyeClasificacion.ToString <> "" Then
|
||||
dtPS = dtPS.FiltraParametros(String.Format("CveClasificacion IN ({0})", IncluyeClasificacion.ToString.TrimEnd(",")))
|
||||
End If
|
||||
If ExcluyeClasificacion.ToString <> "" Then
|
||||
dtPS = dtPS.FiltraParametros(String.Format("CveClasificacion NOT IN ({0})", ExcluyeClasificacion.ToString.TrimEnd(",")))
|
||||
End If
|
||||
If IncluyeProveedor.ToString <> "" Then
|
||||
dtPS = dtPS.FiltraParametros(String.Format("CveProveedorCompra IN ({0})", IncluyeProveedor.ToString.TrimEnd(",")))
|
||||
End If
|
||||
dtPS = dtPS.FiltraParametros("", "PS", {"Codigo", "PS"})
|
||||
Dim NombreArchivo As String
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
Dim workbook As New ExcelFile()
|
||||
Dim worksheet = workbook.Worksheets.Add("Cxp")
|
||||
worksheet.InsertDataTable(dtPS, New InsertDataTableOptions() With
|
||||
{
|
||||
.ColumnHeaders = True,
|
||||
.StartRow = 0,
|
||||
.StartColumn = 0
|
||||
})
|
||||
|
||||
'worksheet.Columns("B").Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255))
|
||||
'worksheet.Columns("C").Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255))
|
||||
'worksheet.Columns("Q").Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255))
|
||||
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(217, 217, 217), SpreadsheetColor.FromArgb(255, 255, 255))
|
||||
|
||||
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
||||
For i = 0 To columnCount
|
||||
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
||||
Next
|
||||
|
||||
NombreArchivo = "CxP"
|
||||
workbook.Save(Response, $"{NombreArchivo}.xlsx", SaveOptions.XlsxDefault)
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
Protected Sub BtnBuscarCodVarras_Click(sender As Object, e As EventArgs)
|
||||
@@ -647,4 +765,68 @@ Partial Class Inventarios_InventarioFisicoDetalle
|
||||
|
||||
' UPAgregarPro.Update()
|
||||
'End Sub
|
||||
|
||||
Protected Sub LnkEditar_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
||||
LimpiarModal()
|
||||
HfCveInventarioFisicoDetalle.Value = GvRow.DataKey("CveInventarioFisicoDetalle").ToString
|
||||
|
||||
HfCvePS.Value = GvRow.DataKey("CvePS").ToString
|
||||
HfCveUM.Value = GvRow.DataKey("CveUnidadMedida").ToString
|
||||
|
||||
TxtSerieLote.Text = GvRow.DataKey("SerieLote").ToString
|
||||
TxtLoteEdit.Text = GvRow.DataKey("Lote").ToString
|
||||
TxtFechaCaducida.Text = GvRow.DataKey("FechaCaducidad").ToString
|
||||
TxtCantidad.Text = GvRow.DataKey("Cantidad").ToString
|
||||
UpEditarPS.Update()
|
||||
|
||||
RegistraScript("$('#ModalEditarPS').modal('show')")
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub LimpiarModal()
|
||||
HfCveInventarioFisicoDetalle.Value = ""
|
||||
HfCvePS.Value = ""
|
||||
HfCveUM.Value = ""
|
||||
TxtSerieLote.Text = ""
|
||||
TxtLoteEdit.Text = ""
|
||||
TxtFechaCaducida.Text = ""
|
||||
TxtCantidad.Text = ""
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnGuadarEditarPS_Click(sender As Object, e As EventArgs)
|
||||
Dim objInventario As New ClsInventarios
|
||||
If Not TxtCantidad.Text.ToEntero > 0 Then
|
||||
Alert("La cantidad debe ser mayor a 0", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
Dim serie As String = IIf(TxtSerieLote.Text.ToString = "", "-1", TxtSerieLote.Text.ToString)
|
||||
Dim Lote As String = IIf(TxtLoteEdit.Text.ToString = "", "-1", TxtLoteEdit.Text.ToString)
|
||||
Dim FechaCaducida As Date = IIf(TxtFechaCaducida.Text.ToString = "", MinFecha, TxtFechaCaducida.Text.ToString.ToDate)
|
||||
|
||||
If objInventario.UpdateInventarioFisicoDetalles(HfCveInventarioFisicoDetalle.Value.ToEntero, HfCvePS.Value.ToEntero, HfCveUM.Value.ToEntero, TxtCantidad.Text.ToEntero, serie, Lote, FechaCaducida) Then
|
||||
If objInventario.GetInventarioFisicoDetalle(CveInventarioFisico, ddlUsuario.SelectedValue.ToString.ToEntero) Then
|
||||
GvIFD.DataSource = objInventario.DtResultados
|
||||
End If
|
||||
|
||||
GvIFD.DataBind()
|
||||
|
||||
If (GvIFD.Rows.Count > 0) Then
|
||||
GvIFD.UseAccessibleHeader = True
|
||||
GvIFD.HeaderRow.TableSection = TableRowSection.TableHeader
|
||||
RegistraScript("OrdenarGV();")
|
||||
End If
|
||||
|
||||
UPPInventario.Update()
|
||||
UPAgregarPro.Update()
|
||||
RegistraScript("$('#ModalEditarPS').modal('hide')")
|
||||
Alert("Se modico el producto correctamente", TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
Alert("Ocurrio un error al actuliazar", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
objInventario.Dispose()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user