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