-- option explicit
This commit is contained in:
@@ -369,7 +369,7 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
|
|
||||||
Dim FileExcel As New ExcelFile()
|
Dim FileExcel As New ExcelFile()
|
||||||
|
|
||||||
Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
|
Dim worksheet As ExcelWorksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
|
||||||
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
||||||
{
|
{
|
||||||
.ColumnHeaders = True,
|
.ColumnHeaders = True,
|
||||||
@@ -379,8 +379,8 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255))
|
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255))
|
||||||
worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255)
|
worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255)
|
||||||
|
|
||||||
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
Dim columnCount As Integer = worksheet.CalculateMaxUsedColumns()
|
||||||
For i = 0 To columnCount
|
For i As Integer = 0 To columnCount
|
||||||
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
||||||
Next
|
Next
|
||||||
|
|
||||||
@@ -401,7 +401,7 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||||
Dim Tipo As String = "EXCEL"
|
Dim Tipo As String = "EXCEL"
|
||||||
Dim dt As DataTable = Nothing
|
Dim dt As DataTable = Nothing
|
||||||
Dim ErrorArchivo = False
|
Dim ErrorArchivo As Boolean = False
|
||||||
|
|
||||||
Try
|
Try
|
||||||
dt = ReadExcelFile(Ruta + FileName, True)
|
dt = ReadExcelFile(Ruta + FileName, True)
|
||||||
@@ -459,14 +459,13 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
For Each row As DataRow In dt.Rows
|
For Each row As DataRow In dt.Rows
|
||||||
Dim Correcto As Boolean = False
|
Dim Correcto As Boolean = False
|
||||||
Dim TieneError As Boolean = False
|
Dim TieneError As Boolean = False
|
||||||
Dim CvePS As Integer = DtPS.FiltroPrimeroValor("CvePS", String.Format("Codigo='{0}' AND CveEmpresa={1}", row(0).ToString(), UsuarioActual.CveEmpresa)).ToEntero
|
Dim CvePS As Integer = DtPS.FiltroPrimeroValor("CvePS", String.Format("Codigo='{0}'", row(0).ToString())).ToEntero
|
||||||
Dim CvePrecioLista As Integer = DdlPrecioListaCarga.SelectedValue.ToEntero()
|
Dim CvePrecioLista As Integer = DdlPrecioListaCarga.SelectedValue.ToEntero()
|
||||||
Dim PrecioNuevo As Decimal = row("Precio").ToString().ToDecimal()
|
Dim PrecioNuevo As Decimal = row("Precio").ToString().ToDecimal()
|
||||||
Dim Porcentaje As Decimal = -1
|
Dim Porcentaje As Decimal = -1
|
||||||
|
|
||||||
If CvePS > 0 AndAlso CvePrecioLista > 0 Then
|
If CvePS > 0 AndAlso CvePrecioLista > 0 Then
|
||||||
|
|
||||||
|
|
||||||
Correcto = ObjPS.UpdatePSPreciosLista(PrecioNuevo, CvePrecioLista, Porcentaje, CvePS, UsuarioActual.CveUsuario, NowADS(), True)
|
Correcto = ObjPS.UpdatePSPreciosLista(PrecioNuevo, CvePrecioLista, Porcentaje, CvePS, UsuarioActual.CveUsuario, NowADS(), True)
|
||||||
If Correcto Then
|
If Correcto Then
|
||||||
RowsCargados += 1
|
RowsCargados += 1
|
||||||
@@ -509,54 +508,8 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable
|
|
||||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
|
||||||
Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath)
|
|
||||||
|
|
||||||
Dim unnamed As Integer = 0
|
|
||||||
Dim cols As Integer
|
|
||||||
Dim columns As String()
|
|
||||||
Dim curRow As Integer = 0
|
|
||||||
Dim curCol As Integer = 0
|
|
||||||
Dim dataTable As DataTable = New DataTable()
|
|
||||||
Dim worksheet As ExcelWorksheet = excelFile.Worksheets(0)
|
|
||||||
|
|
||||||
For cols = 0 To worksheet.Rows(0).AllocatedCells.Count - 1
|
|
||||||
|
|
||||||
If firstRowHasHeaders Then
|
|
||||||
|
|
||||||
If worksheet.Rows(0).Cells(cols).Value IsNot Nothing Then
|
|
||||||
dataTable.Columns.Add(worksheet.Rows(0).Cells(cols).Value.ToString())
|
|
||||||
Else
|
|
||||||
dataTable.Columns.Add("Unnamed Column " & (System.Threading.Interlocked.Increment(unnamed)))
|
|
||||||
End If
|
|
||||||
|
|
||||||
curRow = 1
|
|
||||||
Else
|
|
||||||
dataTable.Columns.Add("Column " & (cols + 1))
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
While curRow < worksheet.Rows.Count
|
|
||||||
columns = New String(cols - 1) {}
|
|
||||||
|
|
||||||
For curCol = 0 To cols - 1
|
|
||||||
|
|
||||||
If worksheet.Rows(curRow).Cells(curCol).Value Is Nothing Then
|
|
||||||
columns(curCol) = ""
|
|
||||||
Else
|
|
||||||
columns(curCol) = worksheet.Rows(curRow).Cells(curCol).Value.ToString()
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
dataTable.Rows.Add(columns)
|
|
||||||
curRow += 1
|
|
||||||
End While
|
|
||||||
|
|
||||||
Return dataTable
|
|
||||||
End Function
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
Protected Sub gvSucursal_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
Protected Sub gvSucursal_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
||||||
@@ -570,11 +523,10 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
Dim StrMsg As New StringBuilder
|
Dim StrMsg As New StringBuilder
|
||||||
Dim StrMsgError As New StringBuilder
|
Dim StrMsgError As New StringBuilder
|
||||||
If FranquiciasStr <> "" Then
|
If FranquiciasStr <> "" Then
|
||||||
|
Dim Franquicias As String() = FranquiciasStr.Split(","c)
|
||||||
Dim Franquicias = FranquiciasStr.Split(","c)
|
|
||||||
Dim Porcentaje As Decimal = If(TxtPorcentaje.Text = "", -1, TxtPorcentaje.Text.ToDecimal)
|
Dim Porcentaje As Decimal = If(TxtPorcentaje.Text = "", -1, TxtPorcentaje.Text.ToDecimal)
|
||||||
|
|
||||||
For Each Franquicia In Franquicias
|
For Each Franquicia As String In Franquicias
|
||||||
Dim CveFranquicia As Integer = Franquicia.ToEntero
|
Dim CveFranquicia As Integer = Franquicia.ToEntero
|
||||||
Dim CvePS As Integer = GlobalDTPSSimplificado(CveFranquicia, Codigo:=Codigo).FiltroPrimeroValor("CvePS", "").ToEntero
|
Dim CvePS As Integer = GlobalDTPSSimplificado(CveFranquicia, Codigo:=Codigo).FiltroPrimeroValor("CvePS", "").ToEntero
|
||||||
Dim CvePrecioLisa As Integer = GlobalDTPrecioListas(CveFranquicia).FiltroPrimeroValor("CvePrecioLista", String.Format("PrecioLista = '{0}'", PrecioLista)).ToEntero
|
Dim CvePrecioLisa As Integer = GlobalDTPrecioListas(CveFranquicia).FiltroPrimeroValor("CvePrecioLista", String.Format("PrecioLista = '{0}'", PrecioLista)).ToEntero
|
||||||
@@ -672,7 +624,7 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
|
|
||||||
Dim FileExcel As New ExcelFile()
|
Dim FileExcel As New ExcelFile()
|
||||||
|
|
||||||
Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
|
Dim worksheet As ExcelWorksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
|
||||||
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
||||||
{
|
{
|
||||||
.ColumnHeaders = True,
|
.ColumnHeaders = True,
|
||||||
@@ -682,8 +634,8 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255))
|
worksheet.Rows(0).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(75, 119, 190), SpreadsheetColor.FromArgb(255, 255, 255))
|
||||||
worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255)
|
worksheet.Rows(0).Style.Font.Color = SpreadsheetColor.FromArgb(255, 255, 255)
|
||||||
|
|
||||||
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
Dim columnCount As Integer = worksheet.CalculateMaxUsedColumns()
|
||||||
For i = 0 To columnCount
|
For i As Integer = 0 To columnCount
|
||||||
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
||||||
Next
|
Next
|
||||||
|
|
||||||
@@ -695,10 +647,10 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
|
|
||||||
|
|
||||||
worksheet.Rows.InsertEmpty(0, TotalRowHeader)
|
worksheet.Rows.InsertEmpty(0, TotalRowHeader)
|
||||||
Dim celdasConTexto = worksheet.GetUsedCellRange(True)
|
Dim celdasConTexto As CellRange = worksheet.GetUsedCellRange(True)
|
||||||
celdasConTexto.Style.Font.Name = "Calibri Light"
|
celdasConTexto.Style.Font.Name = "Calibri Light"
|
||||||
|
|
||||||
Dim RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex)
|
Dim RangoNombreEmpresa As CellRange = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex)
|
||||||
RangoNombreEmpresa.Merged = True
|
RangoNombreEmpresa.Merged = True
|
||||||
RangoNombreEmpresa.Value = UsuarioActual.Empresa.Empresa
|
RangoNombreEmpresa.Value = UsuarioActual.Empresa.Empresa
|
||||||
RangoNombreEmpresa.Style.Font.Size = 20 * 20
|
RangoNombreEmpresa.Style.Font.Size = 20 * 20
|
||||||
@@ -707,7 +659,7 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
||||||
|
|
||||||
|
|
||||||
Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex)
|
Dim RangoTitulo As CellRange = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex)
|
||||||
RangoTitulo.Merged = True
|
RangoTitulo.Merged = True
|
||||||
RangoTitulo.Value = Titulo
|
RangoTitulo.Value = Titulo
|
||||||
RangoTitulo.Style.Font.Size = 17 * 20
|
RangoTitulo.Style.Font.Size = 17 * 20
|
||||||
@@ -728,7 +680,7 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
|
|
||||||
|
|
||||||
If ListaPrecios.Length > 0 Then
|
If ListaPrecios.Length > 0 Then
|
||||||
Dim RangoSubProyecto = worksheet.Cells.GetSubrangeAbsolute(5, celdasConTexto.FirstColumnIndex, 5, celdasConTexto.LastColumnIndex)
|
Dim RangoSubProyecto As CellRange = worksheet.Cells.GetSubrangeAbsolute(5, celdasConTexto.FirstColumnIndex, 5, celdasConTexto.LastColumnIndex)
|
||||||
RangoSubProyecto.Merged = True
|
RangoSubProyecto.Merged = True
|
||||||
RangoSubProyecto.Value = $"Lista de precio: {ListaPrecios}"
|
RangoSubProyecto.Value = $"Lista de precio: {ListaPrecios}"
|
||||||
RangoSubProyecto.Style.Font.Size = 14 * 20
|
RangoSubProyecto.Style.Font.Size = 14 * 20
|
||||||
@@ -737,8 +689,7 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
RangoSubProyecto.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
RangoSubProyecto.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
For i As Integer = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
|
||||||
For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
|
|
||||||
|
|
||||||
worksheet.Rows(8).Cells(i).Style.Font.Size = 12 * 20
|
worksheet.Rows(8).Cells(i).Style.Font.Size = 12 * 20
|
||||||
worksheet.Rows(8).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
|
worksheet.Rows(8).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
|
||||||
@@ -746,24 +697,17 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
|
|
||||||
worksheet.Rows(8).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255))
|
worksheet.Rows(8).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255))
|
||||||
worksheet.Rows(8).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)
|
worksheet.Rows(8).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
If i > 0 Then
|
If i > 0 Then
|
||||||
Try
|
Try
|
||||||
worksheet.Columns(i).AutoFit(1)
|
worksheet.Columns(i).AutoFit(1)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
End Try
|
End Try
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
|
||||||
Dim IndexEndTable As Integer = DtExcel.Rows.Count + TotalRowHeader + TotalRowFooter
|
Dim IndexEndTable As Integer = DtExcel.Rows.Count + TotalRowHeader + TotalRowFooter
|
||||||
|
|
||||||
worksheet.Rows(IndexEndTable).Cells(0).Value = "Usuario Imprimió"
|
worksheet.Rows(IndexEndTable).Cells(0).Value = "Usuario Imprimió"
|
||||||
worksheet.Rows(IndexEndTable + 1).Cells(0).Value = UsuarioActual.Nombre
|
worksheet.Rows(IndexEndTable + 1).Cells(0).Value = UsuarioActual.Nombre
|
||||||
|
|
||||||
worksheet.Rows(IndexEndTable).Cells(2).Value = "Fecha Impresión"
|
worksheet.Rows(IndexEndTable).Cells(2).Value = "Fecha Impresión"
|
||||||
worksheet.Rows(IndexEndTable + 1).Cells(2).Value = NowADS().ToString("dd/MM/yyyy")
|
worksheet.Rows(IndexEndTable + 1).Cells(2).Value = NowADS().ToString("dd/MM/yyyy")
|
||||||
|
|
||||||
@@ -778,8 +722,7 @@ Partial Class Ventas_ActualizarPrecios
|
|||||||
End Using
|
End Using
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
For I As Integer = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
|
||||||
For I = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
|
|
||||||
|
|
||||||
If I > 0 Then
|
If I > 0 Then
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user