Correcion nombre funcion GetRepIndicadorDiario
This commit is contained in:
@@ -1,552 +0,0 @@
|
||||
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports System.Xml
|
||||
'Imports msExcel = Microsoft.Office.Interop.Excel
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
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
|
||||
Dim Conexion As Odbc.OdbcConnection = Nothing
|
||||
Dim ErrorArchivo = False
|
||||
Dim ErrorExcel = False
|
||||
Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
|
||||
Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
|
||||
Dim objDbAdapter As Common.DbDataAdapter = objDbFactory.CreateDataAdapter()
|
||||
Dim objDbConnection As Common.DbConnection = objDbFactory.CreateConnection()
|
||||
objDbConnection.ConnectionString = strConnString
|
||||
objDbConnection.Open()
|
||||
Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
|
||||
Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
|
||||
Try
|
||||
Select Case Tipo
|
||||
Case "CSV"
|
||||
Conexion = New Odbc.OdbcConnection("Driver={Microsoft Access Text Driver (*.txt, *.csv)};Dbq=" + Ruta + ";Extensions=asc,csv,tab,txt;")
|
||||
Conexion.Open()
|
||||
Dim cmd = Conexion.CreateCommand()
|
||||
cmd.CommandType = CommandType.Text
|
||||
cmd.CommandText = $"SELECT * FROM [{FileName}]"
|
||||
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
||||
DataAdapter.Fill(dt)
|
||||
Case "EXCEL"
|
||||
Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
||||
Conexion.Open()
|
||||
Dim cmd = Conexion.CreateCommand()
|
||||
cmd.CommandType = CommandType.Text
|
||||
cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
|
||||
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
||||
DataAdapter.Fill(dt)
|
||||
Case Else
|
||||
Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
ErrorArchivo = True
|
||||
OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
||||
End Try
|
||||
Conexion.Close()
|
||||
If Not ErrorArchivo Then
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
ElseIf RblFormato.SelectedValue = "5" Then
|
||||
|
||||
If Not dt.Columns(0).ColumnName = "Codigo" 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 = "Descripción" 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 = "Marca" 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 = "Código de Barras" Then
|
||||
Alert("El nombre de la cuarta columna debe ser 'Código de Barras'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If Not dt.Columns(4).ColumnName = "Unidad de Medida" Then
|
||||
Alert("El nombre de la quinta columna debe ser 'Unidad de Medida'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(5).ColumnName = "Producto/Servicio" Then
|
||||
Alert("El nombre de la sexta columna debe ser 'Producto/Servicio'. Favor de corregirlo", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
If Not dt.Columns(6).ColumnName = "Clasificación" 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(7).ColumnName = "Precio" Then
|
||||
Alert("El nombre de la octava columna debe ser 'Precio'. 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 V E E D O R E S
|
||||
If 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 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 Decimal = Row("Código Postal").ToString.ToDecimal
|
||||
Dim Poblacion As String = Row("Población").ToString
|
||||
Dim Estado As String = Row("Estado").ToString
|
||||
Dim Telefono As String = Row("Teléfono").ToString
|
||||
Dim Contacto As String = Row("Contacto").ToString
|
||||
Dim CelularContacto As String = Row("Celular Contacto").ToString
|
||||
Dim CveProveedor As Integer = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveProveedor", $"RFC = '{RFC}'").ToString.ToEntero
|
||||
|
||||
If CveProveedor > 0 Then
|
||||
ExisteProveedor = True
|
||||
Contador = Contador + 1
|
||||
Else
|
||||
If Not ObjProv.AddProveedor(Codigo, RazonSocial, RazonSocial, RazonSocial, RFC, Calle, Telefono,
|
||||
Contacto, "", Telefono, -1, -1, "", 0, 0, 0, -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) Then
|
||||
ErrorProv = True
|
||||
Exit For
|
||||
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> Clientes 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
|
||||
ObjClientes.IniciaTransacSQL()
|
||||
For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows
|
||||
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 Decimal = Row("Código Postal").ToString.ToDecimal
|
||||
Dim Poblacion As String = Row("Población").ToString
|
||||
Dim Estado As String = Row("Estado").ToString
|
||||
Dim Telefono As String = Row("Teléfono").ToString
|
||||
Dim Contacto As String = Row("Contacto").ToString
|
||||
Dim CelularContacto As String = Row("Celular Contacto").ToString
|
||||
Dim CveCliente As Integer = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString.ToEntero
|
||||
|
||||
If CveCliente > 0 Then
|
||||
ExisteCliente = True
|
||||
Contador = Contador + 1
|
||||
Else
|
||||
If Not ObjClientes.AddCliente(RazonSocial, RazonSocial, Calle, "", "", Colonia, "", "", Estado, RFC, CodigoPostal, "", "", Contacto, "", "", "", "", -1, False, 1, -1, -1, False, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "", -1, -1, -1,
|
||||
"-1", "-1", "", 0, "", 0, "0", -1, "0", 0, "", 0, "", 0, "", 0, "", "", "", "", 0, "", 1, False, "", "", "", False, "", "", "", "", "", False, "", "", "", False) 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
|
||||
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
|
||||
DtProveedores = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
||||
|
||||
For Each Row As DataRow In dt.Rows
|
||||
Dim Sucursal As String = Row("Sucursal").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 SubTotal As Double = Row("SubTotal").ToString.ToDouble
|
||||
Dim IVA As Double = Row("IVA").ToString.ToDouble
|
||||
Dim Total As Double = Row("Total").ToString.ToDouble
|
||||
Dim Saldo As Double = Row("Saldo").ToString.ToDouble
|
||||
Dim TipoDocto As String = Row("Tipo Documento").ToString
|
||||
Dim CveProveedor As Integer = DtProveedores.FiltroPrimeroValor("CveProveedor", $"RFC = '{RFC}'").ToString.ToEntero
|
||||
Dim CvePS As Integer = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS").ToString.ToEntero
|
||||
Dim CveUnidadMedida As Integer = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida").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
|
||||
TipoDocto = IIf(TipoDocto = "Ingresos", "Fac", "NC")
|
||||
|
||||
'PrePóliza
|
||||
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Compras/SaldoInicial", 1, Total, Total, 1, Fecha, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
If Not CvePrePoliza > 0 Then ErrorCompras = True : Exit For
|
||||
|
||||
'Compra
|
||||
If Not ObjCompras.AddCompra(TipoDocto, "", Serie, Folio, Folio, CveProveedor.ToEntero, SubTotal, 0, 0, IVA, 0, 0, 0, 0, 0, Total, Fecha, 1, 1, "-1".ToDate,
|
||||
True, "", 1, CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||||
ErrorCompras = True
|
||||
Exit For
|
||||
End If
|
||||
CveCompra = ObjCompras.CveCompra
|
||||
|
||||
'Compra Detalle
|
||||
If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, -1, -1, 0, 1, SubTotal, 0.16, SubTotal, 0, "Carga Inicial", -1) Then
|
||||
ErrorCompras = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
'PrePólizaDetalle
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Folio, IIf(TipoDocto = "Fac", 5, 18), String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor) 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) 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) 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) Then ErrorCompras = True : Exit For
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Folio, 95, Folio, Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor) Then ErrorCompras = True : Exit For
|
||||
End If
|
||||
|
||||
|
||||
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.", NumRows), TipoMensaje.MsgInformacion)
|
||||
ObjCompras.Commit()
|
||||
TxtExcel.Text = ""
|
||||
UpDatos.Update()
|
||||
Else
|
||||
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 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 CveSucursal As Integer = GlobalDTSucursales(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSucursal").ToString.ToEntero
|
||||
Dim CvePS As Integer = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS").ToString.ToEntero
|
||||
Dim CveUnidadMedida As Integer = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida").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
|
||||
|
||||
For Each Row As DataRow In dt.Rows
|
||||
Dim Sucursal As String = 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 SubTotal As Double = Row("SubTotal").ToString.ToDouble
|
||||
Dim IVA As Double = Row("IVA").ToString.ToDouble
|
||||
Dim Total As Double = Row("Total").ToString.ToDouble
|
||||
Dim Saldo As Double = Row("Saldo").ToString.ToDouble
|
||||
Dim CveCliente As Integer = DtClientes.FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString.ToEntero
|
||||
|
||||
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 = "Ingresos", "Ing", "Egs")
|
||||
'PrePóliza
|
||||
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Venta/SaldoIncial", 1, Total, Total, 1, Fecha, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
If Not CvePrePoliza > 0 Then ErrorVentas = True : Exit For
|
||||
|
||||
'Venta
|
||||
If Not ObjVentas.AddVenta(TipoDocto, Folio, CveCliente.ToEntero, -1, SubTotal, 0, 0, IVA, 0, 0, Total, 1, 1,
|
||||
0, 0, 0, Fecha, Fecha, "", "", Fecha, 0, CveSucursal, CveSucursal, "", "", "", 0, 0, 0, "-1".ToDate, "-1".ToDate, "-1".ToDate, -1, -1, 0, CvePrePoliza,
|
||||
UsuarioActual.CveUsuario, CveSucursal, UsuarioActual.CveEmpresa, Serie:=Serie) Then
|
||||
ErrorVentas = True
|
||||
Exit For
|
||||
End If
|
||||
CveVenta = ObjVentas.CveVenta
|
||||
|
||||
If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, 1, CveUnidadMedida, SubTotal, 0.16, SubTotal, "Saldo Inicial", 0, 0, -1, 0) Then
|
||||
ErrorVentas = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
|
||||
'PrePólizaDetalle
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SubTotal, Folio, 4, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=1) Then ErrorVentas = True : Exit For
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Folio, 1, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, Folio, 13, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
||||
|
||||
'Saldo
|
||||
If Saldo < Total Then
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Folio, 2, Folio, Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Folio, 95, Folio, Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
If Not ErrorVentas Then
|
||||
Alert(String.Format("Se agregaron: <b>{0}</b> Ventas correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
||||
ObjVentas.Commit()
|
||||
TxtExcel.Text = ""
|
||||
UpDatos.Update()
|
||||
Else
|
||||
ObjVentas.RollBack()
|
||||
End If
|
||||
ObjVentas.Dispose()
|
||||
|
||||
|
||||
'P R O D U C T O S / S E R V I C I O S
|
||||
ElseIf RblFormato.SelectedValue = "5" Then
|
||||
Dim ObjPS As New ClsProductosServicios
|
||||
Dim ErrorPS As Boolean = False
|
||||
Dim ExistePS As Boolean = False
|
||||
Dim Contador As Integer = 0
|
||||
' ObjPS.IniciaTransacSQL()
|
||||
|
||||
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
|
||||
Dim CodigoBarras As String = Row("Código Barras").ToString
|
||||
Dim UnidadMedida As String = Row("Unidad Medida").ToString
|
||||
Dim Clasificacion As String = Row("Clasificacion").ToString
|
||||
Dim Marca As Decimal = Row("Marca").ToString.ToDecimal
|
||||
Dim AplicaSerie As String = Row("AplicaSerie").ToString
|
||||
Dim Precio As String = Row("Precio").ToString
|
||||
Dim IEPS As String = Row("IEPS").ToString
|
||||
Dim CvePS As Integer = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", $"Codigo = '{Codigo}'").ToString.ToEntero
|
||||
|
||||
If CvePS > 0 Then
|
||||
ExistePS = True
|
||||
Contador = Contador + 1
|
||||
Else
|
||||
If Not ObjPS.AddPS(1, 1, 1, Codigo, "", "", Descripcion, Precio, 0, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1) Then
|
||||
ErrorPS = True
|
||||
Codigo.GuardaLog
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
If Not ErrorPS Then
|
||||
'ObjPS.Commit()
|
||||
If ObjPS.GetPS(-1, -1, -1) Then Application("GlobalDTProductosServicios") = ObjPS.DtResultados.AsEnumerable()
|
||||
If Contador > 0 Then
|
||||
Alert(String.Format("Se agregaron: <b>{0}</b> Productos/Servicios correctamente. <br>Se Omitieron: <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()
|
||||
|
||||
|
||||
End If
|
||||
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\FormatoProveedores.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"
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
@@ -816,19 +816,24 @@ Partial Class General_SaldosIniciales
|
||||
End If
|
||||
|
||||
Else
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user