Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Imports System.IO
Imports Ionic.Zip
Imports Microsoft.Reporting.WebForms
Partial Class Bancos_PagoElectronicoGrupos
Inherits ClsPaginas
Private Shared missing As Object = System.Reflection.Missing.Value
#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 NombreArchivo As String
Get
Return ViewState("NombreArchivo").ToString
End Get
Set(value As String)
ViewState("NombreArchivo") = value
End Set
End Property
Private Property DTPendientes As DataTable
Get
Return CType(ViewState("DTPendientes"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTPendientes") = value
End Set
End Property
Private Property DT_PagosReporte As DataTable
Get
Return CType(ViewState("DT_PagosReporte"), DataTable)
End Get
Set(value As DataTable)
ViewState("DT_PagosReporte") = value
End Set
End Property
Private Property DTAltasPendientes As DataTable
Get
Return CType(ViewState("DTAltasPendientes"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTAltasPendientes") = 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 DTFyE As DataTable
Get
Return CType(ViewState("DTFyE"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTFyE") = value
End Set
End Property
Private Property DTReportes As DataTable
Get
Return CType(ViewState("DTReportes"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTReportes") = value
End Set
End Property
Private Property DTPendienteActual As DataTable
Get
Return CType(ViewState("DTPendienteActual"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTPendienteActual") = value
End Set
End Property
Private Property DTEnviadas As DataTable
Get
Return CType(ViewState("DTEnviadas"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTEnviadas") = 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
Private Property CveCuenta As Integer
Get
Return ViewState("CveCuenta").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveCuenta") = value
End Set
End Property
Private Property DtPago As DataTable
Get
Return CType(ViewState("DtPago"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtPago") = value
End Set
End Property
Private Property DtAlta As DataTable
Get
Return CType(ViewState("DtAlta"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtAlta") = value
End Set
End Property
Private Property CorreoNotificacionesEmpresa As String
Get
Return ViewState("CorreoNotificacionesEmpresa").ToString
End Get
Set(value As String)
ViewState("CorreoNotificacionesEmpresa") = value
End Set
End Property
Private Property TipoMasiva As Integer
Get
Return ViewState("TipoMasiva").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("TipoMasiva") = value
End Set
End Property
Private Property NombreArchivoBancomer As String
Get
Return ViewState("NombreArchivoBancomer").ToString
End Get
Set(value As String)
ViewState("NombreArchivoBancomer") = value
End Set
End Property
Private Property NombreArchivoInterbancario As String
Get
Return ViewState("NombreArchivoInterbancario").ToString
End Get
Set(value As String)
ViewState("NombreArchivoInterbancario") = value
End Set
End Property
Private Property NombreArchivoCIE As String
Get
Return ViewState("NombreArchivoCIE").ToString
End Get
Set(value As String)
ViewState("NombreArchivoCIE") = value
End Set
End Property
Property DTSATBancos As DataTable
Get
If ViewState("DTSATBancos") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("DTSATBancos"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("DTSATBancos") = value
End Set
End Property
Property CveIEPagoActual As Integer
Get
If ViewState("CveIEPagoActual") Is Nothing Then
Return -1
Else
Return ViewState("CveIEPagoActual").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveIEPagoActual") = value
End Set
End Property
Property CveLayoutEnvioDetalleActual As Integer
Get
If ViewState("CveLayoutEnvioDetalleActual") Is Nothing Then
Return -1
Else
Return ViewState("CveLayoutEnvioDetalleActual").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveLayoutEnvioDetalleActual") = value
End Set
End Property
Property GvIndexActual As Integer
Get
If ViewState("GvIndexActual") Is Nothing Then
Return -1
Else
Return ViewState("GvIndexActual").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("GvIndexActual") = value
End Set
End Property
Property DTFoliosPrefijos As DataTable
Get
If ViewState("DTFoliosPrefijos") Is Nothing Then
Crate_DTFoliosPrefijos()
Return DirectCast(ViewState("DTFoliosPrefijos"), DataTable)
Else
Return DirectCast(ViewState("DTFoliosPrefijos"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("DTFoliosPrefijos") = 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("NombreArchivo") = ""
ViewState("HeaderTexto") = ""
ViewState("DetalleTexto") = ""
ViewState("TrailerTexto") = ""
ViewState("Vacio") = ""
ViewState("TotalAcumulado") = 0
CveCuenta = -1
TipoMasiva = 1
txtFechaI.Text = Date.Now.ToShortDateString
txtFechaF.Text = Date.Now.ToShortDateString
CargaCuentas()
CargaProveedores()
InicializaDatosGenerales()
End If
End Sub
Private Sub Crate_DTFoliosPrefijos()
Dim DTFolios As New DataTable
DTFolios.Columns.Add("CveIE", GetType(Integer))
DTFolios.Columns.Add("Folio", GetType(String))
DTFolios.AcceptChanges()
ViewState("DTFoliosPrefijos") = DTFolios.Copy
End Sub
#Region " C A R G A - D A T O S "
Private Sub CargaCuentas()
DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros("UsaLayoutGrupos = 1")
DdlCuenta.DataBind()
UpFiltros.Update()
DdlCuentaReportes.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros("UsaLayoutGrupos = 1")
DdlCuentaReportes.DataBind()
UpFiltrosReporte.Update()
DdlCuentaEnviados.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros("UsaLayoutGrupos = 1")
DdlCuentaEnviados.DataBind()
UpFiltroEnviados.Update()
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
CveCuenta = DdlCuenta.SelectedValue.ToEntero
CargaDatos()
End Sub
Private Sub CargaDatos()
'Carga datos en DT´s
Dim ObjBancos As New ClsBancos
If ObjBancos.GetLayoutPagos(CveCuenta, -1, DdlTipoGeneracion.SelectedValue, PorGrupos:=True) Then
DTPendientes = ObjBancos.DtResultados
Else
DTPendientes = Nothing
End If
ObjBancos.Dispose()
If DTPendientes IsNot Nothing AndAlso DTPendientes.Rows.Count > 0 Then
CargaDatosInformativos()
Else
LbNumeroMovimientos.Text = "0"
LbImporteMovimientos.Text = "0"
UpComandosGeneracion.Update()
End If
'Carga GvPendientes
If DTPendientes IsNot Nothing AndAlso DTPendientes.Rows.Count > 0 Then
GvPendientes.DataSource = DTPendientes
End If
GvPendientes.DataBind()
UpEnviados.Update()
UpGVDatos.Update()
End Sub
Private Sub CargaDatosInformativos()
Dim Altas = 0
Dim Interbancarias = 0
Dim Bancomer = 0
Dim Movimientos = 0
Dim Importe = 0.0
For Each dr As DataRow In DTPendientes.Rows
If dr("EstatusCtaDeposito").ToString <> "True" Then
Continue For
End If
If dr("CveCuentaDeposito").ToString <> "" And dr("EstatusPagoElectronicoGrupos").ToString <> "True" And dr("AltaCuenta").ToString = "1" Then
Altas += 1
If dr("BancoNombre").ToString.ToUpper.Contains("BANCOMER") OrElse dr("BancoNombre").ToString.ToUpper.Contains("BBVA") Then
Bancomer += 1
Else
Interbancarias += 1
End If
ElseIf dr("CveCuentaDeposito").ToString.ToEntero > 0 Then
Movimientos += 1
Importe += dr("Abonado").ToString.ToDouble
End If
Next
LnkNumeroAltas.Text = Altas.ToString
LbNumeroInterbancarias.Text = Interbancarias.ToString
LbNumeroBancomer.Text = Bancomer.ToString
LbNumeroMovimientos.Text = Movimientos.ToString
LbImporteMovimientos.Text = Importe.ToString.FormatoNumero
UpComandosGeneracion.Update()
End Sub
#End Region
#Region " DATOS GENERALES LAYOUT "
Private Sub InicializaDatosGenerales()
If UsuarioActual.CveEmpresa = 66 Then
CorreoNotificacionesEmpresa = "pagos@gluyasconstrucciones.com"
ElseIf UsuarioActual.CveEmpresa = 13 Then
CorreoNotificacionesEmpresa = "signotificaciones@adssistemas.mx"
Else
CorreoNotificacionesEmpresa = "signotificaciones@adssistemas.mx"
End If
End Sub
#End Region
#Region " GENERA Y DESCARGA ARCHIVO (TXT) "
Protected Sub CrearTXT()
Dim path As String = Server.MapPath(String.Format("~/Empresas/{0}/Layout/{1}.txt", UsuarioActual.CveEmpresa, NombreArchivo))
' 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
Private Sub DescargarArchivo()
With HttpContext.Current.Response
.Clear()
.Buffer = True
.ContentType = "textplain"
.AddHeader("Content-Disposition", String.Format("attachment;filename={0}{1}.txt", NombreArchivo, Date.Now.ToString("ddMMyyyy")))
.Charset = "UTF-8"
.ContentEncoding = Encoding.Default
.Write(TextoCompleto)
.Flush()
.End()
End With
End Sub
Private Sub DescargaZip()
Dim path As String = Server.MapPath(String.Format("~/Empresas/{0}/Layout/", UsuarioActual.CveEmpresa))
Response.Clear()
Dim ElZip As ZipFile = New ZipFile()
Using ElZip
ElZip.AddDirectory(path)
ElZip.Save(Response.OutputStream)
End Using
Response.AddHeader("Content-Disposition", "attachment; filename=LayoutPagos.zip")
Response.ContentType = "application/zip"
Response.End()
End Sub
Private Function CreaArchivo(Tipo As Integer, Optional MismoBanco As Boolean = True, Optional ByRef NombreArchivoEnviado As String = "") As Boolean
System.Threading.Thread.Sleep(1000) 'Un segundo de diferencia Para doferentes tipos de bancos
DirectoryExistsCreate(String.Format("{0}Layout", UsuarioActual.Empresa.Ruta))
NombreArchivo = String.Format("{2}{1}{0}.txt", UsuarioActual.CveUsuario, Date.Now.ToString("yyyyMMdd-HH-mm-ss"), If(Tipo = 1, "LAYOUTPAGO", "LAYOUTALTA"))
If Tipo = 1 Then
NombreArchivo = String.Format("{2}{1}{0}.txt", UsuarioActual.CveUsuario, Date.Now.ToString("yyyyMMdd-HH-mm-ss"), "LAYOUTPAGO")
Else
NombreArchivo = String.Format("{2}{1}{0}{3}.txt", UsuarioActual.CveUsuario, Date.Now.ToString("yyyyMMdd-HH-mm-ss"), "LAYOUTALTA", If(MismoBanco, "BANCOMER", "INTERBANCARIO"))
End If
If NombreArchivoEnviado.Length > 0 Then
NombreArchivo = NombreArchivoEnviado
Else
NombreArchivoEnviado = NombreArchivo
End If
Dim path As String = String.Format("{0}Layout\{1}", UsuarioActual.Empresa.Ruta, NombreArchivo)
If File.Exists(path) Then
File.Delete(path)
End If
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()
Return True
End Function
'Private Function GuardaTXT() As Boolean
' Dim Retorno = True
' Try
' Dim Ruta = ""
' Dim FileName As String = Path.GetFileName(FUTxt.PostedFile.FileName)
' NombreArchivo = FileName
' Dim Extension As String = Path.GetExtension(FUTxt.PostedFile.FileName)
' Dim FolderPath As String = String.Format("{0}Empresas\", Request.ApplicationPath)
' Dim FilePath As String = Server.MapPath(FolderPath + FileName)
' FUTxt.SaveAs(FilePath)
' NombreArchivo = FilePath
' Catch ex As Exception
' Retorno = False
' End Try
' Return Retorno
'End Function
#End Region
#Region " TAB PRINCIPAL "
Protected Sub GvPendientes_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim LnkAyuda As LinkButton = e.Row.FCLinkButton("LnkAyuda")
'Colorea GV
If e.Row.DBCampo("RazonSocial").ToString = "" Then
e.Row.BackColor = Drawing.Color.WhiteSmoke
Else
If e.Row.DBCampo("EstatusPagoElectronicoGrupos").ToString <> "True" Then
'e.Row.BackColor = Drawing.Color.LightSalmon
e.Row.ToolTip = "Cuenta Deposito aun sin dar de Alta."
LnkAyuda.Attributes.Add("data-content", "Cuenta Deposito aún sin dar de Alta.")
LnkAyuda.Visible = True
End If
If e.Row.DBCampo("CveProveedor").ToString.ToEntero > 0 Then
e.Row.FCHyperLink("HLProveedor").NavigateUrl = String.Format("/Compras/Proveedores.aspx?CveProveedor={0}", e.Row.DBCampo("CveProveedor"))
Else
e.Row.FCHyperLink("HLProveedor").NavigateUrl = String.Format("/RH/Personal.aspx?CvePersonal={0}", e.Row.DBCampo("CvePersonal"))
End If
End If
If Not e.Row.DBCampo("CveCuentaDeposito").ToString.ToEntero > 0 Then
'e.Row.Cells(0).BackColor = Drawing.Color.Red
e.Row.ToolTip = "Sin Cuenta Deposito asignada"
LnkAyuda.Attributes.Add("data-content", "Sin Cuenta Deposito asignada")
LnkAyuda.Visible = True
End If
If e.Row.DBCampo("EstatusCtaDeposito").ToString = "False" Then
'e.Row.Cells(0).BackColor = Drawing.Color.Red
e.Row.ToolTip = "Cuenta Deposito INACTIVA"
LnkAyuda.Attributes.Add("data-content", "Cuenta Deposito INACTIVA")
LnkAyuda.Visible = True
End If
e.Row.FCHyperLink("HLImporte").NavigateUrl = String.Format("IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE"))
End If
End Sub
Protected Sub GvEnviadas_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
'Colorea GV
If e.Row.DBCampo("CveIE").ToString = "" Then
e.Row.BackColor = Drawing.Color.LightGray
e.Row.FCLabel("LblArchivo").Visible = True
e.Row.FCLabel("LblArchivo").Text = e.Row.DataKey("Archivo")
'Si la fecha de generacion del archivo es diferente de hoy activamos el boton REGENERAR
'If e.Row.DBCampo("Fecha").ToDate.ToShortDateString <> Date.Now.ToShortDateString Then
' e.Row.FCLinkButton("LBRegenerar").Visible = True
'End If
If DTEnviadas.MAX("FueConciliado", String.Format("CveLayoutEnvio = {0}", e.Row.DBCampo("CveLayoutEnvio"))).ToEntero > 0 Then
e.Row.ToolTip = "El movimiento no se puede regenerar ya que alguno de sus movimientos ya fue conciliado"
Else
e.Row.FCLinkButton("LBRegenerar").Visible = True
End If
e.Row.FCTextBox("TxtFolio").Visible = False
e.Row.FCLinkButton("ImgUpload").Visible = False
e.Row.FCLinkButton("LnkGvCancelar").Visible = False
e.Row.FCLinkButton("LnkGvConfirmar").Visible = False
Else
If e.Row.DBCampo("FueConciliado") = "1" Then
e.Row.ForeColor = Drawing.Color.Red
e.Row.ToolTip = "Este movimiento ya fue conciliado."
End If
If e.Row.DBCampo("CveProveedor").ToString.ToEntero > 0 Then
e.Row.FCHyperLink("HLProveedor").NavigateUrl = String.Format("/Compras/Proveedores.aspx?CveProveedor={0}", e.Row.DBCampo("CveProveedor"))
Else
e.Row.FCHyperLink("HLProveedor").NavigateUrl = String.Format("/RH/Personal.aspx?CvePersonal={0}", e.Row.DBCampo("CvePersonal"))
End If
e.Row.FCHyperLink("HLDetalle").NavigateUrl = String.Format("IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE"))
If e.Row.DataKey("Estatus").ToEntero.contiene(2, 3) Then
e.Row.FCLinkButton("ImgUpload").Visible = False
e.Row.FCLinkButton("LnkGvCancelar").Visible = False
e.Row.FCLinkButton("LnkGvConfirmar").Visible = False
e.Row.FCTextBox("TxtFolio").Visible = False
End If
End If
End If
End Sub
Protected Sub LBRegenerar_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim CveBLE = CType(sender, LinkButton).CommandArgument.ToEntero
Dim DtRegenerar As New DataTable
Dim NombreDelArchivo As String = GvRow.DataKey("Archivo")
Dim ObjBancos As New ClsBancos
If ObjBancos.GetLayoutPagos(DdlCuentaEnviados.SelectedValue.ToEntero, CveBLE, "-1", PorGrupos:=True) Then
DtRegenerar = ObjBancos.DtResultados
Else
DtRegenerar = Nothing
End If
ObjBancos.Dispose()
If DtRegenerar IsNot Nothing Then
GeneraPago(DtRegenerar, False, NombreDelArchivo)
Else
Alert("Ocurrió un error al obtener los datos para generar el archivo. Por favor vuelva a intentar.", TipoMensaje.MsgError)
End If
End Sub
#End Region
'RECARGA DATOS
#Region " RECARGA DATOS "
Private Sub RecargaDatos()
CargaDatos()
TipoMasiva = 1
DdlTipoCargaMasiva.SelectedValueExist("1")
CargaProveedores()
End Sub
#End Region
'ARMA Y GENERA TXT'S
#Region "ALTA PROVEEDORES"
Protected Sub BtnAltas_Click(sender As Object, e As EventArgs)
If Not DdlCuenta.SelectedValue.ToEntero > 0 Then
Alert("Primero debe seleccionar una Cuenta", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
AltaProveedores()
End Sub
Private Sub AltaProveedores(Optional DtCuentasPendientesTemp As DataTable = Nothing)
NombreArchivoBancomer = ""
NombreArchivoInterbancario = ""
NombreArchivoCIE = ""
DVDescargaCuentas1.Visible = False
DVDescargaCuentas2.Visible = False
DVDescargaCuentas3.Visible = False
NombreArchivo = ""
Dim RegistrosAltaBancomer As New StringBuilder
Dim RegistrosAltaBancomerCIE As New StringBuilder
Dim RegistrosAltaInterbancario As New StringBuilder
Dim SBErrores As New StringBuilder
Dim CeroRelleno As Char = "0"c
Dim EspacioRelleno As Char = Chr(32)
Dim ErrorLayout = False
If DtCuentasPendientesTemp Is Nothing Then
DtCuentasPendientesTemp = DTPendientes.Copy
End If
DtCuentasPendientesTemp.CaseSensitive = False
Dim DtCuentasPendientesBancomer As DataTable = DtCuentasPendientesTemp.FiltraParametros($" (EstatusPagoElectronicoGrupos IS NULL OR EstatusPagoElectronicoGrupos = False) AND (BancoNombre like '%BBVA%' OR BancoNombre like '%BANCOMER%' AND CveBanco = '012' AND LEN(CIE) = 0) ", "", {"CveCuentaDeposito", "BancoNombre", "CLABEDestino", "Abreviatura", "RazonSocial", "CveProveedor", "CveBanco", "Cuenta", "BBVAAlias", "CIE"})
Dim DtCuentasPendientesCIE As DataTable = DtCuentasPendientesTemp.FiltraParametros($" (EstatusPagoElectronicoGrupos IS NULL OR EstatusPagoElectronicoGrupos = False) AND (BancoNombre like '%BBVA%' OR BancoNombre like '%BANCOMER%' AND LEN(CIE) > 0 AND CveBanco = '012') ", "", {"CveCuentaDeposito", "BancoNombre", "CLABEDestino", "Abreviatura", "RazonSocial", "CveProveedor", "CveBanco", "Cuenta", "BBVAAlias", "CIE"})
Dim DtCuentasPendientesInterbancarias As DataTable = DtCuentasPendientesTemp.FiltraParametros($" (EstatusPagoElectronicoGrupos IS NULL OR EstatusPagoElectronicoGrupos = False) AND (BancoNombre not like '%BBVA%' AND BancoNombre not like '%BANCOMER%' ) ", "", {"CveCuentaDeposito", "BancoNombre", "CLABEDestino", "Abreviatura", "RazonSocial", "CveProveedor", "CveBanco", "Cuenta", "BBVAAlias", "CIE"})
'Cuentas bancomer
If DtCuentasPendientesBancomer.Rows.Count > 0 Then
For Each dRow As DataRow In DtCuentasPendientesBancomer.Rows
Dim SBTmpBancomer As New StringBuilder
Dim SBErroresBancomer As New StringBuilder
Dim ErrorLineaBancomer As Boolean = False
SBErroresBancomer.Append($"{dRow("RazonSocial").ToString } ")
SBErroresBancomer.Append($"Cuenta: {dRow("Cuenta").ToString } ")
If dRow("CLABEDestino").ToString.Length <= 18 Then 'Tamaño maximo 18
SBTmpBancomer.Append(dRow("CLABEDestino").ToString.PadLeft(18, CeroRelleno))
Else
SBErroresBancomer.Append("La cuenta beneficiaria no puede ser mayor a 18 caracteres, ")
ErrorLineaBancomer = True
End If
If dRow("Abreviatura").ToString.Length = 3 Then
SBTmpBancomer.Append(dRow("Abreviatura"))
Else
SBErroresBancomer.Append("El tamaño de la divisa es incorrecto, ")
ErrorLineaBancomer = True
End If
SBTmpBancomer.Append("0999999999999.99")
If dRow("RazonSocial").ToString.Trim.Length < 31 Then 'Tamaño maximo 30
SBTmpBancomer.Append(dRow("RazonSocial").ToString.PadRight(30, EspacioRelleno))
Else
SBTmpBancomer.Append(dRow("RazonSocial").ToString.Trim.Substring(0, 30))
End If
'ALIAS DE LA CUENTA PENDIENTE TAMAÑO MAXIMO 30
SBTmpBancomer.Append(dRow("BBVAAlias").ToString.PadRight(30, EspacioRelleno))
'CORREO OPCIONAL TAMAÑO MAXIMO 80
'RegistrosAlta.Append("".ToString.PadLeft(80, EspacioRelleno))
SBTmpBancomer.Append(vbCrLf)
If Not ErrorLineaBancomer Then
RegistrosAltaBancomer.Append(SBTmpBancomer.ToString)
' ObjGrales.UpdateCuentasDepositosEstatusPagoElectronicoGrupos(dRow("CveCuentaDeposito").ToString.ToEntero, True)
Else
SBErroresBancomer.Append("
")
SBErrores.AppendLine(SBErroresBancomer.ToString)
End If
Next
TextoCompleto = RegistrosAltaBancomer.ToString
If CreaArchivo(2, True) Then
NombreArchivoBancomer = NombreArchivo
End If
End If
'Cuentas bancomer CIE
If DtCuentasPendientesCIE.Rows.Count > 0 Then
For Each dRow As DataRow In DtCuentasPendientesCIE.Rows
Dim SBTmpBancomerCIE As New StringBuilder
Dim SBErroresBancomerCIE As New StringBuilder
Dim ErrorLineaBancomerCIE As Boolean = False
SBErroresBancomerCIE.Append($"{dRow("RazonSocial").ToString } ")
SBErroresBancomerCIE.Append($"Cuenta: {dRow("Cuenta").ToString } ")
SBTmpBancomerCIE.Append("CV")
SBTmpBancomerCIE.Append(dRow("CIE").ToString.PadLeft(18, CeroRelleno))
If dRow("Abreviatura").ToString.Length = 3 Then
SBTmpBancomerCIE.Append(dRow("Abreviatura"))
Else
SBErroresBancomerCIE.Append("El tamaño de la divisa es incorrecto, ")
ErrorLineaBancomerCIE = True
End If
SBTmpBancomerCIE.Append("0999999999999.99")
If dRow("RazonSocial").ToString.Trim.Length < 31 Then 'Tamaño maximo 30
SBTmpBancomerCIE.Append(dRow("RazonSocial").ToString.PadRight(30, EspacioRelleno))
Else
SBTmpBancomerCIE.Append(dRow("RazonSocial").ToString.Trim.Substring(0, 30))
End If
'ALIAS DE LA CUENTA PENDIENTE TAMAÑO MAXIMO 30
SBTmpBancomerCIE.Append(dRow("BBVAAlias").ToString.PadRight(30, EspacioRelleno))
SBTmpBancomerCIE.Append(vbCrLf)
If Not ErrorLineaBancomerCIE Then
RegistrosAltaBancomerCIE.Append(SBTmpBancomerCIE.ToString)
Else
SBErroresBancomerCIE.Append("
")
SBErrores.AppendLine(SBErroresBancomerCIE.ToString)
End If
Next
TextoCompleto = RegistrosAltaBancomerCIE.ToString
If CreaArchivo(2, True) Then
NombreArchivoCIE = NombreArchivo
End If
End If
If DtCuentasPendientesInterbancarias.Rows.Count > 0 Then
For Each dRow As DataRow In DtCuentasPendientesInterbancarias.Rows
Dim SBTmpInterbancarias As New StringBuilder
Dim SBErroresInterBancario As New StringBuilder
Dim ErrorLineaInterbancaria As Boolean = False
SBErroresInterBancario.Append($"{dRow("RazonSocial").ToString } ")
SBErroresInterBancario.Append($"Cuenta: {dRow("Cuenta").ToString } ")
If dRow("CveBanco").ToString.Trim.Length = 3 Then
SBTmpInterbancarias.Append(dRow("CveBanco").ToString.Trim)
Else
SBErroresInterBancario.Append("clave ABM(Clave SAT) incorrecta, ")
ErrorLineaInterbancaria = True
End If
If dRow("CLABEDestino").ToString.Length <= 18 Then 'Tamaño maximo 18
SBTmpInterbancarias.Append(dRow("CLABEDestino").ToString.PadLeft(18, CeroRelleno))
Else
SBErroresInterBancario.Append("La cuenta beneficiaria no puede ser mayor a 18 caracteres, ")
ErrorLineaInterbancaria = True
End If
If dRow("Abreviatura").ToString.Length = 3 Then
SBTmpInterbancarias.Append(dRow("Abreviatura").ToString.Trim)
Else
SBErroresInterBancario.Append("El tamaño de la divisa es incorrecto, ")
ErrorLineaInterbancaria = True
End If
SBTmpInterbancarias.Append("0999999999999.99")
If dRow("RazonSocial").ToString.Trim.Length < 31 Then 'Tamaño maximo 30
SBTmpInterbancarias.Append(dRow("RazonSocial").ToString.PadRight(30, EspacioRelleno))
Else
SBTmpInterbancarias.Append(dRow("RazonSocial").ToString.Trim.Substring(0, 30))
End If
' ALIAS DE LA CUENTA PENDIENTE TAMAÑO MAXIMO 30
SBTmpInterbancarias.Append(dRow("BBVAAlias").ToString.PadRight(30, EspacioRelleno))
'CORREO OPCIONAL TAMAÑO MAXIMO 80
'RegistrosAlta.Append("".ToString.PadLeft(80, EspacioRelleno))
'Tipo de cuenta
SBTmpInterbancarias.Append("40")
SBTmpInterbancarias.Append(vbCrLf)
If Not ErrorLineaInterbancaria Then
RegistrosAltaInterbancario.Append(SBTmpInterbancarias.ToString)
' ObjGrales.UpdateCuentasDepositosEstatusPagoElectronicoGrupos(dRow("CveCuentaDeposito").ToString.ToEntero, True)
Else
SBErroresInterBancario.Append("
")
SBErrores.AppendLine(SBErroresInterBancario.ToString)
End If
Next
If RegistrosAltaInterbancario.Length > 0 Then
TextoCompleto = RegistrosAltaInterbancario.ToString
If CreaArchivo(2, False) Then
NombreArchivoInterbancario = NombreArchivo
End If
End If
End If
' ObjGrales.Dispose()
Dim Mensaje As New StringBuilder
'Mensaje.Append("Descarga Layouts
")
DVDescargaPagos.Visible = False
DVDescargaReporte.Visible = False
If NombreArchivoBancomer.Trim.Length > 0 Then
DVDescargaCuentas1.Visible = True
End If
If NombreArchivoInterbancario.Trim.Length > 0 Then
DVDescargaCuentas2.Visible = True
End If
If NombreArchivoCIE.Trim.Length > 0 Then
DVDescargaCuentas3.Visible = True
End If
If SBErrores.ToString.Length > 0 Then
Mensaje.Append("Errores Cuentas
")
Mensaje.Append("
| ") strBody.AppendFormat(" ") strBody.AppendFormat(" | ") strBody.AppendFormat("
")
'strBody.Append(" De: Bancomer.com [mailto:alertatdu@serviciobancomer.com]
")
strBody.Append("
", UrlSitio)
strBody.Append(" ")
strBody.Append("
")
strBody.AppendFormat(" 
")
strBody.Append("
")
strBody.Append(" Confirmación de pago realizado bajo las siguientes condiciones:
| ") strBody.Append(" | ") strBody.Append("") strBody.Append(" | ") strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" NOMBRE DEL CLIENTE: | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" {0} | ")
strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" NÚMERO DE CONVENIO: | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" {0} | ")
strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" CLAVE DEL PROVEEDOR: | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" {0} | ")
strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" NOMBRE DEL PROVEEDOR/TERCERO: | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" {0} | ")
strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" REFERENCIA DEL PAGO: | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" {0} | ")
strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" TIPO DE PAGO: | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" {0} | ")
strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" CUENTA DE ABONO: | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" {0} | ")
strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" IMPORTE DEL PAGO: | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" ${0} | ")
strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" FECHA DE OPERACIÓN | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" {0} | ")
strBody.Append("
| ")
strBody.Append(" ")
strBody.Append(" MENSAJE ADICIONAL: | ")
strBody.Append(" ")
strBody.Append(" ")
strBody.AppendFormat(" {0} | ")
strBody.Append("
", UrlSitio)
strBody.Append(" ")
strBody.Append("
")
strBody.Append("
")
strBody.Append("
")
strBody.Append("
")
strBody.Append("
| Factura ") strBody.Append(" | Fecha ") strBody.Append(" | Original ") strBody.Append(" | Abonado ") strBody.Append(" | Nota Crédito ") strBody.Append(" | Saldo ") strBody.Append(" |
|---|---|---|---|---|---|
| {Dr2("SerieFolio")} | ") strBody.Append($"{Dr2("FechaCompra").ToString.ToDate.ToShortDateString} | ") strBody.Append($"{Dr2("Total").ToString.ToDouble.FormatoNumero} | ") strBody.Append($"{Dr2("Importe").ToString.ToDouble.FormatoNumero} | ") strBody.Append($"{Dr2("ImporteNC").ToString.ToDouble.FormatoNumero} | ") strBody.Append($"{Dr2("Saldo").ToString.ToDouble.FormatoNumero} | ") strBody.Append("
| ") strBody.AppendFormat(" ") strBody.AppendFormat(" | ") strBody.AppendFormat("
| ") strBody.AppendFormat(" ") strBody.AppendFormat(" | ") strBody.AppendFormat("