Imports System.IO Imports Extensiones Imports System.Data Partial Class Bancos_Transferencias Inherits ClsPaginas #Region "Propiedades" Private Property DtCuentas As DataTable Get Return CType(ViewState("DtCuentas"), DataTable) End Get Set(value As DataTable) ViewState("DtCuentas") = value End Set End Property Private Property Opcion As Integer Get Return ViewState("Opcion").ToString.ToEntero End Get Set(value As Integer) ViewState("Opcion") = value End Set End Property Private Property tCveMonedaOrigen As Integer Get Return ViewState("tCveMonedaOrigen").ToString.ToEntero End Get Set(value As Integer) ViewState("tCveMonedaOrigen") = value End Set End Property Private Property tCveMonedaDestino As Integer Get Return ViewState("tCveMonedaDestino").ToString.ToEntero End Get Set(value As Integer) ViewState("tCveMonedaDestino") = 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 tCveMonedaOrigen = 0 tCveMonedaDestino = 0 If Request("OPC") IsNot Nothing AndAlso IsNumeric(Request("OPC")) Then Opcion = Request("OPC").ToEntero Else Opcion = -1 End If DtCuentas = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) If Opcion = 1 Then LtlTitulo.Text = "Domicialización de tarjeta" RBLOpcion.Visible = True TrCuentaOrigen.Visible = False chkMovimientoTarjeta.Checked = True chkMovimientoTarjeta.Enabled = False chkMovimientoTarjeta_CheckedChanged(Nothing, Nothing) CargaCuenta(-1, DdlCuentaDestino) CargaFolio(DdlCuentaDestino.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero) Else CargaCuenta(-1, DdlCuentaOrigen) CargaCuenta(DdlCuentaOrigen.SelectedValue.ToEntero, DdlCuentaDestino) CargaFolio(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero) End If TxtFechaDocumento.Text = Now.ToShortDateString End If End Sub Private Sub CargaCuenta(CveCuenta As Integer, Ddl As DropDownList) Ddl.Items.Clear() If UsuarioActual.CveEmpresa = 119 Then Ddl.DataSource = DtCuentas Else Ddl.DataSource = DtCuentas.FiltraParametros(String.Format("CveCuenta <> {0}", CveCuenta)) End If Ddl.DataBind() DdlCuentaDestino_SelectedIndexChanged(Nothing, Nothing) If CveCuenta > 0 Then VerificaMonedas() End Sub Private Sub VerificaMonedas() 'si es la destino verifico si la moneda es la misma, sino pregunto por la paridad cambiaria Dim drOrigen As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuentaOrigen.SelectedValue.ToEntero)) Dim drDestino As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuentaDestino.SelectedValue.ToEntero)) 'Dim tCveMonedaOrigen, tCveMonedaDestino As Integer If drOrigen IsNot Nothing AndAlso drDestino IsNot Nothing Then tCveMonedaOrigen = drOrigen("CveMoneda").ToString.ToEntero tCveMonedaDestino = drDestino("CveMoneda").ToString.ToEntero End If If drOrigen IsNot Nothing AndAlso drDestino IsNot Nothing AndAlso drOrigen("CveMoneda").ToString <> drDestino("CveMoneda").ToString Then If tCveMonedaOrigen = 1 AndAlso tCveMonedaDestino <> 1 Then 'pesos a otra moneda se divide TxtTipoCambio.Attributes.Add("onkeyup", "$get('HdnTC').value='2'; Calcula();") RegistraScript("$get('TrTC').style.display=''; $get('HdnTC').value='2'; Calcula();") ElseIf tCveMonedaOrigen <> 1 AndAlso tCveMonedaDestino = 1 Then 'de otra moneda a pesos se multiplica TxtTipoCambio.Attributes.Add("onkeyup", "$get('HdnTC').value='1'; Calcula();") RegistraScript("$get('TrTC').style.display=''; $get('HdnTC').value='1'; Calcula();") End If PnlTipoCambio.Visible = True 'RegistraScript("$get('TrTC').style.display='';") TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) Else PnlTipoCambio.Visible = False RegistraScript("$get('TrTC').style.display='none';") TxtFechaDocumento.Attributes.Remove("onchange") End If If drOrigen IsNot Nothing AndAlso drDestino IsNot Nothing AndAlso tCveMonedaOrigen = 2 OrElse tCveMonedaDestino = 2 Then PnlTipoCambio.Visible = True RegistraScript("$get('TrTC').style.display='';") TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);") TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) End If End Sub Protected Sub DdlCuentaOrigen_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaOrigen.SelectedIndexChanged CargaFolio(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero) CargaCuenta(DdlCuentaOrigen.SelectedValue.ToEntero, DdlCuentaDestino) If DdlCuentaOrigen.SelectedValue.ToEntero() > 0 Then If DtCuentas.FiltroPrimeroValor("CveTipoCuenta", String.Format("CveCuenta = {0}", DdlCuentaOrigen.SelectedValue)) = "1" Then CargaMovimientosCajaChica() TrCajaChica.Visible = True Else DdlCajaChica.DataSource = Nothing DdlCajaChica.DataBind() TrCajaChica.Visible = False End If End If End Sub Protected Sub DdlCuentaDestino_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaDestino.SelectedIndexChanged VerificaMonedas() If Opcion = 1 Then CargaFolio(DdlCuentaDestino.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero) End If If chkMovimientoTarjeta.Checked AndAlso GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveCuenta = {0} AND UsaTarjeta = 1", DdlCuentaDestino.SelectedValue.ToEntero)).Rows.Count > 0 Then CargaGridTarjetas() Else GvTC.Visible = False End If End Sub Private Sub CargaGridTarjetas() Dim ObjCreditos As New ClsBancos If ObjCreditos.GetTarjetasCreditos(DdlCuentaDestino.SelectedValue.ToEntero) Then If ObjCreditos.DtResultados.Rows.Count > 0 Then GvTC.DataSource = ObjCreditos.DtResultados End If GvTC.DataBind() UpGvTC.Update() GvTC.Visible = True End If ObjCreditos.Dispose() End Sub Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click 'VALIDACIONES Dim SumaImportesTarjeta As Decimal If GvTC.Visible Then For Each row As GridViewRow In GvTC.Rows SumaImportesTarjeta += row.FCTextBox("TxtAbono").Text.ToDecimal Next If TxtImporte.Text.ToDouble <> SumaImportesTarjeta Then Alert("Las Cantidades a Abonar no Coinciden con el Importe a Transferir", TipoMensaje.MsgAdvertencia) Exit Sub End If End If If DdlCuentaDestino.SelectedValue = "" Then Alert("Seleccione cuenta destino", TipoMensaje.MsgAdvertencia) Exit Sub End If If TxtImporte.Text.ToDouble <= 0 Then Alert("Debe ingresar un importe", TipoMensaje.MsgAdvertencia) Exit Sub End If If TxtTipoCambio.Visible AndAlso TxtTipoCambio.Text.ToDouble <= 0 Then Alert("Debe ingresar el tipo de cambio", TipoMensaje.MsgAdvertencia) Exit Sub End If Dim MsgError As String = "" Dim ImporteDestino As Double = TxtImporte.Text.Trim.ToDouble Dim ImporteMXOrigen As Double = TxtImporte.Text.Trim.ToDouble Dim ImporteMXDestino As Double = TxtImporte.Text.Trim.ToDouble Dim ObjIE As New ClsBancos() Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL) 'Dim ObjComp As New ClsCompras(ObjIE.IniciaTransacSQL) Dim TipoCambio As Double = If(TxtTipoCambio.Visible, TxtTipoCambio.Text.ToDecimal, 0) Dim CveMonedaOrigen, CveMonedaDestino As Integer Dim FolioOrigen As String = TxtFolio.Text.Trim Dim FolioDestino As String = GetFolio(DdlCuentaDestino.SelectedValue.ToEntero, If(DdlTipoMovto.SelectedValue = "2", 8, 3)) Dim CveIE As Integer Dim CveIEDestino As Integer Dim CuentaDestino As String = "" Dim Observaciones As String = "" Dim dr As DataRow Dim AlertaGlobal As New StringBuilder 'COMPROBANTE Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos Dim filemove As String = "" Dim Comprobante As String = "" For Each fileItem As Archivo In filesgral Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") filemove = fileItem.filename Next dr = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuentaDestino.SelectedValue)) If dr IsNot Nothing Then CveMonedaDestino = dr("CveMoneda").ToString.ToEntero If Opcion = -1 Then dr = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuentaOrigen.SelectedValue)) If dr IsNot Nothing Then CveMonedaOrigen = dr("CveMoneda").ToString.ToEntero Else CveMonedaOrigen = CveMonedaDestino End If If CveMonedaOrigen = 1 AndAlso CveMonedaDestino <> 1 Then 'pesos a otra moneda se divide ImporteDestino = Math.Round(TxtImporte.Text.Trim.ToDouble / TxtTipoCambio.Text.ToDouble, 2) ImporteMXDestino = TxtImporte.Text.Trim.ToDouble ElseIf CveMonedaOrigen <> 1 AndAlso CveMonedaDestino = 1 Then 'de otra moneda a pesos se multiplica ImporteDestino = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2) ImporteMXDestino = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2) ImporteMXOrigen = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2) ElseIf CveMonedaOrigen <> 1 AndAlso CveMonedaDestino <> 1 Then ImporteMXDestino = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2) ImporteMXOrigen = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2) End If If CveMonedaOrigen = 2 AndAlso CveMonedaDestino = 2 Then TipoCambio = TxtTipoCambio.Text.ToDouble 'GlobalTipoCambio(TxtFechaDocumento.Text.ToDate) End If Dim CvePrePoliza As Integer = ObjMov.AddPrePolizas("Bancos/Transferencias", 13, TxtImporte.Text.Trim.ToDouble, TxtImporte.Text.Trim.ToDouble, CveMonedaOrigen, TxtFechaDocumento.Text.ToDate, $"Transferencia entre cuentas {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If UsuarioActual.CveEmpresa = 48 Then CuentaDestino = "Alumbrado publico de Hermosillo S.A de C.V" Observaciones = String.Format("{0} {1}", DdlCuentaDestino.SelectedItem.Text, TxtObservaciones.Text.Trim) Else CuentaDestino = String.Format("Transferencia Cta: {0}", DdlCuentaDestino.SelectedItem.Text) Observaciones = TxtObservaciones.Text.Trim End If If Opcion = 1 Then CveIE = ObjIE.AddBancos_IE(DdlCuentaDestino.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, CuentaDestino, ImporteMXOrigen, CveMonedaOrigen, TipoCambio, Observaciones, "", False, False, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) CveIEDestino = CveIE Else If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then FolioDestino = TxtFolio.Text.Trim If TxtPaguese.Text.Trim <> "" Then CuentaDestino = TxtPaguese.Text.Trim End If End If CveIE = ObjIE.AddBancos_IE(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, CuentaDestino, TxtImporte.Text.Trim.ToDouble, CveMonedaOrigen, TipoCambio, TxtObservaciones.Text.Trim, "", False, False, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) CveIEDestino = ObjIE.AddBancos_IE(DdlCuentaDestino.SelectedValue.ToEntero, If(DdlTipoMovto.SelectedValue = "2", 8, 3), TxtFechaDocumento.Text.Trim.ToDate, FolioDestino, String.Format("Transferencia Cta: {0}", DdlCuentaOrigen.SelectedItem.Text), ImporteDestino, CveMonedaDestino, TipoCambio, TxtObservaciones.Text.Trim, "", False, False, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) End If Dim CveIEDevolucion As Integer = -1 If DdlCajaChica.SelectedValue.ToEntero() > 0 AndAlso TrCajaChica.Visible Then CveIEDevolucion = DdlCajaChica.SelectedValue.ToEntero() End If If (CveIE > 0 AndAlso CveIEDestino > 0) Then If filemove <> "" Then filemove.FilesMove(CveIE.ToString, String.Format("{0}IE", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False) End If 'inserto los movimientos de la conta para abonar al saldo If MsgError = "" Then If CvePrePoliza > 0 Then Dim alertaContabilizacion As String = "Se envió correctamente la siguiente póliza:

