cambio de nombre de objeto
This commit is contained in:
318
OC/OC.aspx.vb
318
OC/OC.aspx.vb
@@ -6082,51 +6082,51 @@ Partial Class OC
|
||||
End If
|
||||
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
|
||||
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
|
||||
|
||||
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
|
||||
@@ -7469,131 +7469,131 @@ Partial Class OC
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "C A R G A R E X C E L "
|
||||
#Region "C A R G A R E X C E L "
|
||||
Protected Sub BtnCargaExcelCot_Click(sender As Object, e As EventArgs)
|
||||
If TxtExcelCot.getfiles().Archivos.Count > 0 Then
|
||||
Dim file As Archivo = TxtExcelCot.getfiles().Archivos(0)
|
||||
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch
|
||||
CargarArchivoCot(Directorio, file.filename)
|
||||
|
||||
CargaCotizaciones(CveOrdenCompra)
|
||||
RegistraScript("$('#DivCargaExcelCotizaciones').modal('hide');")
|
||||
Else
|
||||
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
|
||||
If TxtExcelCot.getfiles().Archivos.Count > 0 Then
|
||||
Dim file As Archivo = TxtExcelCot.getfiles().Archivos(0)
|
||||
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch
|
||||
CargarArchivoCot(Directorio, file.filename)
|
||||
|
||||
CargaCotizaciones(CveOrdenCompra)
|
||||
RegistraScript("$('#DivCargaExcelCotizaciones').modal('hide');")
|
||||
Else
|
||||
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnDescargarFormatoCot_Click(sender As Object, e As EventArgs)
|
||||
'cantidad, Producto, Precio Unitario, Fecha Entrega, Observación
|
||||
Dim DtPS As DataTable = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
||||
|
||||
Dim DtPS As DataTable = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
||||
|
||||
Dim DtExcel As DataTable = (From row As GridViewRow In GvD.Rows
|
||||
Join rowPS In DtPS On rowPS("CvePS").ToString().ToEntero() Equals row.DataKey("CvePS").ToEntero()
|
||||
Where row.RowType = DataControlRowType.DataRow
|
||||
Select New With
|
||||
{
|
||||
.Cantidad = row.DataKey("Cantidad"),
|
||||
.Codigo = rowPS("Codigo"),
|
||||
.Producto = rowPS("PSCodigo"),
|
||||
.PrecioUnitario = row.DataKey("Importe").ToDecimal(),
|
||||
.FechaEntrega = "",
|
||||
.Observacion = row.DataKey("Observacion")
|
||||
}).QueryToDataTable(True)
|
||||
If DtExcel.Rows.Count < 2 Then
|
||||
Alert("No hay resutados en la busqueda.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
DtExcel.TableName = "Cotización"
|
||||
'DtExcel.Columns("Codigo").ColumnName = "Código"
|
||||
'DtExcel.Columns("PS").ColumnName = "Producto / Servicio"
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
|
||||
Dim FileExcel As New ExcelFile()
|
||||
|
||||
Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
|
||||
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
||||
{
|
||||
.ColumnHeaders = True,
|
||||
.StartRow = 0,
|
||||
.StartColumn = 0
|
||||
})
|
||||
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)
|
||||
|
||||
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
||||
For i = 0 To columnCount
|
||||
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
||||
Next
|
||||
|
||||
FileExcel.Save(Response, "Cotizacion.xlsx", SaveOptions.XlsxDefault)
|
||||
|
||||
End Sub
|
||||
Protected Sub CargarArchivoCot(Ruta As String, FileName As String)
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
|
||||
Dim dt As DataTable = Nothing
|
||||
Dim ErrorArchivo = False
|
||||
|
||||
Try
|
||||
dt = ReadExcelFile(Ruta + FileName, True)
|
||||
Catch ex As Exception
|
||||
ErrorArchivo = True
|
||||
OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
||||
End Try
|
||||
|
||||
If Not ErrorArchivo AndAlso dt IsNot Nothing Then
|
||||
'cantidad, Producto, Precio Unitario, Fecha Entrega, Observación
|
||||
If DdlProveedorCot.SelectedValue.ToEntero() <= 0 Then
|
||||
Alert("Debe Seleccionar la lista de precios a cargar. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(0).ColumnName = "Cantidad" Then
|
||||
Alert("El nombre de la tercera columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
Join rowPS In DtPS On rowPS("CvePS").ToString().ToEntero() Equals row.DataKey("CvePS").ToEntero()
|
||||
Where row.RowType = DataControlRowType.DataRow
|
||||
Select New With
|
||||
{
|
||||
.Cantidad = row.DataKey("Cantidad"),
|
||||
.Codigo = rowPS("Codigo"),
|
||||
.Producto = rowPS("PSCodigo"),
|
||||
.PrecioUnitario = row.DataKey("Importe").ToDecimal(),
|
||||
.FechaEntrega = "",
|
||||
.Observacion = row.DataKey("Observacion")
|
||||
}).QueryToDataTable(True)
|
||||
If DtExcel.Rows.Count < 2 Then
|
||||
Alert("No hay resutados en la busqueda.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
DtExcel.TableName = "Cotización"
|
||||
'DtExcel.Columns("Codigo").ColumnName = "Código"
|
||||
'DtExcel.Columns("PS").ColumnName = "Producto / Servicio"
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
|
||||
Dim FileExcel As New ExcelFile()
|
||||
|
||||
Dim worksheet = FileExcel.Worksheets.Add(DtExcel.TableName)
|
||||
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
||||
{
|
||||
.ColumnHeaders = True,
|
||||
.StartRow = 0,
|
||||
.StartColumn = 0
|
||||
})
|
||||
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)
|
||||
|
||||
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
||||
For i = 0 To columnCount
|
||||
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
||||
Next
|
||||
|
||||
FileExcel.Save(Response, "Cotizacion.xlsx", SaveOptions.XlsxDefault)
|
||||
|
||||
End Sub
|
||||
Protected Sub CargarArchivoCot(Ruta As String, FileName As String)
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
|
||||
Dim dt As DataTable = Nothing
|
||||
Dim ErrorArchivo = False
|
||||
|
||||
Try
|
||||
dt = ReadExcelFile(Ruta + FileName, True)
|
||||
Catch ex As Exception
|
||||
ErrorArchivo = True
|
||||
OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
||||
End Try
|
||||
|
||||
If Not ErrorArchivo AndAlso dt IsNot Nothing Then
|
||||
'cantidad, Producto, Precio Unitario, Fecha Entrega, Observación
|
||||
If DdlProveedorCot.SelectedValue.ToEntero() <= 0 Then
|
||||
Alert("Debe Seleccionar la lista de precios a cargar. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(1).ColumnName = "Codigo" Then
|
||||
Alert("El nombre de la cuarta columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(2).ColumnName = "Producto" Then
|
||||
Alert("El nombre de la cuarta columna debe ser 'Producto'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(3).ColumnName = "PrecioUnitario" Then
|
||||
Alert("El nombre de la sexta columna debe ser 'PrecioUnitario'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
If Not dt.Columns(0).ColumnName = "Cantidad" Then
|
||||
Alert("El nombre de la tercera columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(4).ColumnName = "FechaEntrega" Then
|
||||
Alert("El nombre de la sexta columna debe ser 'FechaEntrega'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
If Not dt.Columns(1).ColumnName = "Codigo" Then
|
||||
Alert("El nombre de la cuarta columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(5).ColumnName = "Observacion" Then
|
||||
Alert("El nombre de la sexta columna debe ser 'Observacion'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
dt.TableName = "Datos"
|
||||
Dim ProductosNoCargados As New StringBuilder()
|
||||
Dim RowsCargados As Integer = 0
|
||||
If Not dt.Columns(2).ColumnName = "Producto" Then
|
||||
Alert("El nombre de la cuarta columna debe ser 'Producto'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(3).ColumnName = "PrecioUnitario" Then
|
||||
Alert("El nombre de la sexta columna debe ser 'PrecioUnitario'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(4).ColumnName = "FechaEntrega" Then
|
||||
Alert("El nombre de la sexta columna debe ser 'FechaEntrega'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(5).ColumnName = "Observacion" Then
|
||||
Alert("El nombre de la sexta columna debe ser 'Observacion'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
dt.TableName = "Datos"
|
||||
Dim ProductosNoCargados As New StringBuilder()
|
||||
Dim RowsCargados As Integer = 0
|
||||
Dim RowsNoCargados As Integer = 0
|
||||
Dim TieneError As Boolean = False
|
||||
|
||||
Dim objCotizacion As New ClsOC
|
||||
objCotizacion.IniciaTransacSQL()
|
||||
|
||||
Try
|
||||
Try
|
||||
Dim DtPS As DataTable = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
||||
|
||||
Dim DtOCDetalle As DataTable = (From row As GridViewRow In GvD.Rows
|
||||
Join rowPS In DtPS On rowPS("CvePS").ToString().ToEntero() Equals row.DataKey("CvePS").ToEntero()
|
||||
Where row.RowType = DataControlRowType.DataRow
|
||||
Select New With
|
||||
{
|
||||
.CvePS = row.DataKey("CvePS").ToEntero(),
|
||||
.CveUnidadMedida = rowPS("CveUnidadMedida").ToString().ToEntero(),
|
||||
.CveOrdenCompraDetalle = row.DataKey("CveOrdenCompraDetalle").ToString().ToEntero(),
|
||||
.Codigo = rowPS("Codigo")
|
||||
Select New With
|
||||
{
|
||||
.CvePS = row.DataKey("CvePS").ToEntero(),
|
||||
.CveUnidadMedida = rowPS("CveUnidadMedida").ToString().ToEntero(),
|
||||
.CveOrdenCompraDetalle = row.DataKey("CveOrdenCompraDetalle").ToString().ToEntero(),
|
||||
.Codigo = rowPS("Codigo")
|
||||
}).QueryToDataTable(True)
|
||||
|
||||
|
||||
@@ -7618,23 +7618,23 @@ Partial Class OC
|
||||
End If
|
||||
Else
|
||||
TieneError = False
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
TieneError = True
|
||||
OnError("Ocurrió un error al cargar las cotizaciones.", ex)
|
||||
Finally
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
TieneError = True
|
||||
OnError("Ocurrió un error al cargar las cotizaciones.", ex)
|
||||
Finally
|
||||
If TieneError Then
|
||||
objCotizacion.RollBack()
|
||||
Alert("Ocurrió un error al cargar las cotizaciones.")
|
||||
Else
|
||||
objCotizacion.Commit()
|
||||
Alert("Las cotizaciones se cargaron correctamente.")
|
||||
End If
|
||||
End If
|
||||
objCotizacion.Dispose()
|
||||
End Try
|
||||
|
||||
End If
|
||||
End Try
|
||||
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
Reference in New Issue
Block a user