Cambiar cargar conciliaciones a gembox.
Soporte en compras para actualizar contabilizados. Cambiar cargar contratos a gem box. Soporte en Ventas que no se pueda ingresar productos de diferente moneda.
This commit is contained in:
@@ -5,6 +5,8 @@ Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports System.Xml
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
Imports GemBox.Spreadsheet
|
||||
|
||||
Partial Class Bancos_CargarConciliacionesBancarias
|
||||
Inherits ClsPaginas
|
||||
|
||||
@@ -83,51 +85,99 @@ Partial Class Bancos_CargarConciliacionesBancarias
|
||||
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
|
||||
End Function
|
||||
|
||||
Private Sub CargaExcel(Ruta As String, FileName As String, Tipo As String)
|
||||
If Not DdlCuenta.SelectedValue.ToEntero > 0 Then
|
||||
Alert("Tiene que seleccionar una cuenta", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
Dim dt As New DataTable
|
||||
Dim Conexion As Odbc.OdbcConnection = Nothing
|
||||
Dim ErrorArchivo = False
|
||||
Dim ErrorExcel = False
|
||||
Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
|
||||
Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
|
||||
Dim objDbAdapter As Common.DbDataAdapter = objDbFactory.CreateDataAdapter()
|
||||
Dim objDbConnection As Common.DbConnection = objDbFactory.CreateConnection()
|
||||
objDbConnection.ConnectionString = strConnString
|
||||
objDbConnection.Open()
|
||||
Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
|
||||
Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
|
||||
Try
|
||||
Select Case Tipo
|
||||
Case "CSV"
|
||||
Conexion = New Odbc.OdbcConnection("Driver={Microsoft Access Text Driver (*.txt, *.csv)};Dbq=" + Ruta + ";Extensions=asc,csv,tab,txt;")
|
||||
Conexion.Open()
|
||||
Dim cmd = Conexion.CreateCommand()
|
||||
cmd.CommandType = CommandType.Text
|
||||
cmd.CommandText = $"SELECT * FROM [{FileName}]"
|
||||
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
||||
DataAdapter.Fill(dt)
|
||||
Case "EXCEL"
|
||||
Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
||||
Conexion.Open()
|
||||
Dim cmd = Conexion.CreateCommand()
|
||||
cmd.CommandType = CommandType.Text
|
||||
cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
|
||||
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
||||
DataAdapter.Fill(dt)
|
||||
Case Else
|
||||
Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
ErrorArchivo = True
|
||||
OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
||||
End Try
|
||||
Conexion.Close()
|
||||
If Not ErrorArchivo Then
|
||||
dt = ReadExcelFile(Ruta + FileName, True)
|
||||
'Dim Conexion As Odbc.OdbcConnection = Nothing
|
||||
'Dim ErrorArchivo = False
|
||||
'Dim ErrorExcel = False
|
||||
'Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
|
||||
'Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
|
||||
'Dim objDbAdapter As Common.DbDataAdapter = objDbFactory.CreateDataAdapter()
|
||||
'Dim objDbConnection As Common.DbConnection = objDbFactory.CreateConnection()
|
||||
'objDbConnection.ConnectionString = strConnString
|
||||
'objDbConnection.Open()
|
||||
'Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
|
||||
'Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
|
||||
'Try
|
||||
' Select Case Tipo
|
||||
' Case "CSV"
|
||||
' Conexion = New Odbc.OdbcConnection("Driver={Microsoft Access Text Driver (*.txt, *.csv)};Dbq=" + Ruta + ";Extensions=asc,csv,tab,txt;")
|
||||
' Conexion.Open()
|
||||
' Dim cmd = Conexion.CreateCommand()
|
||||
' cmd.CommandType = CommandType.Text
|
||||
' cmd.CommandText = $"SELECT * FROM [{FileName}]"
|
||||
' Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
||||
' DataAdapter.Fill(dt)
|
||||
' Case "EXCEL"
|
||||
' Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
||||
' Conexion.Open()
|
||||
' Dim cmd = Conexion.CreateCommand()
|
||||
' cmd.CommandType = CommandType.Text
|
||||
' cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
|
||||
' Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
||||
' DataAdapter.Fill(dt)
|
||||
' Case Else
|
||||
' Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
|
||||
' Exit Sub
|
||||
' End Select
|
||||
'Catch ex As Exception
|
||||
' ErrorArchivo = True
|
||||
' OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
||||
'End Try
|
||||
'Conexion.Close()
|
||||
If dt IsNot Nothing Then
|
||||
dt.Columns(0).ColumnName = "FechaDocumento"
|
||||
dt.Columns(1).ColumnName = "Referencia"
|
||||
dt.Columns(2).ColumnName = "Importe"
|
||||
@@ -166,6 +216,8 @@ Partial Class Bancos_CargarConciliacionesBancarias
|
||||
ObjBancos.RollBack()
|
||||
End If
|
||||
ObjBancos.Dispose()
|
||||
Else
|
||||
Alert("Hubo un error al intentar leer el archivo.", TipoMensaje.MsgError)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -8829,6 +8829,16 @@ Partial Class Compras_Compras
|
||||
'Revisamos que los cambios hechos mantengan la interidad de los numeros
|
||||
If HFDiferenciaCompra.Value = TxtTotal.Text Or CveFactura < 1 Or CveCompra < 1 Then
|
||||
|
||||
If IdPoliza > 0 Then
|
||||
If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
|
||||
Retorno = False
|
||||
End If
|
||||
|
||||
If Not ObjContabilidad.UpdatePrePoliza(MinFecha, -1, -1, Nothing, CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
||||
Retorno = False
|
||||
End If
|
||||
End If
|
||||
|
||||
'PORCENTAJE IVA
|
||||
Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal
|
||||
|
||||
@@ -8846,11 +8856,7 @@ Partial Class Compras_Compras
|
||||
' End If
|
||||
'End If
|
||||
|
||||
If IdPoliza > 0 Then
|
||||
If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
|
||||
Retorno = False
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
'If UsuarioActual.Empresa.Funcionalidad(207) = "1" Then
|
||||
If Not ActualizarPrePoliza(ObjContabilidad, ObjCompra) Then
|
||||
@@ -8859,7 +8865,7 @@ Partial Class Compras_Compras
|
||||
'End If
|
||||
|
||||
''EMPIEZA: SI USA AC
|
||||
If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") AndAlso IdPoliza > 0 Then
|
||||
If UsuarioActual.Empresa.UsaAC AndAlso IdPoliza > 0 Then
|
||||
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
||||
ObjContaAC.IniciaTransacSQL()
|
||||
|
||||
@@ -9242,9 +9248,11 @@ Partial Class Compras_Compras
|
||||
Next
|
||||
|
||||
If Retorno Then
|
||||
If ViewState("IdPoliza").ToString.ToEntero > 0 Then
|
||||
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
||||
ObjContaAC.IniciaTransacSQL()
|
||||
If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") AndAlso IdPoliza > 0 Then
|
||||
If ObjContaAC Is Nothing Then
|
||||
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
||||
ObjContaAC.IniciaTransacSQL()
|
||||
End If
|
||||
|
||||
If Not ObjContabilidad.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveEmpresa, UsuarioActual.Empresa, MinFecha, String.Format("{0}-{1}", Serie, Folio), ObjContaAC, pIDPoliza:=ViewState("IdPoliza").ToString.ToEntero) Then
|
||||
Retorno = False
|
||||
@@ -9261,6 +9269,18 @@ Partial Class Compras_Compras
|
||||
|
||||
'Retorno = True
|
||||
'Alert("La Compra se actualizó correctamente.")
|
||||
Else
|
||||
|
||||
If IdPoliza > 0 Then
|
||||
If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, True) Then
|
||||
Retorno = False
|
||||
End If
|
||||
|
||||
If Not ObjContabilidad.UpdatePrePoliza(MinFecha, -1, -1, IdPoliza, CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
||||
Retorno = False
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
@@ -9275,7 +9295,7 @@ Partial Class Compras_Compras
|
||||
Catch ex As Exception
|
||||
Alert("Ocurrió un error al actualizar la compra", TipoMensaje.MsgError)
|
||||
ObjCompra.RollBack()
|
||||
ObjContaAC.RollBack()
|
||||
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
||||
|
||||
Finally
|
||||
If Retorno Then
|
||||
|
||||
@@ -6,6 +6,7 @@ Imports System.IO
|
||||
Imports System.Data
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
Imports System.Globalization
|
||||
Imports GemBox.Spreadsheet
|
||||
|
||||
Partial Class Contratos_Default
|
||||
Inherits ClsPaginas
|
||||
@@ -3185,32 +3186,79 @@ Partial Class Contratos_Default
|
||||
Public Sub LbDescargarExcel_Click(sender As Object, e As EventArgs) Handles LbDescargarExcel.Click
|
||||
DescargarFormato()
|
||||
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
|
||||
|
||||
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
|
||||
Dim dt As New DataTable
|
||||
Dim Conexion As Odbc.OdbcConnection = Nothing
|
||||
dt = ReadExcelFile(Ruta + FileName, True)
|
||||
Dim ErrorArchivo = False
|
||||
|
||||
Try
|
||||
Select Case Tipo
|
||||
Case "EXCEL"
|
||||
Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
||||
Conexion.Open()
|
||||
Dim cmd = Conexion.CreateCommand()
|
||||
cmd.CommandType = CommandType.Text
|
||||
cmd.CommandText = "SELECT * FROM [Hoja1$]"
|
||||
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
||||
DataAdapter.Fill(dt)
|
||||
Case Else
|
||||
Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
ErrorArchivo = True
|
||||
OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
||||
End Try
|
||||
Conexion.Close()
|
||||
If Not ErrorArchivo Then
|
||||
'Dim Conexion As Odbc.OdbcConnection = Nothing
|
||||
'Try
|
||||
' Select Case Tipo
|
||||
' Case "EXCEL"
|
||||
' Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
||||
' Conexion.Open()
|
||||
' Dim cmd = Conexion.CreateCommand()
|
||||
' cmd.CommandType = CommandType.Text
|
||||
' cmd.CommandText = "SELECT * FROM [Hoja1$]"
|
||||
' Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
||||
' DataAdapter.Fill(dt)
|
||||
' Case Else
|
||||
' Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
|
||||
' Exit Sub
|
||||
' End Select
|
||||
'Catch ex As Exception
|
||||
' ErrorArchivo = True
|
||||
' OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
||||
'End Try
|
||||
'Conexion.Close()
|
||||
If Not ErrorArchivo AndAlso dt IsNot Nothing Then
|
||||
If Not dt.Columns(0).ColumnName = "OC Interna" Then
|
||||
Alert("El nombre de la primera columna debe ser 'OC Interna'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
|
||||
@@ -12650,8 +12650,12 @@ Partial Class Ventas
|
||||
DdlUnidadMedida.SelectedValue = "-1"
|
||||
DdlUnidadMedida.DataBind()
|
||||
DdlUnidadMedida.SelectedValueExist(drPS("CveUnidadMedida").ToString)
|
||||
DdlMoneda.SelectedValueExist(drPS("CveMoneda").ToString)
|
||||
CambiaMoneda()
|
||||
|
||||
If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count = 0 Then
|
||||
DdlMoneda.SelectedValueExist(drPS("CveMoneda").ToString)
|
||||
CambiaMoneda()
|
||||
End If
|
||||
|
||||
'SUGIERE PRECIO
|
||||
Dim PrecioSugerido = 0.0
|
||||
PrecioSugerido = drPS("Precio").ToString.ToDouble
|
||||
@@ -13239,6 +13243,15 @@ Partial Class Ventas
|
||||
Return False
|
||||
End If
|
||||
|
||||
If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count >= 1 Then
|
||||
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0)
|
||||
If DrPS IsNot Nothing Then
|
||||
If DrPS("CveMoneda").ToString.ToEntero <> DdlMoneda.SelectedValue.ToEntero Then
|
||||
Alert("No puede agregar un producto de diferente moneda a la ya seleccionada", TipoMensaje.MsgAdvertencia)
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not UsuarioActual.TienePermisoProceso(169) Then ' NO VALIDA EXISTENCIAS NI COSTO - PERMISO PARA NO VALIDAR
|
||||
'SOLO VALIDA EXISTENCIAS Y COSTO: SI USA INVENTARIOS, SOLO PRODUCTOS TIPO PRODUCTO, SOLO REMISIONES E INGRESOS
|
||||
|
||||
Reference in New Issue
Block a user