" Dim CuentasContablesInvalidas As New StringBuilder Dim IdCtaContableOrigen As Integer = 0 Dim IDCtaContableComplementariaOrigen As Integer = 0 Dim IDCtaContableComplementariaDestino As Integer = 0 Dim IdCtaContableDestino As Integer = 0 Dim CuentasContablesInvalidasSIG As New StringBuilder Dim RowCuentaOrigen As DataRow = Nothing RowCuentaOrigen = DtCuentas.FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuentaOrigen.SelectedValue.ToEntero)) Dim RowCuentaDestino As DataRow = DtCuentas.FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuentaDestino.SelectedValue.ToEntero)) If RowCuentaOrigen IsNot Nothing Then IdCtaContableOrigen = RowCuentaOrigen("IdCtaContable").ToString.ToEntero IDCtaContableComplementariaOrigen = RowCuentaOrigen("IDCtaContableComplementaria").ToString.ToEntero End If If RowCuentaDestino IsNot Nothing Then IdCtaContableDestino = RowCuentaDestino("IdCtaContable").ToString.ToEntero IDCtaContableComplementariaDestino = RowCuentaDestino("IDCtaContableComplementaria").ToString.ToEntero End If 'Conta ContPAQ If IdCtaContableOrigen < 1 Then CuentasContablesInvalidas.Append("
Cuenta Contable Origen") End If If IdCtaContableDestino < 1 Then CuentasContablesInvalidas.Append("
Cuenta Contable Destino") End If If Opcion = 1 Then ' CUANDO ES DOMICILIZACION IdCtaContableOrigen = IdCtaContableDestino End If Dim TipoMovtoDetalle As Boolean = True If RBLOpcion.SelectedValue = "2" Then TipoMovtoDetalle = False ' cuando sea un reembolso/devolución, es ingreso a bancos Dim TC As Decimal = TxtTipoCambio.Text.ToDecimal If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoDetalle, TxtImporte.Text.ToDouble, $"Transferencia entre cuentas {TxtObservaciones.Text}", 30, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, IdCtaContableOrigen, -1, CveIE, ImporteMX:=If(Not UsuarioActual.CveEmpresa.Contiene(13, 83), TxtImporte.Text.ToDouble, ImporteMXOrigen), ImporteME:=If(CveMonedaOrigen > 1, TxtImporte.Text.ToDouble * TC, 0), CveIEDevolucion:=CveIEDevolucion) Then If CveMonedaOrigen > 1 AndAlso Not UsuarioActual.CveEmpresa.Contiene(13, 83) Then 'Agregamos complementaria If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoDetalle, 0, $"Transferencia entre cuentas {TxtObservaciones.Text}", 204, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, IDCtaContableComplementariaOrigen, -1, CveIE:=CveIE, ImporteMX:=(TxtImporte.Text.ToDouble * TC - TxtImporte.Text.ToDouble).RoundSQL, ImporteME:=TxtImporte.Text.ToDouble, TipoCambio:=TC) Then MsgError = "Ocurrió un error al registrar el asiento del ingreso." End If End If 'Agregamos los Movimientos de Acreedor cuando es tarjeta If GvTC.Visible Then For Each row As GridViewRow In GvTC.Rows If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoDetalle, row.FCTextBox("TxtAbono").Text.ToDouble, $"Transferencia entre cuentas {TxtObservaciones.Text}", 41, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, If(row.DataKey("IdCtaContableTarjeta").ToEntero > 0, row.DataKey("IdCtaContableTarjeta").ToEntero, row.DataKey("IdCtaContable").ToEntero), -1, CveIEDestino, ImporteMX:=row.FCTextBox("TxtAbono").Text.ToDouble) Then MsgError = "Ocurrio un error al ingresar la prepoliza" End If Next 'Agregamos la contraria a bancos cuando es cuenta Else If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoDetalle, ImporteDestino, $"Transferencia entre cuentas {TxtObservaciones.Text}", 30, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, IdCtaContableDestino, -1, CveIEDestino, ImporteMX:=If(Not UsuarioActual.CveEmpresa.Contiene(13, 83), ImporteDestino, ImporteMXDestino), ImporteME:=If(CveMonedaDestino > 1, ImporteDestino, 0)) Then MsgError = "Ocurrio un error al ingresar la prepoliza" End If If CveMonedaDestino > 1 AndAlso Not UsuarioActual.CveEmpresa.Contiene(13, 83) Then 'Agregamos complementaria If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoDetalle, 0, $"Transferencia entre cuentas {TxtObservaciones.Text}", 204, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, IDCtaContableComplementariaDestino, -1, CveIE:=CveIEDestino, ImporteMX:=(ImporteMXDestino - ImporteDestino).RoundSQL, ImporteME:=ImporteDestino, TipoCambio:=TC) Then MsgError = "Ocurrió un error al registrar el asiento del ingreso." End If End If End If If MsgError = "" Then If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then If ObjMov.ValorPolizaDescuadre > 0 Then MsgError = ObjMov.MensajePolizaDescuadre GuardaLogAD($"Bancos/Transferencias | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") End If Else MsgError = "No se pudo validar la prepoliza de cuadre." End If End If If MsgError = "" Then 'Conta ContPAQ If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" Then If (IdCtaContableOrigen > 0 AndAlso IdCtaContableDestino > 0) OrElse (IdCtaContableDestino > 0 AndAlso Opcion = 1) Then If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, Fecha:=TxtFechaDocumento.Text) Then If ObjMov.ContaIdPoliza > 0 Then AlertaGlobal.AppendFormat("

Ver Póliza", ObjMov.ContaIdPoliza) End If Else MsgError = "Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico" End If Else MsgError = String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son invalidas: {0}", CuentasContablesInvalidas) End If End If If CveIE > 0 Then AlertaGlobal.AppendFormat("

Movimiento: {1}", CveIE, FolioOrigen) End If If CveIEDestino > 0 AndAlso CveIE <> CveIEDestino Then AlertaGlobal.AppendFormat("

Recepción: {1}", CveIEDestino, FolioDestino) End If Else MsgError = "no se pudo insertar el detalle de la póliza2" End If Else MsgError = "no se pudo insertar el detalle de la póliza" End If Else MsgError = "No se pudo insertar la póliza" End If Else MsgError = "No se insertó el encabezado" End If Else MsgError = "Error al guardar" End If If MsgError = "" Then ObjIE.Commit() Alert(String.Format("El Movimiento se realizo correctamente.
{0}", AlertaGlobal), TipoMensaje.MsgInformacion) Anexo.Text = "" 'Enviar Correo a los usuarios que tienen acceso a las dos cuentas If UsuarioActual.CveEmpresa = 13 Then EnviaCorreo(Comprobante) 'LIMPIA CargaFolio(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero) TxtImporte.Text = "" TxtObservaciones.Text = "" GeneraChequePDF(CveIEDestino, UsuarioActual.Empresa) Else ObjIE.RollBack() Alert(MsgError) End If ObjIE.Dispose() ObjMov.Dispose() 'If ObjComp IsNot Nothing Then ObjComp.Dispose() End Sub Private Sub EnviaCorreo(Comprobante As String) Dim dtcorreo As DataTable = GlobalDTBancosCuentas(-1, DdlCuentaOrigen.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa) dtcorreo.Merge(GlobalDTBancosCuentas(-1, DdlCuentaDestino.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa)) ' Dim CorreosCCP As New List(Of String) Dim StrCorreos As New StringBuilder For Each Row As DataRow In dtcorreo.Rows ' CorreosCCP.Add(GlobalDTUsuarios(Row("CveUsuario").ToString.ToEntero)(0)("correo").ToString) StrCorreos.AppendFormat("{0};", GlobalDTUsuarios(Row("CveUsuario").ToString.ToEntero)(0)("correo").ToString) Next Dim strBody As New StringBuilder strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append("
Transferencia Bancaria ") strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", DdlCuentaOrigen.SelectedItem.Text) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", DdlCuentaDestino.SelectedItem.Text) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", TxtFolio.Text.Trim) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", TxtImporte.Text.FormatoNumero) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", TxtFechaDocumento.Text) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", TxtObservaciones.Text) strBody.Append(" ") strBody.Append("
Cuenta Origen:{0}
Cuenta Destino:{0}
Folio:{0}
Importe:$ {0}
Fecha: {0}
Observaciones
") strBody.Append("
") strBody.Append("
") strBody.Append("") Try ViewState("Para") = StrCorreos.ToString 'String.Join(";", CorreosCCP.Distinct().ToArray) 'ViewState("ArrayCC") = ViewState("Asunto") = "SIG -Transferencia Realizada" ViewState("Body") = strBody.ToString ViewState("Adjunto") = Comprobante Dim Hilo As New System.Threading.Thread(AddressOf MandaCorreo) Hilo.Start() ' If NotificarAlert = True Then Alert("Se enviara correo por cambio de Estatus") Catch ex As Exception OnError("Ocurrió error al mandar MAIL", ex) End Try End Sub Private Sub MandaCorreo() 'Dim ArrayAttachment As New List(Of String) Dim ListaArchivos As New List(Of ClsSisMail.ArchivoMail) If ViewState("Adjunto") IsNot Nothing AndAlso ViewState("Adjunto") <> "" Then ' ArrayAttachment.Add(ViewState("Adjunto").ToString) ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.Ruta = ViewState("Adjunto").ToString}) End If Dim Mail As New ClsSisMail() 'Mail.MandaCorreo(EmpresaNotificaciones, ViewState("Para").ToString, ViewState("Asunto").ToString, ViewState("Body").ToString, ArrayAttachment:=ArrayAttachment) Mail.SendMail(EmpresaNotificaciones, ViewState("Para").ToString, ViewState("Asunto").ToString, ViewState("Body").ToString, Archivos:=ListaArchivos) End Sub Private Sub CargaFolio(CveCuenta As Integer, CveTipoTransaccion As Integer) TxtFolio.Text = GetFolio(CveCuenta, CveTipoTransaccion) End Sub Private Function GetFolio(CveCuenta As Integer, CveTipoTransaccion As Integer) As String Dim Folio As String Dim Banco As New ClsBancos Folio = Banco.GetNextFolio(CveCuenta, CveTipoTransaccion).ToString Banco.Dispose() Return Folio End Function Private Sub chkMovimientoTarjeta_CheckedChanged(sender As Object, e As EventArgs) Handles chkMovimientoTarjeta.CheckedChanged If chkMovimientoTarjeta.Checked Then If GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveCuenta = {0} AND UsaTarjeta = 1", DdlCuentaDestino.SelectedValue.ToEntero)).Rows.Count > 0 Then CargaGridTarjetas() End If Else GvTC.Visible = False UpGvTC.Update() End If End Sub Private Sub DdlTipoMovto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoMovto.SelectedIndexChanged If Opcion = 1 Then CargaFolio(DdlCuentaDestino.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero) Else CargaFolio(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero) End If End Sub Protected Sub RBLOpcion_SelectedIndexChanged(sender As Object, e As EventArgs) If RBLOpcion.SelectedValue = "2" Then ' reembolso DdlTipoMovto.Items.Clear() DdlTipoMovto.Items.Add(New ListItem("Depósito", "4")) Else DdlTipoMovto.Items.Clear() DdlTipoMovto.Items.Add(New ListItem("Cheque Emitido", "1")) DdlTipoMovto.Items.Add(New ListItem("Transferencia Bancaria", "2")) End If End Sub Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs) CambiaTipoMoneda() End Sub Private Sub CambiaTipoMoneda() If TxtTipoCambio.Visible = True Then TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4) End If If tCveMonedaOrigen = 1 AndAlso tCveMonedaDestino <> 1 Then 'pesos a otra moneda se divide RegistraScript("$get('TrTC').style.display=''; $get('HdnTC').value='2'; Calcula();") ElseIf tCveMonedaOrigen <> 1 AndAlso tCveMonedaDestino = 1 Then 'de otra moneda a pesos se multiplica RegistraScript("$get('TrTC').style.display=''; $get('HdnTC').value='1'; Calcula();") End If UPPDatos.Update() End Sub Private Sub CargaMovimientosCajaChica() Dim CveCajaChica As Integer = DdlCuentaOrigen.SelectedValue.ToEntero() Dim ObjMovtos As New ClsMovimientos If ObjMovtos.GetCajaChicaDetalle(CveCajaChica, UsuarioActual.CveEmpresa) Then DdlCajaChica.DataSource = ObjMovtos.DtResultados.FiltraParametros("CveIE > 0", "FechaDocumento, FolioFecha") End If ObjMovtos.Dispose() DdlCajaChica.DataBind() DdlCajaChica.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub End Class