2111 lines
119 KiB
VB.net
2111 lines
119 KiB
VB.net
Option Strict On
|
|
Option Explicit On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.Xml
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports GemBox.Spreadsheet
|
|
|
|
Partial Class General_SaldosIniciales
|
|
Inherits ClsPaginas
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
|
|
If TxtExcel.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
|
|
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch
|
|
Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
|
CargarArchivo(Directorio, file.filename, Tipo)
|
|
Else
|
|
Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
|
|
Dim dt As New DataTable
|
|
' Conexion As Odbc.OdbcConnection = Nothing
|
|
Dim ErrorArchivo = False
|
|
Dim ErrorExcel = False
|
|
|
|
dt = ReadExcelFile(Ruta + FileName, True)
|
|
'Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1;"""
|
|
'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
|
|
|
|
If RblFormato.SelectedValue = "1" Or RblFormato.SelectedValue = "2" Then
|
|
If Not dt.Columns(0).ColumnName = "Codigo" Then
|
|
Alert("El nombre de la primera columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(1).ColumnName = "RazonSocial" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Fecha'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(2).ColumnName = "RFC" Then
|
|
Alert("El nombre de la tercera columna debe ser 'RFC'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(3).ColumnName = "Calle" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Calle'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(4).ColumnName = "Número exterior" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Número exterior' .Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(5).ColumnName = "Colonia" Then
|
|
Alert("El nombre de la sexta columna debe ser 'Colonia'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(6).ColumnName = "Código postal" Then
|
|
Alert("El nombre de la séptima columna debe ser 'Código postal'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(7).ColumnName = "Población" Then
|
|
Alert("El nombre de la octava columna debe ser 'Población'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(8).ColumnName = "Estado" Then
|
|
Alert("El nombre de la novena columna debe ser 'Estado'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(9).ColumnName = "Teléfono" Then
|
|
Alert("El nombre de la décima columna debe ser 'Teléfono'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(10).ColumnName = "Contacto" Then
|
|
Alert("El nombre de la onceava columna debe ser 'Contacto'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(11).ColumnName = "Celular Contacto" Then
|
|
Alert("El nombre de la doceava columna debe ser 'Celular Contacto'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(12).ColumnName = "Limite Credito" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Limite Credito'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(13).ColumnName = "Plazo Cobranza" Then
|
|
Alert("El nombre de la catorceava columna debe ser 'Plazo Cobranza'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
'If Not dt.Columns(14).ColumnName = "Pais" Then
|
|
' Alert("El nombre de la quinceava columna debe ser 'Plazo Cobranza'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
' Exit Sub
|
|
'End If
|
|
|
|
|
|
|
|
If Not dt.Columns(14).ColumnName.ToUpper = "BANCO" Then
|
|
Alert("El nombre de la quinceava columna debe ser 'Banco'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(15).ColumnName.ToUpper = "N° CUENTA" Then
|
|
Alert("El nombre de la dieciseisava columna debe ser 'N° Cuenta'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(16).ColumnName.ToUpper = "CLABE INTER" Then
|
|
Alert("El nombre de la diecisieteava columna debe ser 'Clabe Inter'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
ElseIf RblFormato.SelectedValue = "2" Then
|
|
|
|
If Not dt.Columns(0).ColumnName = "Codigo" Then
|
|
Alert("El nombre de la primera columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(1).ColumnName = "RazonSocial" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Fecha'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(2).ColumnName = "RFC" Then
|
|
Alert("El nombre de la tercera columna debe ser 'RFC'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(3).ColumnName = "Calle" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Calle'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(4).ColumnName = "Número exterior" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Número exterior' .Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(5).ColumnName = "Colonia" Then
|
|
Alert("El nombre de la sexta columna debe ser 'Colonia'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(6).ColumnName = "Código postal" Then
|
|
Alert("El nombre de la séptima columna debe ser 'Código postal'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(7).ColumnName = "Población" Then
|
|
Alert("El nombre de la octava columna debe ser 'Población'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(8).ColumnName = "Estado" Then
|
|
Alert("El nombre de la novena columna debe ser 'Estado'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(9).ColumnName = "Teléfono" Then
|
|
Alert("El nombre de la décima columna debe ser 'Teléfono'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(10).ColumnName = "Contacto" Then
|
|
Alert("El nombre de la onceava columna debe ser 'Contacto'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(11).ColumnName = "Celular Contacto" Then
|
|
Alert("El nombre de la doceava columna debe ser 'Celular Contacto'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(12).ColumnName = "Limite Credito" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Limite Credito'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(13).ColumnName = "Plazo Cobranza" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Plazo Cobranza'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
If Not dt.Columns(14).ColumnName = "Vendedor" Then
|
|
Alert("El nombre de la catorceava columna debe ser 'Es distribuidor'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(15).ColumnName = "Clasificación" Then
|
|
Alert("El nombre de la catorceava columna debe ser 'Es distribuidor'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(16).ColumnName = "Es distribuidor" Then
|
|
Alert("El nombre de la catorceava columna debe ser 'Es distribuidor'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
|
|
ElseIf RblFormato.SelectedValue = "3" Or RblFormato.SelectedValue = "4" Then
|
|
If Not dt.Columns(0).ColumnName = "Sucursal" Then
|
|
Alert("El nombre de la primera columna debe ser 'Sucursal'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(1).ColumnName = "RFC" Then
|
|
Alert("El nombre de la segunda columna debe ser 'RFC'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(2).ColumnName = "Serie" Then
|
|
Alert("El nombre de la tercera columna debe ser 'Serie'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(3).ColumnName = "Folio" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Folio'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(4).ColumnName = "Fecha" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Fecha'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(5).ColumnName = "SubTotal" Then
|
|
Alert("El nombre de la sexta columna debe ser 'SubTotal'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(6).ColumnName = "IVA" Then
|
|
Alert("El nombre de la séptima columna debe ser 'IVA'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(7).ColumnName = "Total" Then
|
|
Alert("El nombre de la octava columna debe ser 'Total'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(8).ColumnName = "Saldo" Then
|
|
Alert("El nombre de la novena columna debe ser 'Saldo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(9).ColumnName = "Tipo Documento" Then
|
|
Alert("El nombre de la décima columna debe ser 'Tipo Documento'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(10).ColumnName = "Ret IVA" Then
|
|
Alert("El nombre de la onceava columna debe ser 'Ret IVA'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(11).ColumnName = "Ret ISR" Then
|
|
Alert("El nombre de la doceava columna debe ser 'Ret ISR'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(12).ColumnName = "Moneda" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Moneda'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(13).ColumnName = "Tipo Cambio" Then
|
|
Alert("El nombre de la catorceava columna debe ser 'Tipo Cambio'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(14).ColumnName = "Fecha Vencimiento" Then
|
|
Alert("El nombre de la quinceava columna debe ser 'Fecha Vencimiento'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
'If RblFormato.SelectedValue = "4" Then
|
|
' If Not dt.Columns(15).ColumnName = "ImpuestoLocal" Then
|
|
' Alert("El nombre de la diesciseisava columna debe ser 'ImpuestoLocal'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
' Exit Sub
|
|
' End If
|
|
|
|
' If Not dt.Columns(16).ColumnName = "Amort.Ant" Then
|
|
' Alert("El nombre de la diescisieteava columna debe ser 'Amort.Ant'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
' Exit Sub
|
|
' End If
|
|
'End If
|
|
|
|
|
|
ElseIf RblFormato.SelectedValue = "5" Then
|
|
|
|
If Not dt.Columns(0).ColumnName = "Codigo" Then
|
|
Alert("El nombre de la primera columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(1).ColumnName = "Descripcion" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Descripcion'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(2).ColumnName = "Tipo" Then
|
|
Alert("El nombre de la terera columna debe ser 'Tipo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(3).ColumnName = "Código Barras" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Código Barras'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(4).ColumnName = "Unidad Medida" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Unidad Medida'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(5).ColumnName = "Clasificacion" Then
|
|
Alert("El nombre de la sexta columna debe ser 'Clasificacion'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(6).ColumnName = "Marca" Then
|
|
Alert("El nombre de la séptima columna debe ser 'Marca'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(7).ColumnName = "AplicaSerie" Then
|
|
Alert("El nombre de la octava columna debe ser 'AplicaSerie'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(8).ColumnName = "Precio" Then
|
|
Alert("El nombre de la novena columna debe ser 'Precio'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(9).ColumnName = "IEPS" Then
|
|
Alert("El nombre de la décima columna debe ser 'IEPS'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(10).ColumnName = "Tamaño" Then
|
|
Alert("El nombre de la onceava columna debe ser 'Tamaño'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(11).ColumnName = "Código SAT" Then
|
|
Alert("El nombre de la doceava columna debe ser 'Código SAT'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
'If Not dt.Columns(12).ColumnName = "Servicio" Then
|
|
' Alert("El nombre de la treceava columna debe ser 'Servicio'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
' Exit Sub
|
|
'End If
|
|
|
|
'If Not dt.Columns(13).ColumnName = "Conversion Unidad" Then
|
|
' Alert("El nombre de la catorceava columna debe ser 'Conversion Unidad'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
' Exit Sub
|
|
'End If
|
|
|
|
ElseIf RblFormato.SelectedValue = "6" Then
|
|
If Not dt.Columns(0).ColumnName = "Código" Then
|
|
Alert("El nombre de la primera columna debe ser 'Código'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(1).ColumnName = "Apellido Paterno" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Apellido Paterno'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(2).ColumnName = "Apellido Materno" Then
|
|
Alert("El nombre de la tercera columna debe ser 'Apellido Materno'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(3).ColumnName = "Nombre" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Nombre'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(4).ColumnName = "Correo Electronico" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Correo Electronico'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(5).ColumnName = "Fecha Nacimiento" Then
|
|
Alert("El nombre de la sexta columna debe ser 'Fecha Nacimiento'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(6).ColumnName = "Sexo" Then
|
|
Alert("El nombre de la séptima columna debe ser 'Sexo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(7).ColumnName = "Lugar Nacimiento" Then
|
|
Alert("El nombre de la octava columna debe ser 'Lugar Nacimiento'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(8).ColumnName = "Dirección" Then
|
|
Alert("El nombre de la novena columna debe ser 'Dirección'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(9).ColumnName = "Ciudad" Then
|
|
Alert("El nombre de la décima columna debe ser 'Ciudad'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(10).ColumnName = "Estado Civil" Then
|
|
Alert("El nombre de la onceava columna debe ser 'Estado Civil'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(11).ColumnName = "Teléfono" Then
|
|
Alert("El nombre de la doceava columna debe ser 'Teléfono'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(12).ColumnName = "Celular" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Celular'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(13).ColumnName = "RFC" Then
|
|
Alert("El nombre de la catorceava columna debe ser 'RFC'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(14).ColumnName = "CURP" Then
|
|
Alert("El nombre de la quinceava columna debe ser 'CURP'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(15).ColumnName = "Numero SS" Then
|
|
Alert("El nombre de la diesciseisava columna debe ser 'Numero SS'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(16).ColumnName = "CLABE" Then
|
|
Alert("El nombre de la diescisieteava columna debe ser 'CLABE'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(17).ColumnName = "Fecha Ingreso" Then
|
|
Alert("El nombre de la dieciochoava columna debe ser 'Fecha Ingreso'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(18).ColumnName = "Fecha Baja" Then
|
|
Alert("El nombre de la diecinueveava columna debe ser 'Fecha Baja'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(19).ColumnName = "Alta IMSS" Then
|
|
Alert("El nombre de la veinteava columna debe ser 'Alta IMSS'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(20).ColumnName = "Salario Diario" Then
|
|
Alert("El nombre de la veinteunava columna debe ser 'Salario Diario'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(21).ColumnName = "Código Postal" Then
|
|
Alert("El nombre de la veintedosava columna debe ser 'Código Postal'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(22).ColumnName = "Estatus Personal" Then
|
|
Alert("El nombre de la veintetresava columna debe ser 'Estatus Personal'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(23).ColumnName = "Estado" Then
|
|
Alert("El nombre de la veintecuatroava columna debe ser 'Estado'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(24).ColumnName = "Nombre Padre" Then
|
|
Alert("El nombre de la veintecincoava columna debe ser 'Nombre Padre'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(25).ColumnName = "Nombre Madre" Then
|
|
Alert("El nombre de la veinteseisava columna debe ser 'Nombre Madre'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(26).ColumnName = "Puesto" Then
|
|
Alert("El nombre de la veintesieteava columna debe ser 'Puesto'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(27).ColumnName = "Turno" Then
|
|
Alert("El nombre de la veinteochaava columna debe ser 'Turno'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(28).ColumnName = "Tipo Contrato" Then
|
|
Alert("El nombre de la veintenueveava columna debe ser 'Tipo Contrato'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
End If
|
|
|
|
ElseIf RblFormato.SelectedValue = "7" Then
|
|
If Not dt.Columns(0).ColumnName = "Código" Then
|
|
Alert("El nombre de la primera columna debe ser 'Código'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(1).ColumnName = "Descripcion" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Descripción'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(2).ColumnName = "Tipo" Then
|
|
Alert("El nombre de la tercera columna debe ser 'Tipo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(3).ColumnName = "Linea" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Linea'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
If Not dt.Columns(4).ColumnName = "Codigo Barras" Then
|
|
Alert("El nombre de la sexta columna debe ser 'Codigo Barras'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(5).ColumnName = "Clasificacion" Then
|
|
Alert("El nombre de la séptima columna debe ser 'Clasificacion'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(6).ColumnName = "Marca" Then
|
|
Alert("El nombre de la octava columna debe ser 'Marca'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(7).ColumnName = "Modelo" Then
|
|
Alert("El nombre de la novena columna debe ser 'Modelo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(8).ColumnName = "Medida" Then
|
|
Alert("El nombre de la décima columna debe ser 'Medida'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(9).ColumnName = "Tamaño de Rin" Then
|
|
Alert("El nombre de la onceava columna debe ser 'Tamaño de Rin'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(10).ColumnName = "CODIGO SAT" Then
|
|
Alert("El nombre de la diesciseisava columna debe ser 'CODIGO SAT'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(11).ColumnName = "Clave Unidad" Then
|
|
Alert("El nombre de la diescisieteava columna debe ser 'Clave Unidad'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
ElseIf RblFormato.SelectedValue = "9" Then
|
|
|
|
If Not dt.Columns(0).ColumnName = "Cuenta" Then
|
|
Alert("El nombre de la primera columna debe ser 'Cuenta'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(1).ColumnName = "NombreCuenta" Then
|
|
Alert("El nombre de la segunda columna debe ser 'NombreCuenta'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(2).ColumnName = "TipoCuenta" Then
|
|
Alert("El nombre de la tercera columna debe ser 'TipoCuenta'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(3).ColumnName = "CuentaPadre" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'CuentaPadre'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(5).ColumnName = "AgrupadorSAT" Then
|
|
Alert("El nombre de la quinta columna debe ser 'AgrupadorSAT'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
ElseIf RblFormato.SelectedValue = "12" Then
|
|
If Not dt.Columns(0).ColumnName = "CodigoPS" Then
|
|
Alert("El nombre de la primera columna debe ser 'CodigoPS'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(1).ColumnName = "Almacen" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Almacen'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(2).ColumnName = "Existencia" Then
|
|
Alert("El nombre de la tercera columna debe ser 'Existencia'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dt.Columns(3).ColumnName = "Valor" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Valor'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
|
|
dt.TableName = "Datos"
|
|
Dim NumRows As Integer = dt.Rows.Count
|
|
|
|
If Not ErrorArchivo Then
|
|
|
|
'P R O D U C T O S / S E R V I C I O S
|
|
If RblFormato.SelectedValue = "5" Then
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
Dim ObjGral As New ClsGenerales(ObjPS.IniciaTransacSQL())
|
|
Dim ObjClas As New ClsClasificaciones(ObjPS.IniciaTransacSQL())
|
|
Dim ObjVenta As New ClsVentas(ObjPS.IniciaTransacSQL())
|
|
Dim ObjUM As New ClsUnidadesMedida(ObjPS.IniciaTransacSQL())
|
|
Dim ErrorPS As Boolean = False
|
|
Dim ExistePS As Boolean = False
|
|
Dim Contador As Integer = 0
|
|
Dim DtMarcas As DataTable = Nothing
|
|
Dim DtMedidas As DataTable = Nothing
|
|
Dim DtRinTamaño As DataTable = Nothing
|
|
Dim DtModelos As DataTable = Nothing
|
|
Dim DTPS As DataTable = Nothing
|
|
|
|
|
|
If ObjPS.GetMarcas(UsuarioActual.CveEmpresa) Then
|
|
DtMarcas = ObjPS.DtResultados.Copy
|
|
End If
|
|
|
|
If ObjGral.GetMedidas(UsuarioActual.CveEmpresa) Then
|
|
DtMedidas = ObjGral.DtResultados.Copy
|
|
End If
|
|
|
|
If ObjGral.GetRimTamanios(UsuarioActual.CveEmpresa) Then
|
|
DtRinTamaño = ObjGral.DtResultados.Copy
|
|
End If
|
|
|
|
If ObjGral.GetModelos(UsuarioActual.CveEmpresa) Then
|
|
DtModelos = ObjGral.DtResultados.Copy
|
|
End If
|
|
|
|
|
|
If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then
|
|
DTPS = ObjPS.DtResultados
|
|
End If
|
|
|
|
|
|
For Each Row As DataRow In dt.Rows
|
|
Dim Codigo As String = Row("Codigo").ToString
|
|
Dim Descripcion As String = Row("Descripcion").ToString
|
|
Dim TipoPS As String = Row("Tipo").ToString.Trim.ToUpper
|
|
Dim CodigoBarras As String = Row("Código Barras").ToString
|
|
Dim UnidadMedida As String = Row("Unidad Medida").ToString.Trim
|
|
Dim Clasificacion As String = Row("Clasificacion").ToString.Trim
|
|
Dim Marca As String = Row("Marca").ToString.Trim
|
|
'Dim AplicaSerie As String = Row("AplicaSerie").ToString.Trim
|
|
Dim Precio As Double = Row("Precio").ToString.ToDouble
|
|
Dim IEPS As Decimal = Row("IEPS").ToString.ToDecimal
|
|
Dim Tamaño As String = Row("Tamaño").ToString.Trim
|
|
Dim SATClavePS As String = Row("Código SAT").ToString.Trim
|
|
Dim Clasificacion2 As String = If(dt.Columns.Contains("Servicio"), Row("Servicio").ToString.Trim, "")
|
|
Dim Litraje As Double = If(dt.Columns.Contains("Conversion Unidad"), Row("Conversion Unidad").ToString.ToDouble, 0)
|
|
Dim RinTamaño As String = If(Row.Table.Columns.Contains("Tamaño de Rin"), Row("Tamaño de Rin").ToString.Trim, "")
|
|
Dim Medida As String = If(Row.Table.Columns.Contains("Medida"), Row("Medida").ToString.Trim, "")
|
|
Dim SATClaveUnidadMedida As String = If(Row.Table.Columns.Contains("Clave Unidad"), Row("Clave Unidad").ToString.Trim, "")
|
|
Dim Linea As String = If(Row.Table.Columns.Contains("Linea"), Row("Linea").ToString.Trim, "")
|
|
Dim Modelo As String = If(Row.Table.Columns.Contains("Modelo"), Row("Modelo").ToString.Trim, "")
|
|
|
|
Dim CvePS As Integer = DTPS.FiltroPrimeroValor("CvePS", $"Codigo = '{Codigo}'").ToString.ToEntero
|
|
|
|
Dim CveTipoPS As Integer = If(TipoPS.ToUpper = "PRODUCTO", 2, 1)
|
|
Dim CveClasificacion As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", $"Clasificacion = '{Clasificacion}'").ToString.ToEntero
|
|
Dim CveUnidadMedida As Integer = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"UnidadMedida = '{UnidadMedida}' OR Abreviatura = '{UnidadMedida}'").ToString.ToEntero
|
|
Dim CveSATPS As Integer = GlobalDTPSATPS.FiltroPrimeroValor("CveSATPS", $"SATClavePS = '{SATClavePS}'").ToString.ToEntero
|
|
Dim CveTamaño As Integer = GlobalDTAcumTamaños.FiltroPrimeroValor("CveTamaño", $"Tamaño = '{Tamaño}' AND CveEmpresa = {UsuarioActual.CveEmpresa}").ToString.ToEntero
|
|
Dim CveClasificacion2 As Integer = GlobalDTClasificaciones2(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", $"Clasificacion = '{Clasificacion2}'").ToString.ToEntero
|
|
|
|
If Not CveClasificacion > 0 AndAlso Clasificacion <> "" Then
|
|
If ObjClas.AddClasificaciones(Clasificacion, "", -1, "-1", -1, "-1", -1, "-1",
|
|
GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCategoria", "").ToString.ToEntero, UsuarioActual.CveUsuario,
|
|
UsuarioActual.CveEmpresa) Then
|
|
If ObjClas.GetClasificaciones() Then Application("GlobalDTClasificaciones") = ObjClas.DtResultados
|
|
CveClasificacion = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", $"Clasificacion = '{Clasificacion}'").ToString.ToEntero
|
|
End If
|
|
End If
|
|
|
|
If Not CveUnidadMedida > 0 AndAlso UnidadMedida <> "" Then
|
|
If ObjUM.AddUnidadMedida(UnidadMedida, UnidadMedida, "", "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).ToEntero > 0 Then
|
|
If ObjUM.GetUnidadesMedida(UsuarioActual.CveEmpresa) Then GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) = Nothing
|
|
CveUnidadMedida = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"UnidadMedida = '{UnidadMedida}'").ToString.ToEntero
|
|
End If
|
|
End If
|
|
|
|
Dim CveMarca As Integer = -1
|
|
If Marca <> "" AndAlso DtMarcas IsNot Nothing Then
|
|
CveMarca = DtMarcas.FiltroPrimeroValor("CveMarca", $"Marca = '{Marca}'").ToString.ToEntero
|
|
If Not CveMarca > 0 Then
|
|
If ObjPS.AddMarcas(Marca, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
If ObjPS.GetMarcas(UsuarioActual.CveEmpresa) Then
|
|
DtMarcas = ObjPS.DtResultados.Copy
|
|
CveMarca = DtMarcas.FiltroPrimeroValor("CveMarca", $"Marca = '{Marca}'").ToString.ToEntero
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Dim CveMedida As Integer = -1
|
|
If Medida <> "" AndAlso DtMedidas IsNot Nothing Then
|
|
CveMedida = DtMedidas.FiltroPrimeroValor("CveMedida", $"Medida = '{Medida}'").ToString.ToEntero
|
|
If Not CveMedida > 0 Then
|
|
If ObjGral.AddMedidas(CveClasificacion, "", Medida, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
If ObjGral.GetMedidas(UsuarioActual.CveEmpresa) Then
|
|
DtMedidas = ObjGral.DtResultados.Copy
|
|
CveMedida = DtMedidas.FiltroPrimeroValor("CveMedida", $"Medida = '{Medida}'").ToString.ToEntero
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Dim CveRinTamaño As Integer = -1
|
|
If RinTamaño <> "" AndAlso DtRinTamaño IsNot Nothing Then
|
|
CveRinTamaño = DtRinTamaño.FiltroPrimeroValor("CveRinTamaño", $"RinTamaño = '{RinTamaño}'").ToString.ToEntero
|
|
If Not CveRinTamaño > 0 Then
|
|
If ObjGral.AddRimTamanios(CveClasificacion, "", RinTamaño, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
If ObjGral.GetRimTamanios(UsuarioActual.CveEmpresa) Then
|
|
DtRinTamaño = ObjGral.DtResultados.Copy
|
|
CveRinTamaño = DtRinTamaño.FiltroPrimeroValor("CveRinTamaño", $"RinTamaño = '{RinTamaño}'").ToString.ToEntero
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Dim CveModelo As Integer = -1
|
|
If Modelo <> "" AndAlso DtModelos IsNot Nothing Then
|
|
CveModelo = DtModelos.FiltroPrimeroValor("CveModelo", $"Modelo = '{Modelo}'").ToString.ToEntero
|
|
If Not CveModelo > 0 Then
|
|
If ObjGral.AddModelos(CveMarca, "", Modelo, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
If ObjGral.GetModelos(UsuarioActual.CveEmpresa) Then
|
|
DtModelos = ObjGral.DtResultados.Copy
|
|
CveModelo = DtModelos.FiltroPrimeroValor("CveModelo", $"Modelo = '{Modelo}'").ToString.ToEntero
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If Not CveClasificacion2 > 0 AndAlso Clasificacion2 <> "" Then
|
|
Dim CveCategoria As Integer
|
|
|
|
|
|
|
|
If ObjGral.GetCategorias(UsuarioActual.CveEmpresa, 4) Then
|
|
CveCategoria = ObjGral.DtResultados.FiltroPrimeroValor("CveCategoria", "").ToEntero
|
|
End If
|
|
|
|
If Not CveCategoria > 0 Then
|
|
If ObjGral.AddCategorias(Clasificacion2, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4) Then
|
|
|
|
If ObjGral.GetCategorias(UsuarioActual.CveEmpresa, 4) Then
|
|
CveCategoria = ObjGral.DtResultados.FiltroPrimeroValor("CveCategoria", "").ToEntero
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
|
|
If ObjClas.GetClasificaciones(UsuarioActual.CveEmpresa) Then
|
|
CveClasificacion2 = ObjClas.DtResultados.FiltroPrimeroValor("CveClasificacion", $"Clasificacion = '{ Clasificacion2.Trim }'").ToEntero
|
|
End If
|
|
|
|
|
|
If CveClasificacion2 = 0 Then
|
|
|
|
If ObjClas.AddClasificaciones(Clasificacion2, "", -1, "-1", -1, "-1", -1, "-1", CveCategoria, UsuarioActual.CveUsuario,
|
|
UsuarioActual.CveEmpresa) Then
|
|
If ObjClas.GetClasificaciones(Tipo:=4) Then Application("GlobalDTClasificaciones2") = ObjClas.DtResultados
|
|
CveClasificacion2 = GlobalDTClasificaciones2(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", $"Clasificacion = '{Clasificacion2}'").ToString.ToEntero
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
If Not CveClasificacion > 0 AndAlso Clasificacion <> "" Then Alert("No se encontró la Clasificación: " + Clasificacion, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
If Not CveUnidadMedida > 0 AndAlso UnidadMedida <> "" Then Alert("No se encontró la Unidad de Medida: " + UnidadMedida, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
If Not CveSATPS > 0 AndAlso SATClavePS <> "" Then Alert("No se encontró la Clve SAT PS: " + SATClavePS, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
If Not CveMarca > 0 AndAlso Marca <> "" Then Alert("No se encontró la Marca: " + Marca, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
If Not CveMedida > 0 AndAlso Medida <> "" Then Alert("No se encontró la Media: " + Medida, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
If Not CveRinTamaño > 0 AndAlso RinTamaño <> "" Then Alert("No se encontró el Tamaño: " + RinTamaño, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
If Not CveModelo > 0 AndAlso Modelo <> "" Then Alert("No se encontró el Modelo: " + Modelo, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
'If Not CveClasificacion2 > 0 AndAlso Clasificacion2 <> "" Then Alert("No se encontró la Serie: " + Clasificacion2, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
|
|
If CvePS > 0 Then
|
|
If Not ObjPS.UpdatePS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, 1, 1, False, 0, True, True, True, UsuarioActual.CveUsuario, CvePS, -1, -1, CveSATPS,
|
|
CveTipoPS:=CveTipoPS, CveMarca:=CveMarca, CveMedida:=CveMedida, CveRinTamaño:=CveRinTamaño,
|
|
CveModelo:=CveModelo, Litraje:=Litraje, IEPSPorcentaje:=IEPS, CveClasificacion2:=CveClasificacion2, CveTamaño:=CveTamaño) Then
|
|
'If Not ObjPS.UpdatePS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, 0, 1, 1, False, 0, True, True, True, UsuarioActual.CveUsuario, CvePS, -1, -1, CveSATPS,
|
|
' CveTipoPS:=CveTipoPS, CveMarca:=CveMarca, CveTamaño:=CveTamaño, CveMedida:=CveMedida) Then
|
|
ErrorPS = True
|
|
Codigo.GuardaLog
|
|
Exit For
|
|
Else
|
|
Contador += 1
|
|
End If
|
|
|
|
Else
|
|
|
|
If Codigo.Length > 0 Then
|
|
|
|
If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, 0, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1,
|
|
CveTipoPS:=CveTipoPS, CveSATPS:=CveSATPS, CveMarca:=CveMarca, CveTamaño:=CveTamaño, CveMedida:=CveMedida, CveRinTamaño:=CveRinTamaño,
|
|
CveModelo:=CveModelo, Litraje:=Litraje, IEPSPorcentaje:=IEPS, CveClasificacion2:=CveClasificacion2) <= 0 Then
|
|
'If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", "", Descripcion, 0, 0, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1,
|
|
' CveTipoPS:=CveTipoPS, CveSATPS:=CveSATPS, CveMarca:=CveMarca, CveTamaño:=CveTamaño, CveMedida:=CveMedida) <= 0 Then
|
|
ErrorPS = True
|
|
Codigo.GuardaLog
|
|
Exit For
|
|
Else
|
|
If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then
|
|
DTPS = ObjPS.DtResultados
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
If Not ErrorPS Then
|
|
ObjPS.Commit()
|
|
GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) = Nothing
|
|
'If ObjPS.GetPSSimplificado(-1) Then Application("GlobalDTPSSimplificado") = ObjPS.DtResultados.AsEnumerable()
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Productos/Servicios correctamente. <br>Se Actualizaron: <b>{1}</b> Productos/Servicios ya que ya se encontraban registrados.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Productos/Servicios correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
End If
|
|
TxtExcel.Text = ""
|
|
UpDatos.Update()
|
|
Else
|
|
ObjPS.RollBack()
|
|
End If
|
|
ObjPS.Dispose()
|
|
ObjGral.Dispose()
|
|
ObjClas.Dispose()
|
|
ObjVenta.Dispose()
|
|
ObjUM.Dispose()
|
|
|
|
'P R O V E E D O R E S
|
|
ElseIf RblFormato.SelectedValue = "1" Then
|
|
Dim ObjProv As New ClsCompProveedores
|
|
Dim ErrorProv As Boolean = False
|
|
Dim Contador As Integer = 0
|
|
Dim ExisteProveedor As Boolean = False
|
|
|
|
ObjProv.IniciaTransacSQL()
|
|
For Each Row As DataRow In dt.Rows
|
|
|
|
Dim Codigo As String = Row("Codigo").ToString
|
|
Dim RazonSocial As String = Row("RazonSocial").ToString
|
|
Dim RFC As String = Row("RFC").ToString.Trim
|
|
|
|
Dim Dirrecion As String = $"{ Row("Población").ToString}, { Row("Estado").ToString} , Colonia { Row("Colonia").ToString}, {Row("Calle").ToString} #{Row("Número exterior").ToString}"
|
|
|
|
'Dim NumExt As String = Row("Número exterior").ToString
|
|
|
|
|
|
' Dim Colonia As String = Row("Colonia").ToString
|
|
Dim CodigoPostal As Integer = Row("Código Postal").ToString.ToEntero
|
|
|
|
' Dim Poblacion As String = Row("Población").ToString
|
|
|
|
'Dim Estado As String = Row("Estado").ToString
|
|
Dim Telefono As String = Row("Teléfono").ToString
|
|
Dim ContactoMail As String = Row("Contacto").ToString
|
|
Dim CelularContacto As String = Row("Celular Contacto").ToString
|
|
Dim LimiteCredito As Double = Row("Limite Credito").ToString.ToDouble
|
|
Dim PlazoCobranza As Integer = Row("Plazo Cobranza").ToString.ToEntero
|
|
|
|
Dim Banco As String = Row("Banco").ToString
|
|
Dim NumeroCuenta As String = Row("N° CUENTA").ToString.Replace("-", "").Replace(" ", "")
|
|
Dim ClabeInter As String = Row("Clabe Inter").ToString.Replace("-", "").Replace(" ", "")
|
|
|
|
Dim CveProveedor As Integer = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveProveedor", $"RFC = '{RFC}'").ToString.ToEntero
|
|
Dim CveProveedor2 As Integer = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveProveedor", $"RazonSocial = '{RazonSocial}'").ToString.ToEntero
|
|
Dim CveProveedor3 As Integer = 0
|
|
|
|
If Codigo.Trim.Length > 0 Then
|
|
CveProveedor3 = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveProveedor", $"Codigo = '{Codigo}'").ToString.ToEntero
|
|
End If
|
|
|
|
|
|
|
|
' If CveProveedor > 0 Or CveProveedor2 > 0 Or CveProveedor3 > 0 Then
|
|
If CveProveedor > 0 Or CveProveedor2 > 0 Or CveProveedor3 > 0 Then
|
|
Contador = Contador + 1
|
|
|
|
'If Not ObjProv.UpdateProveedor(Codigo, RazonSocial, RazonSocial, RazonSocial, RFC, Calle, Telefono,
|
|
' Contacto, "", Telefono, LimiteCredito, PlazoCobranza, "", 0, 0, 0, -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "",
|
|
' -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, -1, True, "", "", False, CveProveedor) Then
|
|
' ErrorProv = True
|
|
' Exit For
|
|
'End If
|
|
|
|
Else
|
|
|
|
Telefono = Telefono.Replace("-", "").Replace("(", "").Replace(")", "").Trim
|
|
CelularContacto = CelularContacto.Replace("-", "").Replace("(", "").Replace(")", "").Trim
|
|
|
|
Telefono = If(Telefono.Length > 10, "", Telefono)
|
|
CelularContacto = If(CelularContacto.Length > 10, "", Telefono)
|
|
|
|
If Not ObjProv.AddProveedor(Codigo, RazonSocial, RazonSocial, RazonSocial, RFC, Dirrecion, Telefono,
|
|
"", ContactoMail, CelularContacto, LimiteCredito, PlazoCobranza, "", 0, 0, 0, -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "",
|
|
-1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, -1, "", "", False, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CP:=CodigoPostal) Then
|
|
ErrorProv = True
|
|
Exit For
|
|
|
|
|
|
Else
|
|
|
|
Dim ErrorCuentaDeposito As Boolean = False
|
|
'RESTRICCIONES GENERALES
|
|
'QUE TENGA ALGUN DATO DE TIPO DE CUENTA
|
|
If NumeroCuenta.Trim.Length = 0 AndAlso ClabeInter.Trim.Length = 0 Then
|
|
ErrorCuentaDeposito = True
|
|
End If
|
|
|
|
'SI CLABE TIENE ALGO DEBE TENER UNA LOGITUD EXACTA DE 18
|
|
If ClabeInter.Trim.Length <> 0 AndAlso ClabeInter.Trim.Length <> 18 Then
|
|
ErrorCuentaDeposito = True
|
|
End If
|
|
|
|
If Not ErrorCuentaDeposito Then
|
|
Dim ObjGrales As New ClsGenerales(ObjProv.IniciaTransacSQL)
|
|
If Not ObjGrales.AddCuentasDepositos(Banco, "-1", "-1", NumeroCuenta, ClabeInter, "-1", "-1", "-1", "-1", UsuarioActual.CveUsuario, 1, CveProveedor:=ObjProv.CveProveedor) Then
|
|
'ErrorProv = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If Not ErrorProv Then
|
|
ObjProv.Commit()
|
|
If ObjProv.GetProveedores(ClsCompProveedores.TipoConsulta.ParaGlobalDT, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, -1) Then Application("GlobalDTCompProveedores") = ObjProv.DtResultados
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Proveedores correctamente. <br>Se Omitieron: <b>{1}</b> Proveedores ya que ya se encontraban registrados.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Proveedores correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
End If
|
|
TxtExcel.Text = ""
|
|
UpDatos.Update()
|
|
Else
|
|
ObjProv.RollBack()
|
|
End If
|
|
ObjProv.Dispose()
|
|
|
|
' C L I E N T E S
|
|
ElseIf RblFormato.SelectedValue = "2" Then
|
|
Dim ObjClientes As New ClsClientes
|
|
Dim ErrorClientes As Boolean = False
|
|
Dim ExisteCliente As Boolean = False
|
|
Dim Contador As Integer = 0
|
|
Dim NumRow As Integer = 0
|
|
|
|
ObjClientes.IniciaTransacSQL()
|
|
For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows
|
|
NumRow = NumRow + 1
|
|
|
|
|
|
Dim Codigo As String = Row("Codigo").ToString
|
|
Dim RazonSocial As String = Row("RazonSocial").ToString
|
|
Dim RFC As String = Row("RFC").ToString.Trim
|
|
Dim Calle As String = Row("Calle").ToString
|
|
Dim NumExt As Decimal = Row("Número exterior").ToString.ToDecimal
|
|
Dim Colonia As String = Row("Colonia").ToString
|
|
Dim CodigoPostal As String = Row("Código Postal").ToString
|
|
Dim Poblacion As String = Row("Población").ToString
|
|
Dim Estado As String = Row("Estado").ToString
|
|
Dim Pais As String = Row("Pais").ToString
|
|
Dim Telefono As String = Row("Teléfono").ToString.Replace("-", "").Replace(" ", "").Replace("(", "").Replace(")", "")
|
|
Dim Contacto As String = Row("Contacto").ToString
|
|
|
|
|
|
Dim Vendedor As String = Row("Vendedor").ToString
|
|
Dim Clasificacion As String = Row("Clasificación").ToString
|
|
Dim CveCliente As Integer = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString.ToEntero
|
|
|
|
Dim CveVendedor As Integer = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveVendedor", $"Vendedor = '{Vendedor}'").ToString.ToEntero
|
|
Dim CveClasificación As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", $"Clasificacion = '{Clasificacion}'").ToString.ToEntero
|
|
Dim EsDistribuidor As Boolean = If(Row("Es distribuidor").ToString.ToUpper = "SI", True, False)
|
|
Dim CargoUsado As Boolean = If(Row("Cargo Usados").ToString.ToUpper = "SI", True, False)
|
|
Dim BonificacionUsado As Boolean = If(Row("EmitirBon Usado").ToString.ToUpper = "SI", True, False)
|
|
|
|
Dim LimiteCredito As Decimal = Row("Limite Credito").ToString.ToDecimal
|
|
Dim CobranzaCorreo As String = Row("CorreoPago").ToString
|
|
Dim PlazoCobranza As Integer = Row("Plazo Cobranza").ToString.ToEntero
|
|
|
|
Dim DìaVisita As String = Row("Dia Pago").ToString
|
|
Dim DiasPagoEspecifico As String = Row("Dìa Visita").ToString
|
|
Dim CobranzaContacto As String = Row("Encargado Pago").ToString
|
|
Dim CobranzaTelefono As String = Row("Celular Contacto").ToString.Replace("-", "").Replace(" ", "").Replace("(", "").Replace(")", "")
|
|
|
|
|
|
' CobranzaContacto = Regex.Replace(CobranzaContacto, "[^0-9]", "")
|
|
|
|
'Telefono
|
|
|
|
If Telefono.Trim.Length > 10 Then
|
|
Telefono = ""
|
|
End If
|
|
|
|
If CobranzaTelefono.Trim.Length > 10 Then
|
|
|
|
CobranzaTelefono = ""
|
|
End If
|
|
|
|
Dim FormaPago As String = Row("Forma Pago").ToString
|
|
Dim CveFormaPago33 As Integer = 99
|
|
|
|
Select Case FormaPago
|
|
|
|
Case "01"
|
|
CveFormaPago33 = 1
|
|
Exit Select
|
|
Case "02"
|
|
CveFormaPago33 = 2
|
|
Exit Select
|
|
Case "03"
|
|
CveFormaPago33 = 3
|
|
Exit Select
|
|
Case "04"
|
|
CveFormaPago33 = 4
|
|
Exit Select
|
|
Case "05"
|
|
CveFormaPago33 = 5
|
|
Exit Select
|
|
Case "06"
|
|
CveFormaPago33 = 6
|
|
Exit Select
|
|
Case "08"
|
|
CveFormaPago33 = 7
|
|
Exit Select
|
|
Case "12"
|
|
CveFormaPago33 = 8
|
|
Exit Select
|
|
Case "13"
|
|
CveFormaPago33 = 9
|
|
Exit Select
|
|
Case "14"
|
|
CveFormaPago33 = 10
|
|
Exit Select
|
|
Case "15"
|
|
CveFormaPago33 = 11
|
|
Exit Select
|
|
Case "17"
|
|
CveFormaPago33 = 12
|
|
Exit Select
|
|
Case "23"
|
|
CveFormaPago33 = 13
|
|
Exit Select
|
|
Case "24"
|
|
CveFormaPago33 = 14
|
|
Exit Select
|
|
Case "25"
|
|
CveFormaPago33 = 15
|
|
Exit Select
|
|
Case "26"
|
|
CveFormaPago33 = 16
|
|
Exit Select
|
|
Case "27"
|
|
CveFormaPago33 = 17
|
|
Exit Select
|
|
Case "28"
|
|
CveFormaPago33 = 18
|
|
Exit Select
|
|
Case "29"
|
|
CveFormaPago33 = 19
|
|
Exit Select
|
|
Case "99"
|
|
CveFormaPago33 = 20
|
|
Exit Select
|
|
Case "30"
|
|
CveFormaPago33 = 21
|
|
Exit Select
|
|
Case "31"
|
|
CveFormaPago33 = 22
|
|
Exit Select
|
|
Case Else
|
|
CveFormaPago33 = 99
|
|
|
|
End Select
|
|
|
|
|
|
|
|
'Dim RazonSocial As String = Row("RazonSocial").ToString
|
|
|
|
'Contacto
|
|
|
|
If CveCliente > 0 Then
|
|
ExisteCliente = True
|
|
Contador = Contador + 1
|
|
|
|
'If Not ObjClientes.UpdateCliente(RazonSocial, RazonSocial, Calle, "", "", Colonia, "", "", Estado, RFC, CodigoPostal, "", "", Contacto, "", "", "", "", -1, False, 1, -1, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "", -1, -1, -1,
|
|
' "-1", -1, -1, -1, -1, "0", -1, "0", 0, "", 0, "", 0, "", 0, "", "", "", "", 0, "", 1, False, "", "", "", False, "", "", "", "", "", False, "", "", "", False, 0, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "", "", False, -1) Then
|
|
' ErrorClientes = True
|
|
' RFC.GuardaLog
|
|
' Exit For
|
|
'End If
|
|
Else
|
|
|
|
If Not ObjClientes.AddCliente(RazonSocial, RazonSocial, Calle, NumExt.ToString, "", Colonia, Poblacion, Poblacion, Estado, Pais, RFC, CodigoPostal, Telefono, Contacto, "", "", "", "", "", -1, False, 0, 0, False, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "", CveVendedor, PlazoCobranza, -1,
|
|
"-1", "-1", -1, "-1", -1, "0", -1, "0", 0, "", 0, "", 0, "", 0, "", "", "", Codigo, LimiteCredito, "", 1, False, "", "", "", False, "", "", "", "", "", False, "", "", "", False, 0, -1, EsDistribuidor:=EsDistribuidor, CveClienteClasificacion:=CveClasificación, CargoUsado:=CargoUsado,
|
|
BonificacionUsado:=BonificacionUsado, CobranzaContacto:=CobranzaContacto, CobranzaCorreo:=CobranzaCorreo, DiasEspecifico:=DiasPagoEspecifico, DiasRevision:=DìaVisita, CobranzaTelefono:=CobranzaTelefono, CveFormaPago33:=CveFormaPago33) Then
|
|
|
|
ErrorClientes = True
|
|
RFC.GuardaLog
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
If Not ErrorClientes Then
|
|
ObjClientes.Commit()
|
|
'If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1) Then Application("GlobalDTCliente") = ObjClientes.DtResultados
|
|
GlobalDTCliente(UsuarioActual.CveEmpresa) = Nothing
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Clientes correctamente. <br>Se Omitieron: <b>{1}</b> Clientes ya que ya se encontraban registrados.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Clientes correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
End If
|
|
TxtExcel.Text = ""
|
|
UpDatos.Update()
|
|
Else
|
|
ObjClientes.RollBack()
|
|
End If
|
|
ObjClientes.Dispose()
|
|
|
|
'P R O V E E D O R E S - F A C T U R A S
|
|
ElseIf RblFormato.SelectedValue = "3" Then
|
|
Dim ObjCompras As New ClsCompras
|
|
Dim ErrorCompras As Boolean = False
|
|
Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL())
|
|
Dim CveCompra As Integer
|
|
Dim Contador As Integer = 0
|
|
Dim ExisteCompra As Boolean = False
|
|
Dim DtProveedores = New DataTable
|
|
Dim NoEncontrados = 0
|
|
Dim Encontrados As Integer = 0
|
|
DtProveedores = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
Dim RFC As String = ""
|
|
Dim drr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero("")
|
|
Dim CvePS As Integer = drr("CvePS").ToString.ToEntero
|
|
Dim CveUnidadMedida As Integer = drr("CveUnidadMedida").ToString.ToEntero
|
|
Dim CveClasificacion As Integer = drr("CveClasificacion").ToString.ToEntero
|
|
Dim dtsubp As DataTable = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
|
|
|
|
For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows
|
|
Dim Sucursal As String = dtsubp.FiltroPrimeroValor("CveSubProyecto", $"SubProyecto = '{Row("Sucursal").ToString}'")
|
|
RFC = Row("RFC").ToString.Trim
|
|
RFC = Row("RFC").ToString.Trim
|
|
Dim Serie As String = Row("Serie").ToString
|
|
Dim Folio As String = Row("Folio").ToString
|
|
Dim Fecha As Date = Row("Fecha").ToString.ToDate
|
|
Dim SubTotal As Decimal = Row("SubTotal").ToString.ToDecimal
|
|
Dim IVA As Decimal = Row("IVA").ToString.ToDecimal
|
|
Dim Total As Decimal = Row("Total").ToString.ToDecimal
|
|
Dim Saldo As Decimal = Row("Saldo").ToString.ToDecimal
|
|
Dim TipoDocto As String = Row("Tipo Documento").ToString
|
|
Dim CveProveedor As Integer = DtProveedores.FiltroPrimeroValor("CveProveedor", $"RFC = '{RFC}'").ToString.ToEntero
|
|
GuardaLog(Sucursal + " - " + Row("Sucursal").ToString)
|
|
Dim RetIVA As Double = Row("Ret IVA").ToString.ToDouble
|
|
Dim RetISR As Double = Row("Ret ISR").ToString.ToDouble
|
|
Dim IEPS As Decimal = Row("IEPS").ToString.ToDecimal
|
|
Dim Moneda As String = Row("Moneda").ToString
|
|
Dim TipoCambio As String = Row("Tipo Cambio").ToString
|
|
Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString.ToDate
|
|
Dim CveMoneda As Integer = 1
|
|
Dim CveProveedorSucursal As Integer = Row("CveProveedorSucursal").ToString.ToEntero
|
|
|
|
|
|
If Not CvePS > 0 Then Alert(String.Format("No se encontró el Producto Servicio"), TipoMensaje.MsgError) : ErrorCompras = True
|
|
If Not CveUnidadMedida > 0 Then Alert(String.Format("No se encontró la Unidad de Medida."), TipoMensaje.MsgError) : ErrorCompras = True
|
|
If Not CveProveedor > 0 Then Alert(String.Format("No se encontró el Proveedor con el RFC: {0}", {RFC}), TipoMensaje.MsgError) : ErrorCompras = True : Exit For
|
|
If Not CveProveedorSucursal > 0 Then CveProveedorSucursal = -1
|
|
|
|
TipoDocto = IIf(TipoDocto = "Ingresos", "Fac", "NC").ToString
|
|
|
|
|
|
'Temporalmente SE BORRARA
|
|
Dim Transaccion As String = "" 'Row("Transaccion2").ToString
|
|
Dim Folio2 As String = "" 'Row("Folio2").ToString
|
|
Dim CodProvee As String = "" 'Row("CodProvee2").ToString
|
|
|
|
'Moneda
|
|
If Moneda = "Pesos" Then
|
|
CveMoneda = 1
|
|
ElseIf Moneda = "Dólares" Then
|
|
CveMoneda = 2
|
|
End If
|
|
|
|
'Si no se especifica TC, se manda como pesos.
|
|
If TipoCambio = "" Then TipoCambio = "1"
|
|
|
|
'PrePóliza
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Compras/SaldoInicial", 1, Total, Total, CveMoneda, Fecha, String.Format("{0}-{1}", Serie, Folio), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If Not CvePrePoliza > 0 Then
|
|
ErrorCompras = True
|
|
Exit For
|
|
End If
|
|
|
|
If FechaVencimiento = "".ToDate Or FechaVencimiento < "1900/01/01".ToDate Then
|
|
FechaVencimiento = Fecha
|
|
End If
|
|
|
|
|
|
|
|
|
|
'Compra
|
|
If Not ObjCompras.AddCompra(TipoDocto, "", Serie, Folio, Folio2, CveProveedor.ToEntero, SubTotal, 0, 0, IVA, RetIVA, RetISR, IEPS, 0, 0, Total, Fecha, CveMoneda, TipoCambio.ToDouble, FechaVencimiento,
|
|
False, CodProvee, 1, CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveProveedorSucursal:=CveProveedorSucursal,
|
|
NumeroReembolso:=Transaccion, PorcentajeIVA:=0.16) Then
|
|
ErrorCompras = True
|
|
Exit For
|
|
End If
|
|
CveCompra = ObjCompras.CveCompra
|
|
|
|
'Compra Detalle
|
|
If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, Sucursal.ToEntero, -1, 0, 1, SubTotal, 0.16, SubTotal, 0, "Carga Inicial", -1) Then
|
|
ErrorCompras = True
|
|
Exit For
|
|
End If
|
|
Dim ConceptoContablePago As Integer = 17
|
|
If TipoDocto = "NC" Then ConceptoContablePago = 60
|
|
|
|
'PrePólizaDetalle
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Folio, IIf(TipoDocto = "Fac", 5, 18).ToString.ToEntero, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=Total, CveSubProyecto:=Sucursal.ToEntero) Then ErrorCompras = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, SubTotal, Folio, 6, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=SubTotal, CveClasificacion:=CveClasificacion, CveSubProyecto:=Sucursal.ToEntero) Then ErrorCompras = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, IVA, Folio, 14, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=IVA, CveSubProyecto:=Sucursal.ToEntero) Then ErrorCompras = True : Exit For
|
|
If IEPS > 0 Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, IEPS, Folio, 25, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=IEPS, CveSubProyecto:=Sucursal.ToEntero) Then ErrorCompras = True : Exit For
|
|
|
|
|
|
'Saldo
|
|
If Saldo < Total Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Folio, 17, Folio, Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=Total - Saldo) Then ErrorCompras = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Folio, 95, Folio, Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteMX:=Total - Saldo) Then ErrorCompras = True : Exit For
|
|
End If
|
|
Encontrados = Encontrados + 1
|
|
|
|
Next
|
|
If Not ErrorCompras Then
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Compras correctamente.<br>Se Omitieron: <b>{1}</b> Compras ya que ya se encuentran registradas.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Compras correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
End If
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Compras correctamente. RFC:{1} ", Encontrados, RFC), TipoMensaje.MsgInformacion)
|
|
ObjCompras.Commit()
|
|
TxtExcel.Text = ""
|
|
UpDatos.Update()
|
|
Else
|
|
Alert(String.Format("NO Se agregaron: <b>{0}</b> Compras.", NumRows), TipoMensaje.MsgError)
|
|
ObjCompras.RollBack()
|
|
End If
|
|
ObjCompras.Dispose()
|
|
|
|
'C L I E N T E S - F A C T U R A S
|
|
ElseIf RblFormato.SelectedValue = "4" Then
|
|
Dim ObjVentas As New ClsVentas
|
|
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
|
Dim ObjIE As New ClsBancos(ObjVentas.IniciaTransacSQL())
|
|
Dim ErrorVentas As Boolean = False
|
|
Dim CveVenta As Integer
|
|
Dim DtClientes = New DataTable
|
|
'Dim ExisteVenta As Boolean = False
|
|
'Dim Contador As Integer = 0
|
|
DtClientes = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
Dim NoEncontrados As Integer = 0
|
|
Dim Encontrados As Integer = 0
|
|
Dim StrRFCNoencontrados As New StringBuilder
|
|
Dim drr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero("")
|
|
Dim CvePS As Integer = drr("CvePS").ToString.ToEntero
|
|
Dim CveUnidadMedida As Integer = drr("CveUnidadMedida").ToString.ToEntero
|
|
Dim CveClasificacion As Integer = drr("CveClasificacion").ToString.ToEntero
|
|
|
|
If Not CvePS > 0 Then Alert(String.Format("No se encontró el Producto Servicio"), TipoMensaje.MsgError) : ErrorVentas = True
|
|
' If Not CveSucursal > 0 Then Alert("No se encontró la sucursal.", TipoMensaje.MsgError) : ErrorVentas = True
|
|
If Not CveUnidadMedida > 0 Then Alert(String.Format("No se encontró la Unidad de Medida."), TipoMensaje.MsgError) : ErrorVentas = True
|
|
Dim dtsubp As DataTable = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
|
|
|
|
For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows
|
|
Dim Sucursal As String = dtsubp.FiltroPrimeroValor("CveSubProyecto", $"SubProyecto = '{Row("Sucursal").ToString}'")
|
|
Dim TipoDocto As String = Row("Tipo Documento").ToString
|
|
Dim RFC As String = Row("RFC").ToString.Trim
|
|
Dim Serie As String = Row("Serie").ToString
|
|
Dim Folio As Integer = Row("Folio").ToString.ToEntero
|
|
Dim Fecha As Date = Row("Fecha").ToString.ToDate
|
|
Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString.ToDate
|
|
Dim ImpuestoLocal As Double = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString.ToDouble, 0)
|
|
Dim Amortizacion As Double = If(dt.Columns.Contains("Amort.Ant"), Row("Amort.Ant").ToString.ToDouble, 0)
|
|
Dim SubTotal As Decimal = Row("SubTotal").ToString.ToDecimal
|
|
Dim IVA As Decimal = Row("IVA").ToString.ToDecimal
|
|
Dim Total As Decimal = Row("Total").ToString.ToDecimal
|
|
Dim Saldo As Decimal = Row("Saldo").ToString.ToDecimal
|
|
Dim CveCliente As Integer = DtClientes.FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString.ToEntero
|
|
Dim RetIVA As Double = Row("Ret IVA").ToString.ToDouble
|
|
Dim RetISR As Double = Row("Ret ISR").ToString.ToDouble
|
|
Dim Moneda As String = Row("Moneda").ToString
|
|
Dim TipoCambio As String = Row("Tipo Cambio").ToString
|
|
Dim CveMoneda As Integer = 1
|
|
Dim Vendedor As String = "" 'Row("Vendedor").ToString
|
|
Dim CveVendedor As Integer = 0
|
|
Dim IEPS As Decimal = 0 'Row("IEPS").ToString.ToDecimal
|
|
Dim CveClienteSucursal As Integer = 0 'Row("CveClienteSucursal").ToString.ToEntero
|
|
Dim ImpuestosLocales As Decimal = If(dt.Columns.Contains("ImpuestoLocal"), Row("ImpuestoLocal").ToString.ToDecimal, 0)
|
|
Dim FolioFiscal As String = If(dt.Columns.Contains("Folio Fiscal"), Row("Folio Fiscal").ToString, "")
|
|
|
|
GuardaLog(Sucursal + "-" + Row("Folio").ToString)
|
|
'Temporalmente SE BORRARA
|
|
Dim Transaccion As String = "" ' Row("Transaccion2").ToString
|
|
Dim Folio2 As String = "" ' Row("Folio2").ToString
|
|
Dim CodCliente As String = "" 'Row("CodCliente2").ToString
|
|
|
|
|
|
'If Not CveCliente > 0 Then Alert(String.Format("No se encontró el cliente con el RFC: {0}", {RFC}), TipoMensaje.MsgError) : ErrorVentas = True : RFC.GuardaLog : Exit For
|
|
TipoDocto = IIf(TipoDocto = "INGRESO", "Ing", IIf(TipoDocto = "EGRESO", "Egs", "Rem")).ToString
|
|
'PrePóliza
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Venta/SaldoInicial", 1, Total, Total, 1, Fecha, String.Format("{0}-{1}", Serie, Folio), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If Vendedor <> "" Then
|
|
CveVendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveVendedor", $"Vendedor = '{Vendedor}'").ToString.ToEntero
|
|
If Not CveVendedor > 0 Then CveVendedor = 0
|
|
Else
|
|
CveVendedor = 0
|
|
End If
|
|
|
|
'Moneda
|
|
If Moneda = "Pesos" Then
|
|
CveMoneda = 1
|
|
ElseIf Moneda = "Dólares" Then
|
|
CveMoneda = 2
|
|
End If
|
|
|
|
'Si no se especifica TC, se manda como pesos.
|
|
If TipoCambio = "" Then TipoCambio = "1"
|
|
|
|
If Not CveClienteSucursal > 0 Then CveClienteSucursal = -1
|
|
|
|
If FechaVencimiento = "".ToDate Or FechaVencimiento < "1900/01/01".ToDate Then
|
|
FechaVencimiento = Fecha
|
|
End If
|
|
|
|
|
|
'Venta
|
|
If CveCliente > 0 Then
|
|
|
|
|
|
If TipoDocto.Contiene("Ing", "Egs", "Rem") Then
|
|
GuardaLog(Serie & "-" & Folio)
|
|
If Not ObjVentas.AddVenta(TipoDocto, Folio, CveCliente.ToEntero, CveClienteSucursal, SubTotal, 0, Amortizacion, IVA, RetIVA, RetISR, Total, CveMoneda, TipoCambio.ToDouble,
|
|
0, 0, 0, FechaVencimiento, Fecha, "", "", Fecha, CveVendedor, Folio2, "", "", 0, 0, 0, "-1".ToDate, "-1".ToDate, "-1".ToDate, -1, -1, 0, CvePrePoliza,
|
|
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Serie:=Serie, CveSubProyecto:=Sucursal.ToEntero, CveSubProyectoEjecucion:=Sucursal.ToEntero,
|
|
CveSubProyectoCobranza:=Sucursal.ToEntero, IEPS:=IEPS,
|
|
ObservacionesAlmacen:=Transaccion, Entrega:=CodCliente, ImpuestoLocal:=ImpuestosLocales) Then
|
|
ErrorVentas = True
|
|
Exit For
|
|
End If
|
|
CveVenta = ObjVentas.CveVenta
|
|
|
|
If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, 1, CveUnidadMedida, SubTotal, 0.16, SubTotal * 0.16, "Saldo Inicial", 0, 0, -1, 0) Then
|
|
ErrorVentas = True
|
|
Exit For
|
|
End If
|
|
|
|
If FolioFiscal IsNot "" Then
|
|
If Not ObjVentas.UpdateEstatusFactura(3, FolioFiscal, "", FechaVencimiento, CveVenta, CvePAC:=1) Then
|
|
ErrorVentas = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
Dim ConceptoContable As Integer = 1
|
|
Dim ConceptoContablePago As Integer = 2
|
|
If TipoDocto = "Egs" Then
|
|
ConceptoContable = 12
|
|
ConceptoContablePago = 91
|
|
End If
|
|
|
|
|
|
'PrePólizaDetalle
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SubTotal, Folio.ToString, 4, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, ImporteMX:=SubTotal, CveSubProyecto:=Sucursal.ToEntero) Then ErrorVentas = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Folio.ToString, ConceptoContable, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Total) Then ErrorVentas = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, Folio.ToString, 13, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=IVA) Then ErrorVentas = True : Exit For
|
|
'If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, Folio.ToString, 38, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=IEPS) Then ErrorVentas = True : Exit For
|
|
|
|
|
|
'Saldo
|
|
If Saldo < Total Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Folio.ToString, ConceptoContablePago, Folio.ToString, Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Total - Saldo, CveVentaAmortizacion:=CveVenta) Then ErrorVentas = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Folio.ToString, 95, Folio.ToString, Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Total - Saldo) Then ErrorVentas = True : Exit For
|
|
End If
|
|
|
|
Else
|
|
'ANTICIPOS
|
|
Dim CveIE As Integer = ObjIE.AddBancos_IE(1, 1, Fecha, Folio.ToString, "", Total, 1,
|
|
1, "Anticipo Cliente", "", False, False, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Folio.ToString, 30, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveIE:=CveIE, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Folio.ToString, 66, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveIE:=CveIE, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
|
|
|
End If
|
|
Encontrados = Encontrados + 1
|
|
|
|
Else
|
|
NoEncontrados = NoEncontrados + 1
|
|
StrRFCNoencontrados.AppendFormat("{0}<br/>", RFC)
|
|
ErrorVentas = True
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
If Not ErrorVentas Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Ventas correctamente. <b>{1} no encontrados</b><br/>{2} ", Encontrados, NoEncontrados, StrRFCNoencontrados), TipoMensaje.MsgInformacion)
|
|
ObjVentas.Commit()
|
|
TxtExcel.Text = ""
|
|
UpDatos.Update()
|
|
Else
|
|
Alert(String.Format("Error al registrar : <b>{0}</b> Ventas correctamente. <b>{1} no encontrados</b><br/>{2} ", Encontrados, NoEncontrados, StrRFCNoencontrados), TipoMensaje.MsgError)
|
|
ObjVentas.RollBack()
|
|
End If
|
|
ObjVentas.Dispose()
|
|
|
|
|
|
' R H - P E R S O N A L
|
|
ElseIf RblFormato.SelectedValue = "6" Then
|
|
Dim ObjRH As New ClsRH
|
|
Try
|
|
ObjRH.IniciaTransacSQL()
|
|
Dim ErrorRH As Boolean = False
|
|
Dim Contador As Integer = 0
|
|
Dim NumRow As Integer = 0
|
|
|
|
For Each Row As DataRow In dt.Rows
|
|
Dim Codigo As String = Row("Código").ToString
|
|
Dim ApellidoPaterno As String = Row("Apellido Paterno").ToString
|
|
Dim ApellidoMaterno As String = Row("Apellido Materno").ToString
|
|
Dim Nombre As String = Row("Nombre").ToString
|
|
Dim CorreoElectronico As String = Row("Correo Electronico").ToString
|
|
Dim FechaIngreso As String = Row("Fecha Ingreso").ToString
|
|
Dim FechaBaja As String = Row("Fecha Baja").ToString
|
|
Dim NumeroSS As String = Row("Numero SS").ToString
|
|
Dim AltaIMSS As String = Row("Alta IMSS").ToString
|
|
Dim SalarioDiario As String = Row("Salario Diario").ToString
|
|
Dim Direccion As String = Row("Dirección").ToString
|
|
Dim FechaNacimiento As String = Row("Fecha Nacimiento").ToString
|
|
Dim LugarNacimiento As String = Row("Lugar Nacimiento").ToString
|
|
Dim Sexo As String = Row("Sexo").ToString
|
|
Dim CodigoPostal As String = Row("Código Postal").ToString
|
|
Dim Ciudad As String = Row("Ciudad").ToString
|
|
Dim EstadoCivil As String = Row("Estado Civil").ToString.ToUpper
|
|
Dim Telefono As String = Row("Teléfono").ToString
|
|
Dim Celular As String = Row("Celular").ToString
|
|
Dim RFC As String = Row("RFC").ToString
|
|
Dim CURP As String = Row("CURP").ToString
|
|
Dim ClabeInterbancaria As String = Row("CLABE").ToString
|
|
Dim EstatusPersonal As String = Row("Estatus Personal").ToString.ToUpper
|
|
|
|
'Nuevas
|
|
Dim Estado As String = Row("Estado").ToString
|
|
Dim NombrePadre As String = Row("Nombre Padre").ToString
|
|
Dim NombreMadre As String = Row("Nombre Madre").ToString
|
|
Dim Puesto As String = Row("Puesto").ToString
|
|
Dim Turno As String = Row("Turno").ToString
|
|
Dim TipoContrato As String = Row("Tipo Contrato").ToString
|
|
Dim Departamento As String = Row("Departamento").ToString
|
|
Dim TipoPeriodo As String = Row("Tipo Periodo").ToString
|
|
Dim Escolaridad As String = Row("Escolaridad").ToString
|
|
Dim SDI As String = Row("SDI").ToString
|
|
Dim MetodoPago As String = Row("Metodo Pago").ToString
|
|
Dim Nominista As String = Row("Nominista").ToString
|
|
|
|
'CLAVES
|
|
Dim CveGenero As Integer = 0
|
|
Dim CveEstadoCivil As Integer = 0
|
|
Dim CveEstatusPersonal As Integer = 0
|
|
' Dim CveSucursal As Integer = GlobalDTSucursales(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSucursal").ToString.ToEntero
|
|
Dim CvePuesto As Integer = GlobalDTRHPuestos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePuesto", $"Puesto = '{Puesto}'").ToString.ToEntero
|
|
Dim CveTurno As Integer = GlobalDTTurno().FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}").FiltroPrimeroValor("CveTurno", $"Turno = '{Turno}'").ToString.ToEntero
|
|
Dim CveDepartamento As Integer = GlobalDTDepartamentos().FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}").FiltroPrimeroValor("CveDepartamento", $"Departamento = '{Departamento}'").ToString.ToEntero
|
|
Dim CveEstado As Integer = GlobalDTGralEstados(1).FiltroPrimeroValor("CveEstado", $"Clave = '{Estado}'").ToString.ToEntero
|
|
Dim CveTipoContrato As Integer = GlobalDTTiposContrato().FiltroPrimeroValor("CveTipoContrato", $"TipoContrato = '{TipoContrato}'").ToString.ToEntero
|
|
Dim CveTipoPeriodo As Integer = GlobalDTTipoPeriodo().FiltroPrimeroValor("CveTipoPeriodo", $"TipoPeriodo = '{TipoPeriodo}'").ToString.ToEntero
|
|
Dim CveEscolaridad As Integer = GlobalDTEscolaridad().FiltroPrimeroValor("CveEscolaridad", $"Escolaridad = '{Escolaridad}'").ToString.ToEntero
|
|
Dim CveMetodoPago As Integer = GlobalDTMetodosPago().FiltroPrimeroValor("CveMetodoPago", $"ClaveSAT = '{MetodoPago}'").ToString.ToEntero
|
|
Dim CveUsuarioNomina As Integer = GlobalDTUsuarios(-1, -1).FiltroPrimeroValor("CveUsuario", $"Nombre = '{Nominista}'").ToString.ToEntero
|
|
|
|
Dim FechaIn As Date
|
|
Dim FechaFn As Date
|
|
Dim FechaNac As Date
|
|
FechaIn = If(IsDate(FechaIngreso), FechaIngreso.ToDate, MinFecha)
|
|
FechaFn = If(IsDate(FechaBaja), FechaBaja.ToDate, MinFecha)
|
|
FechaNac = If(IsDate(FechaNacimiento), FechaNacimiento.ToDate, MinFecha)
|
|
|
|
'VALIDACIONES
|
|
' If Not CveSucursal > 0 Then Alert("La Empresa no cuenta con Sucursal, es necesario dar una Sucursal de alta.", TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
If Not CveDepartamento > 0 Then Alert($"No se encontró el Departamento: {Departamento} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
If Not CvePuesto > 0 Then Alert($"No se encontró el Puesto: {Puesto} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
If Not CveTurno > 0 Then Alert($"No se encontró el turno: {Turno} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
If Not CveEstado > 0 Then Alert($"No se encontró el Estado: {Estado} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
If Not CveTipoContrato > 0 Then Alert($"No se encontró el Tipo Contrato: {TipoContrato} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
If Not CveTipoPeriodo > 0 Then Alert($"No se encontró el Tipo Periodo: {TipoPeriodo} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
If Not CveEscolaridad > 0 Then Alert($"No se encontró el Escolaridad: {Escolaridad} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
If Not CveMetodoPago > 0 Then Alert($"No se encontró el Método de Pago: {MetodoPago} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
If Not CveUsuarioNomina > 0 Then CveUsuarioNomina = -1 'Alert("No se encontró el Nominista: " + Nominista + " Renglón: " + NumRow, TipoMensaje.MsgAdvertencia) : ErrorRH = True : Exit For
|
|
|
|
|
|
Dim NombreCompleto As String = $"{Nombre} {ApellidoPaterno} {ApellidoMaterno}"
|
|
Dim CvePersonal As Integer = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePersonal", $"NombreCompletoNombre = '{NombreCompleto}'").ToString.ToEntero
|
|
|
|
|
|
'PENDIENTES POR MEJORAR
|
|
Dim CveSATRegimenContratacion As Integer = 1
|
|
Dim CveSATRiesgoPuesto As Integer = 1
|
|
Dim CveJornada As Integer = 1
|
|
|
|
If Sexo = "Masculino" Then CveGenero = 1 Else CveGenero = 2
|
|
If AltaIMSS = "SI" Then AltaIMSS = "True" Else AltaIMSS = "False"
|
|
|
|
Select Case EstadoCivil
|
|
Case "SOLTERO"
|
|
CveEstadoCivil = 1
|
|
Case "CASADO"
|
|
CveEstadoCivil = 2
|
|
Case "DIVORCIADO"
|
|
CveEstadoCivil = 3
|
|
Case "UNIÓN LIBRE"
|
|
CveEstadoCivil = 4
|
|
Case "VIUDO"
|
|
CveEstadoCivil = 5
|
|
Case Else
|
|
CveEstadoCivil = 1
|
|
End Select
|
|
|
|
Select Case EstatusPersonal
|
|
Case "ACTIVO"
|
|
CveEstatusPersonal = 1
|
|
Case "INACTIVO"
|
|
CveEstatusPersonal = 2
|
|
Case "REINGRESO"
|
|
CveEstatusPersonal = 5
|
|
Case Else
|
|
CveEstatusPersonal = 1
|
|
End Select
|
|
|
|
If CvePersonal > 0 Then
|
|
Contador = Contador + 1
|
|
Else
|
|
If Not ObjRH.AddPersonal(Codigo, ApellidoPaterno, ApellidoMaterno, Nombre, CorreoElectronico, FechaIn, CveTipoPeriodo, NumeroSS, CBool(AltaIMSS), SalarioDiario.ToDouble, SalarioDiario.ToDouble, SDI.ToDouble, SalarioDiario.ToDouble,
|
|
-1, -1, -1, CveMetodoPago, FechaIn, FechaFn.ToString, CveTipoContrato, Direccion, CveTurno, CvePuesto, CveDepartamento, -1, CveEscolaridad, CveEstadoCivil, CveGenero, -1, FechaBaja, CveEstatusPersonal, FechaNac,
|
|
LugarNacimiento, Direccion, "", "", "", CodigoPostal, Ciudad, CveEstado, Telefono, Celular, RFC, CURP, NombrePadre, NombreMadre, -1, CveSATRiesgoPuesto, CveSATRegimenContratacion, -1, -1, "", -1,
|
|
ClabeInterbancaria, "", CveJornada, CveJornada, "", -1, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveUsuarioNomina) Then
|
|
ErrorRH = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
NumRow = NumRow + 1
|
|
Next
|
|
|
|
|
|
If Not ErrorRH Then
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Empleados correctamente. <br>Se Omitieron: <b>{1}</b> Empleados ya que ya se encontraban registrados.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
ObjRH.Commit()
|
|
TxtExcel.Text = ""
|
|
UpDatos.Update()
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Empleados correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
ObjRH.Commit()
|
|
TxtExcel.Text = ""
|
|
UpDatos.Update()
|
|
End If
|
|
Else
|
|
ObjRH.RollBack()
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
GuardaLog($"Ocurrio un error al insertar el personal.: {ex}")
|
|
ObjRH.RollBack()
|
|
|
|
Finally
|
|
ObjRH.Dispose()
|
|
End Try
|
|
|
|
|
|
|
|
' A F - A C T I V O F I J O
|
|
ElseIf RblFormato.SelectedValue = "7" Then
|
|
Dim ObjAF As New ClsAF
|
|
Try
|
|
ObjAF.IniciaTransacSQL()
|
|
Dim ErrorAF As Boolean = False
|
|
Dim Contador As Integer = 0
|
|
Dim NumRow As Integer = 0
|
|
|
|
For Each Row As DataRow In dt.Rows
|
|
Dim Codigo As String = Row("Código").ToString
|
|
Dim Descripcion As String = Row("Descripción").ToString
|
|
Dim TipoAF As String = Row("Tipo").ToString
|
|
Dim SubTipo As String = Row("SubTipo").ToString
|
|
Dim Valor As String = Row("Valor").ToString
|
|
Dim FechaAF As String = Row("Fecha").ToString
|
|
Dim NumeroSerie As String = Row("No. Serie").ToString
|
|
Dim Año As String = Row("Año").ToString
|
|
Dim CuentaContable As String = Row("Cuenta Contable").ToString
|
|
Dim Estado As String = Row("Estado").ToString
|
|
Dim Responsable As String = Row("Responsable").ToString
|
|
Dim Proyecto As String = Row("Proyecto").ToString
|
|
Dim SubProyecto As String = Row("SubProyecto").ToString
|
|
Dim Cliente As String = Row("Cliente").ToString
|
|
Dim Observaciones As String = Row("Observaciones").ToString
|
|
Dim CtaDepreciacion As String = Row("Cuenta Depreciación").ToString
|
|
Dim PorcentajeDepreciacion As String = Row("% Depreciación").ToString
|
|
|
|
'CLAVES
|
|
Dim CveAF As Integer = GlobalDTActivoFijos(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveActivoFijo", $"Código = '{Codigo}'").ToString.ToEntero
|
|
Dim CveSubTipoAF As Integer = GlobalDTSubTipoActivoFijo(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubTipoActivoFijo", $"TipoActivoFijo = '{TipoAF}'").ToString.ToEntero
|
|
Dim CveSubProyecto As Integer = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"SubProyecto = '{SubProyecto}'").ToString.ToEntero
|
|
Dim CveEstadoFijo As Integer = GlobalDTEstadoActivoFijo().FiltroPrimeroValor("CveEstadoFijo", $"Estado = '{Estado}'").ToString.ToEntero
|
|
Dim CveCliente As Integer = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCliente", $"Nombre = '{Cliente}'").ToString.ToEntero
|
|
|
|
|
|
'VALIDACIONES
|
|
If Not CveSubTipoAF > 0 Then Alert($"No se encontró el SubTipo: {TipoAF} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorAF = True : Exit For
|
|
If Not CveSubProyecto > 0 Then Alert($"No se encontró el SubProyecto: {SubProyecto} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorAF = True : Exit For
|
|
If Not CveEstadoFijo > 0 Then Alert($"No se encontró el Estado: {CveEstadoFijo} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorAF = True : Exit For
|
|
If Not CveCliente > 0 Then Alert($"No se encontró el Cliente: {Cliente} Renglón: {NumRow}: ", TipoMensaje.MsgAdvertencia) : ErrorAF = True : Exit For
|
|
|
|
|
|
'If CveAF > 0 Then
|
|
' Contador = Contador + 1
|
|
'Else
|
|
' If Not ObjAF.AddActivosFijos(Codigo, Descripcion, Valor, FechaAF, CveSubTipoAF, -1, NumeroSerie, Año, CveSubProyecto, CtaDepreciacion, CveEstadoFijo,
|
|
' CtaDepreciacion, PorcentajeDepreciacion, Observaciones, CveCliente, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
' ErrorAF = True
|
|
' Exit For
|
|
' End If
|
|
'End If
|
|
|
|
NumRow = NumRow + 1
|
|
Next
|
|
|
|
|
|
If Not ErrorAF Then
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Activos Fijos correctamente. <br>Se Omitieron: <b>{1}</b> Activos Fijos ya que ya se encontraban registrados.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
ObjAF.Commit()
|
|
TxtExcel.Text = ""
|
|
UpDatos.Update()
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Activos Fijos correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
ObjAF.Commit()
|
|
TxtExcel.Text = ""
|
|
UpDatos.Update()
|
|
End If
|
|
Else
|
|
ObjAF.RollBack()
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
GuardaLog($"Ocurrio un error al agregar Activo Fijo: {ex}")
|
|
ObjAF.RollBack()
|
|
|
|
Finally
|
|
ObjAF.Dispose()
|
|
End Try
|
|
|
|
' C U E N T A S C O N T A B L E S
|
|
ElseIf RblFormato.SelectedValue = "8" Then
|
|
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjConta.IniciaTransacSQL()
|
|
Try
|
|
|
|
|
|
Dim TieneError As Boolean = False
|
|
Dim ContadorUpdate As Integer = 0
|
|
Dim ContadorError As Integer = 0
|
|
Dim NombreCuenta As String = ""
|
|
Dim CuentaPadre As String = ""
|
|
|
|
For Each Row As DataRow In dt.Rows
|
|
NombreCuenta = Row("NombreCuenta").ToString
|
|
CuentaPadre = Row("CuentaPadre").ToString
|
|
Dim Cuenta As String = Row("Cuenta").ToString
|
|
Dim TipoCuenta As String = Row("TipoCuenta").ToString
|
|
Dim AgrupadorSAT As String = Row("AgrupadorSAT").ToString
|
|
Dim CveCuentaPadre As Integer = -1
|
|
|
|
If NombreCuenta <> "" Then
|
|
|
|
If ObjConta.GetCuentas(-1, CuentaPadre.Replace("-", ""), -1) Then
|
|
If ObjConta.DtResultados.Rows.Count > 0 Then
|
|
CveCuentaPadre = ObjConta.DtResultados().FiltroPrimeroValor("Id").ToEntero
|
|
Else
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
|
|
Dim IdNew = ObjConta.AddCuenta(Cuenta.Replace("-", ""), NombreCuenta, TipoCuenta, 1, 0, 1, 0, "", 0, CveCuentaPadre, AgrupadorSAT.ToEntero)
|
|
If IdNew > 0 Then
|
|
ContadorUpdate = ContadorUpdate + 1
|
|
Else
|
|
TieneError = True
|
|
ContadorError = ContadorError + 1
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
|
|
If Not TieneError Then
|
|
ObjConta.Commit()
|
|
Else
|
|
Alert($"No pudimos agregar la cuenta: {NombreCuenta} - Cuenta Padre: {CuentaPadre}", TipoMensaje.MsgError)
|
|
ObjConta.RollBack()
|
|
End If
|
|
|
|
Alert($"Se agregaron {ContadorUpdate} Cuentas Correctamente y se omitieron: {ContadorError} cuentas.")
|
|
|
|
Catch ex As Exception
|
|
ObjConta.RollBack()
|
|
End Try
|
|
|
|
ObjConta.Dispose()
|
|
|
|
'C U E N T A S C O N T A B L E S - C O N T A S I G
|
|
ElseIf RblFormato.SelectedValue = "9" Then
|
|
Dim ObjConta As New ClsContabilidad
|
|
ObjConta.IniciaTransacSQL()
|
|
Try
|
|
Dim TieneError As Boolean = False
|
|
Dim ContadorUpdate As Integer = 0
|
|
Dim ContadorError As Integer = 0
|
|
Dim NombreCuenta As String = ""
|
|
Dim CuentaPadre As String = ""
|
|
|
|
Dim AgrupadoresSAT As DataTable = New DataTable
|
|
If ObjConta.GetAgrupadoresSAT(UsuarioActual.CveEmpresa) Then
|
|
AgrupadoresSAT = ObjConta.DtResultados
|
|
End If
|
|
|
|
If AgrupadoresSAT.Rows.Count > 0 Then
|
|
|
|
|
|
For Each Row As DataRow In dt.Rows
|
|
NombreCuenta = Row("NombreCuenta").ToString
|
|
CuentaPadre = Row("CuentaPadre").ToString
|
|
Dim Cuenta As String = Row("Cuenta").ToString
|
|
Dim TipoCuenta As String = Row("TipoCuenta").ToString
|
|
Dim AgrupadorSAT As String = Row("AgrupadorSAT").ToString
|
|
Dim CveCuentaPadre As Integer = -1
|
|
Dim CveAgrupadorSAT As Integer = If(AgrupadorSAT = "0", -1, AgrupadoresSAT.FiltroPrimeroValor("CveAgrupadorSAT", String.Format("CodigoNombre LIKE '%{0}%'", AgrupadorSAT)).ToEntero)
|
|
|
|
If Not CuentaPadre = "" Then
|
|
If ObjConta.GetCuentas(-1, CuentaPadre.Replace("-", ""), -1, UsuarioActual.CveEmpresa) Then
|
|
If ObjConta.DtResultados.Rows.Count > 0 Then
|
|
CveCuentaPadre = ObjConta.DtResultados().FiltroPrimeroValor("Id").ToEntero
|
|
Else
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
CveCuentaPadre = -2
|
|
End If
|
|
|
|
Dim IdNew = ObjConta.AddCuenta(CveCuentaPadre, Cuenta.Replace("-", ""), NombreCuenta, TipoCuenta, 1, 1, CveEmpresaParam:=UsuarioActual.CveEmpresa, CveAgrupadorSAT:=CveAgrupadorSAT)
|
|
If IdNew > 0 Then
|
|
ContadorUpdate = ContadorUpdate + 1
|
|
Else
|
|
TieneError = True
|
|
ContadorError = ContadorError + 1
|
|
Exit For
|
|
End If
|
|
Next
|
|
Else
|
|
Alert("No se tienen asociados Agrupadores para esta empresa")
|
|
TieneError = True
|
|
End If
|
|
If Not TieneError Then
|
|
ObjConta.Commit()
|
|
Else
|
|
Alert($"No pudimos agregar la cuenta en ContaSIG: {NombreCuenta} - Cuenta Padre: {CuentaPadre}", TipoMensaje.MsgError)
|
|
ObjConta.RollBack()
|
|
End If
|
|
|
|
Alert($"Se agregaron {ContadorUpdate} Cuentas Correctamente y se omitieron: {ContadorError} cuentas.")
|
|
|
|
Catch ex As Exception
|
|
ObjConta.RollBack()
|
|
End Try
|
|
|
|
ObjConta.Dispose()
|
|
|
|
ElseIf RblFormato.SelectedValue = "10" Then
|
|
|
|
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjConta.IniciaTransacSQL()
|
|
Try
|
|
Dim TieneError As Boolean = False
|
|
Dim ContadorUpdate As Integer = 0
|
|
Dim ContadorError As Integer = 0
|
|
Dim NombreCuenta As String = ""
|
|
Dim IdPoliza As Integer = 0
|
|
Dim Cuenta As String = ""
|
|
Dim Reporte As New StringBuilder
|
|
|
|
IdPoliza = ObjConta.AddPoliza(1, "Saldos Iniciales", 0, 0, 100, Now.ToDate)
|
|
|
|
|
|
|
|
For Each Row As DataRow In dt.Rows
|
|
NombreCuenta = Row("NombreCuenta").ToString
|
|
Cuenta = Row("Cuenta").ToString
|
|
Dim TipoCuenta As String = Row("TipoCuenta").ToString
|
|
Dim Importe As Double = Row("Importe").ToString.ToDouble
|
|
Dim IdCuenta As Integer = -1
|
|
Dim CargoAbono As Boolean = True
|
|
Dim YaExiste As Boolean = False
|
|
|
|
|
|
If ObjConta.GetCuentas(-1, Cuenta.Replace("-", ""), 1) Then
|
|
If ObjConta.DtResultados.Rows.Count > 0 Then
|
|
IdCuenta = ObjConta.DtResultados().FiltroPrimeroValor("Id").ToEntero
|
|
TipoCuenta = ObjConta.DtResultados().FiltroPrimeroValor("Tipo")
|
|
Else
|
|
Reporte.AppendLine($"{Cuenta} - {NombreCuenta} - {Importe} </br>")
|
|
TieneError = True
|
|
YaExiste = True
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
|
|
|
|
If TipoCuenta.Contiene("A", "C", "E") Then
|
|
CargoAbono = False
|
|
End If
|
|
|
|
If YaExiste = False Then
|
|
If IdCuenta > 0 Then
|
|
If Not ObjConta.AddMovimiento(IdPoliza, IdCuenta, CargoAbono, Importe, "", "Saldos Iniciales", -1, Now, "") Then
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
IdCuenta = -2
|
|
End If
|
|
End If
|
|
|
|
|
|
Next
|
|
|
|
If Not TieneError Then
|
|
ObjConta.Commit()
|
|
Alert($"Se agregó la póliza {IdPoliza}")
|
|
|
|
Else
|
|
Alert($"No encontraron las siguientes cuentas: {Reporte.ToString} ", TipoMensaje.MsgError)
|
|
ObjConta.RollBack()
|
|
End If
|
|
|
|
|
|
Catch ex As Exception
|
|
ObjConta.RollBack()
|
|
End Try
|
|
|
|
ObjConta.Dispose()
|
|
ElseIf RblFormato.SelectedValue = "12" Then
|
|
Dim ObjMovimientos As New ClsInventarios
|
|
ObjMovimientos.IniciaTransacSQL()
|
|
|
|
Dim ProductosServiciosRef As DataTable = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
|
Dim AlmacenRef As DataTable = GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
Dim contadorMovimientos As Integer = 0
|
|
Dim listadoMovimientos As String = ""
|
|
Dim mensajeError As String = ""
|
|
Try
|
|
For Each almacenSinRepetir As DataRow In dt.FiltraParametros("Almacen <> ''", DistinctColumns:={"Almacen"}).Rows
|
|
Dim almacenActual As String = almacenSinRepetir("Almacen").ToString
|
|
'Dim CveAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"Almacen = '{almacenActual}'").ToEntero
|
|
Dim CveAlmacen As Integer = AlmacenRef.FiltroPrimeroValor("CveAlmacen", $"Almacen = '{almacenActual}'").ToEntero
|
|
Dim movimientoCabecera As Integer = ObjMovimientos.AddMovimiento(CveAlmacen, 1, 1, Date.Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1)
|
|
listadoMovimientos += $"movimiento con folio <a href='/Inventarios/EntradasSalidas.aspx?CveMovimiento={movimientoCabecera}' target='_blank' style='color:blue'>{ObjMovimientos.Folio}</a><br/>"
|
|
If CveAlmacen > 0 Then
|
|
contadorMovimientos += 1
|
|
For Each nuevaEntrada As DataRow In dt.FiltraParametros($"Almacen = '{almacenActual}'").Rows
|
|
Dim RowPS As DataRow = ProductosServiciosRef.FiltroPrimero($"Codigo = '{nuevaEntrada("CodigoPS")}' AND CveEmpresa = {UsuarioActual.CveEmpresa}")
|
|
If RowPS IsNot Nothing Then
|
|
Dim CvePS As Integer = RowPS("CvePS").ToString().ToEntero
|
|
Dim CveUM As Integer = RowPS("CveUnidadMedida").ToString().ToEntero
|
|
If CveUM > 0 Then
|
|
Dim Cantidad As Decimal = nuevaEntrada("Existencia").ToString.ToDecimal
|
|
Dim Valor As Decimal = nuevaEntrada("Valor").ToString.ToDecimal
|
|
|
|
If Not ObjMovimientos.AddMovimientoDetalle(movimientoCabecera, Cantidad, CveUM, CvePS, (Valor / Cantidad), -1, -1) Then
|
|
mensajeError = "No se logró generar el detalle del movimiento"
|
|
Throw New Exception()
|
|
End If
|
|
Else
|
|
mensajeError = $"La unidad de medida no se reconoce para el producto servicio:{nuevaEntrada("CodigoPS")}"
|
|
Throw New Exception()
|
|
End If
|
|
Else
|
|
mensajeError = $"No se encontró el producto o servicio con código ""{nuevaEntrada("CodigoPS")}"""
|
|
Throw New Exception()
|
|
End If
|
|
Next
|
|
Else
|
|
mensajeError = $"No se encontró el almacén con nombre ""{almacenActual}"""
|
|
Throw New Exception()
|
|
Exit For
|
|
End If
|
|
|
|
Next
|
|
Catch ex As Exception
|
|
If mensajeError = "" Then
|
|
mensajeError = "Error técnico, informar a soporte"
|
|
End If
|
|
ObjMovimientos.RollBack()
|
|
End Try
|
|
|
|
If mensajeError = "" Then
|
|
ObjMovimientos.Commit()
|
|
Alert($"Se cargaron correctamente {contadorMovimientos} movimientos<br/><br/>{listadoMovimientos}")
|
|
Else
|
|
Alert(mensajeError, TipoMensaje.MsgError)
|
|
ObjMovimientos.RollBack()
|
|
End If
|
|
|
|
ObjMovimientos.Dispose()
|
|
ProductosServiciosRef.Dispose()
|
|
AlmacenRef.Dispose()
|
|
End If
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
|
|
|
|
Dim Directorio As String = ""
|
|
|
|
If RblFormato.SelectedValue = "1" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoProveedor.xlsx"
|
|
ElseIf RblFormato.SelectedValue = "2" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoClientes.xlsx"
|
|
ElseIf RblFormato.SelectedValue = "3" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoProveedores-Facturas.xlsx"
|
|
ElseIf RblFormato.SelectedValue = "4" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoClientes-Facturas.xlsx"
|
|
ElseIf RblFormato.SelectedValue = "5" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoPS.xlsx"
|
|
ElseIf RblFormato.SelectedValue = "6" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoRH-Personal.xlsx"
|
|
ElseIf RblFormato.SelectedValue = "7" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoAF-ActivosFijos.xlsx"
|
|
ElseIf RblFormato.SelectedValue = "8" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoContabilidad.xlsx"
|
|
ElseIf RblFormato.SelectedValue = "9" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoContabilidad.xlsx"
|
|
ElseIf RblFormato.SelectedValue = "12" Then
|
|
Directorio = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\SaldosIniciales\FormatoAlmacen.xlsx"
|
|
End If
|
|
|
|
Dim Archivo As New IO.FileInfo(Directorio)
|
|
If Archivo.Exists Then
|
|
Response.Clear()
|
|
Response.ClearHeaders()
|
|
Response.ClearContent()
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
|
|
Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
Response.ContentType = "text/plain"
|
|
Response.Flush()
|
|
Response.TransmitFile(Archivo.FullName)
|
|
Response.End()
|
|
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().Trim)
|
|
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 Class
|