417 lines
18 KiB
VB.net
417 lines
18 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Data.SqlClient
|
|
Imports Extensiones
|
|
Imports System
|
|
Imports System.IO
|
|
Imports System.Text
|
|
Partial Class Bancos_MovimientosBancarios
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property HeaderTexto As String
|
|
Get
|
|
Return ViewState("HeaderTexto").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("HeaderTexto") = value
|
|
End Set
|
|
End Property
|
|
Private Property DetalleTexto As String
|
|
Get
|
|
Return ViewState("DetalleTexto").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("DetalleTexto") = value
|
|
End Set
|
|
End Property
|
|
Private Property TrailerTexto As String
|
|
Get
|
|
Return ViewState("TrailerTexto").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("TrailerTexto") = value
|
|
End Set
|
|
End Property
|
|
Private Property TextoCompleto As String
|
|
Get
|
|
Return ViewState("TextoCompleto").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("TextoCompleto") = value
|
|
End Set
|
|
End Property
|
|
Private Property Vacio As String
|
|
Get
|
|
Return ViewState("Vacio").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Vacio") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTProveedores As DataTable
|
|
Get
|
|
Return CType(ViewState("DTProveedores"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTProveedores") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTProveedorActual As DataTable
|
|
Get
|
|
Return CType(ViewState("DTProveedorActual"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTProveedorActual") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTProveedorBancos As DataTable
|
|
Get
|
|
Return CType(ViewState("DTProveedorBancos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTProveedorBancos") = value
|
|
End Set
|
|
End Property
|
|
Private Property RowBanco As DataRow
|
|
Get
|
|
Return CType(ViewState("RowBanco"), DataRow)
|
|
End Get
|
|
Set(value As DataRow)
|
|
ViewState("RowBanco") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private ReadOnly Property PadCeros As Char
|
|
Get
|
|
Return "0"c
|
|
End Get
|
|
End Property
|
|
Private Property TotalAcumulado As Double
|
|
Get
|
|
Return ViewState("TotalAcumulado").ToString.ToDouble
|
|
End Get
|
|
Set(value As Double)
|
|
ViewState("TotalAcumulado") = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
ViewState("HeaderTexto") = ""
|
|
ViewState("DetalleTexto") = ""
|
|
ViewState("TrailerTexto") = ""
|
|
ViewState("Vacio") = ""
|
|
ViewState("TotalAcumulado") = 0
|
|
|
|
Dim ObjProveedores As New ClsCompProveedores
|
|
ObjProveedores.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa)
|
|
DTProveedores = ObjProveedores.DtResultados
|
|
|
|
GvProveedores.DataSource = DTProveedores.FiltraParametros("EstatusPagoElectronico = 0")
|
|
GvProveedores.DataBind()
|
|
UPGV.Update()
|
|
DdlProveedores.DataSource = DTProveedores
|
|
DdlProveedores.DataBind()
|
|
DdlProveedores.Items.Insert(0, New ListItem("Seleccione un Proveedor", "-1"))
|
|
UpDatosAlta.Update()
|
|
|
|
'UpDatosCuentaBBVA.Visible = False
|
|
'UpDatosOtrosBancos.Visible = False
|
|
'UpDatosPF.Visible = False
|
|
'UpDatosMoral.Visible = False
|
|
|
|
ReplaceCaracteresEspeciales("MañAna, $#&&sí mañana &&será otro día.")
|
|
End If
|
|
End Sub
|
|
Protected Sub CrearTXT()
|
|
Dim path As String = "c:\Hola.txt"
|
|
|
|
' Create or overwrite the file.
|
|
Dim fs As FileStream = File.Create(path)
|
|
|
|
' Add text to the file.
|
|
Dim info As Byte() = New UTF8Encoding(True).GetBytes(TextoCompleto)
|
|
fs.Write(info, 0, info.Length)
|
|
fs.Close()
|
|
End Sub
|
|
|
|
|
|
#Region "ALTA PROVEEDORES"
|
|
Protected Sub BtnAltas_Click(sender As Object, e As EventArgs)
|
|
Dim ObjCuentasBancos As New ClsGenerales
|
|
|
|
Dim TotalDetalles As Integer = 0
|
|
'Dim ObjPro As New ClsCompProveedores
|
|
For i As Integer = 0 To (GvProveedores.Rows.Count - 1)
|
|
If GvProveedores.Rows(i).FCCheckBox("CheckAgregar").Checked = True Then
|
|
DTProveedorActual = DTProveedores.FiltraParametros(String.Format("CveProveedor = {0}", GvProveedores.Rows(i).DataKey("CveProveedor")))
|
|
|
|
If ObjCuentasBancos.GetCuentasDepositos(CveProveedor:=21109) Then
|
|
DTProveedorBancos = ObjCuentasBancos.DtResultados
|
|
RowBanco = DTProveedorBancos.Rows(0)
|
|
Else
|
|
Alert("Error al cargar Banco.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjCuentasBancos.Dispose()
|
|
|
|
If TotalDetalles > 0 Then
|
|
DetalleTexto &= vbCrLf
|
|
End If
|
|
CrearDetalle()
|
|
'ObjPro.UpdateProveedorPagoElectronico(GvProveedores.Rows(i).DataKey("CveProveedor").ToEntero)
|
|
TotalDetalles += 1
|
|
End If
|
|
Next
|
|
If TotalDetalles > 0 Then
|
|
FormarTexto(TotalDetalles)
|
|
CrearTXT()
|
|
Else
|
|
Alert("No selecciono ningun Proveedor", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
Protected Sub FormarTexto(Registros As Integer)
|
|
'''''' LLENADO HEADER
|
|
Dim convenio As String = "000775770"
|
|
'Campos #1-4 del Header
|
|
HeaderTexto = String.Format("H{0}{1}GRUPO01 ", convenio.PadLeft(9, PadCeros), DateTime.Now().ToString("yyyy-MM-dd"))
|
|
'Campo #5 del Header
|
|
HeaderTexto &= String.Format("{0}{1}", DTProveedorActual(0)("CveProveedor"), DateTime.Now().ToString("yyyyMMdd")).PadRight(20)
|
|
'Campos #6-8 del Header
|
|
HeaderTexto &= String.Format("00").PadRight(586)
|
|
Dim HeaderLength = HeaderTexto.Length
|
|
|
|
|
|
''''' LLENADO DE TRAILER
|
|
TrailerTexto = String.Format("T{0}{1}{2}", Registros.ToString.PadLeft(10, PadCeros), Vacio.PadRight(50, PadCeros), Vacio.PadRight(575))
|
|
|
|
|
|
|
|
''''' ARMADO DEL TEXTO COMPLETO
|
|
TextoCompleto = String.Format("{1}{0}{2}{0}{3}{0}", vbCrLf, HeaderTexto, DetalleTexto, TrailerTexto)
|
|
TxtAltas.Text = TextoCompleto
|
|
End Sub
|
|
Protected Sub CrearDetalle()
|
|
Dim Resultado = True
|
|
|
|
''''' LLENADO DE DETALLE
|
|
'Campos #1-4 del Detalle
|
|
DetalleTexto &= String.Format("DA{0}N ", DTProveedorActual(0)("CveProveedor").ToString.ToUpper.PadLeft(30, PadCeros))
|
|
'Banco BBVA
|
|
If RowBanco("BancoNombre").ToString = "BBVA" Then
|
|
'Llenamos datos de BBVA
|
|
'Campo #5-7 del detalle
|
|
DetalleTexto &= String.Format("MXP99{0}", RowBanco("Cuenta").ToString.PadLeft(35, PadCeros))
|
|
|
|
'Llenamos en blanco datos de otros bancos
|
|
'Campos 8-17 del detalle --- 64 de otros bancos y 45 para FILLER --- Fecha de Alta
|
|
DetalleTexto &= String.Format("{0}{1}", Vacio.PadLeft(109), DateTime.Now().ToString("yyyy-MM-dd"))
|
|
|
|
'Otros Bancos NACIONAL!!
|
|
Else
|
|
'Llenamos en blanco datos de BBVA
|
|
DetalleTexto &= Vacio.PadRight(40)
|
|
|
|
'Llenamos datos de otros bancos
|
|
'Campos 8- 17 del detalle --- 44 de otros bancos --- 20 de internacional --- 45 Filler -- Fecha de Alta
|
|
DetalleTexto &= String.Format("MXP40{0}0014{1}{2}{3}", RowBanco("CLABE").ToString.PadLeft(35, PadCeros), Vacio.PadRight(20), Vacio.PadRight(45), DateTime.Now().ToString("yyyy-MM-dd"))
|
|
End If
|
|
|
|
'Llenamos datos de Tipo de Persona - Fisica o Moral
|
|
TipoPersona()
|
|
|
|
'Campos 27-32 --- Fillers --- datos de otros bancos (internacional)
|
|
DetalleTexto &= Vacio.PadLeft(153)
|
|
|
|
'Campos 33-36 --- Datos de confirmacion
|
|
If DTProveedorActual(0)("ContactoMail").ToString.Length > 0 Then
|
|
DetalleTexto &= String.Format("{0}02{1}", Vacio.PadRight(40), DTProveedorActual(0)("ContactoMail").ToString.ToUpper.PadRight(50))
|
|
ElseIf DTProveedorActual(0)("ContactoMail").ToString.Length <= 0 Then
|
|
DetalleTexto &= String.Format("{0}00{1}", Vacio.PadRight(40), Vacio.PadRight(50))
|
|
End If
|
|
|
|
'Campos 37-39 -- FILLER
|
|
DetalleTexto &= String.Format("00{0}", Vacio.PadRight(38))
|
|
|
|
End Sub
|
|
Protected Sub TipoPersona()
|
|
'Persona Moral
|
|
If DTProveedorActual(0)("RFC").ToString.Length = 12 Then
|
|
Dim fecha As String = DTProveedorActual(0)("FechaIng").ToString
|
|
'Campo 18-20 del detalle
|
|
DetalleTexto &= String.Format("M{0}{1}-{2}-{3}", ReplaceCaracteresEspeciales(DTProveedorActual(0)("RazonSocial").ToString).ToUpper.PadRight(50), fecha.Substring(6, 4), fecha.Substring(3, 2), fecha.Substring(0, 2))
|
|
'Campo 21-26 del detalle --- 10 FILLER - 70 de TipoPersona FISICA - 14 de RFC
|
|
DetalleTexto &= String.Format("{0}{1}", Vacio.PadLeft(80), DTProveedorActual(0)("RFC").ToString.ToUpper.PadRight(14))
|
|
|
|
'Persona Fisica
|
|
ElseIf DTProveedorActual(0)("RFC").ToString.Length = 13 Then
|
|
'Obtener nombre
|
|
Dim Nombre() As String = Split(DTProveedorActual(0)("RazonSocial").ToString)
|
|
'Campo 18-24 del detalle --- 60 Tipo Persona Moral --- 10 Filler -- Datos Persona Fisica
|
|
If Nombre.Length = 3 Then
|
|
DetalleTexto &= String.Format("F{0}{1}{2}", Vacio.PadRight(70), Nombre(0).PadRight(20), Nombre(1).PadRight(20), Nombre(2).PadRight(20))
|
|
ElseIf Nombre.Length = 4 Then
|
|
DetalleTexto &= String.Format("F{0}{1}{2}", Vacio.PadRight(70), (Nombre(0) & Nombre(1)).PadRight(20), Nombre(2).PadRight(20), Nombre(3).PadRight(20))
|
|
End If
|
|
'Campo 25-26 del detalle -- Fecha Nacimiento -- RFC
|
|
Dim fecha As String = DTProveedorActual(0)("RFC").ToString.Substring(4, 6)
|
|
DetalleTexto &= String.Format("19{0}-{1}-{2}{3}", fecha.Substring(0, 2), fecha.Substring(2, 2), fecha.Substring(4, 2), DTProveedorActual(0)("RFC").ToString.ToUpper.PadRight(14))
|
|
End If
|
|
End Sub
|
|
Protected Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
TxtBanco.Text = ""
|
|
TxtBancoCuenta.Text = ""
|
|
If DdlProveedores.SelectedValue <> "-1" Then
|
|
DTProveedorActual = DTProveedores.FiltraParametros(String.Format("CveProveedor = {0}", DdlProveedores.SelectedValue.ToString))
|
|
UpBanco.Visible = True
|
|
TxtBanco.Text = RowBanco("BancoNombre").ToString
|
|
If RowBanco("Cuenta").ToString.Length = 10 Then TxtBancoCuenta.Text = RowBanco("Cuenta").ToString.Substring(6, 4)
|
|
End If
|
|
End Sub
|
|
'Protected Sub TipoPersonaDinamico()
|
|
' If DdlTipoPersona.SelectedValue = "M" Then
|
|
' 'Campo 18-20 del detalle
|
|
' DetalleTexto &= String.Format("{0}{1}{2}", DdlTipoPersona.SelectedValue, DTProveedorActual(0)("RazonSocial").ToString.ToUpper.PadRight(50), DTProveedorActual(0)("FechaIng").ToString.Substring(0, 10))
|
|
' 'Campo 21-26 del detalle --- 10 FILLER - 70 de TipoPersona FISICA - 14 de RFC
|
|
' DetalleTexto &= String.Format("{0}{1}", Vacio.PadLeft(80), DTProveedorActual(0)("RFC").ToString.ToUpper.PadRight(14))
|
|
' ElseIf DdlTipoPersona.SelectedValue = "F" Then
|
|
' 'Campos 19-21 --- 60 Tipo Persona Moral y 10 FILLER
|
|
' DetalleTexto &= Vacio.PadLeft(70)
|
|
' 'Campos 22-26 --- Tipo Persona Fisica y #26 RFC
|
|
' DetalleTexto &= String.Format("{0}{1}{2}{3}{4}", TxtNombrePF.Text.ToUpper.PadRight(20), TxtApellidoPPF.Text.ToUpper.PadRight(20), TxtApellidoMPF.Text.ToUpper.PadRight(20), DateTime.Now().ToString("yyyy-MM-dd"), TxtRFC.Text.ToUpper.PadRight(14))
|
|
' End If
|
|
'End Sub
|
|
|
|
'Protected Sub DdlTipoPersona_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
' If DdlTipoPersona.SelectedValue = "-1" Then
|
|
' UpDatosPF.Visible = False
|
|
' UpDatosMoral.Visible = False
|
|
' ElseIf DdlTipoPersona.SelectedValue = "F" Then
|
|
' UpDatosPF.Visible = True
|
|
' UpDatosMoral.Visible = False
|
|
' ElseIf DdlTipoPersona.SelectedValue = "M" Then
|
|
' UpDatosPF.Visible = False
|
|
' UpDatosMoral.Visible = True
|
|
' End If
|
|
'End Sub
|
|
|
|
'Protected Sub DdlTipoBanco_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
' If DdlTipoBanco.SelectedValue = "-1" Then
|
|
' UpDatosCuentaBBVA.Visible = False
|
|
' UpDatosOtrosBancos.Visible = False
|
|
' ElseIf DdlTipoBanco.SelectedValue = "1" Then
|
|
' UpDatosCuentaBBVA.Visible = True
|
|
' UpDatosOtrosBancos.Visible = False
|
|
' ElseIf DdlTipoBanco.SelectedValue = "2" Then
|
|
' UpDatosCuentaBBVA.Visible = False
|
|
' UpDatosOtrosBancos.Visible = True
|
|
' End If
|
|
'End Sub
|
|
#End Region
|
|
|
|
#Region "PAGO PROVEEDORES"
|
|
Protected Sub BtnPagos_Click(sender As Object, e As EventArgs)
|
|
Dim ObjCuentasBancos As New ClsGenerales
|
|
|
|
DTProveedorActual = DTProveedores.FiltraParametros(String.Format("CveProveedor = 21114"))
|
|
|
|
If ObjCuentasBancos.GetCuentasDepositos(CveProveedor:=21114) Then
|
|
DTProveedorBancos = ObjCuentasBancos.DtResultados
|
|
RowBanco = DTProveedorBancos.Rows(0)
|
|
Else
|
|
Alert("Error al cargar Banco.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjCuentasBancos.Dispose()
|
|
|
|
CrearDetallePagos()
|
|
FormarTextoPagos(1, TotalAcumulado.ToString.FormatoNumero.Replace(",", "").Replace(".", ""))
|
|
CrearTXT()
|
|
|
|
End Sub
|
|
Protected Sub FormarTextoPagos(Registros As Integer, Total As String)
|
|
Dim convenio As String = "000775770"
|
|
|
|
'''''' LLENADO HEADER
|
|
'Campos #1-4 del Header
|
|
HeaderTexto = String.Format("H{0}{1}01", convenio.PadLeft(9, PadCeros), DateTime.Now().ToString("yyyy-MM-dd"))
|
|
'Campo #5 del Header
|
|
HeaderTexto &= String.Format("P{0}{1}", DateTime.Now().ToString("s").Replace("-", "").Replace(":", ""), Vacio.PadRight(14))
|
|
'Campos #6-11 del Header
|
|
HeaderTexto &= String.Format("00").PadRight(1314)
|
|
|
|
|
|
''''' LLENADO DE TRAILER
|
|
TrailerTexto = String.Format("T{0}{1}{2}{3}", Registros.ToString.PadLeft(10, PadCeros), Total.PadLeft(15, PadCeros), Vacio.PadRight(225, PadCeros), Vacio.PadRight(1115))
|
|
|
|
|
|
''''' ARMADO DEL TEXTO COMPLETO
|
|
TextoCompleto = String.Format("{1}{0}{2}{0}{3}{0}", vbCrLf, HeaderTexto, DetalleTexto, TrailerTexto)
|
|
TxtPagos.Text = TextoCompleto
|
|
End Sub
|
|
Protected Sub CrearDetallePagos()
|
|
Dim Resultado = True
|
|
Dim Importe As String = "1000"
|
|
Dim Divisa As String = "MXP"
|
|
Dim Factura As String = "FAC-123456".Replace("-", "")
|
|
Dim Referencia As String = String.Format("F{0}", Factura)
|
|
Dim Datos As String = String.Format("Pago de Factura {0}", Factura)
|
|
|
|
''''' LLENADO DE DETALLE
|
|
'Campos #1-6 del Detalle
|
|
DetalleTexto &= String.Format("DAP{0}{1}PDA", Referencia.PadRight(20), DTProveedorActual(0)("CveProveedor").ToString.PadLeft(30, PadCeros))
|
|
|
|
'Pago a cuenta BBVA
|
|
If RowBanco("BancoNombre").ToString.ToUpper = "BBVA" Then
|
|
'Campos 7-24 del Detalle
|
|
DetalleTexto &= String.Format("2{0}{1}N{2}99{3}", Vacio.PadLeft(20, PadCeros), Vacio.PadRight(154), Vacio.PadRight(8), Vacio.PadRight(177))
|
|
Else
|
|
Dim ReferenciaNumerica As String = "1234567"
|
|
Dim Motivo As String = "Pago de equipo de computo"
|
|
|
|
'Campos 7-24 del Detalle
|
|
DetalleTexto &= String.Format("6{0}{1}{2}{3}{4}N{5}", Vacio.PadRight(20, PadCeros), Vacio.PadRight(15), ReferenciaNumerica.PadRight(25), Motivo.ToUpper.PadRight(37), Vacio.PadRight(77), Vacio.PadRight(187))
|
|
End If
|
|
|
|
'Campos 24-50 del Detalle 0 1 2 3 4 5 6 7 8 9
|
|
DetalleTexto &= String.Format("{0}{1}FA{2}{3}01{4}N{5}{6}{7}{7}{7}{6}N {7}700{8}{9}{7}", Divisa, Vacio.PadLeft(20), Importe.FormatoNumero.Replace(",", "").Replace(".", "").PadLeft(15, PadCeros), Vacio.PadRight(15, PadCeros), Vacio.PadRight(50), Vacio.PadRight(12, PadCeros), DateTime.Now.ToString("yyyy-MM-dd"), "0001-01-01", Datos.PadRight(700), Vacio.PadRight(52))
|
|
TotalAcumulado += Importe.ToEntero
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
Public Function ReplaceCaracteresEspeciales(TextoOriginal As String) As String
|
|
'Metodo simplificado UNIDOCE
|
|
Dim textoNormalizado = TextoOriginal.Normalize(NormalizationForm.FormD)
|
|
Dim reg = New Regex("[^a-zA-Z0-9 ]")
|
|
Dim textoSinAcentos = reg.Replace(TextoOriginal, "")
|
|
|
|
|
|
'Metodo por letra
|
|
Dim inputString = TextoOriginal.ToLower
|
|
Dim a As Regex = New Regex("[á|à|ä|â]", RegexOptions.Compiled)
|
|
Dim e As Regex = New Regex("[é|è|ë|ê]", RegexOptions.Compiled)
|
|
Dim i As Regex = New Regex("[í|ì|ï|î]", RegexOptions.Compiled)
|
|
Dim o As Regex = New Regex("[ó|ò|ö|ô]", RegexOptions.Compiled)
|
|
Dim u As Regex = New Regex("[ú|ù|ü|û]", RegexOptions.Compiled)
|
|
Dim ñ As Regex = New Regex("[ñ|Ñ]", RegexOptions.Compiled)
|
|
Dim CaracteresEspeciales = New Regex("[^a-zA-Z0-9 ]")
|
|
|
|
inputString = a.Replace(inputString, "a")
|
|
inputString = e.Replace(inputString, "e")
|
|
inputString = i.Replace(inputString, "i")
|
|
inputString = o.Replace(inputString, "o")
|
|
inputString = u.Replace(inputString, "u")
|
|
inputString = ñ.Replace(inputString, "n")
|
|
inputString = CaracteresEspeciales.Replace(inputString, "")
|
|
|
|
|
|
Return (inputString.ToLower)
|
|
End Function
|
|
|
|
End Class
|